@tscircuit/core 0.0.268 → 0.0.270

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/dist/index.d.ts CHANGED
@@ -66,6 +66,16 @@ declare abstract class Renderable implements IRenderable {
66
66
  renderError(message: string | Omit<PcbTraceError, "pcb_error_id"> | Omit<PcbPlacementError, "pcb_error_id"> | Omit<PcbManualEditConflictError, "pcb_error_id">): void;
67
67
  }
68
68
 
69
+ /**
70
+ * This is how we render in React. This can be a confusing part of the codebase,
71
+ * but here are some helpful reference implementations:
72
+ *
73
+ * https://github.com/diegomura/react-pdf/blob/fabecc56727dfb6d590a3fa1e11f50250ecbbea1/packages/reconciler/src/reconciler-31.js
74
+ * https://github.com/pmndrs/react-three-fiber/blob/ec4f00bb61cc4f6e28b3a12b1dca9daa5594f10e/packages/fiber/src/core/renderer.ts
75
+ *
76
+ *
77
+ */
78
+
69
79
  type ReactSubtree = {
70
80
  element: ReactElement;
71
81
  component: NormalComponent;
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ import Debug4 from "debug";
57
57
 
58
58
  // lib/fiber/create-instance-from-react-element.ts
59
59
  import ReactReconciler from "react-reconciler";
60
+ import { DefaultEventPriority } from "react-reconciler/constants";
60
61
 
61
62
  // lib/components/base-components/Renderable.ts
62
63
  import Debug from "debug";
@@ -354,9 +355,6 @@ var hostConfig = {
354
355
  },
355
356
  noTimeout: void 0,
356
357
  isPrimaryRenderer: false,
357
- getCurrentEventPriority() {
358
- throw new Error("Function not implemented.");
359
- },
360
358
  getInstanceFromNode(node) {
361
359
  throw new Error("Function not implemented.");
362
360
  },
@@ -375,6 +373,15 @@ var hostConfig = {
375
373
  detachDeletedInstance: (node) => {
376
374
  throw new Error("Function not implemented.");
377
375
  },
376
+ // https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
377
+ getCurrentEventPriority: () => DefaultEventPriority,
378
+ // @ts-expect-error
379
+ // https://github.com/diegomura/react-pdf/blob/fabecc56727dfb6d590a3fa1e11f50250ecbbea1/packages/reconciler/src/reconciler-31.js#L57
380
+ getCurrentUpdatePriority: () => DefaultEventPriority,
381
+ resolveUpdatePriority: () => DefaultEventPriority,
382
+ setCurrentUpdatePriority: () => {
383
+ },
384
+ maySuspendCommit: () => false,
378
385
  supportsHydration: false
379
386
  };
380
387
  var reconciler = ReactReconciler(hostConfig);
@@ -392,6 +399,7 @@ var createInstanceFromReactElement = (reactElm) => {
392
399
  return identity();
393
400
  }
394
401
  };
