@itwin/core-geometry 4.0.0-dev.7 → 4.0.0-dev.8

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.
Files changed (53) hide show
  1. package/lib/cjs/Geometry.d.ts +3 -3
  2. package/lib/cjs/Geometry.d.ts.map +1 -1
  3. package/lib/cjs/Geometry.js +27 -11
  4. package/lib/cjs/Geometry.js.map +1 -1
  5. package/lib/cjs/curve/CurveCurve.d.ts +11 -8
  6. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  7. package/lib/cjs/curve/CurveCurve.js +16 -12
  8. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  9. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts +5 -1
  10. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +1 -1
  11. package/lib/cjs/curve/CurveCurveIntersectXY.js +11 -10
  12. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +1 -1
  13. package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +1 -0
  14. package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
  15. package/lib/cjs/geometry3d/CoincidentGeometryOps.js +3 -0
  16. package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
  17. package/lib/cjs/geometry3d/Matrix3d.d.ts +171 -118
  18. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  19. package/lib/cjs/geometry3d/Matrix3d.js +448 -417
  20. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  21. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -1
  22. package/lib/cjs/geometry3d/Point3dVector3d.js +1 -1
  23. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  24. package/lib/cjs/geometry3d/Segment1d.d.ts +1 -1
  25. package/lib/cjs/geometry3d/Segment1d.js +1 -1
  26. package/lib/cjs/geometry3d/Segment1d.js.map +1 -1
  27. package/lib/esm/Geometry.d.ts +3 -3
  28. package/lib/esm/Geometry.d.ts.map +1 -1
  29. package/lib/esm/Geometry.js +27 -11
  30. package/lib/esm/Geometry.js.map +1 -1
  31. package/lib/esm/curve/CurveCurve.d.ts +11 -8
  32. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  33. package/lib/esm/curve/CurveCurve.js +16 -12
  34. package/lib/esm/curve/CurveCurve.js.map +1 -1
  35. package/lib/esm/curve/CurveCurveIntersectXY.d.ts +5 -1
  36. package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +1 -1
  37. package/lib/esm/curve/CurveCurveIntersectXY.js +11 -10
  38. package/lib/esm/curve/CurveCurveIntersectXY.js.map +1 -1
  39. package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +1 -0
  40. package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
  41. package/lib/esm/geometry3d/CoincidentGeometryOps.js +3 -0
  42. package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
  43. package/lib/esm/geometry3d/Matrix3d.d.ts +171 -118
  44. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  45. package/lib/esm/geometry3d/Matrix3d.js +448 -417
  46. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  47. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -1
  48. package/lib/esm/geometry3d/Point3dVector3d.js +1 -1
  49. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  50. package/lib/esm/geometry3d/Segment1d.d.ts +1 -1
  51. package/lib/esm/geometry3d/Segment1d.js +1 -1
  52. package/lib/esm/geometry3d/Segment1d.js.map +1 -1
  53. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"Segment1d.js","sourceRoot":"","sources":["../../../src/geometry3d/Segment1d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,O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,KAAK,CAAC;SAChB;aAAM;YACL,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,CAAC,CAAC;YACnB,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,CAAC,CAAC;YACnB,IAAI,EAAE,IAAI,EAAE;gBACV,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\n\r\n/**\r\n * * A Segment1d is an interval of an axis named x.\r\n * * The interval is defined by two values x0 and x1.\r\n * * The x0 and x1 values can be in either order.\r\n * * if `x0 < x1` fractional coordinates within the segment move from left to right.\r\n * * if `x0 > x1` fractional coordinates within the segment move from right to left.\r\n * * This differs from a Range1d in that:\r\n * * For a Range1d the reversed ordering of its limit values means \"empty interval\".\r\n * * For a Segment1d the reversed ordering is a real interval but fractional positions move backwards.\r\n * * The segment is parameterized with a fraction\r\n * * * Fraction 0 is the start (`x0`)\r\n * * * Fraction 1 is the end (`x1`)\r\n * * * The fraction equation is `x = x0 + fraction * (x1-x0)` or (equivalently) `x = (1-fraction) * x0 + fraction * x1`\r\n * @public\r\n */\r\nexport class Segment1d {\r\n /** start coordinate */\r\n public x0: number;\r\n /** end coordinate */\r\n public x1: number;\r\n private constructor(x0: number, x1: number) {\r\n this.x0 = x0;\r\n this.x1 = x1;\r\n }\r\n /**\r\n * replace both end values.\r\n * @param x0 new x0 value\r\n * @param x1 new y0 value\r\n */\r\n public set(x0: number, x1: number) { this.x0 = x0, this.x1 = x1; }\r\n /**\r\n * shift (translate) the segment along its axis by adding `dx` to both `x0` and `x1`.\r\n * @param dx value to add to both x0 and x1\r\n */\r\n public shift(dx: number) { this.x0 += dx, this.x1 += dx; }\r\n /**\r\n * create segment1d with given end values\r\n * @param x0 start value\r\n * @param x1 end value\r\n * @param result optional pre-existing result to be reinitialized.\r\n */\r\n public static create(x0: number = 0, x1: number = 1, result?: Segment1d): Segment1d {\r\n if (!result)\r\n return new Segment1d(x0, x1);\r\n result.set(x0, x1);\r\n return result;\r\n }\r\n /**\r\n * Copy both end values from other Segment1d\r\n * @param other source Segment1d\r\n */\r\n public setFrom(other: Segment1d) { this.x0 = other.x0; this.x1 = other.x1; }\r\n /**\r\n * clone this Segment1d, return as a separate object.\r\n */\r\n public clone(): Segment1d { return new Segment1d(this.x0, this.x1); }\r\n /**\r\n * Returns true if both coordinates (`x0` and `x1`) are in the 0..1 range.\r\n */\r\n public get isIn01() {\r\n return Geometry.isIn01(this.x0) && Geometry.isIn01(this.x1);\r\n\r\n }\r\n /**\r\n * Evaluate the segment at fractional position\r\n * @returns position within the segment\r\n * @param fraction fractional position within this segment\r\n */\r\n public fractionToPoint(fraction: number): number { return Geometry.interpolate(this.x0, fraction, this.x1); }\r\n /**\r\n * Return the signed start-to-end shift (aka signed distance)\r\n */\r\n public signedDelta(): number { return this.x1 - this.x0; }\r\n /**\r\n * Return the absolute start-to-end shift (aka distance)\r\n */\r\n public absoluteDelta(): number { return Math.abs(this.x1 - this.x0); }\r\n /**\r\n * * swap the x0 and x1 member values.\r\n * * This makes the fractionToPoint evaluates reverse direction.\r\n */\r\n public reverseInPlace(): void { const x = this.x0; this.x0 = this.x1; this.x1 = x; }\r\n /**\r\n * * if `x1<x0` multiplied by the scale factor is (strictly) negative, swap the x0 and x1 member values.\r\n * * This makes the fractionToPoint evaluates reverse direction.\r\n */\r\n public reverseIfNeededForDeltaSign(sign: number = 1): void {\r\n if (sign * (this.x1 - this.x0) < 0)\r\n this.reverseInPlace();\r\n }\r\n /**\r\n * Near equality test, using Geometry.isSameCoordinate for tolerances.\r\n */\r\n public isAlmostEqual(other: Segment1d): boolean {\r\n return Geometry.isSameCoordinate(this.x0, other.x0) && Geometry.isSameCoordinate(this.x1, other.x1);\r\n }\r\n /**\r\n * Return true if the segment limits are (exactly) 0 and 1\r\n */\r\n public get isExact01(): boolean { return this.x0 === 0.0 && this.x1 === 1.0; }\r\n /**\r\n * Return true if the segment limits are (exactly) 1 and 0\r\n */\r\n public get isExact01Reversed(): boolean { return this.x0 === 1.0 && this.x1 === 0.0; }\r\n\r\n /** On input, `this` is an interval of a line. On output, the interval has been clipped to positive parts of a linear function\r\n * * f0 and f1 are values at parameter values 0 and 1 (which are in general NOT x0 and x1)\r\n * * From that determine where the segment crosses function value 0.\r\n * * The segment contains some interval in the same parameter space.\r\n * * Clip the segment to the positive part of the space.\r\n * * Return true (and modify the segment) if any of the segment remains.\r\n * * Return false (but without modifying the segment) if the active part is entirely out.\r\n */\r\n public clipBy01FunctionValuesPositive(f0: number, f1: number): boolean {\r\n const df01 = f1 - f0;\r\n const fA = f0 + this.x0 * df01;\r\n const fB = f0 + this.x1 * df01;\r\n const dfAB = fB - fA;\r\n if (fA > 0) {\r\n if (fB >= 0) return true; // inside at both ends\r\n /** There is an inside to outside crossing. The division is safe ... (and value between 0 and 1) */\r\n const u = -fA / dfAB;\r\n this.x1 = this.x0 + u * (this.x1 - this.x0);\r\n return true;\r\n } else if (fA < 0) {\r\n if (fB < 0) return false; // outside at both ends.\r\n /** There is an outside to inside crossing crossing. The division is safe ... (and value between 0 and 1) */\r\n const u = -fA / dfAB;\r\n this.x0 = this.x0 + u * (this.x1 - this.x0);\r\n return true;\r\n }\r\n /** fA is on the cut. fB determines the entire segment. */\r\n return fB > 0;\r\n }\r\n /**\r\n * * On input, (f0,f1) is a (directed) segment.\r\n * * On output, it is restricted to (0,1) while maintaining direction\r\n * * If the clip leaves nothing, leave this segment alone and return false.\r\n * * If the clip leaves something, update this segment and return true.\r\n */\r\n public clampDirectedTo01(): boolean {\r\n let x0 = this.x0;\r\n let x1 = this.x1;\r\n if (x1 > x0) {\r\n if (x0 < 0) x0 = 0;\r\n if (x1 > 1) x1 = 1;\r\n if (x0 >= x1)\r\n return false;\r\n } else {\r\n if (x0 > 1) x0 = 1;\r\n if (x1 < 0) x1 = 0;\r\n if (x0 <= x1)\r\n return false;\r\n }\r\n this.set(x0, x1);\r\n return true;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"Segment1d.js","sourceRoot":"","sources":["../../../src/geometry3d/Segment1d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,SAAS;IAKpB,YAAoB,EAAU,EAAE,EAAU;QACxC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD;;;;OAIG;IACI,GAAG,CAAC,EAAU,EAAE,EAAU,IAAI,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAClE;;;OAGG;IACI,KAAK,CAAC,EAAU,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1D;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAa,CAAC,EAAE,KAAa,CAAC,EAAE,MAAkB;QACrE,IAAI,CAAC,MAAM;YACT,OAAO,IAAI,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC/B,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACnB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD;;;OAGG;IACI,OAAO,CAAC,KAAgB,IAAI,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAA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AG,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC;SACb;QACD,4DAA4D;QAC5D,OAAO,EAAE,GAAG,CAAC,CAAC;IAChB,CAAC;IACD;;;;;OAKG;IACI,iBAAiB;QACtB,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACjB,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACjB,IAAI,EAAE,GAAG,EAAE,EAAE;YACX,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,CAAC,CAAC;YACnB,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,CAAC,CAAC;YACnB,IAAI,EAAE,IAAI,EAAE;gBACV,OAAO,KAAK,CAAC;SAChB;aAAM;YACL,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,CAAC,CAAC;YACnB,IAAI,EAAE,GAAG,CAAC;gBAAE,EAAE,GAAG,CAAC,CAAC;YACnB,IAAI,EAAE,IAAI,EAAE;gBACV,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\n\r\n/**\r\n * * A Segment1d is an interval of an axis named x.\r\n * * The interval is defined by two values x0 and x1.\r\n * * The x0 and x1 values can be in either order.\r\n * * if `x0 < x1` fractional coordinates within the segment move from left to right.\r\n * * if `x0 > x1` fractional coordinates within the segment move from right to left.\r\n * * This differs from a Range1d in that:\r\n * * For a Range1d the reversed ordering of its limit values means \"empty interval\".\r\n * * For a Segment1d the reversed ordering is a real interval but fractional positions move backwards.\r\n * * The segment is parameterized with a fraction\r\n * * * Fraction 0 is the start (`x0`)\r\n * * * Fraction 1 is the end (`x1`)\r\n * * * The fraction equation is `x = x0 + fraction * (x1-x0)` or (equivalently) `x = (1-fraction) * x0 + fraction * x1`\r\n * @public\r\n */\r\nexport class Segment1d {\r\n /** start coordinate */\r\n public x0: number;\r\n /** end coordinate */\r\n public x1: number;\r\n private constructor(x0: number, x1: number) {\r\n this.x0 = x0;\r\n this.x1 = x1;\r\n }\r\n /**\r\n * replace both end values.\r\n * @param x0 new x0 value\r\n * @param x1 new y0 value\r\n */\r\n public set(x0: number, x1: number) { this.x0 = x0, this.x1 = x1; }\r\n /**\r\n * shift (translate) the segment along its axis by adding `dx` to both `x0` and `x1`.\r\n * @param dx value to add to both x0 and x1\r\n */\r\n public shift(dx: number) { this.x0 += dx, this.x1 += dx; }\r\n /**\r\n * create segment1d with given end values\r\n * @param x0 start value\r\n * @param x1 end value\r\n * @param result optional pre-existing result to be reinitialized.\r\n */\r\n public static create(x0: number = 0, x1: number = 1, result?: Segment1d): Segment1d {\r\n if (!result)\r\n return new Segment1d(x0, x1);\r\n result.set(x0, x1);\r\n return result;\r\n }\r\n /**\r\n * Copy both end values from other Segment1d\r\n * @param other source Segment1d\r\n */\r\n public setFrom(other: Segment1d) { this.x0 = other.x0; this.x1 = other.x1; }\r\n /**\r\n * clone this Segment1d, return as a separate object.\r\n */\r\n public clone(): Segment1d { return new Segment1d(this.x0, this.x1); }\r\n /**\r\n * Returns true if both coordinates (`x0` and `x1`) are in the 0..1 range.\r\n */\r\n public get isIn01() {\r\n return Geometry.isIn01(this.x0) && Geometry.isIn01(this.x1);\r\n\r\n }\r\n /**\r\n * Evaluate the segment at fractional position\r\n * @returns position within the segment\r\n * @param fraction fractional position within this segment\r\n */\r\n public fractionToPoint(fraction: number): number { return Geometry.interpolate(this.x0, fraction, this.x1); }\r\n /**\r\n * Return the signed start-to-end shift (aka signed distance)\r\n */\r\n public signedDelta(): number { return this.x1 - this.x0; }\r\n /**\r\n * Return the absolute start-to-end shift (aka distance)\r\n */\r\n public absoluteDelta(): number { return Math.abs(this.x1 - this.x0); }\r\n /**\r\n * * swap the x0 and x1 member values.\r\n * * This makes the fractionToPoint evaluates reverse direction.\r\n */\r\n public reverseInPlace(): void { const x = this.x0; this.x0 = this.x1; this.x1 = x; }\r\n /**\r\n * * if `x1-x0` multiplied by the scale factor is (strictly) negative, swap the x0 and x1 member values.\r\n * * This makes the fractionToPoint evaluates reverse direction.\r\n */\r\n public reverseIfNeededForDeltaSign(sign: number = 1): void {\r\n if (sign * (this.x1 - this.x0) < 0)\r\n this.reverseInPlace();\r\n }\r\n /**\r\n * Near equality test, using Geometry.isSameCoordinate for tolerances.\r\n */\r\n public isAlmostEqual(other: Segment1d): boolean {\r\n return Geometry.isSameCoordinate(this.x0, other.x0) && Geometry.isSameCoordinate(this.x1, other.x1);\r\n }\r\n /**\r\n * Return true if the segment limits are (exactly) 0 and 1\r\n */\r\n public get isExact01(): boolean { return this.x0 === 0.0 && this.x1 === 1.0; }\r\n /**\r\n * Return true if the segment limits are (exactly) 1 and 0\r\n */\r\n public get isExact01Reversed(): boolean { return this.x0 === 1.0 && this.x1 === 0.0; }\r\n\r\n /** On input, `this` is an interval of a line. On output, the interval has been clipped to positive parts of a linear function\r\n * * f0 and f1 are values at parameter values 0 and 1 (which are in general NOT x0 and x1)\r\n * * From that determine where the segment crosses function value 0.\r\n * * The segment contains some interval in the same parameter space.\r\n * * Clip the segment to the positive part of the space.\r\n * * Return true (and modify the segment) if any of the segment remains.\r\n * * Return false (but without modifying the segment) if the active part is entirely out.\r\n */\r\n public clipBy01FunctionValuesPositive(f0: number, f1: number): boolean {\r\n const df01 = f1 - f0;\r\n const fA = f0 + this.x0 * df01;\r\n const fB = f0 + this.x1 * df01;\r\n const dfAB = fB - fA;\r\n if (fA > 0) {\r\n if (fB >= 0) return true; // inside at both ends\r\n /** There is an inside to outside crossing. The division is safe ... (and value between 0 and 1) */\r\n const u = -fA / dfAB;\r\n this.x1 = this.x0 + u * (this.x1 - this.x0);\r\n return true;\r\n } else if (fA < 0) {\r\n if (fB < 0) return false; // outside at both ends.\r\n /** There is an outside to inside crossing crossing. The division is safe ... (and value between 0 and 1) */\r\n const u = -fA / dfAB;\r\n this.x0 = this.x0 + u * (this.x1 - this.x0);\r\n return true;\r\n }\r\n /** fA is on the cut. fB determines the entire segment. */\r\n return fB > 0;\r\n }\r\n /**\r\n * * On input, (f0,f1) is a (directed) segment.\r\n * * On output, it is restricted to (0,1) while maintaining direction\r\n * * If the clip leaves nothing, leave this segment alone and return false.\r\n * * If the clip leaves something, update this segment and return true.\r\n */\r\n public clampDirectedTo01(): boolean {\r\n let x0 = this.x0;\r\n let x1 = this.x1;\r\n if (x1 > x0) {\r\n if (x0 < 0) x0 = 0;\r\n if (x1 > 1) x1 = 1;\r\n if (x0 >= x1)\r\n return false;\r\n } else {\r\n if (x0 > 1) x0 = 1;\r\n if (x1 < 0) x1 = 0;\r\n if (x0 <= x1)\r\n return false;\r\n }\r\n this.set(x0, x1);\r\n return true;\r\n }\r\n\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-geometry",
3
- "version": "4.0.0-dev.7",
3
+ "version": "4.0.0-dev.8",
4
4
  "description": "iTwin.js Core Geometry library",
5
5
  "main": "lib/cjs/core-geometry.js",
6
6
  "module": "lib/esm/core-geometry.js",
@@ -22,8 +22,8 @@
22
22
  "url": "http://www.bentley.com"
23
23
  },
24
24
  "devDependencies": {
25
- "@itwin/build-tools": "4.0.0-dev.7",
26
- "@itwin/eslint-plugin": "4.0.0-dev.7",
25
+ "@itwin/build-tools": "4.0.0-dev.8",
26
+ "@itwin/eslint-plugin": "4.0.0-dev.8",
27
27
  "@types/chai": "4.3.1",
28
28
  "@types/flatbuffers": "~1.10.0",
29
29
  "@types/mocha": "^8.2.2",
@@ -38,7 +38,7 @@
38
38
  "typescript": "~4.4.0"
39
39
  },
40
40
  "dependencies": {
41
- "@itwin/core-bentley": "4.0.0-dev.7",
41
+ "@itwin/core-bentley": "4.0.0-dev.8",
42
42
  "flatbuffers": "~1.12.0"
43
43
  },
44
44
  "nyc": {