@tscircuit/core 0.0.9 → 0.0.11

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.js CHANGED
@@ -133,7 +133,8 @@ function isMatchingSelector(component, selector) {
133
133
  if (classMatch) {
134
134
  return component.isMatchingNameOrAlias(classMatch[1]);
135
135
  }
136
- const [type, ...conditions] = selector.split(/(?=[#.[])/);
136
+ let [type, ...conditions] = selector.split(/(?=[#.[])/);
137
+ if (type === "pin") type = "port";
137
138
  if (type && type !== "*" && component.lowercaseComponentName !== type.toLowerCase()) {
138
139
  return false;
139
140
  }
@@ -1110,6 +1111,19 @@ var Resistor = class extends NormalComponent {
1110
1111
  }
1111
1112
  pin1 = this.portMap.pin1;
1112
1113
  pin2 = this.portMap.pin2;
1114
+ doInitialSourceRender() {
1115
+ const { db } = this.project;
1116
+ const { _parsedProps: props } = this;
1117
+ const source_component = db.source_component.insert({
1118
+ ftype: "simple_resistor",
1119
+ name: props.name,
1120
+ // @ts-ignore
1121
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
1122
+ supplier_part_numbers: props.supplierPartNumbers,
1123
+ resistance: props.resistance
1124
+ });
1125
+ this.source_component_id = source_component.source_component_id;
1126
+ }
1113
1127
  };
1114
1128
 
1115
1129
  // lib/components/normal-components/Led.ts
@@ -1,6 +1,7 @@
1
1
  import { resistorProps } from "@tscircuit/props"
2
2
  import type { PassivePorts, Ftype, BaseSymbolName } from "lib/utils/constants"
3
3
  import { NormalComponent } from "../base-components/NormalComponent"
4
+ import type { SourceSimpleResistorInput } from "@tscircuit/soup"
4
5
 
5
6
  export class Resistor extends NormalComponent<
6
7
  typeof resistorProps,
@@ -16,4 +17,19 @@ export class Resistor extends NormalComponent<
16
17
 
17
18
  pin1 = this.portMap.pin1
18
19
  pin2 = this.portMap.pin2
20
+
21
+ doInitialSourceRender() {
22
+ const { db } = this.project!
23
+ const { _parsedProps: props } = this
24
+ const source_component = db.source_component.insert({
25
+ ftype: "simple_resistor",
26
+ name: props.name,
27
+ // @ts-ignore
28
+ manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
29
+ supplier_part_numbers: props.supplierPartNumbers,
30
+
31
+ resistance: props.resistance,
32
+ } as SourceSimpleResistorInput)
33
+ this.source_component_id = source_component.source_component_id
34
+ }
19
35
  }
@@ -0,0 +1,12 @@
1
+ export const extendAliases = (
2
+ aliases: string[],
3
+ additionalAliases: Record<string, string[]>,
4
+ ): string[] => {
5
+ return Array.from(
6
+ new Set(
7
+ aliases.flatMap((alias) => {
8
+ return [alias, ...(additionalAliases[alias] || [])]
9
+ }),
10
+ ),
11
+ )
12
+ }
@@ -33,7 +33,9 @@ export function isMatchingSelector(
33
33
  }
34
34
 
35
35
  // Split the selector into type and conditions
36
- const [type, ...conditions] = selector.split(/(?=[#.[])/)
36
+ let [type, ...conditions] = selector.split(/(?=[#.[])/)
37
+
38
+ if (type === "pin") type = "port"
37
39
 
38
40
  // Check if the component type matches
39
41
  if (
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
5
  "types": "index.ts",
6
- "version": "0.0.9",
6
+ "version": "0.0.11",
7
7
  "main": "dist/index.js",
8
8
  "files": [
9
9
  "index.ts",