taffy-js 0.2.4 → 0.2.5
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/README.md +3 -2
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -16
- package/taffy_js.d.ts +0 -2074
- package/taffy_js.js +0 -3015
- package/taffy_js_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -23,7 +23,8 @@ npm install taffy-js
|
|
|
23
23
|
## 🚀 Quick Start
|
|
24
24
|
|
|
25
25
|
```javascript
|
|
26
|
-
import
|
|
26
|
+
import {
|
|
27
|
+
loadTaffy,
|
|
27
28
|
TaffyTree,
|
|
28
29
|
Style,
|
|
29
30
|
Display,
|
|
@@ -33,7 +34,7 @@ import init, {
|
|
|
33
34
|
|
|
34
35
|
async function main() {
|
|
35
36
|
// Initialize WebAssembly module
|
|
36
|
-
await
|
|
37
|
+
await loadTaffy();
|
|
37
38
|
|
|
38
39
|
// Create a layout tree
|
|
39
40
|
const tree = new TaffyTree();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taffy-JS: TypeScript wrapper for Taffy WASM bindings
|
|
3
|
+
*
|
|
4
|
+
* This module provides the `loadTaffy` function for initializing the WASM module
|
|
5
|
+
* and re-exports all types and functions from the underlying WASM bindings.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { loadTaffy, TaffyTree, Style, Display } from 'taffy-js';
|
|
10
|
+
*
|
|
11
|
+
* await loadTaffy();
|
|
12
|
+
*
|
|
13
|
+
* const tree = new TaffyTree();
|
|
14
|
+
* const style = new Style();
|
|
15
|
+
* style.display = Display.Flex;
|
|
16
|
+
* const node = tree.newLeaf(style);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export * from "../pkg/taffy_wasm.js";
|
|
20
|
+
export type { InitOutput } from "../pkg/taffy_wasm.js";
|
|
21
|
+
import type { InitOutput } from "../pkg/taffy_wasm.js";
|
|
22
|
+
/**
|
|
23
|
+
* Universal initialization function for Taffy WASM module.
|
|
24
|
+
*
|
|
25
|
+
* Automatically detects the environment (Web or Node.js) and loads the WASM accordingly.
|
|
26
|
+
* - In a **Web environment**, it uses `fetch` to load the WASM file.
|
|
27
|
+
* - In a **Node.js environment**, it uses `fs` to read the WASM file.
|
|
28
|
+
*
|
|
29
|
+
* @returns - A promise that resolves to the WASM module exports.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { loadTaffy } from 'taffy-js';
|
|
34
|
+
* await loadTaffy();
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function loadTaffy(): Promise<InitOutput>;
|
|
38
|
+
export default loadTaffy;
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAavD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAkBrD;AAGD,eAAe,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taffy-JS: TypeScript wrapper for Taffy WASM bindings
|
|
3
|
+
*
|
|
4
|
+
* This module provides the `loadTaffy` function for initializing the WASM module
|
|
5
|
+
* and re-exports all types and functions from the underlying WASM bindings.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { loadTaffy, TaffyTree, Style, Display } from 'taffy-js';
|
|
10
|
+
*
|
|
11
|
+
* await loadTaffy();
|
|
12
|
+
*
|
|
13
|
+
* const tree = new TaffyTree();
|
|
14
|
+
* const style = new Style();
|
|
15
|
+
* style.display = Display.Flex;
|
|
16
|
+
* const node = tree.newLeaf(style);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
// Re-export everything from the WASM module
|
|
20
|
+
export * from "../pkg/taffy_wasm.js";
|
|
21
|
+
// Import the init functions for the loader
|
|
22
|
+
import init, { initSync } from "../pkg/taffy_wasm.js";
|
|
23
|
+
/**
|
|
24
|
+
* Detects if running in a Node.js environment
|
|
25
|
+
*/
|
|
26
|
+
function isNode() {
|
|
27
|
+
return (typeof process !== "undefined" &&
|
|
28
|
+
process.versions != null &&
|
|
29
|
+
process.versions.node != null);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Universal initialization function for Taffy WASM module.
|
|
33
|
+
*
|
|
34
|
+
* Automatically detects the environment (Web or Node.js) and loads the WASM accordingly.
|
|
35
|
+
* - In a **Web environment**, it uses `fetch` to load the WASM file.
|
|
36
|
+
* - In a **Node.js environment**, it uses `fs` to read the WASM file.
|
|
37
|
+
*
|
|
38
|
+
* @returns - A promise that resolves to the WASM module exports.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { loadTaffy } from 'taffy-js';
|
|
43
|
+
* await loadTaffy();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export async function loadTaffy() {
|
|
47
|
+
if (isNode()) {
|
|
48
|
+
// Node.js environment - use fs to read the WASM file
|
|
49
|
+
const fs = await import("fs");
|
|
50
|
+
const url = await import("url");
|
|
51
|
+
const path = await import("path");
|
|
52
|
+
// Resolve WASM path relative to this module
|
|
53
|
+
const __filename = url.fileURLToPath(import.meta.url);
|
|
54
|
+
const __dirname = path.dirname(__filename);
|
|
55
|
+
const wasmPath = path.join(__dirname, "..", "pkg", "taffy_wasm_bg.wasm");
|
|
56
|
+
const wasmBuffer = fs.readFileSync(wasmPath);
|
|
57
|
+
return initSync({ module: wasmBuffer });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Web environment - use fetch via the default init function
|
|
61
|
+
return await init();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Default export for convenience
|
|
65
|
+
export default loadTaffy;
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,4CAA4C;AAC5C,cAAc,sBAAsB,CAAC;AAGrC,2CAA2C;AAC3C,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,SAAS,MAAM;IACb,OAAO,CACL,OAAO,OAAO,KAAK,WAAW;QAC9B,OAAO,CAAC,QAAQ,IAAI,IAAI;QACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAC9B,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,IAAI,MAAM,EAAE,EAAE,CAAC;QACb,qDAAqD;QACrD,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QAElC,4CAA4C;QAC5C,MAAM,UAAU,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC;QAEzE,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,4DAA4D;QAC5D,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;AACH,CAAC;AAED,iCAAiC;AACjC,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taffy-js",
|
|
3
|
-
"
|
|
4
|
-
"collaborators": [
|
|
5
|
-
"ByteLandTechnology <github@byteland.app>"
|
|
6
|
-
],
|
|
3
|
+
"version": "0.2.5",
|
|
7
4
|
"description": "WebAssembly bindings for Taffy layout library",
|
|
8
|
-
"
|
|
9
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"layout",
|
|
7
|
+
"flexbox",
|
|
8
|
+
"css-grid",
|
|
9
|
+
"grid",
|
|
10
|
+
"ui",
|
|
11
|
+
"wasm",
|
|
12
|
+
"webassembly"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/ByteLandTechnology/taffy-js#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/ByteLandTechnology/taffy-js/issues"
|
|
17
|
+
},
|
|
10
18
|
"repository": {
|
|
11
19
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/ByteLandTechnology/taffy-js"
|
|
20
|
+
"url": "git+https://github.com/ByteLandTechnology/taffy-js.git"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "ByteLandTechnology <github@byteland.app>",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./wasm": {
|
|
33
|
+
"types": "./pkg/taffy_wasm.d.ts",
|
|
34
|
+
"import": "./pkg/taffy_wasm.js"
|
|
35
|
+
}
|
|
13
36
|
},
|
|
14
37
|
"files": [
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"taffy_js.d.ts"
|
|
38
|
+
"dist",
|
|
39
|
+
"pkg"
|
|
18
40
|
],
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "npm run build:wasm && npm run build:ts && npm run docs",
|
|
43
|
+
"build:wasm": "wasm-pack build --release --target web && npm run patch-dts",
|
|
44
|
+
"build:ts": "tsc",
|
|
45
|
+
"build:dev": "wasm-pack build --dev --target web && npm run patch-dts && npm run build:ts",
|
|
46
|
+
"docs": "typedoc && prettier --write docs",
|
|
47
|
+
"patch-dts": "npx tsx scripts/patch-dts.ts",
|
|
48
|
+
"test": "wasm-pack test --node",
|
|
49
|
+
"prepare": "husky"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@commitlint/cli": "^20.3.0",
|
|
53
|
+
"@commitlint/config-conventional": "^20.3.0",
|
|
54
|
+
"@types/node": "^22.0.0",
|
|
55
|
+
"husky": "^9.1.7",
|
|
56
|
+
"lint-staged": "^16.2.7",
|
|
57
|
+
"prettier": "^3.7.4",
|
|
58
|
+
"tsx": "^4.0.0",
|
|
59
|
+
"typedoc": "^0.28.15",
|
|
60
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
61
|
+
"typescript": "^5.7.0",
|
|
62
|
+
"wasm-pack": "^0.13.1"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=12"
|
|
66
|
+
},
|
|
67
|
+
"overrides": {
|
|
68
|
+
"axios": "^1.7.9"
|
|
69
|
+
},
|
|
70
|
+
"commitlint": {
|
|
71
|
+
"extends": [
|
|
72
|
+
"@commitlint/config-conventional"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"lint-staged": {
|
|
76
|
+
"*.{js,ts,jsx,tsx,json,md,yaml,yml}": "prettier --write",
|
|
77
|
+
"*.rs": "cargo fmt --"
|
|
78
|
+
}
|
|
79
|
+
}
|