@tscircuit/cli 0.1.1526 → 0.1.1528

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.
@@ -10815,15 +10815,16 @@ var require_range = __commonJS((exports, module) => {
10815
10815
  };
10816
10816
  var replaceTilde = (comp, options) => {
10817
10817
  const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
10818
+ const z = options.includePrerelease ? "-0" : "";
10818
10819
  return comp.replace(r, (_, M, m, p, pr) => {
10819
10820
  debug2("tilde", comp, _, M, m, p, pr);
10820
10821
  let ret;
10821
10822
  if (isX(M)) {
10822
10823
  ret = "";
10823
10824
  } else if (isX(m)) {
10824
- ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
10825
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
10825
10826
  } else if (isX(p)) {
10826
- ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
10827
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
10827
10828
  } else if (pr) {
10828
10829
  debug2("replaceTilde pr", pr);
10829
10830
  ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
@@ -12086,16 +12087,20 @@ var DEFAULT_IMAGE_FORMAT_SELECTION = {
12086
12087
  threeDPngs: true,
12087
12088
  pcbPngs: false,
12088
12089
  pcbSvgs: true,
12089
- schematicSvgs: true
12090
+ schematicSvgs: true,
12091
+ simulationSvgs: false,
12092
+ simulationSchematicSvgs: false
12090
12093
  };
12091
12094
  var EMPTY_IMAGE_FORMAT_SELECTION = {
12092
12095
  threeDPngs: false,
12093
12096
  pcbPngs: false,
12094
12097
  pcbSvgs: false,
12095
- schematicSvgs: false
12098
+ schematicSvgs: false,
12099
+ simulationSvgs: false,
12100
+ simulationSchematicSvgs: false
12096
12101
  };
12097
- var hasAnyImageFormatSelected = (selection) => selection.threeDPngs || selection.pcbPngs || selection.pcbSvgs || selection.schematicSvgs;
12098
- var hasNewOutputFlags = (options) => Boolean(options?.pngs || options?.pcbPng || options?.svgs || options?.pcbSvgs || options?.schematicSvgs);
12102
+ var hasAnyImageFormatSelected = (selection) => selection.threeDPngs || selection.pcbPngs || selection.pcbSvgs || selection.schematicSvgs || selection.simulationSvgs || selection.simulationSchematicSvgs;
12103
+ var hasNewOutputFlags = (options) => Boolean(options?.pngs || options?.pcbPng || options?.svgs || options?.pcbSvgs || options?.simulationSvgs || options?.simulationSchematicSvgs || options?.schematicSvgs);
12099
12104
  var hasEstablishedOutputFlags = (options) => Boolean(options?.["3d"] || options?.["3dPng"] || options?.pcbOnly || options?.schematicOnly);
12100
12105
  var resolveImageFormatSelection = (options) => {
12101
12106
  const hasNewFlags = hasNewOutputFlags(options);
@@ -12112,7 +12117,9 @@ var resolveImageFormatSelection = (options) => {
12112
12117
  threeDPngs: Boolean(options?.["3d"] || options?.["3dPng"]),
12113
12118
  pcbPngs: false,
12114
12119
  pcbSvgs: true,
12115
- schematicSvgs: true
12120
+ schematicSvgs: true,
12121
+ simulationSvgs: false,
12122
+ simulationSchematicSvgs: false
12116
12123
  };
12117
12124
  if (options?.pcbOnly && !options?.schematicOnly) {
12118
12125
  selection2.schematicSvgs = false;
@@ -12128,6 +12135,8 @@ var resolveImageFormatSelection = (options) => {
12128
12135
  if (options?.svgs) {
12129
12136
  selection.pcbSvgs = true;
12130
12137
  selection.schematicSvgs = true;
12138
+ selection.simulationSvgs = true;
12139
+ selection.simulationSchematicSvgs = true;
12131
12140
  }
12132
12141
  if (options?.pcbSvgs) {
12133
12142
  selection.pcbSvgs = true;
@@ -12138,6 +12147,12 @@ var resolveImageFormatSelection = (options) => {
12138
12147
  if (options?.schematicSvgs) {
12139
12148
  selection.schematicSvgs = true;
12140
12149
  }
12150
+ if (options?.simulationSvgs) {
12151
+ selection.simulationSvgs = true;
12152
+ }
12153
+ if (options?.simulationSchematicSvgs) {
12154
+ selection.simulationSchematicSvgs = true;
12155
+ }
12141
12156
  if (options?.pngs || options?.["3d"] || options?.["3dPng"]) {
12142
12157
  selection.threeDPngs = true;
12143
12158
  }
@@ -16038,7 +16053,57 @@ async function loadLocalStepModelFsMap(circuitJson) {
16038
16053
  return fsMap;
16039
16054
  }
16040
16055
 
16056
+ // lib/shared/simulation-svg-assets.ts
16057
+ import {
16058
+ convertCircuitJsonToSchematicSimulationSvg,
16059
+ convertCircuitJsonToSimulationGraphSvg,
16060
+ isSimulationExperiment,
16061
+ isSimulationTransientVoltageGraph
16062
+ } from "circuit-to-svg";
16063
+ var getSimulationSvgInputs = (circuitJson) => {
16064
+ const simulationExperiment = circuitJson.find(isSimulationExperiment);
16065
+ if (!simulationExperiment)
16066
+ return;
16067
+ const simulationTransientVoltageGraphIds = circuitJson.filter((element) => isSimulationTransientVoltageGraph(element) && element.simulation_experiment_id === simulationExperiment.simulation_experiment_id).map((element) => element.simulation_transient_voltage_graph_id);
16068
+ if (simulationTransientVoltageGraphIds.length === 0)
16069
+ return;
16070
+ return {
16071
+ simulation_experiment_id: simulationExperiment.simulation_experiment_id,
16072
+ simulation_transient_voltage_graph_ids: simulationTransientVoltageGraphIds
16073
+ };
16074
+ };
16075
+ var getSimulationSvgAssetsFromCircuitJson = (circuitJson) => {
16076
+ const simulationSvgInputs = getSimulationSvgInputs(circuitJson);
16077
+ if (!simulationSvgInputs)
16078
+ return;
16079
+ return {
16080
+ simulationSvg: convertCircuitJsonToSimulationGraphSvg({
16081
+ circuitJson,
16082
+ ...simulationSvgInputs
16083
+ }),
16084
+ schematicSimulationSvg: convertCircuitJsonToSchematicSimulationSvg({
16085
+ circuitJson,
16086
+ ...simulationSvgInputs
16087
+ })
16088
+ };
16089
+ };
16090
+
16041
16091
  // cli/build/worker-output-generators.ts
16092
+ var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageFormats) => {
16093
+ if (!imageFormats.simulationSvgs && !imageFormats.simulationSchematicSvgs) {
16094
+ return false;
16095
+ }
16096
+ const simulationSvgAssets = getSimulationSvgAssetsFromCircuitJson(circuitJson);
16097
+ if (!simulationSvgAssets)
16098
+ return false;
16099
+ if (imageFormats.simulationSvgs) {
16100
+ fs9.writeFileSync(path13.join(outputDir, "simulation.svg"), simulationSvgAssets.simulationSvg, "utf-8");
16101
+ }
16102
+ if (imageFormats.simulationSchematicSvgs) {
16103
+ fs9.writeFileSync(path13.join(outputDir, "simulation-schematic.svg"), simulationSvgAssets.schematicSimulationSvg, "utf-8");
16104
+ }
16105
+ return true;
16106
+ };
16042
16107
  var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
16043
16108
  const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
16044
16109
  const glbBuffer = await convertCircuitJsonToGltf(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
@@ -16070,6 +16135,7 @@ var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
16070
16135
  const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
16071
16136
  fs9.writeFileSync(path13.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
16072
16137
  }
16138
+ writeSimulationSvgAssetsFromCircuitJson(circuitJson, outputDir, imageFormats);
16073
16139
  if (imageFormats.threeDPngs) {
16074
16140
  const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
16075
16141
  const glbBuffer = await convertCircuitJsonToGltf(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));