circuit-json 0.0.521 → 0.0.522

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.mjs CHANGED
@@ -4633,7 +4633,8 @@ var experiment_type = z203.union([
4633
4633
  z203.literal("spice_dc_sweep"),
4634
4634
  z203.literal("spice_dc_operating_point"),
4635
4635
  z203.literal("spice_transient_analysis"),
4636
- z203.literal("spice_ac_analysis")
4636
+ z203.literal("spice_ac_analysis"),
4637
+ z203.literal("pcb_return_current")
4637
4638
  ]);
4638
4639
  var spice_simulation_options = z203.object({
4639
4640
  method: z203.enum(["trap", "gear"]).optional(),
@@ -5175,9 +5176,297 @@ var simulation_oscilloscope_trace = z221.object({
5175
5176
  });
5176
5177
  expectTypesMatch(true);
5177
5178
 
5178
- // src/any_circuit_element.ts
5179
+ // src/simulation/simulation_return_current_contact.ts
5179
5180
  import { z as z222 } from "zod";
5180
- var any_circuit_element = z222.union([
5181
+ var contact_position = z222.object({
5182
+ x: z222.number().finite(),
5183
+ y: z222.number().finite(),
5184
+ layer: layer_ref
5185
+ });
5186
+ var simulation_return_current_contact = z222.discriminatedUnion("contact_type", [
5187
+ contact_position.extend({
5188
+ contact_type: z222.literal("pcb_port"),
5189
+ pcb_port_id: z222.string().min(1)
5190
+ }),
5191
+ contact_position.extend({
5192
+ contact_type: z222.literal("pcb_via"),
5193
+ pcb_via_id: z222.string().min(1)
5194
+ }),
5195
+ contact_position.extend({
5196
+ contact_type: z222.literal("pcb_copper_pour"),
5197
+ pcb_copper_pour_id: z222.string().min(1)
5198
+ })
5199
+ ]).describe("Identifies the reference conductor at a return-current contact");
5200
+ expectTypesMatch(true);
5201
+
5202
+ // src/simulation/simulation_terminal_port.ts
5203
+ import { z as z223 } from "zod";
5204
+ var simulation_terminal_port = z223.object({
5205
+ signal_pcb_port_id: z223.string().min(1),
5206
+ reference_pcb_port_id: z223.string().min(1).optional(),
5207
+ reference_layer: layer_ref,
5208
+ resistance: z223.number().finite().positive()
5209
+ }).describe(
5210
+ "A two-terminal return-current excitation port with resistance in ohms"
5211
+ );
5212
+ expectTypesMatch(true);
5213
+
5214
+ // src/simulation/simulation_return_current_excitation.ts
5215
+ import { z as z224 } from "zod";
5216
+ var simulation_return_current_excitation = z224.object({
5217
+ type: z224.literal("simulation_return_current_excitation"),
5218
+ simulation_return_current_excitation_id: getZodPrefixedIdWithDefault(
5219
+ "simulation_return_current_excitation"
5220
+ ),
5221
+ simulation_experiment_id: z224.string().min(1),
5222
+ pcb_trace_id: z224.string().min(1),
5223
+ ground_source_net_id: z224.string().min(1),
5224
+ current: z224.number().finite(),
5225
+ return_source: simulation_return_current_contact,
5226
+ return_sink: simulation_return_current_contact,
5227
+ source_port: simulation_terminal_port.optional(),
5228
+ load_port: simulation_terminal_port.optional()
5229
+ }).describe(
5230
+ "Excites a signal trace with signed current in amperes, peak for AC; return_source is near the load and return_sink near the driver for positive current"
5231
+ );
5232
+ expectTypesMatch(true);
5233
+
5234
+ // src/simulation/simulation_pcb_return_current_result.ts
5235
+ import { z as z225 } from "zod";
5236
+ var simulation_pcb_return_current_result = z225.object({
5237
+ type: z225.literal("simulation_pcb_return_current_result"),
5238
+ simulation_pcb_return_current_result_id: getZodPrefixedIdWithDefault(
5239
+ "simulation_pcb_return_current_result"
5240
+ ),
5241
+ simulation_experiment_id: z225.string().min(1),
5242
+ pcb_board_id: z225.string().min(1),
5243
+ simulation_return_current_excitation_ids: z225.array(z225.string().min(1)).min(1).refine(
5244
+ (ids) => new Set(ids).size === ids.length,
5245
+ "Excitation IDs must be unique"
5246
+ ),
5247
+ frequency_hz: z225.number().finite().positive().optional()
5248
+ }).describe(
5249
+ "A PCB return-current result at one frequency, or a frequency-independent result when frequency_hz is absent"
5250
+ );
5251
+ expectTypesMatch(true);
5252
+
5253
+ // src/simulation/simulation_return_current_asset.ts
5254
+ import { z as z226 } from "zod";
5255
+ function createSimulationReturnCurrentAssetSchema(mimetypes) {
5256
+ return asset.extend({
5257
+ project_relative_path: z226.string().min(1),
5258
+ url: z226.string().url()
5259
+ }).superRefine((value, context) => {
5260
+ if (!mimetypes.includes(value.mimetype)) {
5261
+ context.addIssue({
5262
+ code: z226.ZodIssueCode.custom,
5263
+ path: ["mimetype"],
5264
+ message: `Expected one of: ${mimetypes.join(", ")}`
5265
+ });
5266
+ }
5267
+ if (value.url.startsWith("data:")) {
5268
+ const mediaType = /^data:([^;,]*)(?:;[^,]*)?,/i.exec(value.url)?.[1];
5269
+ if (mediaType?.toLowerCase() !== value.mimetype) {
5270
+ context.addIssue({
5271
+ code: z226.ZodIssueCode.custom,
5272
+ path: ["url"],
5273
+ message: "Data URL media type must match asset.mimetype"
5274
+ });
5275
+ }
5276
+ }
5277
+ });
5278
+ }
5279
+ var simulation_return_current_field_asset = createSimulationReturnCurrentAssetSchema([
5280
+ "application/json",
5281
+ "application/gzip"
5282
+ ]);
5283
+ var simulation_return_current_image_asset = createSimulationReturnCurrentAssetSchema(["image/png", "image/webp"]);
5284
+
5285
+ // src/simulation/simulation_pcb_return_current_field.ts
5286
+ import { z as z227 } from "zod";
5287
+ var simulation_pcb_return_current_field = z227.object({
5288
+ type: z227.literal("simulation_pcb_return_current_field"),
5289
+ simulation_pcb_return_current_field_id: getZodPrefixedIdWithDefault(
5290
+ "simulation_pcb_return_current_field"
5291
+ ),
5292
+ simulation_pcb_return_current_result_id: z227.string().min(1),
5293
+ layer: layer_ref,
5294
+ source_net_id: z227.string().min(1),
5295
+ field_type: z227.enum(["real", "complex_phasor"]),
5296
+ min_x: z227.number().finite(),
5297
+ min_y: z227.number().finite(),
5298
+ columns: z227.number().int().positive().safe(),
5299
+ rows: z227.number().int().positive().safe(),
5300
+ cell_width: z227.number().finite().positive(),
5301
+ cell_height: z227.number().finite().positive(),
5302
+ copper_thickness: z227.number().finite().positive(),
5303
+ data_format: z227.literal("simulation_return_current_grid_json_v1"),
5304
+ field_asset: simulation_return_current_field_asset
5305
+ }).superRefine((field, context) => {
5306
+ if (!Number.isSafeInteger(field.columns * field.rows)) {
5307
+ context.addIssue({
5308
+ code: z227.ZodIssueCode.custom,
5309
+ path: ["columns"],
5310
+ message: "The grid cell count must be a safe integer"
5311
+ });
5312
+ }
5313
+ }).describe(
5314
+ "A sampled sheet-current field in A/mm, using plain or gzipped JSON Asset URLs; dimensions are PCB millimeters"
5315
+ );
5316
+ expectTypesMatch(true);
5317
+
5318
+ // src/simulation/simulation_return_current_grid_json.ts
5319
+ import { z as z228 } from "zod";
5320
+ var channel = z228.array(z228.number().finite().nullable()).min(1);
5321
+ var simulation_return_current_grid_json = z228.discriminatedUnion("field_type", [
5322
+ z228.object({
5323
+ field_type: z228.literal("real"),
5324
+ sheet_current_x: channel,
5325
+ sheet_current_y: channel
5326
+ }),
5327
+ z228.object({
5328
+ field_type: z228.literal("complex_phasor"),
5329
+ sheet_current_x_real: channel,
5330
+ sheet_current_x_imag: channel,
5331
+ sheet_current_y_real: channel,
5332
+ sheet_current_y_imag: channel
5333
+ })
5334
+ ]).superRefine((grid, context) => {
5335
+ const channels = grid.field_type === "real" ? [grid.sheet_current_x, grid.sheet_current_y] : [
5336
+ grid.sheet_current_x_real,
5337
+ grid.sheet_current_x_imag,
5338
+ grid.sheet_current_y_real,
5339
+ grid.sheet_current_y_imag
5340
+ ];
5341
+ const first = channels[0];
5342
+ if (channels.some((values) => values.length !== first.length)) {
5343
+ context.addIssue({
5344
+ code: z228.ZodIssueCode.custom,
5345
+ message: "Current channels must have equal lengths"
5346
+ });
5347
+ return;
5348
+ }
5349
+ for (let index = 0; index < first.length; index++) {
5350
+ const masked = first[index] === null;
5351
+ if (channels.some((values) => values[index] === null !== masked)) {
5352
+ context.addIssue({
5353
+ code: z228.ZodIssueCode.custom,
5354
+ message: `Cell ${index} must be null in every channel or finite in every channel`
5355
+ });
5356
+ return;
5357
+ }
5358
+ }
5359
+ }).describe(
5360
+ "Decoded real or complex sheet-current arrays with a shared conductor mask"
5361
+ );
5362
+ expectTypesMatch(true);
5363
+ function getSimulationReturnCurrentGridJsonSchema(field) {
5364
+ const count = field.columns * field.rows;
5365
+ if (!Number.isSafeInteger(field.columns) || field.columns <= 0 || !Number.isSafeInteger(field.rows) || field.rows <= 0 || !Number.isSafeInteger(count))
5366
+ throw new Error("Grid dimensions must be positive safe integers");
5367
+ return simulation_return_current_grid_json.superRefine((grid, context) => {
5368
+ if (grid.field_type !== field.field_type) {
5369
+ context.addIssue({
5370
+ code: z228.ZodIssueCode.custom,
5371
+ path: ["field_type"],
5372
+ message: "Decoded field_type must match the parent field"
5373
+ });
5374
+ }
5375
+ const first = grid.field_type === "real" ? grid.sheet_current_x : grid.sheet_current_x_real;
5376
+ if (first.length !== count) {
5377
+ context.addIssue({
5378
+ code: z228.ZodIssueCode.custom,
5379
+ message: `Each current channel must have ${count} entries (columns * rows)`
5380
+ });
5381
+ }
5382
+ });
5383
+ }
5384
+
5385
+ // src/simulation/simulation_pcb_return_current_heatmap.ts
5386
+ import { z as z229 } from "zod";
5387
+ var simulation_pcb_return_current_heatmap = z229.object({
5388
+ type: z229.literal("simulation_pcb_return_current_heatmap"),
5389
+ simulation_pcb_return_current_heatmap_id: getZodPrefixedIdWithDefault(
5390
+ "simulation_pcb_return_current_heatmap"
5391
+ ),
5392
+ simulation_pcb_return_current_result_id: z229.string().min(1),
5393
+ layer: layer_ref,
5394
+ source_net_id: z229.string().min(1),
5395
+ min_x: z229.number().finite(),
5396
+ min_y: z229.number().finite(),
5397
+ max_x: z229.number().finite(),
5398
+ max_y: z229.number().finite(),
5399
+ image_asset: simulation_return_current_image_asset
5400
+ }).superRefine((heatmap, context) => {
5401
+ for (const axis of ["x", "y"]) {
5402
+ if (heatmap[`max_${axis}`] <= heatmap[`min_${axis}`]) {
5403
+ context.addIssue({
5404
+ code: z229.ZodIssueCode.custom,
5405
+ path: [`max_${axis}`],
5406
+ message: "Heatmap bounds must have positive width and height"
5407
+ });
5408
+ }
5409
+ }
5410
+ }).describe(
5411
+ "A transparent PNG/WebP current-density overlay in A/mm\xB2; the top-left pixel maps to (min_x, max_y)"
5412
+ );
5413
+ expectTypesMatch(true);
5414
+
5415
+ // src/simulation/simulation_pcb_return_current_marker.ts
5416
+ import { z as z230 } from "zod";
5417
+ var marker_base = z230.object({
5418
+ type: z230.literal("simulation_pcb_return_current_marker"),
5419
+ simulation_pcb_return_current_marker_id: getZodPrefixedIdWithDefault(
5420
+ "simulation_pcb_return_current_marker"
5421
+ ),
5422
+ simulation_pcb_return_current_result_id: z230.string().min(1),
5423
+ role: z230.enum([
5424
+ "signal_source",
5425
+ "signal_load",
5426
+ "return_source",
5427
+ "return_sink",
5428
+ "signal_transition",
5429
+ "return_transition"
5430
+ ]),
5431
+ label: z230.string().optional(),
5432
+ label_x: z230.number().finite().optional(),
5433
+ label_y: z230.number().finite().optional()
5434
+ });
5435
+ var simulation_pcb_return_current_marker = z230.discriminatedUnion("target_type", [
5436
+ marker_base.extend({
5437
+ target_type: z230.literal("pcb_port"),
5438
+ pcb_port_id: z230.string().min(1),
5439
+ layer: layer_ref
5440
+ }),
5441
+ marker_base.extend({
5442
+ target_type: z230.literal("pcb_via"),
5443
+ pcb_via_id: z230.string().min(1),
5444
+ from_layer: layer_ref,
5445
+ to_layer: layer_ref
5446
+ })
5447
+ ]).superRefine((marker, context) => {
5448
+ if (marker.label_x === void 0 !== (marker.label_y === void 0)) {
5449
+ context.addIssue({
5450
+ code: z230.ZodIssueCode.custom,
5451
+ path: ["label_x"],
5452
+ message: "label_x and label_y must be provided together"
5453
+ });
5454
+ }
5455
+ if (marker.target_type === "pcb_via" && marker.from_layer === marker.to_layer) {
5456
+ context.addIssue({
5457
+ code: z230.ZodIssueCode.custom,
5458
+ path: ["to_layer"],
5459
+ message: "A via transition must connect distinct layers"
5460
+ });
5461
+ }
5462
+ }).describe(
5463
+ "A signal/return port or via highlight; markers do not assert measured via-transfer currents"
5464
+ );
5465
+ expectTypesMatch(true);
5466
+
5467
+ // src/any_circuit_element.ts
5468
+ import { z as z231 } from "zod";
5469
+ var any_circuit_element = z231.union([
5181
5470
  source_runtime_error,
5182
5471
  source_trace,
5183
5472
  source_bus,
@@ -5340,6 +5629,11 @@ var any_circuit_element = z222.union([
5340
5629
  simulation_voltage_source,
5341
5630
  simulation_current_source,
5342
5631
  simulation_experiment,
5632
+ simulation_return_current_excitation,
5633
+ simulation_pcb_return_current_result,
5634
+ simulation_pcb_return_current_field,
5635
+ simulation_pcb_return_current_heatmap,
5636
+ simulation_pcb_return_current_marker,
5343
5637
  simulation_transient_voltage_graph,
5344
5638
  simulation_transient_current_graph,
5345
5639
  simulation_dc_operating_point_voltage,
@@ -5385,6 +5679,7 @@ export {
5385
5679
  external_footprint_load_error,
5386
5680
  frequency,
5387
5681
  getRotationBetweenPcbPin1Locations,
5682
+ getSimulationReturnCurrentGridJsonSchema,
5388
5683
  getZodPrefixedIdWithDefault,
5389
5684
  inductance,
5390
5685
  insertionDirectionToCanonical,
@@ -5591,8 +5886,18 @@ export {
5591
5886
  simulation_parameter_sweep_coordinate,
5592
5887
  simulation_parameter_type,
5593
5888
  simulation_parameter_unit,
5889
+ simulation_pcb_return_current_field,
5890
+ simulation_pcb_return_current_heatmap,
5891
+ simulation_pcb_return_current_marker,
5892
+ simulation_pcb_return_current_result,
5893
+ simulation_return_current_contact,
5894
+ simulation_return_current_excitation,
5895
+ simulation_return_current_field_asset,
5896
+ simulation_return_current_grid_json,
5897
+ simulation_return_current_image_asset,
5594
5898
  simulation_spice_subcircuit,
5595
5899
  simulation_switch,
5900
+ simulation_terminal_port,
5596
5901
  simulation_transient_current_graph,
5597
5902
  simulation_transient_voltage_graph,
5598
5903
  simulation_unknown_experiment_error,