glib-web 2.4.1 → 3.0.0-beta1
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/LICENSE +0 -0
- package/action.js +6 -1
- package/actions/auth/restart.js +0 -0
- package/actions/commands/enqueue.js +17 -0
- package/actions/components/update.js +13 -14
- package/actions/dialogs/oauth.js +0 -0
- package/actions/dialogs/options.js +0 -0
- package/app.vue +25 -26
- package/components/_button.vue +21 -28
- package/components/_chip.vue +14 -19
- package/components/_dropdownMenu.vue +10 -23
- package/components/_icon.vue +5 -5
- package/components/_message.vue +0 -0
- package/components/_responsive.vue +7 -21
- package/components/avatar.vue +11 -15
- package/components/banners/alert.vue +2 -7
- package/components/banners/select.vue +18 -30
- package/components/button.vue +5 -5
- package/components/component.vue +97 -100
- package/components/datetime.vue +0 -0
- package/components/fab.vue +0 -0
- package/components/fields/_patternText.vue +5 -19
- package/components/fields/_select.vue +7 -28
- package/components/fields/autocomplete.vue +5 -21
- package/components/fields/check.vue +19 -11
- package/components/fields/country/countries.js +0 -0
- package/components/fields/country/field.vue +9 -27
- package/components/fields/country/regions.js +0 -0
- package/components/fields/date.vue +5 -5
- package/components/fields/datetime.vue +5 -5
- package/components/fields/dynamicSelect.vue +8 -29
- package/components/fields/newRichText.vue +66 -53
- package/components/fields/otpField.vue +90 -0
- package/components/fields/phone/field.vue +60 -78
- package/components/fields/radio.vue +16 -23
- package/components/fields/rating.vue +9 -16
- package/components/fields/richText.vue +8 -28
- package/components/fields/select.vue +10 -7
- package/components/fields/stripeExternalAccount.vue +10 -24
- package/components/fields/text.vue +24 -40
- package/components/fields/textarea.vue +13 -27
- package/components/fields/timeZone.vue +9 -6
- package/components/fields/timer.vue +3 -10
- package/components/hr.vue +0 -0
- package/components/html.vue +0 -0
- package/components/image.vue +13 -20
- package/components/map.vue +115 -29
- package/components/markdown.vue +15 -8
- package/components/mixins/events.js +17 -6
- package/components/mixins/longClick.js +0 -0
- package/components/mixins/scrolling.js +0 -0
- package/components/mixins/styles.js +18 -15
- package/components/mixins/table/export.js +0 -0
- package/components/mixins/table/import.js +0 -0
- package/components/p.vue +0 -0
- package/components/panels/column.vue +5 -5
- package/components/panels/custom.vue +15 -15
- package/components/panels/flow.vue +19 -13
- package/components/panels/form.vue +17 -28
- package/components/panels/grid.vue +15 -9
- package/components/panels/horizontal.vue +149 -18
- package/components/panels/list.vue +63 -70
- package/components/panels/responsive.vue +13 -33
- package/components/panels/split.vue +2 -2
- package/components/panels/table.vue +27 -61
- package/components/panels/timeline.vue +20 -30
- package/components/panels/vertical.vue +9 -14
- package/components/tabBar.vue +27 -19
- package/index.js +68 -72
- package/keys.js +0 -0
- package/nav/appbar.vue +4 -4
- package/nav/dialog.vue +24 -34
- package/nav/drawer.vue +39 -51
- package/nav/drawerButton.vue +5 -7
- package/nav/drawerLabel.vue +2 -3
- package/nav/sheet.vue +18 -24
- package/nav/snackbar.vue +16 -26
- package/package.json +10 -11
- package/plugins/driverCustomBehavior.js +1 -1
- package/plugins/updatableComponent.js +1 -7
- package/plugins/vuetify.js +27 -0
- package/settings.json.example +0 -0
- package/styles/test.sass +0 -0
- package/styles/test.scss +0 -0
- package/templates/comment.vue +42 -19
- package/templates/featured.vue +8 -9
- package/templates/thumbnail-old.vue +188 -0
- package/templates/thumbnail.vue +5 -188
- package/templates/unsupported.vue +0 -0
- package/tsconfig.json +1 -1
- package/utils/dom.js +0 -0
- package/utils/eventBus.js +9 -2
- package/utils/history.js +7 -4
- package/utils/http.js +7 -2
- package/utils/launch.js +43 -51
- package/utils/public.js +6 -0
- package/utils/queue.js +110 -0
- package/utils/settings.js +3 -1
- package/utils/storage.js +0 -0
- package/utils/url.js +0 -0
package/templates/thumbnail.vue
CHANGED
|
@@ -1,194 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
v-if="spec.leftOuterButtons"
|
|
5
|
-
class="left-universal"
|
|
6
|
-
style="display:flex; margin-top: 10px;"
|
|
7
|
-
>
|
|
8
|
-
<template v-for="(item, index) in spec.leftOuterButtons">
|
|
9
|
-
<common-button
|
|
10
|
-
:key="index"
|
|
11
|
-
:spec="buttonSpec(item)"
|
|
12
|
-
:disabled="$isBusy"
|
|
13
|
-
/>
|
|
14
|
-
</template>
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<v-list-item
|
|
18
|
-
v-longclick="$onLongPress"
|
|
19
|
-
:href="$href()"
|
|
20
|
-
style="padding-left: 0;display:flex;"
|
|
21
|
-
:style="columnStyles()"
|
|
22
|
-
@[clickCondition]="$onClick()"
|
|
23
|
-
>
|
|
24
|
-
<v-icon v-if="spec.onReorder" class="handle">drag_indicator</v-icon>
|
|
25
|
-
|
|
26
|
-
<!-- Specify a key to prevent reuse which causes an issue where the checkbox would use the previous name. -->
|
|
27
|
-
<fields-check v-if="checkSpec" :key="checkSpec.name" :spec="checkSpec" />
|
|
28
|
-
|
|
29
|
-
<div v-if="spec.leftButtons" class="left-universal">
|
|
30
|
-
<template v-for="(item, index) in spec.leftButtons">
|
|
31
|
-
<rich-button
|
|
32
|
-
:key="index"
|
|
33
|
-
:spec="buttonSpec(item)"
|
|
34
|
-
:disabled="$isBusy"
|
|
35
|
-
/>
|
|
36
|
-
</template>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<v-list-item-avatar
|
|
40
|
-
v-if="$type.isString(spec.imageUrl)"
|
|
41
|
-
:tile="!spec.avatar"
|
|
42
|
-
style="display:flex;"
|
|
43
|
-
class="left-thumbnail"
|
|
44
|
-
:size="spec.imageSize"
|
|
45
|
-
>
|
|
46
|
-
<img :src="spec.imageUrl" />
|
|
47
|
-
</v-list-item-avatar>
|
|
48
|
-
<!-- <v-list-item-avatar v-else-if="$type.isObject(spec.icon)">
|
|
49
|
-
<common-icon :spec="spec.icon" />
|
|
50
|
-
</v-list-item-avatar> -->
|
|
51
|
-
<div v-else class="left-icon">
|
|
52
|
-
<v-list-item-avatar v-if="$type.isObject(spec.icon)">
|
|
53
|
-
<common-icon :spec="spec.icon" />
|
|
54
|
-
</v-list-item-avatar>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<v-list-item-content style="display:flex;">
|
|
58
|
-
<v-text-field
|
|
59
|
-
v-if="spec.fieldTitleName"
|
|
60
|
-
:name="spec.fieldTitleName"
|
|
61
|
-
:value="spec.title"
|
|
62
|
-
/>
|
|
63
|
-
<v-list-item-title v-else>{{ spec.title }}</v-list-item-title>
|
|
64
|
-
|
|
65
|
-
<v-list-item-subtitle v-if="spec.subtitle">{{
|
|
66
|
-
spec.subtitle
|
|
67
|
-
}}</v-list-item-subtitle>
|
|
68
|
-
<v-list-item-subtitle v-if="spec.subsubtitle">{{
|
|
69
|
-
spec.subsubtitle
|
|
70
|
-
}}</v-list-item-subtitle>
|
|
71
|
-
|
|
72
|
-
<div class="chips">
|
|
73
|
-
<template v-for="(item, index) in chips">
|
|
74
|
-
<common-chip :key="index" :spec="item" />
|
|
75
|
-
</template>
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<!-- NOTE: Experimental -->
|
|
79
|
-
<panels-responsive :spec="accessory" />
|
|
80
|
-
</v-list-item-content>
|
|
81
|
-
|
|
82
|
-
<template v-for="(item, index) in spec.rightButtons">
|
|
83
|
-
<rich-button
|
|
84
|
-
:key="index"
|
|
85
|
-
:spec="buttonSpec(item)"
|
|
86
|
-
:disabled="$isBusy"
|
|
87
|
-
/>
|
|
88
|
-
</template>
|
|
89
|
-
|
|
90
|
-
<templates-menu :edit-buttons="editButtons" />
|
|
91
|
-
</v-list-item>
|
|
92
|
-
</div>
|
|
2
|
+
<v-list-item :key="spec.title" :title="spec.title" :subtitle="spec.subtitle" :prepend-avatar="spec.imageUrl"
|
|
3
|
+
@click="$event => spec.onClick ? $onClick() : null"></v-list-item>
|
|
93
4
|
</template>
|
|
94
|
-
|
|
95
5
|
<script>
|
|
96
|
-
import CheckField from "../components/fields/check";
|
|
97
|
-
|
|
98
6
|
export default {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
props: {
|
|
103
|
-
spec: { type: Object, required: true },
|
|
104
|
-
responsiveCols: { type: Number, default: () => 0 }
|
|
105
|
-
},
|
|
106
|
-
data() {
|
|
107
|
-
return {
|
|
108
|
-
accessory: {},
|
|
109
|
-
editButtons: []
|
|
110
|
-
// checkSpec: null
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
computed: {
|
|
114
|
-
clickCondition() {
|
|
115
|
-
if (this.spec.onClick || this.spec.onLongPress) {
|
|
116
|
-
// This will show the clickable indication
|
|
117
|
-
return "click";
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
},
|
|
121
|
-
// Implemented as computed so that it gets reflected when reordering
|
|
122
|
-
chips() {
|
|
123
|
-
return (this.spec.chips || []).map(item => {
|
|
124
|
-
var color = null;
|
|
125
|
-
this.$type.ifArray(item.styleClasses, classes => {
|
|
126
|
-
for (const val of ["success", "info", "warning", "error"]) {
|
|
127
|
-
if (classes.includes(val)) {
|
|
128
|
-
color = val;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
return Object.assign({}, item, { color: color, view: "chip" });
|
|
133
|
-
});
|
|
134
|
-
},
|
|
135
|
-
// Implemented as computed so that it gets reflected when navigating to another list containing check fields.
|
|
136
|
-
checkSpec() {
|
|
137
|
-
if (this.spec.fieldCheckName) {
|
|
138
|
-
return {
|
|
139
|
-
view: "fields/checkGroup",
|
|
140
|
-
name: this.spec.fieldCheckName,
|
|
141
|
-
checkValue: true,
|
|
142
|
-
valueIf: this.spec.fieldCheckValueIf,
|
|
143
|
-
padding: { left: 16 }
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
7
|
+
props: {
|
|
8
|
+
spec: { type: Object, required: true },
|
|
147
9
|
}
|
|
148
|
-
},
|
|
149
|
-
methods: {
|
|
150
|
-
$ready() {
|
|
151
|
-
this.accessory = { childViews: this.spec.accessoryViews };
|
|
152
|
-
this.editButtons = this.spec.editButtons || [];
|
|
153
|
-
},
|
|
154
|
-
buttonSpec(item) {
|
|
155
|
-
return Object.assign({}, item, {
|
|
156
|
-
view: "button-v1",
|
|
157
|
-
styleClasses: item.text ? ["text"] : ["icon"]
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
columnStyles() {
|
|
161
|
-
if (this.responsiveCols) {
|
|
162
|
-
return `width: ${100 / this.responsiveCols}%; float: left;`;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
</script>
|
|
168
|
-
|
|
169
|
-
<style lang="scss">
|
|
170
|
-
.chips > * {
|
|
171
|
-
margin-right: 10px;
|
|
172
|
-
}
|
|
173
|
-
</style>
|
|
174
|
-
|
|
175
|
-
<style lang="scss" scoped>
|
|
176
|
-
@media (min-width: 600px) {
|
|
177
|
-
.left-thumbnail.v-avatar.v-list-item__avatar {
|
|
178
|
-
margin: 6px 6px 6px 6px;
|
|
179
|
-
width: 60px;
|
|
180
|
-
height: 60px;
|
|
181
|
-
}
|
|
182
|
-
.left-icon {
|
|
183
|
-
// margin-left: 16px;
|
|
184
|
-
margin-left: 4px;
|
|
185
|
-
}
|
|
186
|
-
.left-universal {
|
|
187
|
-
padding-left: 16px;
|
|
188
|
-
}
|
|
189
|
-
.handle {
|
|
190
|
-
margin-left: 10px;
|
|
191
|
-
cursor: move;
|
|
192
|
-
}
|
|
193
10
|
}
|
|
194
|
-
</
|
|
11
|
+
</script>
|
|
File without changes
|
package/tsconfig.json
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
40
40
|
|
|
41
41
|
/* JavaScript Support */
|
|
42
|
-
|
|
42
|
+
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
43
43
|
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
44
44
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
45
45
|
|
package/utils/dom.js
CHANGED
|
File without changes
|
package/utils/eventBus.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// eventBus.js
|
|
2
|
+
import emitter from 'tiny-emitter/instance'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
$on: (...args) => emitter.on(...args),
|
|
6
|
+
$once: (...args) => emitter.once(...args),
|
|
7
|
+
$off: (...args) => emitter.off(...args),
|
|
8
|
+
$emit: (...args) => emitter.emit(...args)
|
|
9
|
+
}
|
package/utils/history.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { nextTick } from "vue";
|
|
2
|
+
import eventBus from "./eventBus";
|
|
2
3
|
|
|
3
4
|
export default class {
|
|
4
5
|
static saveInitialContent(content) {
|
|
@@ -20,7 +21,7 @@ export default class {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
static _data(content) {
|
|
23
|
-
return { content: content, navigationCount: this.navigationCount };
|
|
24
|
+
return { content: JSON.parse(JSON.stringify(content)), navigationCount: this.navigationCount };
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
static pushPage(content, url) {
|
|
@@ -54,10 +55,12 @@ export default class {
|
|
|
54
55
|
|
|
55
56
|
const data = event.state;
|
|
56
57
|
data.content.__poppedState = true;
|
|
57
|
-
|
|
58
|
+
//
|
|
59
|
+
|
|
60
|
+
eventBus.$emit('app/updatePage', data.content)
|
|
58
61
|
vm.navigationCount = data.navigationCount;
|
|
59
62
|
|
|
60
|
-
|
|
63
|
+
nextTick(() => {
|
|
61
64
|
const scrollTop = this.bodyScrollTops[this.navigationCount];
|
|
62
65
|
this._pageBody.scrollTop = scrollTop;
|
|
63
66
|
});
|
package/utils/http.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Type from "./type";
|
|
2
2
|
import Action from "../action";
|
|
3
|
+
import eventBus from "./eventBus";
|
|
3
4
|
|
|
4
5
|
let loading = false;
|
|
5
6
|
const dirtyPrompt = "Changes you made have not been saved. Are you sure?";
|
|
@@ -60,7 +61,10 @@ export default class {
|
|
|
60
61
|
|
|
61
62
|
this.forceComponentUpdate(() => {
|
|
62
63
|
Utils.history.resetScroll();
|
|
63
|
-
window.vueApp.page = data;
|
|
64
|
+
// window.vueApp.page = data;
|
|
65
|
+
|
|
66
|
+
eventBus.$emit('app/updatePage', data)
|
|
67
|
+
|
|
64
68
|
Action.execute(properties["onOpen"], component);
|
|
65
69
|
});
|
|
66
70
|
});
|
|
@@ -113,7 +117,8 @@ export default class {
|
|
|
113
117
|
|
|
114
118
|
Utils.http.execute(data, "GET", component, (page, response) => {
|
|
115
119
|
Utils.http.forceComponentUpdate(() => {
|
|
116
|
-
window.vueApp.page = page;
|
|
120
|
+
// window.vueApp.page = page;
|
|
121
|
+
eventBus.$emit('app/updatePage', page)
|
|
117
122
|
const redirectUrl = Utils.url.htmlUrl(response.url);
|
|
118
123
|
Utils.history.updatePage(redirectUrl);
|
|
119
124
|
|
package/utils/launch.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Vue from "
|
|
2
|
-
import Dialog from "../nav/dialog";
|
|
3
|
-
import Sheet from "../nav/sheet";
|
|
4
|
-
import Snackbar from "../nav/snackbar";
|
|
5
|
-
import
|
|
1
|
+
import { Vue } from "../index";
|
|
2
|
+
import Dialog from "../nav/dialog.vue";
|
|
3
|
+
import Sheet from "../nav/sheet.vue";
|
|
4
|
+
import Snackbar from "../nav/snackbar.vue";
|
|
5
|
+
import { createApp, h } from "vue";
|
|
6
6
|
|
|
7
7
|
export default class {
|
|
8
8
|
static get dialog() {
|
|
@@ -36,30 +36,27 @@ class LaunchDialog {
|
|
|
36
36
|
this.stack = [];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
|
|
39
40
|
// https://css-tricks.com/creating-vue-js-component-instances-programmatically/
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const props = {
|
|
42
|
+
spec: properties,
|
|
43
|
+
stack: this.stack,
|
|
44
|
+
vueApp: window.vueApp
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const instance = createApp(
|
|
48
|
+
{
|
|
49
|
+
render: function () {
|
|
50
|
+
return h(Dialog, props)
|
|
45
51
|
}
|
|
46
|
-
}),
|
|
47
|
-
propsData: {
|
|
48
|
-
spec: properties,
|
|
49
|
-
stack: this.stack,
|
|
50
|
-
vueApp: window.vueApp
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
)
|
|
54
|
+
Object.assign(instance._context, Vue._context)
|
|
53
55
|
|
|
54
56
|
if (component) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const placeholder = component.$el.appendChild(
|
|
60
|
-
document.createElement("div")
|
|
61
|
-
);
|
|
62
|
-
instance.$mount(placeholder);
|
|
57
|
+
const placeholder = document.createElement('div')
|
|
58
|
+
document.body.appendChild(placeholder)
|
|
59
|
+
instance.mount(placeholder);
|
|
63
60
|
} else {
|
|
64
61
|
console.error("A dialog has to be displayed in a component");
|
|
65
62
|
}
|
|
@@ -108,21 +105,19 @@ class LaunchDialog {
|
|
|
108
105
|
|
|
109
106
|
class LaunchSheet {
|
|
110
107
|
static open(properties, component) {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
themes: Utils.settings.themes
|
|
108
|
+
const instance = createApp(
|
|
109
|
+
{
|
|
110
|
+
render: function () {
|
|
111
|
+
return h(Sheet, { spec: properties })
|
|
116
112
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
Object.assign(instance._context, Vue._context)
|
|
120
116
|
|
|
121
117
|
if (component) {
|
|
122
|
-
const placeholder =
|
|
123
|
-
|
|
124
|
-
);
|
|
125
|
-
instance.$mount(placeholder);
|
|
118
|
+
const placeholder = document.createElement('div')
|
|
119
|
+
document.body.appendChild(placeholder)
|
|
120
|
+
instance.mount(placeholder);
|
|
126
121
|
} else {
|
|
127
122
|
console.error("A sheet has to be displayed in a component");
|
|
128
123
|
}
|
|
@@ -150,25 +145,22 @@ class LaunchSheet {
|
|
|
150
145
|
|
|
151
146
|
class LaunchSnackbar {
|
|
152
147
|
static open(properties, component) {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
const instance = createApp(
|
|
149
|
+
{
|
|
150
|
+
render: function () {
|
|
151
|
+
return h(Snackbar, { spec: properties, vueApp: window.vueApp })
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
Object.assign(instance._context, Vue._context)
|
|
158
156
|
|
|
159
157
|
if (component) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// );
|
|
164
|
-
|
|
165
|
-
const placeholder = document.body.appendChild(
|
|
166
|
-
document.createElement("div")
|
|
167
|
-
);
|
|
168
|
-
instance.$mount(placeholder);
|
|
158
|
+
const placeholder = document.createElement('div')
|
|
159
|
+
document.body.appendChild(placeholder)
|
|
160
|
+
instance.mount(placeholder);
|
|
169
161
|
instance.show = true;
|
|
170
162
|
} else {
|
|
171
|
-
console.error("A
|
|
163
|
+
console.error("A Snackbar has to be displayed in a component");
|
|
172
164
|
}
|
|
173
165
|
|
|
174
166
|
return instance;
|
package/utils/public.js
CHANGED
|
@@ -5,6 +5,9 @@ import Type from "./type";
|
|
|
5
5
|
import Form from "./form";
|
|
6
6
|
import Component from "./component";
|
|
7
7
|
import Hash from "./hash";
|
|
8
|
+
import Queue from "./queue";
|
|
9
|
+
|
|
10
|
+
const _queue = new Queue();
|
|
8
11
|
|
|
9
12
|
export default class {
|
|
10
13
|
static get action() {
|
|
@@ -28,4 +31,7 @@ export default class {
|
|
|
28
31
|
static get Hash() {
|
|
29
32
|
return Hash;
|
|
30
33
|
}
|
|
34
|
+
static get queue() {
|
|
35
|
+
return _queue;
|
|
36
|
+
}
|
|
31
37
|
}
|
package/utils/queue.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// From https://stackoverflow.com/questions/47157428/how-to-implement-a-pseudo-blocking-async-queue-in-js-ts
|
|
2
|
+
|
|
3
|
+
// const jobQueue = [];
|
|
4
|
+
export default class {
|
|
5
|
+
constructor() {
|
|
6
|
+
// invariant: at least one of the arrays is empty
|
|
7
|
+
this.resolvers = [];
|
|
8
|
+
this.promises = [];
|
|
9
|
+
}
|
|
10
|
+
_add() {
|
|
11
|
+
this.promises.push(
|
|
12
|
+
new Promise(resolve => {
|
|
13
|
+
this.resolvers.push(resolve);
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
enqueue(t) {
|
|
18
|
+
// if (this.resolvers.length) this.resolvers.shift()(t);
|
|
19
|
+
// else this.promises.push(Promise.resolve(t));
|
|
20
|
+
if (!this.resolvers.length) this._add();
|
|
21
|
+
this.resolvers.shift()(t);
|
|
22
|
+
}
|
|
23
|
+
dequeue() {
|
|
24
|
+
if (!this.promises.length) this._add();
|
|
25
|
+
return this.promises.shift();
|
|
26
|
+
}
|
|
27
|
+
// now some utilities:
|
|
28
|
+
isEmpty() {
|
|
29
|
+
// there are no values available
|
|
30
|
+
return !this.promises.length; // this.length <= 0
|
|
31
|
+
}
|
|
32
|
+
isBlocked() {
|
|
33
|
+
// it's waiting for values
|
|
34
|
+
return !!this.resolvers.length; // this.length < 0
|
|
35
|
+
}
|
|
36
|
+
get length() {
|
|
37
|
+
return this.promises.length - this.resolvers.length;
|
|
38
|
+
}
|
|
39
|
+
sleep(ms) {
|
|
40
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
41
|
+
}
|
|
42
|
+
async start() {
|
|
43
|
+
// TODO: This is experimental
|
|
44
|
+
const delayBetweenJobs = 2000;
|
|
45
|
+
|
|
46
|
+
for await (const job of this) {
|
|
47
|
+
console.log("Executing job...");
|
|
48
|
+
job();
|
|
49
|
+
if (delayBetweenJobs) {
|
|
50
|
+
console.log("Waiting for next job1...");
|
|
51
|
+
await this.sleep(delayBetweenJobs);
|
|
52
|
+
console.log("Waiting for next job2...");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// console.log("JOB1");
|
|
56
|
+
// const job = this.dequeue();
|
|
57
|
+
// console.log("JOB2", job);
|
|
58
|
+
// job();
|
|
59
|
+
// Vue.nextTick(() => {
|
|
60
|
+
// this.start();
|
|
61
|
+
// });
|
|
62
|
+
// await this.next();
|
|
63
|
+
}
|
|
64
|
+
[Symbol.asyncIterator]() {
|
|
65
|
+
// Todo: Use AsyncIterator.from()
|
|
66
|
+
return {
|
|
67
|
+
next: () => this.dequeue().then(value => ({ done: false, value })),
|
|
68
|
+
[Symbol.asyncIterator]() {
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// export default class {
|
|
76
|
+
// constructor() {
|
|
77
|
+
// this.jobQueue = [];
|
|
78
|
+
// this.timerHandle = null;
|
|
79
|
+
// }
|
|
80
|
+
// // static get csrfElement() {
|
|
81
|
+
// // return document.querySelector(`meta[name="csrf-token"]`);
|
|
82
|
+
// // }
|
|
83
|
+
|
|
84
|
+
// // static getCsrf() {
|
|
85
|
+
// // return this.csrfElement.getAttribute("content");
|
|
86
|
+
// // }
|
|
87
|
+
|
|
88
|
+
// // static setCsrf(value) {
|
|
89
|
+
// // return this.csrfElement.setAttribute("content", value);
|
|
90
|
+
// // }
|
|
91
|
+
|
|
92
|
+
// start(interval) {
|
|
93
|
+
// this.timerHandle = setInterval(() => {
|
|
94
|
+
// console.log("DEQUQE1");
|
|
95
|
+
// const oldestJob = this.jobQueue.shift();
|
|
96
|
+
// if (oldestJob) {
|
|
97
|
+
// console.log("DEQUQE2");
|
|
98
|
+
// oldestJob();
|
|
99
|
+
// }
|
|
100
|
+
// }, interval);
|
|
101
|
+
// }
|
|
102
|
+
|
|
103
|
+
// stop() {
|
|
104
|
+
// clearInterval(this.timerHandle);
|
|
105
|
+
// }
|
|
106
|
+
|
|
107
|
+
// enqueue(job) {
|
|
108
|
+
// this.jobQueue.push(job);
|
|
109
|
+
// }
|
|
110
|
+
// }
|
package/utils/settings.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import config from '../package.json';
|
|
2
|
+
|
|
1
3
|
class MutableSettings {
|
|
2
4
|
constructor() {
|
|
3
5
|
this.reactive = true;
|
|
@@ -22,7 +24,7 @@ export default class ImmutableSettings {
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
static get appVersion() {
|
|
25
|
-
return
|
|
27
|
+
return config.version;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
// static get build() {
|
package/utils/storage.js
CHANGED
|
File without changes
|
package/utils/url.js
CHANGED
|
File without changes
|