@wlearn/liblinear 0.1.0 → 0.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/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@wlearn/liblinear",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "LIBLINEAR v2.50 compiled to WebAssembly -- linear classification and regression in browsers and Node.js",
5
- "type": "module",
5
+ "type": "commonjs",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
- ".": "./src/index.js"
8
+ ".": {
9
+ "require": "./src/index.js",
10
+ "default": "./src/index.js"
11
+ }
9
12
  },
10
13
  "files": [
11
14
  "src/",
12
15
  "wasm/",
16
+ "dist/",
13
17
  "LICENSE",
14
18
  "README.md",
15
19
  "CHANGELOG.md"
@@ -19,13 +23,15 @@
19
23
  "access": "public"
20
24
  },
21
25
  "scripts": {
22
- "test": "node --experimental-vm-modules test/test.js",
26
+ "test": "node test/test.js",
23
27
  "build": "bash scripts/build-wasm.sh",
24
- "verify": "bash scripts/verify-exports.sh"
28
+ "build:browser": "bash scripts/build-browser.sh",
29
+ "verify": "bash scripts/verify-exports.sh",
30
+ "prepack": "node scripts/prepack.js",
31
+ "prepublishOnly": "node scripts/prepublish.js"
25
32
  },
26
33
  "dependencies": {
27
- "@wlearn/types": "0.1.0",
28
- "@wlearn/core": "0.1.0"
34
+ "@wlearn/core": "0.2.0"
29
35
  },
30
36
  "keywords": [
31
37
  "liblinear",
@@ -37,5 +43,17 @@
37
43
  "wlearn"
38
44
  ],
39
45
  "author": "Anton Zemlyansky",
40
- "license": "BSD-3-Clause"
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/wlearn-org/liblinear-wasm.git"
49
+ },
50
+ "license": "BSD-3-Clause",
51
+ "devDependencies": {
52
+ "esbuild": "^0.27.3",
53
+ "playwright": "^1.58.2"
54
+ },
55
+ "bugs": {
56
+ "url": "https://github.com/wlearn-org/liblinear-wasm/issues"
57
+ },
58
+ "homepage": "https://wlearn.org"
41
59
  }
package/src/index.js CHANGED
@@ -1,17 +1,22 @@
1
- export { loadLinear, getWasm } from './wasm.js'
2
- export { LinearModel, Solver } from './model.js'
1
+ const { loadLinear, getWasm } = require('./wasm.js')
2
+ const { LinearModel: LinearModelImpl, Solver } = require('./model.js')
3
+ const { createModelClass } = require('@wlearn/core')
4
+
5
+ const LinearModel = createModelClass(LinearModelImpl, LinearModelImpl, { name: 'LinearModel', load: loadLinear })
3
6
 
4
7
  // Convenience: create, fit, return fitted model
5
- export async function train(params, X, y) {
8
+ async function train(params, X, y) {
6
9
  const model = await LinearModel.create(params)
7
- model.fit(X, y)
10
+ await model.fit(X, y)
8
11
  return model
9
12
  }
10
13
 
11
14
  // Convenience: load WLRN bundle and predict, auto-disposes model
12
- export async function predict(bundleBytes, X) {
15
+ async function predict(bundleBytes, X) {
13
16
  const model = await LinearModel.load(bundleBytes)
14
17
  const result = model.predict(X)
15
18
  model.dispose()
16
19
  return result
17
20
  }
21
+
22
+ module.exports = { loadLinear, getWasm, LinearModel, Solver, train, predict }
package/src/model.js CHANGED
@@ -1,10 +1,10 @@
1
- import { getWasm, loadLinear } from './wasm.js'
2
- import {
1
+ const { getWasm, loadLinear } = require('./wasm.js')
2
+ const {
3
3
  normalizeX, normalizeY,
4
4
  encodeBundle, decodeBundle,
5
5
  register,
6
6
  DisposedError, NotFittedError
7
- } from '@wlearn/core'
7
+ } = require('@wlearn/core')
8
8
 
9
9
  // FinalizationRegistry safety net -- warns if dispose() was never called
10
10
  const leakRegistry = typeof FinalizationRegistry !== 'undefined'
@@ -18,7 +18,7 @@ const leakRegistry = typeof FinalizationRegistry !== 'undefined'
18
18
 
19
19
  // --- Solver constants ---
20
20
 
21
- export const Solver = {
21
+ const Solver = {
22
22
  L2R_LR: 0,
23
23
  L2R_L2LOSS_SVC_DUAL: 1,
24
24
  L2R_L2LOSS_SVC: 2,
@@ -68,7 +68,7 @@ const LOAD_SENTINEL = Symbol('load')
68
68
 
69
69
  // --- LinearModel ---
70
70
 
71
- export class LinearModel {
71
+ class LinearModel {
72
72
  #handle = null
73
73
  #freed = false
74
74
  #ptrRef = null
@@ -473,3 +473,5 @@ export class LinearModel {
473
473
 
474
474
  register('wlearn.liblinear.classifier@1', (m, t, b) => LinearModel._fromBundle(m, t, b))
475
475
  register('wlearn.liblinear.regressor@1', (m, t, b) => LinearModel._fromBundle(m, t, b))
476
+
477
+ module.exports = { LinearModel, Solver }
package/src/wasm.js CHANGED
@@ -1,19 +1,15 @@
1
1
  // WASM loader -- loads the LIBLINEAR WASM module (singleton, lazy init)
2
2
 
3
- import { createRequire } from 'module'
4
-
5
3
  let wasmModule = null
6
4
  let loading = null
7
5
 
8
- export async function loadLinear(options = {}) {
6
+ async function loadLinear(options = {}) {
9
7
  if (wasmModule) return wasmModule
10
8
  if (loading) return loading
11
9
 
12
10
  loading = (async () => {
13
11
  // SINGLE_FILE=1: .wasm is embedded in the .js file, no locateFile needed
14
- // Emscripten output is CJS, use createRequire for ESM compatibility
15
- const require = createRequire(import.meta.url)
16
- const createLinear = require('../wasm/linear.cjs')
12
+ const createLinear = require('../wasm/linear.js')
17
13
  wasmModule = await createLinear(options)
18
14
  return wasmModule
19
15
  })()
@@ -21,7 +17,9 @@ export async function loadLinear(options = {}) {
21
17
  return loading
22
18
  }
23
19
 
24
- export function getWasm() {
20
+ function getWasm() {
25
21
  if (!wasmModule) throw new Error('WASM not loaded -- call loadLinear() first')
26
22
  return wasmModule
27
23
  }
24
+
25
+ module.exports = { loadLinear, getWasm }
package/wasm/BUILD_INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  upstream: liblinear v2.50
2
2
  upstream_commit: 491c9f1188b97ba70847c70a68be363d186ddf9d
3
- build_date: 2026-02-27T13:01:37Z
3
+ build_date: 2026-05-25T14:47:50Z
4
4
  emscripten: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 5.0.2 (dc80f645ee70178c11666de0c3860d9e064d50e4)
5
5
  build_flags: -O2 SINGLE_FILE=1
6
6
  wasm_embedded: true