@nxtedition/lib 23.0.9 → 23.1.0

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.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { Logger } from './logger.js'
4
4
  import type { CouchClient } from './couch.js'
5
5
  import type { Server } from 'http'
6
6
  import type { BehaviorSubject } from 'rxjs'
7
+ import type { Subscription } from 'rxjs'
7
8
 
8
9
  export function makeApp<Records, RpcMethods, Config = Record<string, unknown>>(
9
10
  appConfig: AppConfig<Config>,
@@ -23,14 +24,13 @@ export interface App<Records, RpcMethods, Config = Record<string, unknown>> {
23
24
  nxt: NxtDeepstreamClient<Records, RpcMethods>
24
25
  couch: CouchClient
25
26
  server: Server
26
- compiler: unkonwn
27
+ compiler: unknown // TODO: type
27
28
  config: Config
28
29
  logger: Logger
29
- trace: unknown
30
- trace: unknown
30
+ trace: unknown // TODO: type
31
31
  toobusy: TooBusy
32
32
  destroyers: Array<
33
- | rxjs.Subscription
33
+ | Subscription
34
34
  | ((logger: Logger) => void)
35
35
  | ((logger: Logger) => Promise<void>)
36
36
  | Disposable
package/ass.js CHANGED
@@ -61,7 +61,7 @@ export function encodeASS(
61
61
  futureWordWrapping = false,
62
62
  } = {},
63
63
  ) {
64
- const scale = typeof width === 'number' ? BASE_WIDTH / width : 1
64
+ const scale = typeof width === 'number' ? BASE_HEIGHT / height : 1
65
65
  const playResX = scale * (width || BASE_WIDTH)
66
66
  const playResY = scale * (height || BASE_HEIGHT)
67
67
  return [
@@ -97,10 +97,12 @@ function formatDialogues(events, styles, scriptResX, futureWordWrapping) {
97
97
  .split(/\\n|\n|\\N/)
98
98
  .map((line) => line.trim())
99
99
  .flatMap((line) =>
100
- futureWordWrapping ? wordwrap(line, fontSize, fontFamily, maxWidth) : [line],
100
+ futureWordWrapping
101
+ ? wordwrap(line, { fontSize, fontFamily, maxWidth, breakWord: false })
102
+ : [line],
101
103
  )
102
104
  .map((line) => line.trim())
103
- .join('\\N')}`
105
+ .join('\\N')}\n`
104
106
  }
105
107
  }
106
108
  return s
package/couch.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface CouchRequestOptions<Stream extends boolean = false> {
17
17
  startkey?: string
18
18
  endkey?: string
19
19
  update?: boolean
20
+ seq?: string
20
21
  }
21
22
  seq?: string
22
23
  signal?: AbortSignal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.0.9",
3
+ "version": "23.1.0",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/wordwrap.js CHANGED
@@ -8,11 +8,13 @@ const ctx = canvas.getContext('2d')
8
8
  * Takes a string and a maxWidth and splits the text into lines.
9
9
  *
10
10
  * @param {string} text
11
- * @param {number} fontSize
12
- * @param {string} fontFamily
13
- * @param {number} maxWidth
11
+ * @param {object} options
12
+ * @param {number} options.fontSize
13
+ * @param {string} options.fontFamily
14
+ * @param {number} options.maxWidth
15
+ * @param {boolean} [options.breakWord]
14
16
  */
15
- export function wordwrap(text, fontSize, fontFamily, maxWidth) {
17
+ export function wordwrap(text, { fontSize, fontFamily, maxWidth, breakWord = true }) {
16
18
  // TODO: Register fonts
17
19
  // const fontFile = name =>
18
20
  // path.join(path.dirname(__dirname), 'fonts', `${name}.ttf`)
@@ -42,7 +44,7 @@ export function wordwrap(text, fontSize, fontFamily, maxWidth) {
42
44
  const measure = ctx.measureText(word).width
43
45
 
44
46
  // Edge case - If the current word is too long for one line, break it into maximized pieces.
45
- if (measure > maxWidth) {
47
+ if (breakWord && measure > maxWidth) {
46
48
  // TODO - a divide and conquer method might be nicer.
47
49
  const edgewords = splitWord(word, maxWidth)
48
50