@tscircuit/core 0.0.269 → 0.0.271
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 +28 -1
- package/dist/index.js +43 -4
- package/package.json +15 -7
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;
|
|
@@ -961,6 +971,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
961
971
|
}, {
|
|
962
972
|
name: z.ZodOptional<z.ZodString>;
|
|
963
973
|
children: z.ZodOptional<z.ZodAny>;
|
|
974
|
+
key: z.ZodOptional<z.ZodAny>;
|
|
964
975
|
}>, {
|
|
965
976
|
layout: z.ZodOptional<z.ZodType<_tscircuit_layout.LayoutBuilder, z.ZodTypeDef, _tscircuit_layout.LayoutBuilder>>;
|
|
966
977
|
manualEdits: z.ZodOptional<z.ZodObject<{
|
|
@@ -1176,6 +1187,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
1176
1187
|
schRotation?: number | undefined;
|
|
1177
1188
|
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
1178
1189
|
footprint?: _tscircuit_props.Footprint | undefined;
|
|
1190
|
+
key?: any;
|
|
1179
1191
|
name?: string | undefined;
|
|
1180
1192
|
children?: any;
|
|
1181
1193
|
width?: number | undefined;
|
|
@@ -1239,6 +1251,7 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
1239
1251
|
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
1240
1252
|
} | undefined;
|
|
1241
1253
|
footprint?: _tscircuit_props.Footprint | undefined;
|
|
1254
|
+
key?: any;
|
|
1242
1255
|
name?: string | undefined;
|
|
1243
1256
|
children?: any;
|
|
1244
1257
|
width?: string | number | undefined;
|
|
@@ -9888,6 +9901,20 @@ declare const getSimpleRouteJsonFromCircuitJson: ({ circuitJson, minTraceWidth,
|
|
|
9888
9901
|
minTraceWidth?: number;
|
|
9889
9902
|
}) => SimpleRouteJson;
|
|
9890
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
|
+
|
|
9891
9918
|
interface TscircuitElements {
|
|
9892
9919
|
resistor: _tscircuit_props.ResistorProps;
|
|
9893
9920
|
capacitor: _tscircuit_props.CapacitorProps;
|
|
@@ -9950,4 +9977,4 @@ declare module "react/jsx-runtime" {
|
|
|
9950
9977
|
}
|
|
9951
9978
|
}
|
|
9952
9979
|
|
|
9953
|
-
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
|
@@ -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.
|
|
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
|
);
|
|
@@ -6641,6 +6654,31 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
6641
6654
|
};
|
|
6642
6655
|
};
|
|
6643
6656
|
|
|
6657
|
+
// lib/utils/render-events/getPhaseTimingsFromRenderEvents.ts
|
|
6658
|
+
var getPhaseTimingsFromRenderEvents = (renderEvents) => {
|
|
6659
|
+
const phaseTimings = {};
|
|
6660
|
+
if (!renderEvents) return phaseTimings;
|
|
6661
|
+
for (const renderPhase of orderedRenderPhases) {
|
|
6662
|
+
phaseTimings[renderPhase] = 0;
|
|
6663
|
+
}
|
|
6664
|
+
const startEvents = /* @__PURE__ */ new Map();
|
|
6665
|
+
for (const event of renderEvents) {
|
|
6666
|
+
const [, , phase, eventType] = event.type.split(":");
|
|
6667
|
+
if (eventType === "start") {
|
|
6668
|
+
startEvents.set(`${phase}:${event.renderId}`, event);
|
|
6669
|
+
continue;
|
|
6670
|
+
}
|
|
6671
|
+
if (eventType === "end") {
|
|
6672
|
+
const startEvent = startEvents.get(`${phase}:${event.renderId}`);
|
|
6673
|
+
if (startEvent) {
|
|
6674
|
+
const duration = event.createdAt - startEvent.createdAt;
|
|
6675
|
+
phaseTimings[phase] = (phaseTimings[phase] || 0) + duration;
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
return phaseTimings;
|
|
6680
|
+
};
|
|
6681
|
+
|
|
6644
6682
|
// lib/index.ts
|
|
6645
6683
|
import { createElement } from "react";
|
|
6646
6684
|
|
|
@@ -6697,6 +6735,7 @@ export {
|
|
|
6697
6735
|
applyEditEventsToManualEditsFile,
|
|
6698
6736
|
createElement,
|
|
6699
6737
|
createUseComponent,
|
|
6738
|
+
getPhaseTimingsFromRenderEvents,
|
|
6700
6739
|
getSimpleRouteJsonFromCircuitJson,
|
|
6701
6740
|
orderedRenderPhases,
|
|
6702
6741
|
useCapacitor,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.271",
|
|
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,14 +29,20 @@
|
|
|
26
29
|
"@types/bun": "latest",
|
|
27
30
|
"@types/debug": "^4.1.12",
|
|
28
31
|
"@types/react": "^19.0.1",
|
|
29
|
-
"@types/react-
|
|
32
|
+
"@types/react-dom": "^19.0.2",
|
|
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",
|
|
44
|
+
"react": "^19.0.0",
|
|
45
|
+
"react-dom": "^19.0.0",
|
|
37
46
|
"ts-expect": "^1.3.0",
|
|
38
47
|
"tsup": "^8.2.4"
|
|
39
48
|
},
|
|
@@ -44,8 +53,8 @@
|
|
|
44
53
|
"@lume/kiwi": "^0.4.3",
|
|
45
54
|
"@tscircuit/footprinter": "^0.0.97",
|
|
46
55
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
47
|
-
"@tscircuit/math-utils": "^0.0.
|
|
48
|
-
"@tscircuit/props": "^0.0.
|
|
56
|
+
"@tscircuit/math-utils": "^0.0.9",
|
|
57
|
+
"@tscircuit/props": "^0.0.130",
|
|
49
58
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
50
59
|
"@tscircuit/soup-util": "^0.0.41",
|
|
51
60
|
"circuit-json": "^0.0.128",
|
|
@@ -53,8 +62,7 @@
|
|
|
53
62
|
"format-si-unit": "^0.0.2",
|
|
54
63
|
"nanoid": "^5.0.7",
|
|
55
64
|
"performance-now": "^2.1.0",
|
|
56
|
-
"react": "^
|
|
57
|
-
"react-reconciler": "^0.29.2",
|
|
65
|
+
"react-reconciler": "^0.31.0",
|
|
58
66
|
"schematic-symbols": "^0.0.113",
|
|
59
67
|
"transformation-matrix": "^2.16.1",
|
|
60
68
|
"zod": "^3.23.8"
|