brepkit-wasm 2.30.0 → 2.32.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/brepkit_wasm.d.ts CHANGED
@@ -1476,12 +1476,17 @@ export class BrepKernel {
1476
1476
  * Returns an error if thickness is non-positive or the solid is invalid.
1477
1477
  */
1478
1478
  shell(solid: number, thickness: number, open_faces: Uint32Array): number;
1479
+ /**
1480
+ * Add an arc to a sketch (defined by center, start, end point indices).
1481
+ * Returns the arc index.
1482
+ */
1483
+ sketchAddArc(sketch: number, center_idx: number, start_idx: number, end_idx: number): number;
1479
1484
  /**
1480
1485
  * Add a constraint to a sketch from a JSON string.
1481
1486
  *
1482
- * Formats: `{"type":"coincident","p1":0,"p2":1}`,
1483
- * `{"type":"distance","p1":0,"p2":1,"value":5.0}`,
1484
- * `{"type":"fixX","point":0,"value":1.0}`, etc.
1487
+ * Supports all legacy constraint types plus arc-referencing constraints:
1488
+ * `tangentLineArc`, `tangentArcArc`, `pointOnArc`, `equalRadiusArcArc`,
1489
+ * `arcLength`, `concentricArcArc`.
1485
1490
  */
1486
1491
  sketchAddConstraint(sketch: number, json: string): void;
1487
1492
  /**
@@ -1501,7 +1506,8 @@ export class BrepKernel {
1501
1506
  /**
1502
1507
  * Solve the sketch constraints.
1503
1508
  *
1504
- * Returns a JSON string: `{"converged": bool, "iterations": n, "maxResidual": f, "points": [[x,y], ...]}`.
1509
+ * Returns a JSON string with converged status, iteration count, point
1510
+ * positions, and arc definitions.
1505
1511
  */
1506
1512
  sketchSolve(sketch: number, max_iterations: number, tolerance: number): string;
1507
1513
  /**
@@ -3346,12 +3346,28 @@ export class BrepKernel {
3346
3346
  }
3347
3347
  return ret[0] >>> 0;
3348
3348
  }
3349
+ /**
3350
+ * Add an arc to a sketch (defined by center, start, end point indices).
3351
+ * Returns the arc index.
3352
+ * @param {number} sketch
3353
+ * @param {number} center_idx
3354
+ * @param {number} start_idx
3355
+ * @param {number} end_idx
3356
+ * @returns {number}
3357
+ */
3358
+ sketchAddArc(sketch, center_idx, start_idx, end_idx) {
3359
+ const ret = wasm.brepkernel_sketchAddArc(this.__wbg_ptr, sketch, center_idx, start_idx, end_idx);
3360
+ if (ret[2]) {
3361
+ throw takeFromExternrefTable0(ret[1]);
3362
+ }
3363
+ return ret[0] >>> 0;
3364
+ }
3349
3365
  /**
3350
3366
  * Add a constraint to a sketch from a JSON string.
3351
3367
  *
3352
- * Formats: `{"type":"coincident","p1":0,"p2":1}`,
3353
- * `{"type":"distance","p1":0,"p2":1,"value":5.0}`,
3354
- * `{"type":"fixX","point":0,"value":1.0}`, etc.
3368
+ * Supports all legacy constraint types plus arc-referencing constraints:
3369
+ * `tangentLineArc`, `tangentArcArc`, `pointOnArc`, `equalRadiusArcArc`,
3370
+ * `arcLength`, `concentricArcArc`.
3355
3371
  * @param {number} sketch
3356
3372
  * @param {string} json
3357
3373
  */
@@ -3414,7 +3430,8 @@ export class BrepKernel {
3414
3430
  /**
3415
3431
  * Solve the sketch constraints.
3416
3432
  *
3417
- * Returns a JSON string: `{"converged": bool, "iterations": n, "maxResidual": f, "points": [[x,y], ...]}`.
3433
+ * Returns a JSON string with converged status, iteration count, point
3434
+ * positions, and arc definitions.
3418
3435
  * @param {number} sketch
3419
3436
  * @param {number} max_iterations
3420
3437
  * @param {number} tolerance
@@ -4277,6 +4294,13 @@ export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
4277
4294
  const ret = Error(getStringFromWasm0(arg0, arg1));
4278
4295
  return ret;
4279
4296
  }
4297
+ export function __wbg___wbindgen_debug_string_5398f5bb970e0daa(arg0, arg1) {
4298
+ const ret = debugString(arg1);
4299
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4300
+ const len1 = WASM_VECTOR_LEN;
4301
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4302
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4303
+ }
4280
4304
  export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
4281
4305
  throw new Error(getStringFromWasm0(arg0, arg1));
4282
4306
  }
@@ -4310,6 +4334,71 @@ const JsVec3Finalization = (typeof FinalizationRegistry === 'undefined')
4310
4334
  ? { register: () => {}, unregister: () => {} }
4311
4335
  : new FinalizationRegistry(ptr => wasm.__wbg_jsvec3_free(ptr >>> 0, 1));
4312
4336
 
4337
+ function debugString(val) {
4338
+ // primitive types
4339
+ const type = typeof val;
4340
+ if (type == 'number' || type == 'boolean' || val == null) {
4341
+ return `${val}`;
4342
+ }
4343
+ if (type == 'string') {
4344
+ return `"${val}"`;
4345
+ }
4346
+ if (type == 'symbol') {
4347
+ const description = val.description;
4348
+ if (description == null) {
4349
+ return 'Symbol';
4350
+ } else {
4351
+ return `Symbol(${description})`;
4352
+ }
4353
+ }
4354
+ if (type == 'function') {
4355
+ const name = val.name;
4356
+ if (typeof name == 'string' && name.length > 0) {
4357
+ return `Function(${name})`;
4358
+ } else {
4359
+ return 'Function';
4360
+ }
4361
+ }
4362
+ // objects
4363
+ if (Array.isArray(val)) {
4364
+ const length = val.length;
4365
+ let debug = '[';
4366
+ if (length > 0) {
4367
+ debug += debugString(val[0]);
4368
+ }
4369
+ for(let i = 1; i < length; i++) {
4370
+ debug += ', ' + debugString(val[i]);
4371
+ }
4372
+ debug += ']';
4373
+ return debug;
4374
+ }
4375
+ // Test for built-in
4376
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
4377
+ let className;
4378
+ if (builtInMatches && builtInMatches.length > 1) {
4379
+ className = builtInMatches[1];
4380
+ } else {
4381
+ // Failed to match the standard '[object ClassName]'
4382
+ return toString.call(val);
4383
+ }
4384
+ if (className == 'Object') {
4385
+ // we're a user defined class or Object
4386
+ // JSON.stringify avoids problems with cycles, and is generally much
4387
+ // easier than looping through ownProperties of `val`.
4388
+ try {
4389
+ return 'Object(' + JSON.stringify(val) + ')';
4390
+ } catch (_) {
4391
+ return 'Object';
4392
+ }
4393
+ }
4394
+ // errors
4395
+ if (val instanceof Error) {
4396
+ return `${val.name}: ${val.message}\n${val.stack}`;
4397
+ }
4398
+ // TODO we could test for more things here, like `Set`s and `Map`s.
4399
+ return className;
4400
+ }
4401
+
4313
4402
  function getArrayF64FromWasm0(ptr, len) {
4314
4403
  ptr = ptr >>> 0;
4315
4404
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
@@ -4325,6 +4414,14 @@ function getArrayU8FromWasm0(ptr, len) {
4325
4414
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4326
4415
  }
4327
4416
 
4417
+ let cachedDataViewMemory0 = null;
4418
+ function getDataViewMemory0() {
4419
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
4420
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
4421
+ }
4422
+ return cachedDataViewMemory0;
4423
+ }
4424
+
4328
4425
  let cachedFloat64ArrayMemory0 = null;
4329
4426
  function getFloat64ArrayMemory0() {
4330
4427
  if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
Binary file
@@ -3348,12 +3348,28 @@ class BrepKernel {
3348
3348
  }
3349
3349
  return ret[0] >>> 0;
3350
3350
  }
3351
+ /**
3352
+ * Add an arc to a sketch (defined by center, start, end point indices).
3353
+ * Returns the arc index.
3354
+ * @param {number} sketch
3355
+ * @param {number} center_idx
3356
+ * @param {number} start_idx
3357
+ * @param {number} end_idx
3358
+ * @returns {number}
3359
+ */
3360
+ sketchAddArc(sketch, center_idx, start_idx, end_idx) {
3361
+ const ret = wasm.brepkernel_sketchAddArc(this.__wbg_ptr, sketch, center_idx, start_idx, end_idx);
3362
+ if (ret[2]) {
3363
+ throw takeFromExternrefTable0(ret[1]);
3364
+ }
3365
+ return ret[0] >>> 0;
3366
+ }
3351
3367
  /**
3352
3368
  * Add a constraint to a sketch from a JSON string.
3353
3369
  *
3354
- * Formats: `{"type":"coincident","p1":0,"p2":1}`,
3355
- * `{"type":"distance","p1":0,"p2":1,"value":5.0}`,
3356
- * `{"type":"fixX","point":0,"value":1.0}`, etc.
3370
+ * Supports all legacy constraint types plus arc-referencing constraints:
3371
+ * `tangentLineArc`, `tangentArcArc`, `pointOnArc`, `equalRadiusArcArc`,
3372
+ * `arcLength`, `concentricArcArc`.
3357
3373
  * @param {number} sketch
3358
3374
  * @param {string} json
3359
3375
  */
@@ -3416,7 +3432,8 @@ class BrepKernel {
3416
3432
  /**
3417
3433
  * Solve the sketch constraints.
3418
3434
  *
3419
- * Returns a JSON string: `{"converged": bool, "iterations": n, "maxResidual": f, "points": [[x,y], ...]}`.
3435
+ * Returns a JSON string with converged status, iteration count, point
3436
+ * positions, and arc definitions.
3420
3437
  * @param {number} sketch
3421
3438
  * @param {number} max_iterations
3422
3439
  * @param {number} tolerance
@@ -4288,6 +4305,13 @@ function __wbg_get_imports() {
4288
4305
  const ret = Error(getStringFromWasm0(arg0, arg1));
4289
4306
  return ret;
4290
4307
  },
4308
+ __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
4309
+ const ret = debugString(arg1);
4310
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4311
+ const len1 = WASM_VECTOR_LEN;
4312
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4313
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4314
+ },
4291
4315
  __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
4292
4316
  throw new Error(getStringFromWasm0(arg0, arg1));
4293
4317
  },
@@ -4328,6 +4352,71 @@ const JsVec3Finalization = (typeof FinalizationRegistry === 'undefined')
4328
4352
  ? { register: () => {}, unregister: () => {} }
4329
4353
  : new FinalizationRegistry(ptr => wasm.__wbg_jsvec3_free(ptr >>> 0, 1));
4330
4354
 
4355
+ function debugString(val) {
4356
+ // primitive types
4357
+ const type = typeof val;
4358
+ if (type == 'number' || type == 'boolean' || val == null) {
4359
+ return `${val}`;
4360
+ }
4361
+ if (type == 'string') {
4362
+ return `"${val}"`;
4363
+ }
4364
+ if (type == 'symbol') {
4365
+ const description = val.description;
4366
+ if (description == null) {
4367
+ return 'Symbol';
4368
+ } else {
4369
+ return `Symbol(${description})`;
4370
+ }
4371
+ }
4372
+ if (type == 'function') {
4373
+ const name = val.name;
4374
+ if (typeof name == 'string' && name.length > 0) {
4375
+ return `Function(${name})`;
4376
+ } else {
4377
+ return 'Function';
4378
+ }
4379
+ }
4380
+ // objects
4381
+ if (Array.isArray(val)) {
4382
+ const length = val.length;
4383
+ let debug = '[';
4384
+ if (length > 0) {
4385
+ debug += debugString(val[0]);
4386
+ }
4387
+ for(let i = 1; i < length; i++) {
4388
+ debug += ', ' + debugString(val[i]);
4389
+ }
4390
+ debug += ']';
4391
+ return debug;
4392
+ }
4393
+ // Test for built-in
4394
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
4395
+ let className;
4396
+ if (builtInMatches && builtInMatches.length > 1) {
4397
+ className = builtInMatches[1];
4398
+ } else {
4399
+ // Failed to match the standard '[object ClassName]'
4400
+ return toString.call(val);
4401
+ }
4402
+ if (className == 'Object') {
4403
+ // we're a user defined class or Object
4404
+ // JSON.stringify avoids problems with cycles, and is generally much
4405
+ // easier than looping through ownProperties of `val`.
4406
+ try {
4407
+ return 'Object(' + JSON.stringify(val) + ')';
4408
+ } catch (_) {
4409
+ return 'Object';
4410
+ }
4411
+ }
4412
+ // errors
4413
+ if (val instanceof Error) {
4414
+ return `${val.name}: ${val.message}\n${val.stack}`;
4415
+ }
4416
+ // TODO we could test for more things here, like `Set`s and `Map`s.
4417
+ return className;
4418
+ }
4419
+
4331
4420
  function getArrayF64FromWasm0(ptr, len) {
4332
4421
  ptr = ptr >>> 0;
4333
4422
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
@@ -4343,6 +4432,14 @@ function getArrayU8FromWasm0(ptr, len) {
4343
4432
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
4344
4433
  }
4345
4434
 
4435
+ let cachedDataViewMemory0 = null;
4436
+ function getDataViewMemory0() {
4437
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
4438
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
4439
+ }
4440
+ return cachedDataViewMemory0;
4441
+ }
4442
+
4346
4443
  let cachedFloat64ArrayMemory0 = null;
4347
4444
  function getFloat64ArrayMemory0() {
4348
4445
  if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "brepkit-wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for brepkit — browser-native B-Rep solid modeling",
5
- "version": "2.30.0",
5
+ "version": "2.32.0",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",