@tscircuit/core 0.0.339 → 0.0.340
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 +11 -8
- package/dist/index.js +108 -10
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -135,13 +135,13 @@ declare class RootCircuit {
|
|
|
135
135
|
render(): void;
|
|
136
136
|
renderUntilSettled(): Promise<void>;
|
|
137
137
|
private _hasIncompleteAsyncEffects;
|
|
138
|
-
getSoup(): AnyCircuitElement[];
|
|
139
138
|
getCircuitJson(): AnyCircuitElement[];
|
|
140
139
|
toJson(): AnyCircuitElement[];
|
|
141
140
|
getSvg(options: {
|
|
142
141
|
view: "pcb";
|
|
143
142
|
layer?: string;
|
|
144
143
|
}): Promise<string>;
|
|
144
|
+
getCoreVersion(): string;
|
|
145
145
|
preview(previewNameOrOpts: string | {
|
|
146
146
|
previewName: string;
|
|
147
147
|
tscircuitApiKey?: string;
|
|
@@ -155,6 +155,7 @@ declare class RootCircuit {
|
|
|
155
155
|
_eventListeners: Record<RootCircuitEventName, Array<(...args: any[]) => void>>;
|
|
156
156
|
emit(event: RootCircuitEventName, ...args: any[]): void;
|
|
157
157
|
on(event: RootCircuitEventName, listener: (...args: any[]) => void): void;
|
|
158
|
+
removeListener(event: RootCircuitEventName, listener: (...args: any[]) => void): void;
|
|
158
159
|
getClientOrigin(): string;
|
|
159
160
|
}
|
|
160
161
|
/**
|
|
@@ -180,11 +181,19 @@ interface IGroup extends PrimitiveComponent {
|
|
|
180
181
|
pcb_group_id: string | null;
|
|
181
182
|
}
|
|
182
183
|
|
|
184
|
+
type Ftype = Extract<AnySourceComponent, {
|
|
185
|
+
ftype: string;
|
|
186
|
+
}>["ftype"];
|
|
187
|
+
type TwoPinPorts = "pin1" | "pin2";
|
|
188
|
+
type PassivePorts = TwoPinPorts;
|
|
189
|
+
type PolarizedPassivePorts = PassivePorts | "anode" | "cathode" | "pos" | "neg";
|
|
190
|
+
type TransistorPorts = "pin1" | "pin2" | "pin3" | "emitter" | "collector" | "base";
|
|
191
|
+
|
|
183
192
|
interface BaseComponentConfig {
|
|
184
193
|
componentName: string;
|
|
185
194
|
schematicSymbolName?: string | null;
|
|
186
195
|
zodProps: ZodType;
|
|
187
|
-
sourceFtype?:
|
|
196
|
+
sourceFtype?: Ftype | null;
|
|
188
197
|
shouldRenderAsSchematicBox?: boolean;
|
|
189
198
|
}
|
|
190
199
|
/**
|
|
@@ -1629,12 +1638,6 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
1629
1638
|
_computePcbGlobalTransformBeforeLayout(): Matrix;
|
|
1630
1639
|
}
|
|
1631
1640
|
|
|
1632
|
-
type Ftype = AnySourceComponent["ftype"];
|
|
1633
|
-
type TwoPinPorts = "pin1" | "pin2";
|
|
1634
|
-
type PassivePorts = TwoPinPorts;
|
|
1635
|
-
type PolarizedPassivePorts = PassivePorts | "anode" | "cathode" | "pos" | "neg";
|
|
1636
|
-
type TransistorPorts = "pin1" | "pin2" | "pin3" | "emitter" | "collector" | "base";
|
|
1637
|
-
|
|
1638
1641
|
declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePorts> {
|
|
1639
1642
|
get config(): {
|
|
1640
1643
|
componentName: string;
|
package/dist/index.js
CHANGED
|
@@ -5710,6 +5710,9 @@ var Group = class extends NormalComponent {
|
|
|
5710
5710
|
const serverMode = autorouterConfig.serverMode;
|
|
5711
5711
|
const fetchWithDebug = (url, options) => {
|
|
5712
5712
|
debug4("fetching", url);
|
|
5713
|
+
if (options.headers) {
|
|
5714
|
+
options.headers["Tscircuit-Core-Version"] = this.root?.getCoreVersion();
|
|
5715
|
+
}
|
|
5713
5716
|
return fetch(url, options);
|
|
5714
5717
|
};
|
|
5715
5718
|
const pcbAndSourceCircuitJson = this.root.db.toArray().filter(
|
|
@@ -5731,7 +5734,9 @@ var Group = class extends NormalComponent {
|
|
|
5731
5734
|
}).simpleRouteJson,
|
|
5732
5735
|
subcircuit_id: this.subcircuit_id
|
|
5733
5736
|
}),
|
|
5734
|
-
headers: {
|
|
5737
|
+
headers: {
|
|
5738
|
+
"Content-Type": "application/json"
|
|
5739
|
+
}
|
|
5735
5740
|
}
|
|
5736
5741
|
).then((r) => r.json());
|
|
5737
5742
|
this._asyncAutoroutingResult = autorouting_result2;
|
|
@@ -5746,7 +5751,9 @@ var Group = class extends NormalComponent {
|
|
|
5746
5751
|
input_circuit_json: pcbAndSourceCircuitJson,
|
|
5747
5752
|
subcircuit_id: this.subcircuit_id
|
|
5748
5753
|
}),
|
|
5749
|
-
headers: {
|
|
5754
|
+
headers: {
|
|
5755
|
+
"Content-Type": "application/json"
|
|
5756
|
+
}
|
|
5750
5757
|
}
|
|
5751
5758
|
).then((r) => r.json());
|
|
5752
5759
|
this._asyncAutoroutingResult = autorouting_result;
|
|
@@ -5765,7 +5772,9 @@ var Group = class extends NormalComponent {
|
|
|
5765
5772
|
subcircuit_id: this.subcircuit_id,
|
|
5766
5773
|
server_cache_enabled: autorouterConfig.serverCacheEnabled
|
|
5767
5774
|
}),
|
|
5768
|
-
headers: {
|
|
5775
|
+
headers: {
|
|
5776
|
+
"Content-Type": "application/json"
|
|
5777
|
+
}
|
|
5769
5778
|
}
|
|
5770
5779
|
).then((r) => r.json());
|
|
5771
5780
|
while (true) {
|
|
@@ -6039,7 +6048,7 @@ var Group = class extends NormalComponent {
|
|
|
6039
6048
|
};
|
|
6040
6049
|
return {
|
|
6041
6050
|
local: true,
|
|
6042
|
-
groupMode: "
|
|
6051
|
+
groupMode: "subcircuit"
|
|
6043
6052
|
};
|
|
6044
6053
|
}
|
|
6045
6054
|
/**
|
|
@@ -7220,6 +7229,83 @@ var Switch = class extends NormalComponent {
|
|
|
7220
7229
|
import { su as su3 } from "@tscircuit/soup-util";
|
|
7221
7230
|
import { isValidElement as isValidElement2 } from "react";
|
|
7222
7231
|
import { identity as identity4 } from "transformation-matrix";
|
|
7232
|
+
|
|
7233
|
+
// package.json
|
|
7234
|
+
var package_default = {
|
|
7235
|
+
name: "@tscircuit/core",
|
|
7236
|
+
type: "module",
|
|
7237
|
+
version: "0.0.339",
|
|
7238
|
+
types: "dist/index.d.ts",
|
|
7239
|
+
main: "dist/index.js",
|
|
7240
|
+
module: "dist/index.js",
|
|
7241
|
+
files: [
|
|
7242
|
+
"dist"
|
|
7243
|
+
],
|
|
7244
|
+
repository: {
|
|
7245
|
+
type: "git",
|
|
7246
|
+
url: "https://github.com/tscircuit/core"
|
|
7247
|
+
},
|
|
7248
|
+
scripts: {
|
|
7249
|
+
build: "tsup-node index.ts --format esm --dts",
|
|
7250
|
+
format: "biome format . --write",
|
|
7251
|
+
"measure-bundle": "howfat -r table .",
|
|
7252
|
+
"pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps",
|
|
7253
|
+
"build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
|
|
7254
|
+
"build:benchmarking:watch": `chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,
|
|
7255
|
+
"start:benchmarking": 'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"'
|
|
7256
|
+
},
|
|
7257
|
+
devDependencies: {
|
|
7258
|
+
"@biomejs/biome": "^1.8.3",
|
|
7259
|
+
"@tscircuit/footprinter": "^0.0.140",
|
|
7260
|
+
"@tscircuit/import-snippet": "^0.0.4",
|
|
7261
|
+
"@tscircuit/layout": "^0.0.28",
|
|
7262
|
+
"@tscircuit/log-soup": "^1.0.2",
|
|
7263
|
+
"@types/bun": "latest",
|
|
7264
|
+
"@types/debug": "^4.1.12",
|
|
7265
|
+
"@types/react": "^19.0.1",
|
|
7266
|
+
"@types/react-dom": "^19.0.2",
|
|
7267
|
+
"@types/react-reconciler": "^0.28.9",
|
|
7268
|
+
"bun-match-svg": "0.0.8",
|
|
7269
|
+
"chokidar-cli": "^3.0.0",
|
|
7270
|
+
"circuit-to-svg": "^0.0.99",
|
|
7271
|
+
concurrently: "^9.1.2",
|
|
7272
|
+
debug: "^4.3.6",
|
|
7273
|
+
"graphics-debug": "^0.0.4",
|
|
7274
|
+
howfat: "^0.3.8",
|
|
7275
|
+
"live-server": "^1.2.2",
|
|
7276
|
+
"looks-same": "^9.0.1",
|
|
7277
|
+
"pkg-pr-new": "^0.0.37",
|
|
7278
|
+
react: "^19.0.0",
|
|
7279
|
+
"react-dom": "^19.0.0",
|
|
7280
|
+
"ts-expect": "^1.3.0",
|
|
7281
|
+
tsup: "^8.2.4"
|
|
7282
|
+
},
|
|
7283
|
+
peerDependencies: {
|
|
7284
|
+
typescript: "^5.0.0",
|
|
7285
|
+
"@tscircuit/footprinter": "*"
|
|
7286
|
+
},
|
|
7287
|
+
dependencies: {
|
|
7288
|
+
"@lume/kiwi": "^0.4.3",
|
|
7289
|
+
"@tscircuit/capacity-autorouter": "^0.0.13",
|
|
7290
|
+
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
7291
|
+
"@tscircuit/math-utils": "^0.0.9",
|
|
7292
|
+
"@tscircuit/props": "^0.0.159",
|
|
7293
|
+
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
7294
|
+
"@tscircuit/soup-util": "^0.0.41",
|
|
7295
|
+
"circuit-json": "^0.0.151",
|
|
7296
|
+
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
7297
|
+
"format-si-unit": "^0.0.3",
|
|
7298
|
+
nanoid: "^5.0.7",
|
|
7299
|
+
"performance-now": "^2.1.0",
|
|
7300
|
+
"react-reconciler": "^0.31.0",
|
|
7301
|
+
"react-reconciler-18": "npm:react-reconciler@0.29.2",
|
|
7302
|
+
"schematic-symbols": "^0.0.121",
|
|
7303
|
+
"transformation-matrix": "^2.16.1",
|
|
7304
|
+
zod: "^3.23.8"
|
|
7305
|
+
}
|
|
7306
|
+
};
|
|
7307
|
+
|
|
7308
|
+
// lib/RootCircuit.ts
|
|
7223
7309
|
var RootCircuit = class {
|
|
7224
7310
|
firstChild = null;
|
|
7225
7311
|
children;
|
|
@@ -7291,6 +7377,11 @@ var RootCircuit = class {
|
|
|
7291
7377
|
this._hasRenderedAtleastOnce = true;
|
|
7292
7378
|
}
|
|
7293
7379
|
async renderUntilSettled() {
|
|
7380
|
+
if (!this.db.source_project_metadata.list()?.[0]) {
|
|
7381
|
+
this.db.source_project_metadata.insert({
|
|
7382
|
+
software_used_string: `@tscircuit/core@${this.getCoreVersion()}`
|
|
7383
|
+
});
|
|
7384
|
+
}
|
|
7294
7385
|
this.render();
|
|
7295
7386
|
while (this._hasIncompleteAsyncEffects()) {
|
|
7296
7387
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -7306,26 +7397,27 @@ var RootCircuit = class {
|
|
|
7306
7397
|
);
|
|
7307
7398
|
});
|
|
7308
7399
|
}
|
|
7309
|
-
|
|
7400
|
+
getCircuitJson() {
|
|
7310
7401
|
if (!this._hasRenderedAtleastOnce) this.render();
|
|
7311
7402
|
return this.db.toArray();
|
|
7312
7403
|
}
|
|
7313
|
-
getCircuitJson() {
|
|
7314
|
-
return this.getSoup();
|
|
7315
|
-
}
|
|
7316
7404
|
toJson() {
|
|
7317
|
-
return this.
|
|
7405
|
+
return this.getCircuitJson();
|
|
7318
7406
|
}
|
|
7319
7407
|
async getSvg(options) {
|
|
7320
7408
|
const circuitToSvg = await import("circuit-to-svg").catch((e) => {
|
|
7321
7409
|
throw new Error(
|
|
7322
|
-
`To use
|
|
7410
|
+
`To use circuit.getSvg, you must install the "circuit-to-svg" package.
|
|
7323
7411
|
|
|
7324
7412
|
"${e.message}"`
|
|
7325
7413
|
);
|
|
7326
7414
|
});
|
|
7327
7415
|
return circuitToSvg.convertCircuitJsonToPcbSvg(this.getCircuitJson());
|
|
7328
7416
|
}
|
|
7417
|
+
getCoreVersion() {
|
|
7418
|
+
const [major, minor, patch] = package_default.version.split(".").map(Number);
|
|
7419
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
7420
|
+
}
|
|
7329
7421
|
async preview(previewNameOrOpts) {
|
|
7330
7422
|
const previewOpts = typeof previewNameOrOpts === "object" ? previewNameOrOpts : { previewName: previewNameOrOpts };
|
|
7331
7423
|
throw new Error("project.preview is not yet implemented");
|
|
@@ -7357,6 +7449,12 @@ var RootCircuit = class {
|
|
|
7357
7449
|
}
|
|
7358
7450
|
this._eventListeners[event].push(listener);
|
|
7359
7451
|
}
|
|
7452
|
+
removeListener(event, listener) {
|
|
7453
|
+
if (!this._eventListeners[event]) return;
|
|
7454
|
+
this._eventListeners[event] = this._eventListeners[event].filter(
|
|
7455
|
+
(l) => l !== listener
|
|
7456
|
+
);
|
|
7457
|
+
}
|
|
7360
7458
|
getClientOrigin() {
|
|
7361
7459
|
if (typeof window !== "undefined") {
|
|
7362
7460
|
return window.location.origin;
|
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.340",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@tscircuit/props": "^0.0.159",
|
|
60
60
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
61
61
|
"@tscircuit/soup-util": "^0.0.41",
|
|
62
|
-
"circuit-json": "^0.0.
|
|
62
|
+
"circuit-json": "^0.0.151",
|
|
63
63
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
64
64
|
"format-si-unit": "^0.0.3",
|
|
65
65
|
"nanoid": "^5.0.7",
|