@tscircuit/core 0.0.199 → 0.0.201
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 +4 -0
- package/dist/index.js +31 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ declare abstract class Renderable implements IRenderable {
|
|
|
42
42
|
protected _markDirty(phase: RenderPhase): void;
|
|
43
43
|
protected _queueAsyncEffect(effect: () => Promise<void>): void;
|
|
44
44
|
_hasIncompleteAsyncEffects(): boolean;
|
|
45
|
+
getCurrentRenderPhase(): RenderPhase | null;
|
|
46
|
+
getRenderGraph(): Record<string, any>;
|
|
45
47
|
runRenderCycle(): void;
|
|
46
48
|
/**
|
|
47
49
|
* This runs all the render methods for a given phase, calling one of:
|
|
@@ -118,6 +120,7 @@ declare class Circuit {
|
|
|
118
120
|
_eventListeners: Record<RootCircuitEventName, Array<(...args: any[]) => void>>;
|
|
119
121
|
emit(event: RootCircuitEventName, ...args: any[]): void;
|
|
120
122
|
on(event: RootCircuitEventName, listener: (...args: any[]) => void): void;
|
|
123
|
+
getClientOrigin(): string;
|
|
121
124
|
}
|
|
122
125
|
/**
|
|
123
126
|
* @deprecated
|
|
@@ -805,6 +808,7 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
|
|
|
805
808
|
_getSchematicPortArrangement(): SchematicPortArrangement | null;
|
|
806
809
|
_getSchematicBoxDimensions(): SchematicBoxDimensions | null;
|
|
807
810
|
doInitialCadModelRender(): void;
|
|
811
|
+
private _addCachebustToModelUrl;
|
|
808
812
|
doInitialPartsEngineRender(): void;
|
|
809
813
|
updatePartsEngineRender(): void;
|
|
810
814
|
}
|
package/dist/index.js
CHANGED
|
@@ -146,6 +146,21 @@ var Renderable = class {
|
|
|
146
146
|
_hasIncompleteAsyncEffects() {
|
|
147
147
|
return this._asyncEffects.some((effect) => !effect.complete);
|
|
148
148
|
}
|
|
149
|
+
getCurrentRenderPhase() {
|
|
150
|
+
return this._currentRenderPhase;
|
|
151
|
+
}
|
|
152
|
+
getRenderGraph() {
|
|
153
|
+
const graph = {
|
|
154
|
+
id: this._renderId,
|
|
155
|
+
currentPhase: this._currentRenderPhase,
|
|
156
|
+
renderPhaseStates: this.renderPhaseStates,
|
|
157
|
+
shouldBeRemoved: this.shouldBeRemoved,
|
|
158
|
+
children: this.children.map(
|
|
159
|
+
(child) => child.getRenderGraph()
|
|
160
|
+
)
|
|
161
|
+
};
|
|
162
|
+
return graph;
|
|
163
|
+
}
|
|
149
164
|
runRenderCycle() {
|
|
150
165
|
for (const renderPhase of orderedRenderPhases) {
|
|
151
166
|
this.runRenderPhaseForChildren(renderPhase);
|
|
@@ -3110,12 +3125,17 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
3110
3125
|
},
|
|
3111
3126
|
pcb_component_id: this.pcb_component_id,
|
|
3112
3127
|
source_component_id: this.source_component_id,
|
|
3113
|
-
model_stl_url: "stlUrl" in (cadModel ?? {}) ? cadModel.stlUrl : void 0,
|
|
3114
|
-
model_obj_url: "objUrl" in (cadModel ?? {}) ? cadModel.objUrl : void 0,
|
|
3128
|
+
model_stl_url: "stlUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.stlUrl) : void 0,
|
|
3129
|
+
model_obj_url: "objUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.objUrl) : void 0,
|
|
3115
3130
|
model_jscad: "jscad" in (cadModel ?? {}) ? cadModel.jscad : void 0,
|
|
3116
3131
|
footprinter_string: typeof this.props.footprint === "string" && !cadModel ? this.props.footprint : void 0
|
|
3117
3132
|
});
|
|
3118
3133
|
}
|
|
3134
|
+
_addCachebustToModelUrl(url) {
|
|
3135
|
+
if (!url || !url.includes("modelcdn.tscircuit.com")) return url;
|
|
3136
|
+
const origin = this.root?.getClientOrigin() ?? "";
|
|
3137
|
+
return `${url}${url.includes("?") ? "&" : "?"}cachebust_origin=${encodeURIComponent(origin)}`;
|
|
3138
|
+
}
|
|
3119
3139
|
doInitialPartsEngineRender() {
|
|
3120
3140
|
const { partsEngine } = this.getSubcircuit()._parsedProps;
|
|
3121
3141
|
if (!partsEngine) return;
|
|
@@ -5573,6 +5593,15 @@ var Circuit = class {
|
|
|
5573
5593
|
}
|
|
5574
5594
|
this._eventListeners[event].push(listener);
|
|
5575
5595
|
}
|
|
5596
|
+
getClientOrigin() {
|
|
5597
|
+
if (typeof window !== "undefined") {
|
|
5598
|
+
return window.location.origin;
|
|
5599
|
+
}
|
|
5600
|
+
if (typeof self !== "undefined") {
|
|
5601
|
+
return self.origin;
|
|
5602
|
+
}
|
|
5603
|
+
return "";
|
|
5604
|
+
}
|
|
5576
5605
|
};
|
|
5577
5606
|
var Project = Circuit;
|
|
5578
5607
|
|