@nxtedition/lib 19.4.6 → 19.4.9
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/errors.js +8 -9
- package/package.json +1 -1
- package/util/template/javascript.js +36 -35
package/errors.js
CHANGED
|
@@ -142,15 +142,16 @@ function _serializeError(error, { depth }) {
|
|
|
142
142
|
|
|
143
143
|
// TODO (fix): Recursion guard?
|
|
144
144
|
export function makeMessages(error, options) {
|
|
145
|
-
if (!error) {
|
|
145
|
+
if (!error || error.length === 0) {
|
|
146
146
|
return []
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
if (Array.isArray(error)) {
|
|
150
150
|
return fp.pipe(
|
|
151
151
|
fp.flattenDeep,
|
|
152
|
+
fp.filter(Boolean),
|
|
152
153
|
fp.flatMap((x) => makeMessages(x, options)),
|
|
153
|
-
fp.uniqBy(
|
|
154
|
+
fp.uniqBy('id'),
|
|
154
155
|
)(error)
|
|
155
156
|
} else if (Array.isArray(error.messages)) {
|
|
156
157
|
return makeMessages(error.messages, options)
|
|
@@ -209,13 +210,11 @@ export function makeMessages(error, options) {
|
|
|
209
210
|
|
|
210
211
|
return [
|
|
211
212
|
err,
|
|
212
|
-
...makeMessages(
|
|
213
|
-
error.cause,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
error.status?.messages,
|
|
218
|
-
]),
|
|
213
|
+
...makeMessages(
|
|
214
|
+
[error.cause, error.error, error.errors, error.messages, error.status?.messages].filter(
|
|
215
|
+
Boolean,
|
|
216
|
+
),
|
|
217
|
+
),
|
|
219
218
|
]
|
|
220
219
|
} else {
|
|
221
220
|
return []
|
package/package.json
CHANGED
|
@@ -164,7 +164,7 @@ class PromiseEntry {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
function pipe(value,
|
|
167
|
+
function pipe(value, fns) {
|
|
168
168
|
for (const fn of fns) {
|
|
169
169
|
value = fn(value)
|
|
170
170
|
if (value == null) {
|
|
@@ -233,6 +233,7 @@ export default function ({ ds, proxify, compiler }) {
|
|
|
233
233
|
this._wrap = null
|
|
234
234
|
this._suspended = false
|
|
235
235
|
this._errored = false
|
|
236
|
+
this._refreshImpl = this._refreshImpl.bind(this)
|
|
236
237
|
|
|
237
238
|
if (rxjs.isObservable(args)) {
|
|
238
239
|
this._subscription = args.subscribe({
|
|
@@ -250,7 +251,7 @@ export default function ({ ds, proxify, compiler }) {
|
|
|
250
251
|
})
|
|
251
252
|
} else {
|
|
252
253
|
this._args = proxify ? this.wrap(args) : args
|
|
253
|
-
this.
|
|
254
|
+
this._refreshImpl()
|
|
254
255
|
}
|
|
255
256
|
}
|
|
256
257
|
|
|
@@ -325,78 +326,78 @@ export default function ({ ds, proxify, compiler }) {
|
|
|
325
326
|
}
|
|
326
327
|
}
|
|
327
328
|
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
_refreshImpl() {
|
|
330
|
+
this._refreshing = false
|
|
330
331
|
|
|
331
|
-
if (
|
|
332
|
+
if (this._destroyed || this._disposing || this._args === kEmpty) {
|
|
332
333
|
return
|
|
333
334
|
}
|
|
334
335
|
|
|
335
|
-
|
|
336
|
+
this._counter = (this._counter + 1) & maxInt
|
|
336
337
|
|
|
337
338
|
// TODO (fix): freeze?
|
|
338
|
-
|
|
339
|
-
|
|
339
|
+
this._context.$ = this._args
|
|
340
|
+
this._context.nxt = this
|
|
340
341
|
|
|
341
342
|
const previous = compiler.current
|
|
342
|
-
compiler.current =
|
|
343
|
+
compiler.current = this
|
|
343
344
|
|
|
344
345
|
try {
|
|
345
|
-
assert(
|
|
346
|
-
const value =
|
|
347
|
-
|
|
348
|
-
if (
|
|
346
|
+
assert(this._suspended === false)
|
|
347
|
+
const value = this._script.runInContext(this._context)
|
|
348
|
+
this._errored = false
|
|
349
|
+
if (this._suspended) {
|
|
349
350
|
return
|
|
350
351
|
}
|
|
351
352
|
|
|
352
|
-
if (value !==
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
if (value !== this._value) {
|
|
354
|
+
this._value = value
|
|
355
|
+
this._observer.next(value)
|
|
355
356
|
}
|
|
356
357
|
} catch (err) {
|
|
357
358
|
if (err === kSuspend) {
|
|
358
359
|
return
|
|
359
360
|
}
|
|
360
361
|
|
|
361
|
-
|
|
362
|
+
this._errored = true
|
|
362
363
|
|
|
363
364
|
const error = Object.assign(new Error('expression failed'), {
|
|
364
365
|
cause: err,
|
|
365
|
-
data:
|
|
366
|
+
data: this._expression,
|
|
366
367
|
})
|
|
367
368
|
|
|
368
|
-
if (
|
|
369
|
+
if (this._suspended) {
|
|
369
370
|
process.emitWarning(error)
|
|
370
371
|
} else {
|
|
371
|
-
|
|
372
|
+
this._observer.error(error)
|
|
372
373
|
}
|
|
373
374
|
} finally {
|
|
374
375
|
compiler.current = previous
|
|
375
376
|
|
|
376
|
-
|
|
377
|
-
|
|
377
|
+
this._context.$ = null
|
|
378
|
+
this._context.nxt = null
|
|
378
379
|
|
|
379
|
-
|
|
380
|
-
|
|
380
|
+
this._suspended = false
|
|
381
|
+
this._disposing = true
|
|
381
382
|
|
|
382
|
-
if (
|
|
383
|
-
for (const entry of
|
|
384
|
-
if (entry.counter !==
|
|
383
|
+
if (this._entries) {
|
|
384
|
+
for (const entry of this._entries.values()) {
|
|
385
|
+
if (entry.counter !== this._counter) {
|
|
385
386
|
entry.dispose()
|
|
386
|
-
|
|
387
|
+
this._entries.delete(entry.key)
|
|
387
388
|
}
|
|
388
389
|
}
|
|
389
|
-
if (
|
|
390
|
-
|
|
390
|
+
if (this._entries.size === 0) {
|
|
391
|
+
this._entries = null
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
394
|
|
|
394
395
|
// TODO (perf): Make this work.
|
|
395
|
-
// if (!
|
|
396
|
-
//
|
|
396
|
+
// if (!this._entries) {
|
|
397
|
+
// this._args = null
|
|
397
398
|
// }
|
|
398
399
|
|
|
399
|
-
|
|
400
|
+
this._disposing = false
|
|
400
401
|
}
|
|
401
402
|
}
|
|
402
403
|
|
|
@@ -406,7 +407,7 @@ export default function ({ ds, proxify, compiler }) {
|
|
|
406
407
|
}
|
|
407
408
|
|
|
408
409
|
this._refreshing = true
|
|
409
|
-
|
|
410
|
+
queueMicrotask(this._refreshImpl)
|
|
410
411
|
}
|
|
411
412
|
|
|
412
413
|
_getEntry(key, Entry, opaque) {
|
|
@@ -569,7 +570,7 @@ export default function ({ ds, proxify, compiler }) {
|
|
|
569
570
|
script = new vm.Script(`
|
|
570
571
|
"use strict";
|
|
571
572
|
{
|
|
572
|
-
const _ = (...args) => pipe(
|
|
573
|
+
const _ = (value, ...args) => pipe(value, args);
|
|
573
574
|
_.asset = (type, state, throws) => (id) => nxt._asset(id, type, state, throws);
|
|
574
575
|
_.ds = (postfix, state, throws) => (id) => nxt._ds(id, postfix, state, throws);
|
|
575
576
|
_.timer = (dueTime) => (dueValue) => nxt.timer(dueTime, dueValue);
|