402
+ const containerErrors = [];
395
403
  const container = reconciler.createContainer(
396
404
  // TODO Replace with store like react-three-fiber
397
405
  // https://github.com/pmndrs/react-three-fiber/blob/a457290856f57741bf8beef4f6ff9dbf4879c0a5/packages/fiber/src/core/index.tsx#L172
@@ -405,11 +413,16 @@ var createInstanceFromReactElement = (reactElm) => {
405
413
  (error) => {
406
414
  console.log("Error in createContainer");
407
415
  console.error(error);
416
+ containerErrors.push(error);
408
417
  },
409
418
  null
410
419
  );
411
- reconciler.updateContainer(reactElm, container, null, () => {
420
+ reconciler.updateContainerSync(reactElm, container, null, () => {
412
421
  });
422
+ reconciler.flushSyncWork();
423
+ if (containerErrors.length > 0) {
424
+ throw containerErrors[0];
425
+ }
413
426
  const rootInstance = reconciler.getPublicRootInstance(
414
427
  container
415
428
  );
@@ -4189,10 +4202,10 @@ var getOtherSchematicTraces = ({
4189
4202
  // lib/components/primitive-components/Trace/create-schematic-trace-crossing-segments.ts
4190
4203
  import { getUnitVectorFromPointAToB } from "@tscircuit/math-utils";
4191
4204
  var createSchematicTraceCrossingSegments = ({
4192
- edges,
4205
+ edges: inputEdges,
4193
4206
  otherEdges
4194
4207
  }) => {
4195
- edges = [...edges];
4208
+ const edges = [...inputEdges];
4196
4209
  for (let i = 0; i < edges.length; i++) {
4197
4210
  if (i > 2e3) {
4198
4211
  throw new Error(
@@ -4200,11 +4213,16 @@ var createSchematicTraceCrossingSegments = ({
4200
4213
  );
4201
4214
  }
4202
4215
  const edge = edges[i];
4203
- const edgeOrientation = Math.abs(edge.from.x - edge.to.x) < 0.01 ? "vertical" : "horizontal";
4216
+ const edgeOrientation = Math.abs(edge.from.x - edge.to.x) < 0.01 ? "vertical" : edge.from.y === edge.to.y ? "horizontal" : "not-orthogonal";
4217
+ if (edgeOrientation === "not-orthogonal") {
4218
+ continue;
4219
+ }
4204
4220
  const otherEdgesIntersections = [];
4205
4221
  for (const otherEdge of otherEdges) {
4206
- const otherOrientation = otherEdge.from.x === otherEdge.to.x ? "vertical" : "horizontal";
4207
- if (edgeOrientation === otherOrientation) continue;
4222
+ const otherOrientation = otherEdge.from.x === otherEdge.to.x ? "vertical" : otherEdge.from.y === otherEdge.to.y ? "horizontal" : "not-orthogonal";
4223
+ if (otherOrientation === "not-orthogonal") continue;
4224
+ if (edgeOrientation === otherOrientation)
4225
+ continue;
4208
4226
  const hasIntersection = doesLineIntersectLine(
4209
4227
  [edge.from, edge.to],
4210
4228
  [otherEdge.from, otherEdge.to],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.268",
4
+ "version": "0.0.270",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -20,12 +20,13 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@biomejs/biome": "^1.8.3",
23
+ "@tscircuit/import-snippet": "^0.0.4",
23
24
  "@tscircuit/layout": "^0.0.28",
24
25
  "@tscircuit/log-soup": "^1.0.2",
25
26
  "@types/bun": "latest",
26
27
  "@types/debug": "^4.1.12",
27
28
  "@types/react": "^19.0.1",
28
- "@types/react-reconciler": "^0.28.8",
29
+ "@types/react-reconciler": "^0.28.9",
29
30
  "bun-match-svg": "0.0.8",
30
31
  "circuit-to-svg": "^0.0.99",
31
32
  "debug": "^4.3.6",
@@ -34,7 +35,9 @@
34
35
  "looks-same": "^9.0.1",
35
36
  "pkg-pr-new": "^0.0.37",
36
37
  "ts-expect": "^1.3.0",
37
- "tsup": "^8.2.4"
38
+ "tsup": "^8.2.4",
39
+ "react": "^19.0.0",
40
+ "react-dom": "^19.0.0"
38
41
  },
39
42
  "peerDependencies": {
40
43
  "typescript": "^5.0.0"
@@ -52,8 +55,7 @@
52
55
  "format-si-unit": "^0.0.2",
53
56
  "nanoid": "^5.0.7",
54
57
  "performance-now": "^2.1.0",
55
- "react": "^18.3.1",
56
- "react-reconciler": "^0.29.2",
58
+ "react-reconciler": "^0.31.0",
57
59
  "schematic-symbols": "^0.0.113",
58
60
  "transformation-matrix": "^2.16.1",
59
61
  "zod": "^3.23.8"