@tscircuit/core 0.0.1294 → 0.0.1296
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 +3 -0
- package/dist/index.js +92 -71
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -230,6 +230,7 @@ interface DebugLogOutputEvent {
|
|
|
230
230
|
interface IIsolatedCircuit {
|
|
231
231
|
emit(event: RootCircuitEventName, ...args: any[]): void;
|
|
232
232
|
on(event: RootCircuitEventName, listener: (...args: any[]) => void): void;
|
|
233
|
+
isDoneRendering(): boolean;
|
|
233
234
|
_hasIncompleteAsyncEffectsForPhase(phase: RenderPhase): boolean;
|
|
234
235
|
}
|
|
235
236
|
|
|
@@ -387,6 +388,7 @@ declare class IsolatedCircuit {
|
|
|
387
388
|
_hasRenderedAtleastOnce: boolean;
|
|
388
389
|
private _asyncEffectIdsByPhase;
|
|
389
390
|
private _asyncEffectPhaseById;
|
|
391
|
+
private _hasUnrenderedUpdatesFromAsyncEffects;
|
|
390
392
|
private _runningAsyncEffectsById;
|
|
391
393
|
constructor({ platform, projectUrl, cachedSubcircuits, pendingSubcircuitRenders, }?: {
|
|
392
394
|
platform?: PlatformConfig;
|
|
@@ -403,6 +405,7 @@ declare class IsolatedCircuit {
|
|
|
403
405
|
_guessRootComponent(): void;
|
|
404
406
|
render(): void;
|
|
405
407
|
renderUntilSettled(): Promise<void>;
|
|
408
|
+
isDoneRendering(): boolean;
|
|
406
409
|
_hasIncompleteAsyncEffects(): boolean;
|
|
407
410
|
_hasIncompleteAsyncEffectsForPhase(phase: RenderPhase): boolean;
|
|
408
411
|
getRunningAsyncEffects(): Array<{
|
package/dist/index.js
CHANGED
|
@@ -6027,6 +6027,75 @@ var CourtyardRect = class extends PrimitiveComponent2 {
|
|
|
6027
6027
|
}
|
|
6028
6028
|
};
|
|
6029
6029
|
|
|
6030
|
+
// lib/utils/normalizeTextForCircuitJson.ts
|
|
6031
|
+
function normalizeTextForCircuitJson(text) {
|
|
6032
|
+
return text.replace(/\\n/g, "\n");
|
|
6033
|
+
}
|
|
6034
|
+
|
|
6035
|
+
// lib/components/primitive-components/CopperText.ts
|
|
6036
|
+
import { copperTextProps } from "@tscircuit/props";
|
|
6037
|
+
var CopperText = class extends PrimitiveComponent2 {
|
|
6038
|
+
isPcbPrimitive = true;
|
|
6039
|
+
pcb_copper_text_id = null;
|
|
6040
|
+
get config() {
|
|
6041
|
+
return {
|
|
6042
|
+
componentName: "CopperText",
|
|
6043
|
+
zodProps: copperTextProps
|
|
6044
|
+
};
|
|
6045
|
+
}
|
|
6046
|
+
doInitialPcbPrimitiveRender() {
|
|
6047
|
+
if (this.root?.pcbDisabled) return;
|
|
6048
|
+
const { db } = this.root;
|
|
6049
|
+
const { _parsedProps: props } = this;
|
|
6050
|
+
const container = this.getPrimitiveContainer();
|
|
6051
|
+
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
6052
|
+
const subcircuit = this.getSubcircuit();
|
|
6053
|
+
const pcb_copper_text = db.pcb_copper_text.insert({
|
|
6054
|
+
anchor_alignment: props.anchorAlignment,
|
|
6055
|
+
anchor_position: {
|
|
6056
|
+
x: position.x,
|
|
6057
|
+
y: position.y
|
|
6058
|
+
},
|
|
6059
|
+
font: "tscircuit2024",
|
|
6060
|
+
font_size: props.fontSize,
|
|
6061
|
+
layer: props.layer ?? "top",
|
|
6062
|
+
text: normalizeTextForCircuitJson(props.text),
|
|
6063
|
+
ccw_rotation: props.pcbRotation,
|
|
6064
|
+
is_mirrored: props.mirrored,
|
|
6065
|
+
is_knockout: props.knockout,
|
|
6066
|
+
pcb_component_id: container.pcb_component_id,
|
|
6067
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
6068
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
6069
|
+
});
|
|
6070
|
+
this.pcb_copper_text_id = pcb_copper_text.pcb_copper_text_id;
|
|
6071
|
+
}
|
|
6072
|
+
getPcbSize() {
|
|
6073
|
+
const { _parsedProps: props } = this;
|
|
6074
|
+
const fontSize = props.fontSize ?? 1;
|
|
6075
|
+
const text = props.text ?? "";
|
|
6076
|
+
const textWidth = text.length * fontSize;
|
|
6077
|
+
const textHeight = fontSize;
|
|
6078
|
+
return { width: textWidth * fontSize, height: textHeight * fontSize };
|
|
6079
|
+
}
|
|
6080
|
+
_moveCircuitJsonElements({
|
|
6081
|
+
deltaX,
|
|
6082
|
+
deltaY
|
|
6083
|
+
}) {
|
|
6084
|
+
if (this.root?.pcbDisabled) return;
|
|
6085
|
+
const { db } = this.root;
|
|
6086
|
+
if (!this.pcb_copper_text_id) return;
|
|
6087
|
+
const text = db.pcb_copper_text.get(this.pcb_copper_text_id);
|
|
6088
|
+
if (text) {
|
|
6089
|
+
db.pcb_copper_text.update(this.pcb_copper_text_id, {
|
|
6090
|
+
anchor_position: {
|
|
6091
|
+
x: text.anchor_position.x + deltaX,
|
|
6092
|
+
y: text.anchor_position.y + deltaY
|
|
6093
|
+
}
|
|
6094
|
+
});
|
|
6095
|
+
}
|
|
6096
|
+
}
|
|
6097
|
+
};
|
|
6098
|
+
|
|
6030
6099
|
// lib/components/primitive-components/Cutout.ts
|
|
6031
6100
|
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
6032
6101
|
import { cutoutProps } from "@tscircuit/props";
|
|
@@ -6356,11 +6425,6 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
|
|
|
6356
6425
|
// lib/components/primitive-components/FabricationNoteText.ts
|
|
6357
6426
|
import { fabricationNoteTextProps } from "@tscircuit/props";
|
|
6358
6427
|
|
|
6359
|
-
// lib/utils/normalizeTextForCircuitJson.ts
|
|
6360
|
-
function normalizeTextForCircuitJson(text) {
|
|
6361
|
-
return text.replace(/\\n/g, "\n");
|
|
6362
|
-
}
|
|
6363
|
-
|
|
6364
6428
|
// lib/utils/pcbSx/resolve-pcb-property.ts
|
|
6365
6429
|
function parseSegment(seg) {
|
|
6366
6430
|
const bracketIdx = seg.indexOf("[");
|
|
@@ -8665,6 +8729,20 @@ var createComponentsFromCircuitJson = ({
|
|
|
8665
8729
|
strokeWidth: elm.stroke_width
|
|
8666
8730
|
})
|
|
8667
8731
|
);
|
|
8732
|
+
} else if (elm.type === "pcb_copper_text") {
|
|
8733
|
+
components.push(
|
|
8734
|
+
new CopperText({
|
|
8735
|
+
text: elm.text,
|
|
8736
|
+
pcbX: elm.anchor_position.x,
|
|
8737
|
+
pcbY: elm.anchor_position.y,
|
|
8738
|
+
pcbRotation: elm.ccw_rotation,
|
|
8739
|
+
anchorAlignment: elm.anchor_alignment,
|
|
8740
|
+
fontSize: elm.font_size,
|
|
8741
|
+
layer: elm.layer,
|
|
8742
|
+
mirrored: elm.is_mirrored,
|
|
8743
|
+
knockout: elm.is_knockout
|
|
8744
|
+
})
|
|
8745
|
+
);
|
|
8668
8746
|
} else if (elm.type === "pcb_plated_hole") {
|
|
8669
8747
|
if (elm.shape === "circle") {
|
|
8670
8748
|
components.push(
|
|
@@ -22348,7 +22426,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
22348
22426
|
var package_default = {
|
|
22349
22427
|
name: "@tscircuit/core",
|
|
22350
22428
|
type: "module",
|
|
22351
|
-
version: "0.0.
|
|
22429
|
+
version: "0.0.1295",
|
|
22352
22430
|
types: "dist/index.d.ts",
|
|
22353
22431
|
main: "dist/index.js",
|
|
22354
22432
|
module: "dist/index.js",
|
|
@@ -22524,6 +22602,7 @@ var IsolatedCircuit = class {
|
|
|
22524
22602
|
_hasRenderedAtleastOnce = false;
|
|
22525
22603
|
_asyncEffectIdsByPhase = /* @__PURE__ */ new Map();
|
|
22526
22604
|
_asyncEffectPhaseById = /* @__PURE__ */ new Map();
|
|
22605
|
+
_hasUnrenderedUpdatesFromAsyncEffects = false;
|
|
22527
22606
|
_runningAsyncEffectsById = /* @__PURE__ */ new Map();
|
|
22528
22607
|
constructor({
|
|
22529
22608
|
platform,
|
|
@@ -22610,6 +22689,7 @@ var IsolatedCircuit = class {
|
|
|
22610
22689
|
if (!firstChild) throw new Error("IsolatedCircuit has no root component");
|
|
22611
22690
|
firstChild.parent = this;
|
|
22612
22691
|
firstChild.runRenderCycle();
|
|
22692
|
+
this._hasUnrenderedUpdatesFromAsyncEffects = false;
|
|
22613
22693
|
this._hasRenderedAtleastOnce = true;
|
|
22614
22694
|
}
|
|
22615
22695
|
async renderUntilSettled() {
|
|
@@ -22621,14 +22701,18 @@ var IsolatedCircuit = class {
|
|
|
22621
22701
|
});
|
|
22622
22702
|
}
|
|
22623
22703
|
this.render();
|
|
22624
|
-
while (this.
|
|
22704
|
+
while (!this.isDoneRendering()) {
|
|
22625
22705
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
22626
22706
|
this.render();
|
|
22627
22707
|
}
|
|
22628
22708
|
this.emit("renderComplete");
|
|
22629
22709
|
}
|
|
22710
|
+
isDoneRendering() {
|
|
22711
|
+
return this._hasRenderedAtleastOnce && !this._hasIncompleteAsyncEffects();
|
|
22712
|
+
}
|
|
22630
22713
|
_hasIncompleteAsyncEffects() {
|
|
22631
22714
|
if (this._asyncEffectPhaseById.size > 0) return true;
|
|
22715
|
+
if (this._hasUnrenderedUpdatesFromAsyncEffects) return true;
|
|
22632
22716
|
return this.children.some((child) => child._hasIncompleteAsyncEffects());
|
|
22633
22717
|
}
|
|
22634
22718
|
_hasIncompleteAsyncEffectsForPhase(phase) {
|
|
@@ -22757,6 +22841,7 @@ var IsolatedCircuit = class {
|
|
|
22757
22841
|
}
|
|
22758
22842
|
this._asyncEffectPhaseById.delete(asyncEffectId);
|
|
22759
22843
|
this._runningAsyncEffectsById.delete(asyncEffectId);
|
|
22844
|
+
this._hasUnrenderedUpdatesFromAsyncEffects = true;
|
|
22760
22845
|
}
|
|
22761
22846
|
};
|
|
22762
22847
|
|
|
@@ -27072,70 +27157,6 @@ var CopperPour = class extends PrimitiveComponent2 {
|
|
|
27072
27157
|
}
|
|
27073
27158
|
};
|
|
27074
27159
|
|
|
27075
|
-
// lib/components/primitive-components/CopperText.ts
|
|
27076
|
-
import { copperTextProps } from "@tscircuit/props";
|
|
27077
|
-
var CopperText = class extends PrimitiveComponent2 {
|
|
27078
|
-
isPcbPrimitive = true;
|
|
27079
|
-
pcb_copper_text_id = null;
|
|
27080
|
-
get config() {
|
|
27081
|
-
return {
|
|
27082
|
-
componentName: "CopperText",
|
|
27083
|
-
zodProps: copperTextProps
|
|
27084
|
-
};
|
|
27085
|
-
}
|
|
27086
|
-
doInitialPcbPrimitiveRender() {
|
|
27087
|
-
if (this.root?.pcbDisabled) return;
|
|
27088
|
-
const { db } = this.root;
|
|
27089
|
-
const { _parsedProps: props } = this;
|
|
27090
|
-
const container = this.getPrimitiveContainer();
|
|
27091
|
-
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
27092
|
-
const subcircuit = this.getSubcircuit();
|
|
27093
|
-
const pcb_copper_text = db.pcb_copper_text.insert({
|
|
27094
|
-
anchor_alignment: props.anchorAlignment,
|
|
27095
|
-
anchor_position: {
|
|
27096
|
-
x: position.x,
|
|
27097
|
-
y: position.y
|
|
27098
|
-
},
|
|
27099
|
-
font: "tscircuit2024",
|
|
27100
|
-
font_size: props.fontSize,
|
|
27101
|
-
layer: props.layer ?? "top",
|
|
27102
|
-
text: normalizeTextForCircuitJson(props.text),
|
|
27103
|
-
ccw_rotation: props.pcbRotation,
|
|
27104
|
-
is_mirrored: props.mirrored,
|
|
27105
|
-
is_knockout: props.knockout,
|
|
27106
|
-
pcb_component_id: container.pcb_component_id,
|
|
27107
|
-
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
27108
|
-
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
27109
|
-
});
|
|
27110
|
-
this.pcb_copper_text_id = pcb_copper_text.pcb_copper_text_id;
|
|
27111
|
-
}
|
|
27112
|
-
getPcbSize() {
|
|
27113
|
-
const { _parsedProps: props } = this;
|
|
27114
|
-
const fontSize = props.fontSize ?? 1;
|
|
27115
|
-
const text = props.text ?? "";
|
|
27116
|
-
const textWidth = text.length * fontSize;
|
|
27117
|
-
const textHeight = fontSize;
|
|
27118
|
-
return { width: textWidth * fontSize, height: textHeight * fontSize };
|
|
27119
|
-
}
|
|
27120
|
-
_moveCircuitJsonElements({
|
|
27121
|
-
deltaX,
|
|
27122
|
-
deltaY
|
|
27123
|
-
}) {
|
|
27124
|
-
if (this.root?.pcbDisabled) return;
|
|
27125
|
-
const { db } = this.root;
|
|
27126
|
-
if (!this.pcb_copper_text_id) return;
|
|
27127
|
-
const text = db.pcb_copper_text.get(this.pcb_copper_text_id);
|
|
27128
|
-
if (text) {
|
|
27129
|
-
db.pcb_copper_text.update(this.pcb_copper_text_id, {
|
|
27130
|
-
anchor_position: {
|
|
27131
|
-
x: text.anchor_position.x + deltaX,
|
|
27132
|
-
y: text.anchor_position.y + deltaY
|
|
27133
|
-
}
|
|
27134
|
-
});
|
|
27135
|
-
}
|
|
27136
|
-
}
|
|
27137
|
-
};
|
|
27138
|
-
|
|
27139
27160
|
// lib/components/normal-components/Battery.ts
|
|
27140
27161
|
import { batteryProps } from "@tscircuit/props";
|
|
27141
27162
|
var Battery = class extends NormalComponent3 {
|