@nxtedition/lib 15.1.0 → 15.1.1
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/package.json +1 -1
- package/util/template/javascript.js +36 -26
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ const maxInt = 2147483647
|
|
|
15
15
|
class TimerEntry {
|
|
16
16
|
constructor(key, refresh, delay) {
|
|
17
17
|
this.key = key
|
|
18
|
-
this.counter =
|
|
18
|
+
this.counter = -1
|
|
19
19
|
|
|
20
20
|
this.timer = setTimeout(refresh, delay)
|
|
21
21
|
}
|
|
@@ -35,35 +35,45 @@ const fetchClient = new undici.Agent({
|
|
|
35
35
|
class FetchEntry {
|
|
36
36
|
constructor(key, refresh, { resource, options }) {
|
|
37
37
|
this.key = key
|
|
38
|
-
this.counter =
|
|
38
|
+
this.counter = -1
|
|
39
|
+
this.ac = new AbortController()
|
|
39
40
|
|
|
40
41
|
this.refresh = refresh
|
|
41
|
-
this.ac = new AbortController()
|
|
42
|
-
this.signal = this.ac.signal
|
|
43
42
|
this.body = null
|
|
44
43
|
this.status = null
|
|
45
44
|
this.error = null
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.then(async (res) => {
|
|
53
|
-
try {
|
|
54
|
-
// TODO (fix): max size...
|
|
55
|
-
this.status = res.status
|
|
56
|
-
this.headers = res.headers
|
|
57
|
-
this.body = await res.text()
|
|
58
|
-
} catch (err) {
|
|
59
|
-
this.error = err
|
|
60
|
-
}
|
|
61
|
-
this.refresh()
|
|
62
|
-
})
|
|
63
|
-
.catch((err) => {
|
|
64
|
-
this.error = err
|
|
65
|
-
this.refresh()
|
|
46
|
+
try {
|
|
47
|
+
request(resource, {
|
|
48
|
+
...options,
|
|
49
|
+
signal: this.ac.signal,
|
|
50
|
+
dispatcher: fetchClient,
|
|
66
51
|
})
|
|
52
|
+
.then(async (res) => {
|
|
53
|
+
try {
|
|
54
|
+
// TODO (fix): max size...
|
|
55
|
+
this.status = res.statusCode
|
|
56
|
+
this.headers = res.headers
|
|
57
|
+
this.body = await res.text()
|
|
58
|
+
} catch (err) {
|
|
59
|
+
this.error = err
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (this.refresh) {
|
|
63
|
+
this.refresh()
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.catch((err) => {
|
|
67
|
+
this.error = err
|
|
68
|
+
|
|
69
|
+
if (this.refresh) {
|
|
70
|
+
this.refresh()
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
} catch (err) {
|
|
74
|
+
this.error = err
|
|
75
|
+
this.refresh()
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
dispose() {
|
|
@@ -77,7 +87,7 @@ class FetchEntry {
|
|
|
77
87
|
class RecordEntry {
|
|
78
88
|
constructor(key, refresh, ds) {
|
|
79
89
|
this.key = key
|
|
80
|
-
this.counter =
|
|
90
|
+
this.counter = -1
|
|
81
91
|
|
|
82
92
|
this.refresh = refresh
|
|
83
93
|
this.record = ds.record.getRecord(key)
|
|
@@ -105,7 +115,7 @@ class RecordEntry {
|
|
|
105
115
|
class ObservableEntry {
|
|
106
116
|
constructor(key, refresh, observable) {
|
|
107
117
|
this.key = key
|
|
108
|
-
this.counter =
|
|
118
|
+
this.counter = -1
|
|
109
119
|
this.value = kEmpty
|
|
110
120
|
this.error = null
|
|
111
121
|
this.refresh = refresh
|
|
@@ -131,7 +141,7 @@ class ObservableEntry {
|
|
|
131
141
|
class PromiseEntry {
|
|
132
142
|
constructor(key, refresh, promise) {
|
|
133
143
|
this.key = key
|
|
134
|
-
this.counter =
|
|
144
|
+
this.counter = -1
|
|
135
145
|
this.value = kEmpty
|
|
136
146
|
this.error = null
|
|
137
147
|
this.refresh = refresh
|