@nxtedition/lib 23.15.1 → 23.15.3

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 CHANGED
@@ -391,6 +391,7 @@ export function makeApp(appConfig, onTerminate) {
391
391
  {
392
392
  userAgent,
393
393
  url: isProduction ? 'ws://deepstream:6020/deepstream' : 'ws://127.0.0.1:6020/deepstream',
394
+ schedule: (fn) => setImmediate(fn),
394
395
  },
395
396
  appConfig.deepstream,
396
397
  config.deepstream,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.15.1",
3
+ "version": "23.15.3",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -6,6 +6,7 @@ export interface MakeTemplateCompilerParams {
6
6
  ds?: DeepstreamClient
7
7
  proxify?: unknown
8
8
  logger?: unknown
9
+ platform?: unknown
9
10
  }
10
11
 
11
12
  export function makeTemplateCompiler(params: MakeTemplateCompilerParams): TemplateCompiler
@@ -27,6 +27,7 @@ export function makeTemplateCompiler({ ds, proxify, logger = console }) {
27
27
  },
28
28
  }
29
29
  },
30
+ schedule: (fn) => setTimeout(fn, 0),
30
31
  },
31
32
  })
32
33
  }
@@ -3,7 +3,7 @@ import { readFileSync } from 'node:fs'
3
3
  import { initSync } from '@swc/wasm-web'
4
4
  import { makeTemplateCompiler as commonMakeTemplateCompiler } from './index-common.js'
5
5
  import { hashSync } from 'hasha'
6
- import { request, Agent } from '@nxtedition/nxt-undici'
6
+ import { request } from '@nxtedition/nxt-undici'
7
7
 
8
8
  export * from './index-common.js'
9
9
 
@@ -13,13 +13,9 @@ const wasmBuffer = readFileSync(wasmPath)
13
13
 
14
14
  initSync({ module: wasmBuffer })
15
15
 
16
- const defaultFetchClient = new Agent({
17
- connections: 128,
18
- })
19
-
20
16
  export function makeTemplateCompiler({
21
17
  logger = globalThis.__nxt_lib_app?.logger,
22
- dispatcher = defaultFetchClient,
18
+ dispatcher,
23
19
  platform,
24
20
  ...args
25
21
  }) {
@@ -30,8 +26,9 @@ export function makeTemplateCompiler({
30
26
  platform: {
31
27
  hasha: hashSync,
32
28
  fetch: (resource, options) =>
33
- request(resource, options ? { dispatcher, ...options } : defaultOptions),
29
+ request(resource, options && dispatcher ? { dispatcher, ...options } : defaultOptions),
34
30
  ...platform,
31
+ schedule: (fn) => setImmediate(fn),
35
32
  },
36
33
  })
37
34
  }
@@ -223,6 +223,8 @@ function makeWrapper(expression) {
223
223
  }
224
224
 
225
225
  export default function ({ ds, proxify, compiler, logger, platform }) {
226
+ const schedule = platform?.schedule ?? ((fn) => queueMicrotask(fn))
227
+
226
228
  class Expression {
227
229
  constructor(script, expression, args, observer) {
228
230
  this._expression = expression
@@ -453,7 +455,7 @@ export default function ({ ds, proxify, compiler, logger, platform }) {
453
455
  }
454
456
 
455
457
  this._refreshing = true
456
- setImmediate(this._refreshImpl)
458
+ schedule(this._refreshImpl)
457
459
  }
458
460
 
459
461
  _getEntry(key, Entry, opaque) {