@tscircuit/core 0.0.675 → 0.0.677
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 +5 -1
- package/dist/index.js +108 -78
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1008,9 +1008,14 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
1008
1008
|
reactSubtrees: Array<ReactSubtree>;
|
|
1009
1009
|
_impliedFootprint?: string | undefined;
|
|
1010
1010
|
isPrimitiveContainer: boolean;
|
|
1011
|
+
_isNormalComponent: boolean;
|
|
1012
|
+
_attributeLowerToCamelNameMap: {
|
|
1013
|
+
_isnormalcomponent: string;
|
|
1014
|
+
};
|
|
1011
1015
|
_asyncSupplierPartNumbers?: SupplierPartNumbers;
|
|
1012
1016
|
pcb_missing_footprint_error_id?: string;
|
|
1013
1017
|
_hasStartedFootprintUrlLoad: boolean;
|
|
1018
|
+
private _invalidPinLabelMessages;
|
|
1014
1019
|
/**
|
|
1015
1020
|
* Override this property for component defaults
|
|
1016
1021
|
*/
|
|
@@ -2767,7 +2772,6 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, Polarized
|
|
|
2767
2772
|
|
|
2768
2773
|
declare class Chip<PinLabels extends string = never> extends NormalComponent<typeof chipProps, PinLabels> {
|
|
2769
2774
|
schematicBoxDimensions: SchematicBoxDimensions | null;
|
|
2770
|
-
private _invalidPinLabelMessages;
|
|
2771
2775
|
constructor(props: z.input<typeof chipProps>);
|
|
2772
2776
|
get config(): {
|
|
2773
2777
|
componentName: string;
|
package/dist/index.js
CHANGED
|
@@ -424,6 +424,18 @@ var cssSelectPrimitiveComponentAdapter = {
|
|
|
424
424
|
const value = node._parsedProps[name];
|
|
425
425
|
return typeof value === "string" ? value : value !== null && value !== void 0 ? String(value) : null;
|
|
426
426
|
}
|
|
427
|
+
if (name in node) {
|
|
428
|
+
const value = node[name];
|
|
429
|
+
return typeof value === "string" ? value : value !== null && value !== void 0 ? String(value) : null;
|
|
430
|
+
}
|
|
431
|
+
const reverseMap = node._attributeLowerToCamelNameMap;
|
|
432
|
+
if (reverseMap) {
|
|
433
|
+
const camelCaseName = reverseMap[name];
|
|
434
|
+
if (camelCaseName && camelCaseName in node) {
|
|
435
|
+
const value = node[camelCaseName];
|
|
436
|
+
return typeof value === "string" ? value : value !== null && value !== void 0 ? String(value) : null;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
427
439
|
return null;
|
|
428
440
|
},
|
|
429
441
|
// Check if a node has an attribute
|
|
@@ -431,7 +443,20 @@ var cssSelectPrimitiveComponentAdapter = {
|
|
|
431
443
|
if (name === "class") {
|
|
432
444
|
return !!node._parsedProps?.name;
|
|
433
445
|
}
|
|
434
|
-
|
|
446
|
+
if (node._parsedProps && name in node._parsedProps) {
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
if (name in node) {
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
const reverseMap = node._attributeLowerToCamelNameMap;
|
|
453
|
+
if (reverseMap) {
|
|
454
|
+
const camelCaseName = reverseMap[name];
|
|
455
|
+
if (camelCaseName && camelCaseName in node) {
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return false;
|
|
435
460
|
},
|
|
436
461
|
// Get the siblings of the node
|
|
437
462
|
getSiblings: (node) => {
|
|
@@ -6281,6 +6306,51 @@ var shouldCheckPortForMissingTrace = (component, port) => {
|
|
|
6281
6306
|
return true;
|
|
6282
6307
|
};
|
|
6283
6308
|
|
|
6309
|
+
// lib/utils/filterPinLabels.ts
|
|
6310
|
+
import { chipProps } from "@tscircuit/props";
|
|
6311
|
+
function filterPinLabels(pinLabels) {
|
|
6312
|
+
if (!pinLabels)
|
|
6313
|
+
return {
|
|
6314
|
+
validPinLabels: pinLabels,
|
|
6315
|
+
invalidPinLabelsMessages: []
|
|
6316
|
+
};
|
|
6317
|
+
const validPinLabels = {};
|
|
6318
|
+
const invalidPinLabelsMessages = [];
|
|
6319
|
+
for (const [pin, labelOrLabels] of Object.entries(pinLabels)) {
|
|
6320
|
+
const labels = Array.isArray(labelOrLabels) ? labelOrLabels.slice() : [labelOrLabels];
|
|
6321
|
+
const validLabels = [];
|
|
6322
|
+
for (const label of labels) {
|
|
6323
|
+
if (isValidPinLabel(pin, label)) {
|
|
6324
|
+
validLabels.push(label);
|
|
6325
|
+
} else {
|
|
6326
|
+
invalidPinLabelsMessages.push(
|
|
6327
|
+
`Invalid pin label: ${pin} = '${label}' - excluding from component. Please use a valid pin label.`
|
|
6328
|
+
);
|
|
6329
|
+
}
|
|
6330
|
+
}
|
|
6331
|
+
if (validLabels.length > 0) {
|
|
6332
|
+
validPinLabels[pin] = Array.isArray(labelOrLabels) ? validLabels : validLabels[0];
|
|
6333
|
+
}
|
|
6334
|
+
}
|
|
6335
|
+
return {
|
|
6336
|
+
validPinLabels: Object.keys(validPinLabels).length > 0 ? validPinLabels : void 0,
|
|
6337
|
+
invalidPinLabelsMessages
|
|
6338
|
+
};
|
|
6339
|
+
}
|
|
6340
|
+
function isValidPinLabel(pin, label) {
|
|
6341
|
+
try {
|
|
6342
|
+
const testProps = {
|
|
6343
|
+
name: "test",
|
|
6344
|
+
footprint: "test",
|
|
6345
|
+
pinLabels: { [pin]: label }
|
|
6346
|
+
};
|
|
6347
|
+
const result = chipProps.safeParse(testProps);
|
|
6348
|
+
return result.success;
|
|
6349
|
+
} catch (error) {
|
|
6350
|
+
return false;
|
|
6351
|
+
}
|
|
6352
|
+
}
|
|
6353
|
+
|
|
6284
6354
|
// lib/components/base-components/NormalComponent/NormalComponent.ts
|
|
6285
6355
|
var debug3 = Debug4("tscircuit:core");
|
|
6286
6356
|
var rotation3 = z8.object({
|
|
@@ -6292,9 +6362,17 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
6292
6362
|
reactSubtrees = [];
|
|
6293
6363
|
_impliedFootprint;
|
|
6294
6364
|
isPrimitiveContainer = true;
|
|
6365
|
+
_isNormalComponent = true;
|
|
6366
|
+
// Mapping from camelCase attribute names to their lowercase equivalents
|
|
6367
|
+
// This is used by the CSS selector adapter for fast attribute lookups
|
|
6368
|
+
// Reverse mapping from lowercase to camelCase for O(1) lookups
|
|
6369
|
+
_attributeLowerToCamelNameMap = {
|
|
6370
|
+
_isnormalcomponent: "_isNormalComponent"
|
|
6371
|
+
};
|
|
6295
6372
|
_asyncSupplierPartNumbers;
|
|
6296
6373
|
pcb_missing_footprint_error_id;
|
|
6297
6374
|
_hasStartedFootprintUrlLoad = false;
|
|
6375
|
+
_invalidPinLabelMessages = [];
|
|
6298
6376
|
/**
|
|
6299
6377
|
* Override this property for component defaults
|
|
6300
6378
|
*/
|
|
@@ -6310,7 +6388,15 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
6310
6388
|
);
|
|
6311
6389
|
}
|
|
6312
6390
|
constructor(props) {
|
|
6313
|
-
|
|
6391
|
+
const filteredProps = { ...props };
|
|
6392
|
+
let invalidPinLabelsMessages = [];
|
|
6393
|
+
if (filteredProps.pinLabels && !Array.isArray(filteredProps.pinLabels)) {
|
|
6394
|
+
const { validPinLabels, invalidPinLabelsMessages: messages } = filterPinLabels(filteredProps.pinLabels);
|
|
6395
|
+
filteredProps.pinLabels = validPinLabels;
|
|
6396
|
+
invalidPinLabelsMessages = messages;
|
|
6397
|
+
}
|
|
6398
|
+
super(filteredProps);
|
|
6399
|
+
this._invalidPinLabelMessages = invalidPinLabelsMessages;
|
|
6314
6400
|
this._addChildrenFromStringFootprint();
|
|
6315
6401
|
this.initPorts();
|
|
6316
6402
|
}
|
|
@@ -6569,6 +6655,24 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
6569
6655
|
doInitialSchematicComponentRender() {
|
|
6570
6656
|
if (this.root?.schematicDisabled) return;
|
|
6571
6657
|
const { db } = this.root;
|
|
6658
|
+
if (this._invalidPinLabelMessages?.length && this.root?.db) {
|
|
6659
|
+
for (const message of this._invalidPinLabelMessages) {
|
|
6660
|
+
let property_name = "pinLabels";
|
|
6661
|
+
const match = message.match(
|
|
6662
|
+
/^Invalid pin label:\s*([^=]+)=\s*'([^']+)'/
|
|
6663
|
+
);
|
|
6664
|
+
if (match) {
|
|
6665
|
+
const label = match[2];
|
|
6666
|
+
property_name = `pinLabels['${label}']`;
|
|
6667
|
+
}
|
|
6668
|
+
this.root.db.source_property_ignored_warning.insert({
|
|
6669
|
+
source_component_id: this.source_component_id,
|
|
6670
|
+
property_name,
|
|
6671
|
+
message,
|
|
6672
|
+
error_type: "source_property_ignored_warning"
|
|
6673
|
+
});
|
|
6674
|
+
}
|
|
6675
|
+
}
|
|
6572
6676
|
const { schematicSymbolName } = this.config;
|
|
6573
6677
|
if (schematicSymbolName) {
|
|
6574
6678
|
this._doInitialSchematicComponentRenderWithSymbol();
|
|
@@ -11448,66 +11552,10 @@ var Capacitor = class extends NormalComponent {
|
|
|
11448
11552
|
|
|
11449
11553
|
// lib/components/normal-components/Chip.ts
|
|
11450
11554
|
import { chipProps as chipProps2 } from "@tscircuit/props";
|
|
11451
|
-
|
|
11452
|
-
// lib/utils/filterPinLabels.ts
|
|
11453
|
-
import { chipProps } from "@tscircuit/props";
|
|
11454
|
-
function filterPinLabels(pinLabels) {
|
|
11455
|
-
if (!pinLabels)
|
|
11456
|
-
return {
|
|
11457
|
-
validPinLabels: pinLabels,
|
|
11458
|
-
invalidPinLabelsMessages: []
|
|
11459
|
-
};
|
|
11460
|
-
const validPinLabels = {};
|
|
11461
|
-
const invalidPinLabelsMessages = [];
|
|
11462
|
-
for (const [pin, labelOrLabels] of Object.entries(pinLabels)) {
|
|
11463
|
-
const labels = Array.isArray(labelOrLabels) ? labelOrLabels.slice() : [labelOrLabels];
|
|
11464
|
-
const validLabels = [];
|
|
11465
|
-
for (const label of labels) {
|
|
11466
|
-
if (isValidPinLabel(pin, label)) {
|
|
11467
|
-
validLabels.push(label);
|
|
11468
|
-
} else {
|
|
11469
|
-
invalidPinLabelsMessages.push(
|
|
11470
|
-
`Invalid pin label: ${pin} = '${label}' - excluding from component. Please use a valid pin label.`
|
|
11471
|
-
);
|
|
11472
|
-
}
|
|
11473
|
-
}
|
|
11474
|
-
if (validLabels.length > 0) {
|
|
11475
|
-
validPinLabels[pin] = Array.isArray(labelOrLabels) ? validLabels : validLabels[0];
|
|
11476
|
-
}
|
|
11477
|
-
}
|
|
11478
|
-
return {
|
|
11479
|
-
validPinLabels: Object.keys(validPinLabels).length > 0 ? validPinLabels : void 0,
|
|
11480
|
-
invalidPinLabelsMessages
|
|
11481
|
-
};
|
|
11482
|
-
}
|
|
11483
|
-
function isValidPinLabel(pin, label) {
|
|
11484
|
-
try {
|
|
11485
|
-
const testProps = {
|
|
11486
|
-
name: "test",
|
|
11487
|
-
footprint: "test",
|
|
11488
|
-
pinLabels: { [pin]: label }
|
|
11489
|
-
};
|
|
11490
|
-
const result = chipProps.safeParse(testProps);
|
|
11491
|
-
return result.success;
|
|
11492
|
-
} catch (error) {
|
|
11493
|
-
return false;
|
|
11494
|
-
}
|
|
11495
|
-
}
|
|
11496
|
-
|
|
11497
|
-
// lib/components/normal-components/Chip.ts
|
|
11498
11555
|
var Chip = class extends NormalComponent {
|
|
11499
11556
|
schematicBoxDimensions = null;
|
|
11500
|
-
_invalidPinLabelMessages = [];
|
|
11501
11557
|
constructor(props) {
|
|
11502
|
-
|
|
11503
|
-
let invalidPinLabelsMessages = [];
|
|
11504
|
-
if (filteredProps.pinLabels) {
|
|
11505
|
-
const { validPinLabels, invalidPinLabelsMessages: messages } = filterPinLabels(filteredProps.pinLabels);
|
|
11506
|
-
filteredProps.pinLabels = validPinLabels;
|
|
11507
|
-
invalidPinLabelsMessages = messages;
|
|
11508
|
-
}
|
|
11509
|
-
super(filteredProps);
|
|
11510
|
-
this._invalidPinLabelMessages = invalidPinLabelsMessages;
|
|
11558
|
+
super(props);
|
|
11511
11559
|
}
|
|
11512
11560
|
get config() {
|
|
11513
11561
|
return {
|
|
@@ -11554,24 +11602,6 @@ var Chip = class extends NormalComponent {
|
|
|
11554
11602
|
doInitialSchematicComponentRender() {
|
|
11555
11603
|
const { _parsedProps: props } = this;
|
|
11556
11604
|
if (props?.noSchematicRepresentation === true) return;
|
|
11557
|
-
if (this._invalidPinLabelMessages?.length && this.root?.db) {
|
|
11558
|
-
for (const message of this._invalidPinLabelMessages) {
|
|
11559
|
-
let property_name = "pinLabels";
|
|
11560
|
-
const match = message.match(
|
|
11561
|
-
/^Invalid pin label:\s*([^=]+)=\s*'([^']+)'/
|
|
11562
|
-
);
|
|
11563
|
-
if (match) {
|
|
11564
|
-
const label = match[2];
|
|
11565
|
-
property_name = `pinLabels['${label}']`;
|
|
11566
|
-
}
|
|
11567
|
-
this.root.db.source_property_ignored_warning.insert({
|
|
11568
|
-
source_component_id: this.source_component_id,
|
|
11569
|
-
property_name,
|
|
11570
|
-
message,
|
|
11571
|
-
error_type: "source_property_ignored_warning"
|
|
11572
|
-
});
|
|
11573
|
-
}
|
|
11574
|
-
}
|
|
11575
11605
|
super.doInitialSchematicComponentRender();
|
|
11576
11606
|
}
|
|
11577
11607
|
doInitialSourceRender() {
|
|
@@ -13881,7 +13911,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
13881
13911
|
var package_default = {
|
|
13882
13912
|
name: "@tscircuit/core",
|
|
13883
13913
|
type: "module",
|
|
13884
|
-
version: "0.0.
|
|
13914
|
+
version: "0.0.676",
|
|
13885
13915
|
types: "dist/index.d.ts",
|
|
13886
13916
|
main: "dist/index.js",
|
|
13887
13917
|
module: "dist/index.js",
|