@nxtedition/lib 23.15.4 → 23.15.6
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 +12 -8
- package/yield.js +6 -5
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import fp from 'lodash/fp.js'
|
|
|
7
7
|
import moment from 'moment-timezone'
|
|
8
8
|
import Timecode from 'smpte-timecode'
|
|
9
9
|
import transform from './transform.js'
|
|
10
|
+
import { doYield } from '../../yield.js'
|
|
10
11
|
|
|
11
12
|
const SEP = String.fromCharCode(30) // ASCII 1E
|
|
12
13
|
|
|
@@ -223,7 +224,7 @@ function makeWrapper(expression) {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
export default function ({ ds, proxify, compiler, logger, platform }) {
|
|
226
|
-
const schedule = platform?.schedule ??
|
|
227
|
+
const schedule = platform?.schedule ?? doYield
|
|
227
228
|
|
|
228
229
|
class Expression {
|
|
229
230
|
constructor(script, expression, args, observer) {
|
|
@@ -266,7 +267,7 @@ export default function ({ ds, proxify, compiler, logger, platform }) {
|
|
|
266
267
|
})
|
|
267
268
|
} else {
|
|
268
269
|
this._args = proxify ? this.wrap(args) : args
|
|
269
|
-
this.
|
|
270
|
+
this._refresh()
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
|
|
@@ -630,14 +631,17 @@ export default function ({ ds, proxify, compiler, logger, platform }) {
|
|
|
630
631
|
script = new Function(
|
|
631
632
|
transform(`
|
|
632
633
|
const _ = (value, ...fns) => {
|
|
633
|
-
if (value
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
634
|
+
if (value == null) {
|
|
635
|
+
return value
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
for (const fn of fns) {
|
|
639
|
+
value = fn(value)
|
|
640
|
+
if (value == null) {
|
|
641
|
+
return value
|
|
639
642
|
}
|
|
640
643
|
}
|
|
644
|
+
|
|
641
645
|
return value
|
|
642
646
|
};
|
|
643
647
|
_.asset = (type, state, suspend) => (name) => nxt._asset(name, type, state, suspend);
|
package/yield.js
CHANGED
|
@@ -2,22 +2,23 @@ import { FixedQueue } from './fixed-queue.js'
|
|
|
2
2
|
|
|
3
3
|
const yieldTimeout = 50
|
|
4
4
|
const yieldQueue = new FixedQueue()
|
|
5
|
+
const yieldSchedule = globalThis.setImmediate ?? ((fn) => setTimeout(fn, 0))
|
|
5
6
|
let yieldScheduled = false
|
|
6
7
|
let yieldTime = performance.now()
|
|
7
8
|
let yieldActive = false
|
|
8
9
|
|
|
9
|
-
export function maybeYield(
|
|
10
|
+
export function maybeYield(callback) {
|
|
10
11
|
if (callback != null && typeof callback !== 'function') {
|
|
11
12
|
throw new TypeError('callback must be a function')
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
return performance.now() - yieldTime < yieldTimeout ? null : doYield(
|
|
15
|
+
return performance.now() - yieldTime < yieldTimeout ? null : doYield(callback)
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export function doYield(
|
|
18
|
+
export function doYield(callback) {
|
|
18
19
|
if (!yieldScheduled) {
|
|
19
20
|
yieldScheduled = true
|
|
20
|
-
|
|
21
|
+
yieldSchedule(dispatchYield)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
if (callback) {
|
|
@@ -44,7 +45,7 @@ function dispatchYield() {
|
|
|
44
45
|
resolve(null)
|
|
45
46
|
|
|
46
47
|
if (performance.now() - yieldTime > yieldTimeout) {
|
|
47
|
-
|
|
48
|
+
yieldSchedule(dispatchYield)
|
|
48
49
|
return
|
|
49
50
|
}
|
|
50
51
|
}
|