11import { createRequire } from "module" ;
2- import { OCCTService } from "@bitbybit-dev/occt/lib/occ-service.js" ;
3- import { OccHelper } from "@bitbybit-dev/occt/lib/occ-helper.js" ;
4- import { VectorHelperService } from "@bitbybit-dev/occt/lib/api/vector-helper.service.js" ;
5- import { ShapesHelperService } from "@bitbybit-dev/occt/lib/api/shapes-helper.service.js" ;
6- import initOpenCascade from "@bitbybit-dev/occt/bitbybit-dev-occt/index.js" ;
2+
3+ // Base utilities
4+ import {
5+ MathBitByBit ,
6+ Logic ,
7+ Lists ,
8+ TextBitByBit ,
9+ Vector ,
10+ Point ,
11+ Transforms ,
12+ Color ,
13+ GeometryHelper ,
14+ Line ,
15+ Polyline ,
16+ } from "@bitbybit-dev/base" ;
17+
18+ // Core functionality
19+ import { JSONBitByBit , CSVBitByBit , Verb , ContextBase } from "@bitbybit-dev/core" ;
20+
21+ // JSCAD for Node.js
22+ import { Jscad } from "@bitbybit-dev/jscad" ;
23+
24+ // Manifold for Node.js
25+ import { ManifoldService } from "@bitbybit-dev/manifold" ;
26+
27+ // OCCT for Node.js
28+ import { OCCTService , OccHelper , VectorHelperService , ShapesHelperService } from "@bitbybit-dev/occt" ;
29+ import initOpenCascade , { BitbybitOcctModule } from "@bitbybit-dev/occt/bitbybit-dev-occt/index.js" ;
30+
31+ // Manifold WASM module
32+ import Module from "manifold-3d" ;
33+
34+ // JSON path for advanced JSON queries
35+ import { JSONPath } from "jsonpath-plus" ;
36+
37+ // NURBS functionality
38+ import vrb from "verb-nurbs-web" ;
739
840const require = createRequire ( import . meta. url ) ;
941
1042export class BitByBitBase {
11- public occt ! : OCCTService ;
43+ // Base utilities
44+ public math ! : MathBitByBit ;
45+ public logic ! : Logic ;
46+ public lists ! : Lists ;
47+ public text ! : TextBitByBit ;
48+ public vector ! : Vector ;
49+ public point ! : Point ;
50+ public transforms ! : Transforms ;
51+ public color ! : Color ;
52+ public line ! : Line ;
53+ public polyline ! : Polyline ;
1254
13- constructor ( ) {
14- }
55+ // Core functionality
56+ public json ! : JSONBitByBit ;
57+ public csv ! : CSVBitByBit ;
58+ public verb ! : Verb ;
59+
60+ // Geometry kernels
61+ public jscad ! : Jscad ;
62+ public manifold ! : ManifoldService ;
63+ public occt ! : OCCTService ;
1564
1665 async init ( ) {
17- // For Node.js, we need to specify the path to the WASM file
66+ // Initialize OCCT (OpenCascade) with locateFile for Node.js WASM loading
1867 const wasmPath = require . resolve ( "@bitbybit-dev/occt/bitbybit-dev-occt/bitbybit-dev-occt.5e93f201.wasm" ) ;
19-
20- const occ = await initOpenCascade ( {
68+ const occ = await ( initOpenCascade as ( options ?: { locateFile ?: ( path : string ) => string } ) => Promise < BitbybitOcctModule > ) ( {
2169 locateFile : ( path : string ) => {
2270 if ( path . endsWith ( ".wasm" ) ) {
2371 return wasmPath ;
@@ -26,6 +74,42 @@ export class BitByBitBase {
2674 }
2775 } ) ;
2876
77+ // Initialize JSCAD
78+ const jscadModule = await import ( "@bitbybit-dev/jscad/jscad-generated.js" ) ;
79+ const jscad = jscadModule . default ( ) ;
80+ this . jscad = new Jscad ( jscad ) ;
81+
82+ // Initialize Manifold
83+ const manifoldWasmPath = require . resolve ( "manifold-3d/manifold.wasm" ) ;
84+ const wasm = await Module ( {
85+ locateFile : ( ) => manifoldWasmPath ,
86+ } ) ;
87+ wasm . setup ( ) ;
88+ this . manifold = new ManifoldService ( wasm ) ;
89+
90+ // Initialize base utilities
91+ const geometryHelper = new GeometryHelper ( ) ;
92+ this . math = new MathBitByBit ( ) ;
93+ this . lists = new Lists ( ) ;
94+ this . logic = new Logic ( ) ;
95+ this . color = new Color ( this . math ) ;
96+ this . vector = new Vector ( this . math , geometryHelper ) ;
97+ this . transforms = new Transforms ( this . vector , this . math ) ;
98+ this . point = new Point ( geometryHelper , this . transforms , this . vector , this . lists ) ;
99+ this . line = new Line ( this . vector , this . point , geometryHelper ) ;
100+ this . polyline = new Polyline ( this . vector , this . point , this . line , geometryHelper ) ;
101+ this . text = new TextBitByBit ( this . point ) ;
102+
103+ // Initialize core functionality with context
104+ const context = new ContextBase ( ) ;
105+ context . verb = { geom : vrb . geom , core : vrb . core } ;
106+ context . jsonpath = JSONPath ;
107+
108+ this . verb = new Verb ( context , geometryHelper , this . math ) ;
109+ this . json = new JSONBitByBit ( context ) ;
110+ this . csv = new CSVBitByBit ( ) ;
111+
112+ // Initialize OCCT service
29113 const vecHelper = new VectorHelperService ( ) ;
30114 const shapesHelper = new ShapesHelperService ( ) ;
31115 const occHelper = new OccHelper ( vecHelper , shapesHelper , occ ) ;
0 commit comments