@nxtedition/lib 23.0.10 → 23.2.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.js +12 -0
- package/ass.js +5 -3
- package/couch.d.ts +3 -0
- package/package.json +1 -1
- package/wordwrap.js +7 -5
package/app.js
CHANGED
|
@@ -993,6 +993,18 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
993
993
|
const server = http
|
|
994
994
|
.createServer(async (req, res) => {
|
|
995
995
|
try {
|
|
996
|
+
if (req.method === 'GET' && req.url === '/stats') {
|
|
997
|
+
res.setHeader('content-type', 'application/json')
|
|
998
|
+
res.end(JSON.stringify(stats$.value))
|
|
999
|
+
return
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
if (req.method === 'GET' && req.url === '/status') {
|
|
1003
|
+
res.setHeader('content-type', 'application/json')
|
|
1004
|
+
res.end(JSON.stringify(status$.value))
|
|
1005
|
+
return
|
|
1006
|
+
}
|
|
1007
|
+
|
|
996
1008
|
if (req.method === 'POST' && req.url === '/gc') {
|
|
997
1009
|
utilsBC.postMessage({ type: 'utils:gc' })
|
|
998
1010
|
res.end()
|
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' ?
|
|
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
|
|
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
|
@@ -11,13 +11,16 @@ export interface CouchRequestOptions<Stream extends boolean = false> {
|
|
|
11
11
|
url?: URL
|
|
12
12
|
pathname?: string
|
|
13
13
|
path?: string
|
|
14
|
+
headers?: Record<string, string>
|
|
14
15
|
method?: string
|
|
15
16
|
body?: unknown
|
|
16
17
|
query?: {
|
|
17
18
|
startkey?: string
|
|
18
19
|
endkey?: string
|
|
19
20
|
update?: boolean
|
|
21
|
+
seq?: string
|
|
20
22
|
}
|
|
23
|
+
blocking?: boolean
|
|
21
24
|
seq?: string
|
|
22
25
|
signal?: AbortSignal
|
|
23
26
|
logger?: Logger
|
package/package.json
CHANGED
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 {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
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
|
|