@nxtedition/lib 22.0.9 → 22.0.10

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/ass.js CHANGED
@@ -93,7 +93,7 @@ function encASSStyles({ styles, width, height }) {
93
93
  for (const [id, style] of Object.entries(styles)) {
94
94
  scaledStyles[id] = { ...style }
95
95
  for (const key of ['fontsize', 'marginV', 'marginL', 'marginR']) {
96
- const scale = key === 'fontsize' ? height / BASE_HEIGHT : width / BASE_WIDTH
96
+ const scale = width / BASE_WIDTH
97
97
 
98
98
  if (typeof style[key] === 'string') {
99
99
  const scaled = Number(style[key]) * scale
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "22.0.9",
3
+ "version": "22.0.10",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -1,12 +1,19 @@
1
1
  import { createRequire } from 'node:module'
2
2
  import { readFileSync } from 'node:fs'
3
3
  import { parseSync, printSync, initSync } from '@swc/wasm-web'
4
+ import init from '@swc/wasm-web'
4
5
 
5
- const require = createRequire(import.meta.url)
6
- const wasmPath = require.resolve('@swc/wasm-web').replace('wasm.js', 'wasm_bg.wasm')
7
- const wasmBuffer = readFileSync(wasmPath)
6
+ const isNode = typeof process !== 'undefined' && process.toString() === '[object process]'
8
7
 
9
- initSync({ module: wasmBuffer })
8
+ if (isNode) {
9
+ const require = createRequire(import.meta.url)
10
+ const wasmPath = require.resolve('@swc/wasm-web').replace('wasm.js', 'wasm_bg.wasm')
11
+ const wasmBuffer = readFileSync(wasmPath)
12
+
13
+ initSync({ module: wasmBuffer })
14
+ } else {
15
+ await init()
16
+ }
10
17
 
11
18
  export default function (code) {
12
19
  const ast = parseSync(code, { syntax: 'ecmascript', script: true })