@nxtedition/lib 19.0.18 → 19.0.20
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/app.js +1 -1
- package/deepstream.js +34 -0
- package/mime.js +9 -9
- package/package.json +1 -1
package/app.js
CHANGED
package/deepstream.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
1
2
|
import qs from 'qs'
|
|
2
3
|
import cached from './util/cached.js'
|
|
4
|
+
import * as rxjs from 'rxjs'
|
|
3
5
|
|
|
4
6
|
function provide(ds, domain, callback, options) {
|
|
5
7
|
if (domain instanceof RegExp) {
|
|
@@ -117,6 +119,35 @@ function get(ds, name, ...args) {
|
|
|
117
119
|
)
|
|
118
120
|
}
|
|
119
121
|
|
|
122
|
+
function query(ds, designId, options) {
|
|
123
|
+
const next = (startkey, prevRows, limit) =>
|
|
124
|
+
!limit
|
|
125
|
+
? rxjs.of({ rows: prevRows ?? [] })
|
|
126
|
+
: ds.nxt.record
|
|
127
|
+
.observe(
|
|
128
|
+
designId,
|
|
129
|
+
{
|
|
130
|
+
...options,
|
|
131
|
+
startkey,
|
|
132
|
+
limit: Number.isFinite(limit) ? limit : null,
|
|
133
|
+
},
|
|
134
|
+
ds.record.PROVIDER,
|
|
135
|
+
)
|
|
136
|
+
.pipe(
|
|
137
|
+
rxjs.switchMap(({ rows, finished }) => {
|
|
138
|
+
const nextRows = prevRows ? [...prevRows, ...rows] : rows
|
|
139
|
+
if (rows.length < limit && finished) {
|
|
140
|
+
return rxjs.of({ rows: nextRows })
|
|
141
|
+
} else {
|
|
142
|
+
const last = rows.pop()
|
|
143
|
+
assert(last.key)
|
|
144
|
+
return next(last.key, nextRows, limit - rows.length)
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
)
|
|
148
|
+
return next(options.startkey, null, options.limit ?? Infinity)
|
|
149
|
+
}
|
|
150
|
+
|
|
120
151
|
export function makeDeepstream(ds) {
|
|
121
152
|
const nxt = {
|
|
122
153
|
ds,
|
|
@@ -124,6 +155,7 @@ export function makeDeepstream(ds) {
|
|
|
124
155
|
provide: (...args) => provide(ds, ...args),
|
|
125
156
|
observe: (...args) => observe(ds, ...args),
|
|
126
157
|
observe2: (...args) => observe2(ds, ...args),
|
|
158
|
+
query: (...args) => query(ds, ...args),
|
|
127
159
|
set: (...args) => ds.record.set(...args),
|
|
128
160
|
get: (...args) => get(ds, ...args),
|
|
129
161
|
update: (...args) => ds.record.update(...args),
|
|
@@ -137,11 +169,13 @@ Object.assign(makeDeepstream, {
|
|
|
137
169
|
provide,
|
|
138
170
|
observe,
|
|
139
171
|
observe2,
|
|
172
|
+
query,
|
|
140
173
|
get,
|
|
141
174
|
record: {
|
|
142
175
|
provide,
|
|
143
176
|
observe,
|
|
144
177
|
observe2,
|
|
178
|
+
query,
|
|
145
179
|
get,
|
|
146
180
|
},
|
|
147
181
|
})
|
package/mime.js
CHANGED
|
@@ -29,29 +29,29 @@ export function lookup(name) {
|
|
|
29
29
|
return mime.getType(name)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function extension(
|
|
33
|
-
if (typeof
|
|
32
|
+
export function extension(mimeType, fileName) {
|
|
33
|
+
if (typeof mimeType !== 'string' || mimeType.length === 0) {
|
|
34
34
|
return null
|
|
35
35
|
}
|
|
36
|
-
if (/video\/(x-)?nut/.test(
|
|
36
|
+
if (/video\/(x-)?nut/.test(mimeType)) {
|
|
37
37
|
return 'nut'
|
|
38
38
|
}
|
|
39
|
-
if (/video\/(x-)?dnxhd/.test(
|
|
39
|
+
if (/video\/(x-)?dnxhd/.test(mimeType)) {
|
|
40
40
|
return 'dnxhd'
|
|
41
41
|
}
|
|
42
|
-
if (/audio\/(x-)?pcm-s32le/.test(
|
|
42
|
+
if (/audio\/(x-)?pcm-s32le/.test(mimeType)) {
|
|
43
43
|
return 'pcm-s32le'
|
|
44
44
|
}
|
|
45
|
-
if (/audio\/(x-)?pcm-s24le/.test(
|
|
45
|
+
if (/audio\/(x-)?pcm-s24le/.test(mimeType)) {
|
|
46
46
|
return 'pcm-s24le'
|
|
47
47
|
}
|
|
48
|
-
if (/audio\/(x-)?pcm-s16le/.test(
|
|
48
|
+
if (/audio\/(x-)?pcm-s16le/.test(mimeType)) {
|
|
49
49
|
return 'pcm-s16le'
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const extension = mime.getExtension(
|
|
52
|
+
const extension = mime.getExtension(mimeType) || (mimeType || '').split('/').pop()
|
|
53
53
|
|
|
54
|
-
if (extension === 'qt' && typeof
|
|
54
|
+
if (extension === 'qt' && typeof fileName === 'string' && fileName.endsWith('.mov')) {
|
|
55
55
|
return 'mov'
|
|
56
56
|
}
|
|
57
57
|
|