@tscircuit/core 0.0.270 → 0.0.272

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
@@ -971,6 +971,7 @@ declare class Board extends Group<typeof boardProps> {
971
971
  }, {
972
972
  name: z.ZodOptional<z.ZodString>;
973
973
  children: z.ZodOptional<z.ZodAny>;
974
+ key: z.ZodOptional<z.ZodAny>;
974
975
  }>, {
975
976
  layout: z.ZodOptional<z.ZodType<_tscircuit_layout.LayoutBuilder, z.ZodTypeDef, _tscircuit_layout.LayoutBuilder>>;
976
977
  manualEdits: z.ZodOptional<z.ZodObject<{
@@ -1186,6 +1187,7 @@ declare class Board extends Group<typeof boardProps> {
1186
1187
  schRotation?: number | undefined;
1187
1188
  layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
1188
1189
  footprint?: _tscircuit_props.Footprint | undefined;
1190
+ key?: any;
1189
1191
  name?: string | undefined;
1190
1192
  children?: any;
1191
1193
  width?: number | undefined;
@@ -1249,6 +1251,7 @@ declare class Board extends Group<typeof boardProps> {
1249
1251
  name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
1250
1252
  } | undefined;
1251
1253
  footprint?: _tscircuit_props.Footprint | undefined;
1254
+ key?: any;
1252
1255
  name?: string | undefined;
1253
1256
  children?: any;
1254
1257
  width?: string | number | undefined;
@@ -9898,6 +9901,20 @@ declare const getSimpleRouteJsonFromCircuitJson: ({ circuitJson, minTraceWidth,
9898
9901
  minTraceWidth?: number;
9899
9902
  }) => SimpleRouteJson;
9900
9903
 
9904
+ type RenderEvent = {
9905
+ type: string;
9906
+ renderId: string;
9907
+ createdAt: number;
9908
+ };
9909
+ /**
9910
+ * Given a list of render events, return a map of how much time was spent in each
9911
+ * render phase.
9912
+ *
9913
+ * To get the time spent in each phase, you have to find the end event for each
9914
+ * start event and subtract the createdAt of the start event from the createdAt
9915
+ */
9916
+ declare const getPhaseTimingsFromRenderEvents: (renderEvents: RenderEvent[]) => Record<string, number>;
9917
+
9901
9918
  interface TscircuitElements {
9902
9919
  resistor: _tscircuit_props.ResistorProps;
9903
9920
  capacitor: _tscircuit_props.CapacitorProps;
@@ -9960,4 +9977,4 @@ declare module "react/jsx-runtime" {
9960
9977
  }
9961
9978
  }
9962
9979
 
9963
- export { type AsyncEffect, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Subcircuit, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, createUseComponent, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
9980
+ export { type AsyncEffect, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Subcircuit, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
package/dist/index.js CHANGED
@@ -56,7 +56,9 @@ import { point3, rotation } from "circuit-json";
56
56
  import Debug4 from "debug";
57
57
 
58
58
  // lib/fiber/create-instance-from-react-element.ts
59
+ import React from "react";
59
60
  import ReactReconciler from "react-reconciler";
61
+ import ReactReconciler18 from "react-reconciler-18";
60
62
  import { DefaultEventPriority } from "react-reconciler/constants";
61
63
 
62
64
  // lib/components/base-components/Renderable.ts
@@ -384,7 +386,12 @@ var hostConfig = {
384
386
  maySuspendCommit: () => false,
385
387
  supportsHydration: false
386
388
  };
387
- var reconciler = ReactReconciler(hostConfig);
389
+ var reconciler;
390
+ if (React.version.startsWith("19.")) {
391
+ reconciler = ReactReconciler(hostConfig);
392
+ } else {
393
+ reconciler = ReactReconciler18(hostConfig);
394
+ }
388
395
  var createInstanceFromReactElement = (reactElm) => {
389
396
  const rootContainer = {
390
397
  children: [],
@@ -417,9 +424,14 @@ var createInstanceFromReactElement = (reactElm) => {
417
424
  },
418
425
  null
419
426
  );
420
- reconciler.updateContainerSync(reactElm, container, null, () => {
421
- });
422
- reconciler.flushSyncWork();
427
+ if (React.version.startsWith("19.")) {
428
+ reconciler.updateContainerSync(reactElm, container, null, () => {
429
+ });
430
+ reconciler.flushSyncWork();
431
+ } else {
432
+ reconciler.updateContainer(reactElm, container, null, () => {
433
+ });
434
+ }
423
435
  if (containerErrors.length > 0) {
424
436
  throw containerErrors[0];
425
437
  }
@@ -6436,13 +6448,13 @@ var Project = RootCircuit;
6436
6448
  var Circuit = RootCircuit;
6437
6449
 
6438
6450
  // lib/hooks/use-rendered-circuit.ts
6439
- import React from "react";
6451
+ import React2 from "react";
6440
6452
  var useRenderedCircuit = (reactElements) => {
6441
- const [isLoading, setIsLoading] = React.useState(true);
6442
- const [error, setError] = React.useState(null);
6443
- const [circuit, setCircuit] = React.useState();
6444
- const [circuitJson, setCircuitJson] = React.useState();
6445
- React.useEffect(() => {
6453
+ const [isLoading, setIsLoading] = React2.useState(true);
6454
+ const [error, setError] = React2.useState(null);
6455
+ const [circuit, setCircuit] = React2.useState();
6456
+ const [circuitJson, setCircuitJson] = React2.useState();
6457
+ React2.useEffect(() => {
6446
6458
  setIsLoading(true);
6447
6459
  setError(null);
6448
6460
  if (reactElements) {
@@ -6654,6 +6666,31 @@ var getSimpleRouteJsonFromCircuitJson = ({
6654
6666
  };
6655
6667
  };
6656
6668
 
6669
+ // lib/utils/render-events/getPhaseTimingsFromRenderEvents.ts
6670
+ var getPhaseTimingsFromRenderEvents = (renderEvents) => {
6671
+ const phaseTimings = {};
6672
+ if (!renderEvents) return phaseTimings;
6673
+ for (const renderPhase of orderedRenderPhases) {
6674
+ phaseTimings[renderPhase] = 0;
6675
+ }
6676
+ const startEvents = /* @__PURE__ */ new Map();
6677
+ for (const event of renderEvents) {
6678
+ const [, , phase, eventType] = event.type.split(":");
6679
+ if (eventType === "start") {
6680
+ startEvents.set(`${phase}:${event.renderId}`, event);
6681
+ continue;
6682
+ }
6683
+ if (eventType === "end") {
6684
+ const startEvent = startEvents.get(`${phase}:${event.renderId}`);
6685
+ if (startEvent) {
6686
+ const duration = event.createdAt - startEvent.createdAt;
6687
+ phaseTimings[phase] = (phaseTimings[phase] || 0) + duration;
6688
+ }
6689
+ }
6690
+ }
6691
+ return phaseTimings;
6692
+ };
6693
+
6657
6694
  // lib/index.ts
6658
6695
  import { createElement } from "react";
6659
6696
 
@@ -6710,6 +6747,7 @@ export {
6710
6747
  applyEditEventsToManualEditsFile,
6711
6748
  createElement,
6712
6749
  createUseComponent,
6750
+ getPhaseTimingsFromRenderEvents,
6713
6751
  getSimpleRouteJsonFromCircuitJson,
6714
6752
  orderedRenderPhases,
6715
6753
  useCapacitor,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.270",
4
+ "version": "0.0.272",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -16,7 +16,10 @@
16
16
  "build": "tsup-node index.ts --format esm --dts",
17
17
  "format": "biome format . --write",
18
18
  "measure-bundle": "howfat -r table .",
19
- "pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps"
19
+ "pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps",
20
+ "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
21
+ "build:benchmarking:watch": "chokidar \"./{benchmarking,lib}/**/*.{ts,tsx}\" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'",
22
+ "start:benchmarking": "concurrently \"bun run build:benchmarking:watch\" \"live-server ./benchmarking-dist\""
20
23
  },
21
24
  "devDependencies": {
22
25
  "@biomejs/biome": "^1.8.3",
@@ -26,18 +29,22 @@
26
29
  "@types/bun": "latest",
27
30
  "@types/debug": "^4.1.12",
28
31
  "@types/react": "^19.0.1",
32
+ "@types/react-dom": "^19.0.2",
29
33
  "@types/react-reconciler": "^0.28.9",
30
34
  "bun-match-svg": "0.0.8",
35
+ "chokidar-cli": "^3.0.0",
31
36
  "circuit-to-svg": "^0.0.99",
37
+ "concurrently": "^9.1.2",
32
38
  "debug": "^4.3.6",
33
39
  "graphics-debug": "^0.0.4",
34
40
  "howfat": "^0.3.8",
41
+ "live-server": "^1.2.2",
35
42
  "looks-same": "^9.0.1",
36
43
  "pkg-pr-new": "^0.0.37",
37
- "ts-expect": "^1.3.0",
38
- "tsup": "^8.2.4",
39
44
  "react": "^19.0.0",
40
- "react-dom": "^19.0.0"
45
+ "react-dom": "^19.0.0",
46
+ "ts-expect": "^1.3.0",
47
+ "tsup": "^8.2.4"
41
48
  },
42
49
  "peerDependencies": {
43
50
  "typescript": "^5.0.0"
@@ -46,8 +53,8 @@
46
53
  "@lume/kiwi": "^0.4.3",
47
54
  "@tscircuit/footprinter": "^0.0.97",
48
55
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
49
- "@tscircuit/math-utils": "^0.0.5",
50
- "@tscircuit/props": "^0.0.129",
56
+ "@tscircuit/math-utils": "^0.0.9",
57
+ "@tscircuit/props": "^0.0.130",
51
58
  "@tscircuit/schematic-autolayout": "^0.0.6",
52
59
  "@tscircuit/soup-util": "^0.0.41",
53
60
  "circuit-json": "^0.0.128",
@@ -56,6 +63,7 @@
56
63
  "nanoid": "^5.0.7",
57
64
  "performance-now": "^2.1.0",
58
65
  "react-reconciler": "^0.31.0",
66
+ "react-reconciler-18": "npm:react-reconciler@0.29.2",
59
67
  "schematic-symbols": "^0.0.113",
60
68
  "transformation-matrix": "^2.16.1",
61
69
  "zod": "^3.23.8"