@tscircuit/pcb-viewer 1.10.9 → 1.10.10
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 +604 -1171
- package/dist/index.js.map +1 -1
- package/package.json +5 -8
package/dist/index.js
CHANGED
|
@@ -408,20 +408,6 @@ function _ts_generator(thisArg, body) {
|
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
|
-
function _ts_values(o) {
|
|
412
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
413
|
-
if (m) return m.call(o);
|
|
414
|
-
if (o && typeof o.length === "number") return {
|
|
415
|
-
next: function() {
|
|
416
|
-
if (o && i >= o.length) o = void 0;
|
|
417
|
-
return {
|
|
418
|
-
value: o && o[i++],
|
|
419
|
-
done: !o
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
424
|
-
}
|
|
425
411
|
var _loop = function(letter) {
|
|
426
412
|
lineAlphabet[letter] = [];
|
|
427
413
|
var segs = svgAlphabet[letter].split("M").slice(1).map(function(seg) {
|
|
@@ -2953,1048 +2939,25 @@ var require_lib = __commonJS({
|
|
|
2953
2939
|
});
|
|
2954
2940
|
});
|
|
2955
2941
|
} else {
|
|
2956
|
-
measure = measure || this.origin.measure;
|
|
2957
|
-
each(measures[measure], function(units, system) {
|
|
2958
|
-
if (system == "_anchors") return false;
|
|
2959
|
-
possibilities = possibilities.concat(keys(units));
|
|
2960
|
-
});
|
|
2961
|
-
}
|
|
2962
|
-
return possibilities;
|
|
2963
|
-
};
|
|
2964
|
-
Converter.prototype.measures = function() {
|
|
2965
|
-
return keys(measures);
|
|
2966
|
-
};
|
|
2967
|
-
convert = function convert(value) {
|
|
2968
|
-
return new Converter(value);
|
|
2969
|
-
};
|
|
2970
|
-
module2.exports = convert;
|
|
2971
|
-
}
|
|
2972
|
-
});
|
|
2973
|
-
// node_modules/parsel-js/dist/parsel.min.cjs
|
|
2974
|
-
var require_parsel_min = __commonJS({
|
|
2975
|
-
"node_modules/parsel-js/dist/parsel.min.cjs": function(exports2) {
|
|
2976
|
-
"use strict";
|
|
2977
|
-
Object.defineProperty(exports2, "__esModule", {
|
|
2978
|
-
value: true
|
|
2979
|
-
});
|
|
2980
|
-
var e = {
|
|
2981
|
-
attribute: RegExp("\\[\\s*(?:(?<namespace>\\*|[-\\w\\P{ASCII}]*)\\|)?(?<name>[-\\w\\P{ASCII}]+)\\s*(?:(?<operator>\\W?=)\\s*(?<value>.+?)\\s*(\\s(?<caseSensitive>[iIsS]))?\\s*)?\\]", "gu"),
|
|
2982
|
-
id: RegExp("#(?<name>[-\\w\\P{ASCII}]+)", "gu"),
|
|
2983
|
-
class: RegExp("\\.(?<name>[-\\w\\P{ASCII}]+)", "gu"),
|
|
2984
|
-
comma: /\s*,\s*/g,
|
|
2985
|
-
combinator: /\s*[\s>+~]\s*/g,
|
|
2986
|
-
"pseudo-element": RegExp("::(?<name>[-\\w\\P{ASCII}]+)(?:\\((?<argument>\xb6*)\\))?", "gu"),
|
|
2987
|
-
"pseudo-class": RegExp(":(?<name>[-\\w\\P{ASCII}]+)(?:\\((?<argument>\xb6*)\\))?", "gu"),
|
|
2988
|
-
universal: RegExp("(?:(?<namespace>\\*|[-\\w\\P{ASCII}]*)\\|)?\\*", "gu"),
|
|
2989
|
-
type: RegExp("(?:(?<namespace>\\*|[-\\w\\P{ASCII}]*)\\|)?(?<name>[-\\w\\P{ASCII}]+)", "gu")
|
|
2990
|
-
};
|
|
2991
|
-
var t = /* @__PURE__ */ new Set([
|
|
2992
|
-
"combinator",
|
|
2993
|
-
"comma"
|
|
2994
|
-
]);
|
|
2995
|
-
var n = /* @__PURE__ */ new Set([
|
|
2996
|
-
"not",
|
|
2997
|
-
"is",
|
|
2998
|
-
"where",
|
|
2999
|
-
"has",
|
|
3000
|
-
"matches",
|
|
3001
|
-
"-moz-any",
|
|
3002
|
-
"-webkit-any",
|
|
3003
|
-
"nth-child",
|
|
3004
|
-
"nth-last-child"
|
|
3005
|
-
]);
|
|
3006
|
-
var s = RegExp("(?<index>[\\dn+-]+)\\s+of\\s+(?<subtree>.+)");
|
|
3007
|
-
var o = {
|
|
3008
|
-
"nth-child": s,
|
|
3009
|
-
"nth-last-child": s
|
|
3010
|
-
};
|
|
3011
|
-
var r = function(t2) {
|
|
3012
|
-
switch(t2){
|
|
3013
|
-
case "pseudo-element":
|
|
3014
|
-
case "pseudo-class":
|
|
3015
|
-
return new RegExp(e[t2].source.replace("(?<argument>\xb6*)", "(?<argument>.*)"), "gu");
|
|
3016
|
-
default:
|
|
3017
|
-
return e[t2];
|
|
3018
|
-
}
|
|
3019
|
-
};
|
|
3020
|
-
function c(e2, t2) {
|
|
3021
|
-
var n2 = 0, s2 = "";
|
|
3022
|
-
for(; t2 < e2.length; t2++){
|
|
3023
|
-
var o2 = e2[t2];
|
|
3024
|
-
switch(o2){
|
|
3025
|
-
case "(":
|
|
3026
|
-
++n2;
|
|
3027
|
-
break;
|
|
3028
|
-
case ")":
|
|
3029
|
-
--n2;
|
|
3030
|
-
}
|
|
3031
|
-
if (s2 += o2, 0 === n2) return s2;
|
|
3032
|
-
}
|
|
3033
|
-
return s2;
|
|
3034
|
-
}
|
|
3035
|
-
function i(n2) {
|
|
3036
|
-
var s2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : e;
|
|
3037
|
-
if (!n2) return [];
|
|
3038
|
-
var o2 = [
|
|
3039
|
-
n2
|
|
3040
|
-
];
|
|
3041
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3042
|
-
try {
|
|
3043
|
-
for(var _iterator = Object.entries(s2)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3044
|
-
var _step_value = _sliced_to_array(_step.value, 2), e2 = _step_value[0], t2 = _step_value[1];
|
|
3045
|
-
for(var n3 = 0; n3 < o2.length; n3++){
|
|
3046
|
-
var _o2;
|
|
3047
|
-
var s3 = o2[n3];
|
|
3048
|
-
if ("string" != typeof s3) continue;
|
|
3049
|
-
t2.lastIndex = 0;
|
|
3050
|
-
var r3 = t2.exec(s3);
|
|
3051
|
-
if (!r3) continue;
|
|
3052
|
-
var c2 = r3.index - 1, i2 = [], a2 = r3[0], l2 = s3.slice(0, c2 + 1);
|
|
3053
|
-
l2 && i2.push(l2), i2.push(_object_spread_props(_object_spread({}, r3.groups), {
|
|
3054
|
-
type: e2,
|
|
3055
|
-
content: a2
|
|
3056
|
-
}));
|
|
3057
|
-
var u2 = s3.slice(c2 + a2.length + 1);
|
|
3058
|
-
u2 && i2.push(u2), (_o2 = o2).splice.apply(_o2, [
|
|
3059
|
-
n3,
|
|
3060
|
-
1
|
|
3061
|
-
].concat(_to_consumable_array(i2)));
|
|
3062
|
-
}
|
|
3063
|
-
}
|
|
3064
|
-
} catch (err) {
|
|
3065
|
-
_didIteratorError = true;
|
|
3066
|
-
_iteratorError = err;
|
|
3067
|
-
} finally{
|
|
3068
|
-
try {
|
|
3069
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3070
|
-
_iterator.return();
|
|
3071
|
-
}
|
|
3072
|
-
} finally{
|
|
3073
|
-
if (_didIteratorError) {
|
|
3074
|
-
throw _iteratorError;
|
|
3075
|
-
}
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
var r2 = 0;
|
|
3079
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3080
|
-
try {
|
|
3081
|
-
for(var _iterator1 = o2[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3082
|
-
var e21 = _step1.value;
|
|
3083
|
-
switch(typeof e21 === "undefined" ? "undefined" : _type_of(e21)){
|
|
3084
|
-
case "string":
|
|
3085
|
-
throw new Error("Unexpected sequence ".concat(e21, " found at index ").concat(r2));
|
|
3086
|
-
case "object":
|
|
3087
|
-
r2 += e21.content.length, e21.pos = [
|
|
3088
|
-
r2 - e21.content.length,
|
|
3089
|
-
r2
|
|
3090
|
-
], t.has(e21.type) && (e21.content = e21.content.trim() || " ");
|
|
3091
|
-
}
|
|
3092
|
-
}
|
|
3093
|
-
} catch (err) {
|
|
3094
|
-
_didIteratorError1 = true;
|
|
3095
|
-
_iteratorError1 = err;
|
|
3096
|
-
} finally{
|
|
3097
|
-
try {
|
|
3098
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3099
|
-
_iterator1.return();
|
|
3100
|
-
}
|
|
3101
|
-
} finally{
|
|
3102
|
-
if (_didIteratorError1) {
|
|
3103
|
-
throw _iteratorError1;
|
|
3104
|
-
}
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
return o2;
|
|
3108
|
-
}
|
|
3109
|
-
var a = /(['"])([^\\\n]+?)\1/g;
|
|
3110
|
-
var l = /\\./g;
|
|
3111
|
-
function u(t2) {
|
|
3112
|
-
var n2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : e;
|
|
3113
|
-
if ("" === (t2 = t2.trim())) return [];
|
|
3114
|
-
var s2 = [];
|
|
3115
|
-
t2 = (t2 = t2.replace(l, function(e2, t3) {
|
|
3116
|
-
return s2.push({
|
|
3117
|
-
value: e2,
|
|
3118
|
-
offset: t3
|
|
3119
|
-
}), "".repeat(e2.length);
|
|
3120
|
-
})).replace(a, function(e2, t3, n3, o3) {
|
|
3121
|
-
return s2.push({
|
|
3122
|
-
value: e2,
|
|
3123
|
-
offset: o3
|
|
3124
|
-
}), "".concat(t3).concat("".repeat(n3.length)).concat(t3);
|
|
3125
|
-
});
|
|
3126
|
-
{
|
|
3127
|
-
var e2, n3 = 0;
|
|
3128
|
-
for(; (e2 = t2.indexOf("(", n3)) > -1;){
|
|
3129
|
-
var o3 = c(t2, e2);
|
|
3130
|
-
s2.push({
|
|
3131
|
-
value: o3,
|
|
3132
|
-
offset: e2
|
|
3133
|
-
}), t2 = "".concat(t2.substring(0, e2), "(").concat("\xb6".repeat(o3.length - 2), ")").concat(t2.substring(e2 + o3.length)), n3 = e2 + o3.length;
|
|
3134
|
-
}
|
|
3135
|
-
}
|
|
3136
|
-
var o2 = i(t2, n2), u2 = /* @__PURE__ */ new Set();
|
|
3137
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined, _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3138
|
-
try {
|
|
3139
|
-
for(var _iterator = s2.reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion1 = (_step = _iterator.next()).done); _iteratorNormalCompletion1 = true){
|
|
3140
|
-
var e21 = _step.value;
|
|
3141
|
-
try {
|
|
3142
|
-
for(var _iterator1 = o2[Symbol.iterator](), _step1; !(_iteratorNormalCompletion = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion = true){
|
|
3143
|
-
var t3 = _step1.value;
|
|
3144
|
-
var n31 = e21.offset, s3 = e21.value;
|
|
3145
|
-
if (!(t3.pos[0] <= n31 && n31 + s3.length <= t3.pos[1])) continue;
|
|
3146
|
-
var o31 = t3.content, r2 = n31 - t3.pos[0];
|
|
3147
|
-
t3.content = o31.slice(0, r2) + s3 + o31.slice(r2 + s3.length), t3.content !== o31 && u2.add(t3);
|
|
3148
|
-
}
|
|
3149
|
-
} catch (err) {
|
|
3150
|
-
_didIteratorError = true;
|
|
3151
|
-
_iteratorError = err;
|
|
3152
|
-
} finally{
|
|
3153
|
-
try {
|
|
3154
|
-
if (!_iteratorNormalCompletion && _iterator1.return != null) {
|
|
3155
|
-
_iterator1.return();
|
|
3156
|
-
}
|
|
3157
|
-
} finally{
|
|
3158
|
-
if (_didIteratorError) {
|
|
3159
|
-
throw _iteratorError;
|
|
3160
|
-
}
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
}
|
|
3164
|
-
} catch (err) {
|
|
3165
|
-
_didIteratorError1 = true;
|
|
3166
|
-
_iteratorError1 = err;
|
|
3167
|
-
} finally{
|
|
3168
|
-
try {
|
|
3169
|
-
if (!_iteratorNormalCompletion1 && _iterator.return != null) {
|
|
3170
|
-
_iterator.return();
|
|
3171
|
-
}
|
|
3172
|
-
} finally{
|
|
3173
|
-
if (_didIteratorError1) {
|
|
3174
|
-
throw _iteratorError1;
|
|
3175
|
-
}
|
|
3176
|
-
}
|
|
3177
|
-
}
|
|
3178
|
-
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
|
3179
|
-
try {
|
|
3180
|
-
for(var _iterator2 = u2[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
3181
|
-
var e22 = _step2.value;
|
|
3182
|
-
var t31 = r(e22.type);
|
|
3183
|
-
if (!t31) throw new Error("Unknown token type: ".concat(e22.type));
|
|
3184
|
-
t31.lastIndex = 0;
|
|
3185
|
-
var n32 = t31.exec(e22.content);
|
|
3186
|
-
if (!n32) throw new Error("Unable to parse content for ".concat(e22.type, ": ").concat(e22.content));
|
|
3187
|
-
Object.assign(e22, n32.groups);
|
|
3188
|
-
}
|
|
3189
|
-
} catch (err) {
|
|
3190
|
-
_didIteratorError2 = true;
|
|
3191
|
-
_iteratorError2 = err;
|
|
3192
|
-
} finally{
|
|
3193
|
-
try {
|
|
3194
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
3195
|
-
_iterator2.return();
|
|
3196
|
-
}
|
|
3197
|
-
} finally{
|
|
3198
|
-
if (_didIteratorError2) {
|
|
3199
|
-
throw _iteratorError2;
|
|
3200
|
-
}
|
|
3201
|
-
}
|
|
3202
|
-
}
|
|
3203
|
-
return o2;
|
|
3204
|
-
}
|
|
3205
|
-
function p(e2) {
|
|
3206
|
-
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, tmp = _ref.list, t2 = tmp === void 0 ? true : tmp;
|
|
3207
|
-
if (t2 && e2.find(function(e3) {
|
|
3208
|
-
return "comma" === e3.type;
|
|
3209
|
-
})) {
|
|
3210
|
-
var t3 = [], n2 = [];
|
|
3211
|
-
for(var s2 = 0; s2 < e2.length; s2++)if ("comma" === e2[s2].type) {
|
|
3212
|
-
if (0 === n2.length) throw new Error("Incorrect comma at " + s2);
|
|
3213
|
-
t3.push(p(n2, {
|
|
3214
|
-
list: false
|
|
3215
|
-
})), n2.length = 0;
|
|
3216
|
-
} else n2.push(e2[s2]);
|
|
3217
|
-
if (0 === n2.length) throw new Error("Trailing comma");
|
|
3218
|
-
return t3.push(p(n2, {
|
|
3219
|
-
list: false
|
|
3220
|
-
})), {
|
|
3221
|
-
type: "list",
|
|
3222
|
-
list: t3
|
|
3223
|
-
};
|
|
3224
|
-
}
|
|
3225
|
-
for(var t31 = e2.length - 1; t31 >= 0; t31--){
|
|
3226
|
-
var n21 = e2[t31];
|
|
3227
|
-
if ("combinator" === n21.type) {
|
|
3228
|
-
var s21 = e2.slice(0, t31), o2 = e2.slice(t31 + 1);
|
|
3229
|
-
return {
|
|
3230
|
-
type: "complex",
|
|
3231
|
-
combinator: n21.content,
|
|
3232
|
-
left: p(s21),
|
|
3233
|
-
right: p(o2)
|
|
3234
|
-
};
|
|
3235
|
-
}
|
|
3236
|
-
}
|
|
3237
|
-
switch(e2.length){
|
|
3238
|
-
case 0:
|
|
3239
|
-
throw new Error("Could not build AST.");
|
|
3240
|
-
case 1:
|
|
3241
|
-
return e2[0];
|
|
3242
|
-
default:
|
|
3243
|
-
return {
|
|
3244
|
-
type: "compound",
|
|
3245
|
-
list: _to_consumable_array(e2)
|
|
3246
|
-
};
|
|
3247
|
-
}
|
|
3248
|
-
}
|
|
3249
|
-
function f(e2, t2) {
|
|
3250
|
-
var _, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, t3, err;
|
|
3251
|
-
return _ts_generator(this, function(_state) {
|
|
3252
|
-
switch(_state.label){
|
|
3253
|
-
case 0:
|
|
3254
|
-
_ = e2.type;
|
|
3255
|
-
switch(_){
|
|
3256
|
-
case "list":
|
|
3257
|
-
return [
|
|
3258
|
-
3,
|
|
3259
|
-
1
|
|
3260
|
-
];
|
|
3261
|
-
case "complex":
|
|
3262
|
-
return [
|
|
3263
|
-
3,
|
|
3264
|
-
10
|
|
3265
|
-
];
|
|
3266
|
-
case "compound":
|
|
3267
|
-
return [
|
|
3268
|
-
3,
|
|
3269
|
-
13
|
|
3270
|
-
];
|
|
3271
|
-
}
|
|
3272
|
-
return [
|
|
3273
|
-
3,
|
|
3274
|
-
15
|
|
3275
|
-
];
|
|
3276
|
-
case 1:
|
|
3277
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3278
|
-
_state.label = 2;
|
|
3279
|
-
case 2:
|
|
3280
|
-
_state.trys.push([
|
|
3281
|
-
2,
|
|
3282
|
-
7,
|
|
3283
|
-
8,
|
|
3284
|
-
9
|
|
3285
|
-
]);
|
|
3286
|
-
_iterator = e2.list[Symbol.iterator]();
|
|
3287
|
-
_state.label = 3;
|
|
3288
|
-
case 3:
|
|
3289
|
-
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
3290
|
-
3,
|
|
3291
|
-
6
|
|
3292
|
-
];
|
|
3293
|
-
t3 = _step.value;
|
|
3294
|
-
return [
|
|
3295
|
-
5,
|
|
3296
|
-
_ts_values(f(t3, e2))
|
|
3297
|
-
];
|
|
3298
|
-
case 4:
|
|
3299
|
-
_state.sent();
|
|
3300
|
-
_state.label = 5;
|
|
3301
|
-
case 5:
|
|
3302
|
-
_iteratorNormalCompletion = true;
|
|
3303
|
-
return [
|
|
3304
|
-
3,
|
|
3305
|
-
3
|
|
3306
|
-
];
|
|
3307
|
-
case 6:
|
|
3308
|
-
return [
|
|
3309
|
-
3,
|
|
3310
|
-
9
|
|
3311
|
-
];
|
|
3312
|
-
case 7:
|
|
3313
|
-
err = _state.sent();
|
|
3314
|
-
_didIteratorError = true;
|
|
3315
|
-
_iteratorError = err;
|
|
3316
|
-
return [
|
|
3317
|
-
3,
|
|
3318
|
-
9
|
|
3319
|
-
];
|
|
3320
|
-
case 8:
|
|
3321
|
-
try {
|
|
3322
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3323
|
-
_iterator.return();
|
|
3324
|
-
}
|
|
3325
|
-
} finally{
|
|
3326
|
-
if (_didIteratorError) {
|
|
3327
|
-
throw _iteratorError;
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3330
|
-
return [
|
|
3331
|
-
7
|
|
3332
|
-
];
|
|
3333
|
-
case 9:
|
|
3334
|
-
return [
|
|
3335
|
-
3,
|
|
3336
|
-
17
|
|
3337
|
-
];
|
|
3338
|
-
case 10:
|
|
3339
|
-
return [
|
|
3340
|
-
5,
|
|
3341
|
-
_ts_values(f(e2.left, e2))
|
|
3342
|
-
];
|
|
3343
|
-
case 11:
|
|
3344
|
-
_state.sent();
|
|
3345
|
-
return [
|
|
3346
|
-
5,
|
|
3347
|
-
_ts_values(f(e2.right, e2))
|
|
3348
|
-
];
|
|
3349
|
-
case 12:
|
|
3350
|
-
_state.sent();
|
|
3351
|
-
return [
|
|
3352
|
-
3,
|
|
3353
|
-
17
|
|
3354
|
-
];
|
|
3355
|
-
case 13:
|
|
3356
|
-
return [
|
|
3357
|
-
5,
|
|
3358
|
-
_ts_values(e2.list.map(function(t3) {
|
|
3359
|
-
return [
|
|
3360
|
-
t3,
|
|
3361
|
-
e2
|
|
3362
|
-
];
|
|
3363
|
-
}))
|
|
3364
|
-
];
|
|
3365
|
-
case 14:
|
|
3366
|
-
_state.sent();
|
|
3367
|
-
return [
|
|
3368
|
-
3,
|
|
3369
|
-
17
|
|
3370
|
-
];
|
|
3371
|
-
case 15:
|
|
3372
|
-
return [
|
|
3373
|
-
4,
|
|
3374
|
-
[
|
|
3375
|
-
e2,
|
|
3376
|
-
t2
|
|
3377
|
-
]
|
|
3378
|
-
];
|
|
3379
|
-
case 16:
|
|
3380
|
-
_state.sent();
|
|
3381
|
-
_state.label = 17;
|
|
3382
|
-
case 17:
|
|
3383
|
-
return [
|
|
3384
|
-
2
|
|
3385
|
-
];
|
|
3386
|
-
}
|
|
3387
|
-
});
|
|
3388
|
-
}
|
|
3389
|
-
function h(e2) {
|
|
3390
|
-
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, tmp = _ref.recursive, t2 = tmp === void 0 ? true : tmp, tmp1 = _ref.list, s2 = tmp1 === void 0 ? true : tmp1;
|
|
3391
|
-
var r2 = u(e2);
|
|
3392
|
-
if (!r2) return;
|
|
3393
|
-
var c2 = p(r2, {
|
|
3394
|
-
list: s2
|
|
3395
|
-
});
|
|
3396
|
-
if (!t2) return c2;
|
|
3397
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3398
|
-
try {
|
|
3399
|
-
for(var _iterator = f(c2)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3400
|
-
var _step_value = _sliced_to_array(_step.value, 1), e3 = _step_value[0];
|
|
3401
|
-
if ("pseudo-class" !== e3.type || !e3.argument) continue;
|
|
3402
|
-
if (!n.has(e3.name)) continue;
|
|
3403
|
-
var t3 = e3.argument;
|
|
3404
|
-
var s3 = o[e3.name];
|
|
3405
|
-
if (s3) {
|
|
3406
|
-
var n2 = s3.exec(t3);
|
|
3407
|
-
if (!n2) continue;
|
|
3408
|
-
Object.assign(e3, n2.groups), t3 = n2.groups.subtree;
|
|
3409
|
-
}
|
|
3410
|
-
t3 && Object.assign(e3, {
|
|
3411
|
-
subtree: h(t3, {
|
|
3412
|
-
recursive: true,
|
|
3413
|
-
list: true
|
|
3414
|
-
})
|
|
3415
|
-
});
|
|
3416
|
-
}
|
|
3417
|
-
} catch (err) {
|
|
3418
|
-
_didIteratorError = true;
|
|
3419
|
-
_iteratorError = err;
|
|
3420
|
-
} finally{
|
|
3421
|
-
try {
|
|
3422
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3423
|
-
_iterator.return();
|
|
3424
|
-
}
|
|
3425
|
-
} finally{
|
|
3426
|
-
if (_didIteratorError) {
|
|
3427
|
-
throw _iteratorError;
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
return c2;
|
|
3432
|
-
}
|
|
3433
|
-
function m(e2, t2) {
|
|
3434
|
-
var _Math;
|
|
3435
|
-
return t2 = t2 || (_Math = Math).max.apply(_Math, _to_consumable_array(e2)) + 1, e2[0] * (t2 << 1) + e2[1] * t2 + e2[2];
|
|
3436
|
-
}
|
|
3437
|
-
exports2.RECURSIVE_PSEUDO_CLASSES = n, exports2.RECURSIVE_PSEUDO_CLASSES_ARGS = o, exports2.TOKENS = e, exports2.TRIM_TOKENS = t, exports2.flatten = f, exports2.gobbleParens = c, exports2.parse = h, exports2.specificity = function e2(t2) {
|
|
3438
|
-
var s2 = t2;
|
|
3439
|
-
if ("string" == typeof s2 && (s2 = h(s2, {
|
|
3440
|
-
recursive: true
|
|
3441
|
-
})), !s2) return [];
|
|
3442
|
-
if ("list" === s2.type && "list" in s2) {
|
|
3443
|
-
var _Math;
|
|
3444
|
-
var t3 = 10;
|
|
3445
|
-
var n2 = s2.list.map(function(n3) {
|
|
3446
|
-
var _Math;
|
|
3447
|
-
var s3 = e2(n3);
|
|
3448
|
-
return t3 = (_Math = Math).max.apply(_Math, [
|
|
3449
|
-
t3
|
|
3450
|
-
].concat(_to_consumable_array(e2(n3)))), s3;
|
|
3451
|
-
}), o3 = n2.map(function(e3) {
|
|
3452
|
-
return m(e3, t3);
|
|
3453
|
-
});
|
|
3454
|
-
return n2[o3.indexOf((_Math = Math).max.apply(_Math, _to_consumable_array(o3)))];
|
|
3455
|
-
}
|
|
3456
|
-
var o2 = [
|
|
3457
|
-
0,
|
|
3458
|
-
0,
|
|
3459
|
-
0
|
|
3460
|
-
];
|
|
3461
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3462
|
-
try {
|
|
3463
|
-
for(var _iterator = f(s2)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3464
|
-
var _step_value = _sliced_to_array(_step.value, 1), t31 = _step_value[0];
|
|
3465
|
-
switch(t31.type){
|
|
3466
|
-
case "id":
|
|
3467
|
-
o2[0]++;
|
|
3468
|
-
break;
|
|
3469
|
-
case "class":
|
|
3470
|
-
case "attribute":
|
|
3471
|
-
o2[1]++;
|
|
3472
|
-
break;
|
|
3473
|
-
case "pseudo-element":
|
|
3474
|
-
case "type":
|
|
3475
|
-
o2[2]++;
|
|
3476
|
-
break;
|
|
3477
|
-
case "pseudo-class":
|
|
3478
|
-
if ("where" === t31.name) break;
|
|
3479
|
-
if (!n.has(t31.name) || !t31.subtree) {
|
|
3480
|
-
o2[1]++;
|
|
3481
|
-
break;
|
|
3482
|
-
}
|
|
3483
|
-
e2(t31.subtree).forEach(function(e3, t4) {
|
|
3484
|
-
return o2[t4] += e3;
|
|
3485
|
-
}), "nth-child" !== t31.name && "nth-last-child" !== t31.name || o2[1]++;
|
|
3486
|
-
}
|
|
3487
|
-
}
|
|
3488
|
-
} catch (err) {
|
|
3489
|
-
_didIteratorError = true;
|
|
3490
|
-
_iteratorError = err;
|
|
3491
|
-
} finally{
|
|
3492
|
-
try {
|
|
3493
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3494
|
-
_iterator.return();
|
|
3495
|
-
}
|
|
3496
|
-
} finally{
|
|
3497
|
-
if (_didIteratorError) {
|
|
3498
|
-
throw _iteratorError;
|
|
3499
|
-
}
|
|
3500
|
-
}
|
|
3501
|
-
}
|
|
3502
|
-
return o2;
|
|
3503
|
-
}, exports2.specificityToNumber = m, exports2.stringify = function(e2) {
|
|
3504
|
-
var t2;
|
|
3505
|
-
return t2 = Array.isArray(e2) ? e2 : _to_consumable_array(f(e2)).map(function(param) {
|
|
3506
|
-
var _param = _sliced_to_array(param, 1), e3 = _param[0];
|
|
3507
|
-
return e3;
|
|
3508
|
-
}), t2.map(function(e3) {
|
|
3509
|
-
return e3.content;
|
|
3510
|
-
}).join("");
|
|
3511
|
-
}, exports2.tokenize = u, exports2.tokenizeBy = i, exports2.walk = function(e2, t2, n2) {
|
|
3512
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3513
|
-
if (e2) try {
|
|
3514
|
-
for(var _iterator = f(e2, n2)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3515
|
-
var _step_value = _sliced_to_array(_step.value, 2), s2 = _step_value[0], o2 = _step_value[1];
|
|
3516
|
-
t2(s2, o2);
|
|
3517
|
-
}
|
|
3518
|
-
} catch (err) {
|
|
3519
|
-
_didIteratorError = true;
|
|
3520
|
-
_iteratorError = err;
|
|
3521
|
-
} finally{
|
|
3522
|
-
try {
|
|
3523
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3524
|
-
_iterator.return();
|
|
3525
|
-
}
|
|
3526
|
-
} finally{
|
|
3527
|
-
if (_didIteratorError) {
|
|
3528
|
-
throw _iteratorError;
|
|
3529
|
-
}
|
|
3530
|
-
}
|
|
3531
|
-
}
|
|
3532
|
-
};
|
|
3533
|
-
}
|
|
3534
|
-
});
|
|
3535
|
-
// node_modules/@tscircuit/soup-util/dist/index.cjs
|
|
3536
|
-
var require_dist = __commonJS({
|
|
3537
|
-
"node_modules/@tscircuit/soup-util/dist/index.cjs": function(exports2, module2) {
|
|
3538
|
-
"use strict";
|
|
3539
|
-
var __create2 = Object.create;
|
|
3540
|
-
var __defProp2 = Object.defineProperty;
|
|
3541
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
3542
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
3543
|
-
var __getProtoOf2 = Object.getPrototypeOf;
|
|
3544
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
3545
|
-
var __export2 = function(target, all) {
|
|
3546
|
-
for(var name in all)__defProp2(target, name, {
|
|
3547
|
-
get: all[name],
|
|
3548
|
-
enumerable: true
|
|
3549
|
-
});
|
|
3550
|
-
};
|
|
3551
|
-
var __copyProps2 = function(to, from, except, desc) {
|
|
3552
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
3553
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3554
|
-
try {
|
|
3555
|
-
var _loop = function() {
|
|
3556
|
-
var key = _step.value;
|
|
3557
|
-
if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
3558
|
-
get: function() {
|
|
3559
|
-
return from[key];
|
|
3560
|
-
},
|
|
3561
|
-
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
3562
|
-
});
|
|
3563
|
-
};
|
|
3564
|
-
for(var _iterator = __getOwnPropNames2(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
3565
|
-
} catch (err) {
|
|
3566
|
-
_didIteratorError = true;
|
|
3567
|
-
_iteratorError = err;
|
|
3568
|
-
} finally{
|
|
3569
|
-
try {
|
|
3570
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3571
|
-
_iterator.return();
|
|
3572
|
-
}
|
|
3573
|
-
} finally{
|
|
3574
|
-
if (_didIteratorError) {
|
|
3575
|
-
throw _iteratorError;
|
|
3576
|
-
}
|
|
3577
|
-
}
|
|
3578
|
-
}
|
|
3579
|
-
}
|
|
3580
|
-
return to;
|
|
3581
|
-
};
|
|
3582
|
-
var __toESM2 = function(mod, isNodeMode, target) {
|
|
3583
|
-
return target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(// If the importer is in node compatibility mode or this is not an ESM
|
|
3584
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
3585
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
3586
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
3587
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", {
|
|
3588
|
-
value: mod,
|
|
3589
|
-
enumerable: true
|
|
3590
|
-
}) : target, mod);
|
|
3591
|
-
};
|
|
3592
|
-
var __toCommonJS2 = function(mod) {
|
|
3593
|
-
return __copyProps2(__defProp2({}, "__esModule", {
|
|
3594
|
-
value: true
|
|
3595
|
-
}), mod);
|
|
3596
|
-
};
|
|
3597
|
-
var soup_util_exports = {};
|
|
3598
|
-
__export2(soup_util_exports, {
|
|
3599
|
-
applySelector: function() {
|
|
3600
|
-
return applySelector;
|
|
3601
|
-
},
|
|
3602
|
-
applySelectorAST: function() {
|
|
3603
|
-
return applySelectorAST;
|
|
3604
|
-
},
|
|
3605
|
-
directionToVec: function() {
|
|
3606
|
-
return directionToVec;
|
|
3607
|
-
},
|
|
3608
|
-
oppositeDirection: function() {
|
|
3609
|
-
return oppositeDirection;
|
|
3610
|
-
},
|
|
3611
|
-
oppositeSide: function() {
|
|
3612
|
-
return oppositeSide;
|
|
3613
|
-
},
|
|
3614
|
-
rotateClockwise: function() {
|
|
3615
|
-
return rotateClockwise;
|
|
3616
|
-
},
|
|
3617
|
-
rotateCounterClockwise: function() {
|
|
3618
|
-
return rotateCounterClockwise;
|
|
3619
|
-
},
|
|
3620
|
-
rotateDirection: function() {
|
|
3621
|
-
return rotateDirection;
|
|
3622
|
-
},
|
|
3623
|
-
su: function() {
|
|
3624
|
-
return su_default;
|
|
3625
|
-
},
|
|
3626
|
-
transformPCBElement: function() {
|
|
3627
|
-
return transformPCBElement2;
|
|
3628
|
-
},
|
|
3629
|
-
transformPCBElements: function() {
|
|
3630
|
-
return transformPCBElements2;
|
|
3631
|
-
},
|
|
3632
|
-
transformSchematicElement: function() {
|
|
3633
|
-
return transformSchematicElement;
|
|
3634
|
-
},
|
|
3635
|
-
transformSchematicElements: function() {
|
|
3636
|
-
return transformSchematicElements;
|
|
3637
|
-
},
|
|
3638
|
-
vecToDirection: function() {
|
|
3639
|
-
return vecToDirection;
|
|
3640
|
-
}
|
|
3641
|
-
});
|
|
3642
|
-
module2.exports = __toCommonJS2(soup_util_exports);
|
|
3643
|
-
var su5 = function(soup) {
|
|
3644
|
-
var su22 = new Proxy({}, {
|
|
3645
|
-
get: function(proxy_target, component_type) {
|
|
3646
|
-
return {
|
|
3647
|
-
get: function(id) {
|
|
3648
|
-
return soup.find(function(e) {
|
|
3649
|
-
return e.type === component_type && e["".concat(component_type, "_id")] === id;
|
|
3650
|
-
});
|
|
3651
|
-
},
|
|
3652
|
-
getUsing: function(using) {
|
|
3653
|
-
var keys = Object.keys(using);
|
|
3654
|
-
if (keys.length !== 1) {
|
|
3655
|
-
throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");
|
|
3656
|
-
}
|
|
3657
|
-
var join_key = keys[0];
|
|
3658
|
-
var join_type = join_key.replace("_id", "");
|
|
3659
|
-
var joiner = soup.find(function(e) {
|
|
3660
|
-
return e.type === join_type && e[join_key] === using[join_key];
|
|
3661
|
-
});
|
|
3662
|
-
if (!joiner) return null;
|
|
3663
|
-
return soup.find(function(e) {
|
|
3664
|
-
return e.type === component_type && e["".concat(component_type, "_id")] === joiner["".concat(component_type, "_id")];
|
|
3665
|
-
});
|
|
3666
|
-
},
|
|
3667
|
-
getWhere: function(where) {
|
|
3668
|
-
var keys = Object.keys(where);
|
|
3669
|
-
return soup.find(function(e) {
|
|
3670
|
-
return e.type === component_type && keys.every(function(key) {
|
|
3671
|
-
return e[key] === where[key];
|
|
3672
|
-
});
|
|
3673
|
-
});
|
|
3674
|
-
},
|
|
3675
|
-
list: function(where) {
|
|
3676
|
-
var keys = !where ? [] : Object.keys(where);
|
|
3677
|
-
return soup.filter(function(e) {
|
|
3678
|
-
return e.type === component_type && keys.every(function(key) {
|
|
3679
|
-
return e[key] === where[key];
|
|
3680
|
-
});
|
|
3681
|
-
});
|
|
3682
|
-
},
|
|
3683
|
-
select: function(selector) {
|
|
3684
|
-
if (component_type === "source_component") {
|
|
3685
|
-
return soup.find(function(e) {
|
|
3686
|
-
return e.type === "source_component" && e.name === selector.replace(/\./g, "");
|
|
3687
|
-
});
|
|
3688
|
-
} else if (component_type === "pcb_port" || component_type === "source_port" || component_type === "schematic_port") {
|
|
3689
|
-
var _selector_replace_split = _sliced_to_array(selector.replace(/\./g, "").split(/[\s\>]+/), 2), component_name = _selector_replace_split[0], port_selector = _selector_replace_split[1];
|
|
3690
|
-
var source_component = soup.find(function(e) {
|
|
3691
|
-
return e.type === "source_component" && e.name === component_name;
|
|
3692
|
-
});
|
|
3693
|
-
if (!source_component) return null;
|
|
3694
|
-
var source_port2 = soup.find(function(e) {
|
|
3695
|
-
var _e_port_hints;
|
|
3696
|
-
return e.type === "source_port" && e.source_component_id === source_component.source_component_id && (e.name === port_selector || ((_e_port_hints = e.port_hints) !== null && _e_port_hints !== void 0 ? _e_port_hints : []).includes(port_selector));
|
|
3697
|
-
});
|
|
3698
|
-
if (!source_port2) return null;
|
|
3699
|
-
if (component_type === "source_port") return source_port2;
|
|
3700
|
-
if (component_type === "pcb_port") {
|
|
3701
|
-
return soup.find(function(e) {
|
|
3702
|
-
return e.type === "pcb_port" && e.source_port_id === source_port2.source_port_id;
|
|
3703
|
-
});
|
|
3704
|
-
} else if (component_type === "schematic_port") {
|
|
3705
|
-
return soup.find(function(e) {
|
|
3706
|
-
return e.type === "schematic_port" && e.source_port_id === source_port2.source_port_id;
|
|
3707
|
-
});
|
|
3708
|
-
}
|
|
3709
|
-
}
|
|
3710
|
-
}
|
|
3711
|
-
};
|
|
3712
|
-
}
|
|
3713
|
-
});
|
|
3714
|
-
return su22;
|
|
3715
|
-
};
|
|
3716
|
-
su5.unparsed = su5;
|
|
3717
|
-
var su_default = su5;
|
|
3718
|
-
var directionToVec = function(direction) {
|
|
3719
|
-
if (direction === "up") return {
|
|
3720
|
-
x: 0,
|
|
3721
|
-
y: 1
|
|
3722
|
-
};
|
|
3723
|
-
else if (direction === "down") return {
|
|
3724
|
-
x: 0,
|
|
3725
|
-
y: -1
|
|
3726
|
-
};
|
|
3727
|
-
else if (direction === "left") return {
|
|
3728
|
-
x: -1,
|
|
3729
|
-
y: 0
|
|
3730
|
-
};
|
|
3731
|
-
else if (direction === "right") return {
|
|
3732
|
-
x: 1,
|
|
3733
|
-
y: 0
|
|
3734
|
-
};
|
|
3735
|
-
else throw new Error("Invalid direction");
|
|
3736
|
-
};
|
|
3737
|
-
var vecToDirection = function(param) {
|
|
3738
|
-
var x = param.x, y = param.y;
|
|
3739
|
-
if (x > y) y = 0;
|
|
3740
|
-
if (y > x) x = 0;
|
|
3741
|
-
if (x > 0 && y === 0) return "right";
|
|
3742
|
-
else if (x < 0 && y === 0) return "left";
|
|
3743
|
-
else if (x === 0 && y > 0) return "up";
|
|
3744
|
-
else if (x === 0 && y < 0) return "down";
|
|
3745
|
-
else throw new Error("Invalid vector for direction conversion (".concat(x, ", ").concat(y, ")"));
|
|
3746
|
-
};
|
|
3747
|
-
var rotateClockwise = function(direction) {
|
|
3748
|
-
if (direction === "up") return "right";
|
|
3749
|
-
else if (direction === "right") return "down";
|
|
3750
|
-
else if (direction === "down") return "left";
|
|
3751
|
-
else if (direction === "left") return "up";
|
|
3752
|
-
throw new Error("Invalid direction: ".concat(direction));
|
|
3753
|
-
};
|
|
3754
|
-
var rotateCounterClockwise = function(direction) {
|
|
3755
|
-
if (direction === "up") return "left";
|
|
3756
|
-
else if (direction === "left") return "down";
|
|
3757
|
-
else if (direction === "down") return "right";
|
|
3758
|
-
else if (direction === "right") return "up";
|
|
3759
|
-
throw new Error("Invalid direction: ".concat(direction));
|
|
3760
|
-
};
|
|
3761
|
-
var rotateDirection = function(direction, num90DegreeClockwiseTurns) {
|
|
3762
|
-
while(num90DegreeClockwiseTurns > 0){
|
|
3763
|
-
direction = rotateClockwise(direction);
|
|
3764
|
-
num90DegreeClockwiseTurns--;
|
|
3765
|
-
}
|
|
3766
|
-
while(num90DegreeClockwiseTurns < 0){
|
|
3767
|
-
direction = rotateCounterClockwise(direction);
|
|
3768
|
-
num90DegreeClockwiseTurns++;
|
|
3769
|
-
}
|
|
3770
|
-
return direction;
|
|
3771
|
-
};
|
|
3772
|
-
var oppositeDirection = function(direction) {
|
|
3773
|
-
if (direction === "up") return "down";
|
|
3774
|
-
else if (direction === "down") return "up";
|
|
3775
|
-
else if (direction === "left") return "right";
|
|
3776
|
-
else if (direction === "right") return "left";
|
|
3777
|
-
throw new Error("Invalid direction: ".concat(direction));
|
|
3778
|
-
};
|
|
3779
|
-
var oppositeSide = function(sideOrDir) {
|
|
3780
|
-
if (sideOrDir === "top" || sideOrDir === "up") return "bottom";
|
|
3781
|
-
else if (sideOrDir === "bottom" || sideOrDir === "down") return "top";
|
|
3782
|
-
else if (sideOrDir === "left") return "right";
|
|
3783
|
-
else if (sideOrDir === "right") return "left";
|
|
3784
|
-
throw new Error("Invalid sideOrDir: ".concat(sideOrDir));
|
|
3785
|
-
};
|
|
3786
|
-
var import_transformation_matrix10 = require("transformation-matrix");
|
|
3787
|
-
var transformSchematicElement = function(elm, matrix) {
|
|
3788
|
-
if (elm.type === "schematic_component") {
|
|
3789
|
-
elm.center = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.center);
|
|
3790
|
-
} else if (elm.type === "schematic_port") {
|
|
3791
|
-
elm.center = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.center);
|
|
3792
|
-
if (elm.facing_direction) {
|
|
3793
|
-
elm.facing_direction = rotateDirection(elm.facing_direction, -(Math.atan2(matrix.b, matrix.a) / Math.PI) * 2);
|
|
3794
|
-
}
|
|
3795
|
-
} else if (elm.type === "schematic_text") {
|
|
3796
|
-
elm.position = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.position);
|
|
3797
|
-
} else if (elm.type === "schematic_trace") {} else if (elm.type === "schematic_box") {
|
|
3798
|
-
var _ref = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
3799
|
-
x: elm.x,
|
|
3800
|
-
y: elm.y
|
|
3801
|
-
}), x = _ref.x, y = _ref.y;
|
|
3802
|
-
elm.x = x;
|
|
3803
|
-
elm.y = y;
|
|
3804
|
-
} else if (elm.type === "schematic_line") {
|
|
3805
|
-
var _ref1 = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
3806
|
-
x: elm.x1,
|
|
3807
|
-
y: elm.y1
|
|
3808
|
-
}), x1 = _ref1.x, y1 = _ref1.y;
|
|
3809
|
-
var _ref2 = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
3810
|
-
x: elm.x2,
|
|
3811
|
-
y: elm.y2
|
|
3812
|
-
}), x2 = _ref2.x, y2 = _ref2.y;
|
|
3813
|
-
elm.x1 = x1;
|
|
3814
|
-
elm.y1 = y1;
|
|
3815
|
-
elm.x2 = x2;
|
|
3816
|
-
elm.y2 = y2;
|
|
3817
|
-
}
|
|
3818
|
-
return elm;
|
|
3819
|
-
};
|
|
3820
|
-
var transformSchematicElements = function(elms, matrix) {
|
|
3821
|
-
return elms.map(function(elm) {
|
|
3822
|
-
return transformSchematicElement(elm, matrix);
|
|
3823
|
-
});
|
|
3824
|
-
};
|
|
3825
|
-
var transformPCBElement2 = function(elm, matrix) {
|
|
3826
|
-
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
|
|
3827
|
-
var _ref = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
3828
|
-
x: elm.x,
|
|
3829
|
-
y: elm.y
|
|
3830
|
-
}), x = _ref.x, y = _ref.y;
|
|
3831
|
-
elm.x = x;
|
|
3832
|
-
elm.y = y;
|
|
3833
|
-
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
|
|
3834
|
-
elm.anchor_position = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.anchor_position);
|
|
3835
|
-
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_component") {
|
|
3836
|
-
elm.center = (0, import_transformation_matrix10.applyToPoint)(matrix, elm.center);
|
|
3837
|
-
} else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path") {
|
|
3838
|
-
elm.route = elm.route.map(function(rp) {
|
|
3839
|
-
var tp = (0, import_transformation_matrix10.applyToPoint)(matrix, rp);
|
|
3840
|
-
rp.x = tp.x;
|
|
3841
|
-
rp.y = tp.y;
|
|
3842
|
-
return rp;
|
|
3843
|
-
});
|
|
3844
|
-
} else if (elm.type === "pcb_silkscreen_line") {
|
|
3845
|
-
var p1 = {
|
|
3846
|
-
x: elm.x1,
|
|
3847
|
-
y: elm.y1
|
|
3848
|
-
};
|
|
3849
|
-
var p2 = {
|
|
3850
|
-
x: elm.x2,
|
|
3851
|
-
y: elm.y2
|
|
3852
|
-
};
|
|
3853
|
-
var p1t = (0, import_transformation_matrix10.applyToPoint)(matrix, p1);
|
|
3854
|
-
var p2t = (0, import_transformation_matrix10.applyToPoint)(matrix, p2);
|
|
3855
|
-
elm.x1 = p1t.x;
|
|
3856
|
-
elm.y1 = p1t.y;
|
|
3857
|
-
elm.x2 = p2t.x;
|
|
3858
|
-
elm.y2 = p2t.y;
|
|
3859
|
-
} else if (elm.type === "cad_component") {
|
|
3860
|
-
var newPos = (0, import_transformation_matrix10.applyToPoint)(matrix, {
|
|
3861
|
-
x: elm.position.x,
|
|
3862
|
-
y: elm.position.y
|
|
3863
|
-
});
|
|
3864
|
-
elm.position.x = newPos.x;
|
|
3865
|
-
elm.position.y = newPos.y;
|
|
3866
|
-
}
|
|
3867
|
-
return elm;
|
|
3868
|
-
};
|
|
3869
|
-
var transformPCBElements2 = function(elms, matrix) {
|
|
3870
|
-
var tsr = (0, import_transformation_matrix10.decomposeTSR)(matrix);
|
|
3871
|
-
var flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
|
|
3872
|
-
var transformedElms = elms.map(function(elm) {
|
|
3873
|
-
return transformPCBElement2(elm, matrix);
|
|
3874
|
-
});
|
|
3875
|
-
if (flipPadWidthHeight) {
|
|
3876
|
-
transformedElms = transformedElms.map(function(elm) {
|
|
3877
|
-
if (elm.type === "pcb_smtpad" && elm.shape === "rect") {
|
|
3878
|
-
;
|
|
3879
|
-
var ref;
|
|
3880
|
-
ref = [
|
|
3881
|
-
elm.height,
|
|
3882
|
-
elm.width
|
|
3883
|
-
], elm.width = ref[0], elm.height = ref[1], ref;
|
|
3884
|
-
}
|
|
3885
|
-
return elm;
|
|
2942
|
+
measure = measure || this.origin.measure;
|
|
2943
|
+
each(measures[measure], function(units, system) {
|
|
2944
|
+
if (system == "_anchors") return false;
|
|
2945
|
+
possibilities = possibilities.concat(keys(units));
|
|
3886
2946
|
});
|
|
3887
2947
|
}
|
|
3888
|
-
return
|
|
3889
|
-
};
|
|
3890
|
-
var parsel = __toESM2(require_parsel_min(), 1);
|
|
3891
|
-
var convertAbbrToType = function(abbr) {
|
|
3892
|
-
switch(abbr){
|
|
3893
|
-
case "port":
|
|
3894
|
-
return "source_port";
|
|
3895
|
-
case "net":
|
|
3896
|
-
return "source_net";
|
|
3897
|
-
case "power":
|
|
3898
|
-
return "simple_power_source";
|
|
3899
|
-
}
|
|
3900
|
-
return abbr;
|
|
3901
|
-
};
|
|
3902
|
-
var filterByType = function(elements, type) {
|
|
3903
|
-
type = convertAbbrToType(type);
|
|
3904
|
-
return elements.filter(function(elm) {
|
|
3905
|
-
return "ftype" in elm && elm.ftype === type || elm.type === type;
|
|
3906
|
-
});
|
|
3907
|
-
};
|
|
3908
|
-
var applySelector = function(elements, selectorRaw) {
|
|
3909
|
-
var selectorAST = parsel.parse(selectorRaw);
|
|
3910
|
-
return applySelectorAST(elements, selectorAST);
|
|
2948
|
+
return possibilities;
|
|
3911
2949
|
};
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
return "name" in elm && elm.name === className || "port_hints" in elm && ((_elm_port_hints = elm.port_hints) === null || _elm_port_hints === void 0 ? void 0 : _elm_port_hints.includes(className));
|
|
2950
|
+
Converter.prototype.measures = function() {
|
|
2951
|
+
return keys(measures);
|
|
3915
2952
|
};
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
case "complex":
|
|
3919
|
-
{
|
|
3920
|
-
switch(selectorAST.combinator){
|
|
3921
|
-
case " ":
|
|
3922
|
-
case ">":
|
|
3923
|
-
{
|
|
3924
|
-
var left = selectorAST.left, right = selectorAST.right;
|
|
3925
|
-
if (left.type === "class" || left.type === "type") {
|
|
3926
|
-
var matchElms;
|
|
3927
|
-
if (left.type === "class") {
|
|
3928
|
-
matchElms = elements.filter(function(elm) {
|
|
3929
|
-
return doesElmMatchClassName(elm, left.name);
|
|
3930
|
-
});
|
|
3931
|
-
} else if (left.type === "type") {
|
|
3932
|
-
matchElms = filterByType(elements, left.name);
|
|
3933
|
-
} else {
|
|
3934
|
-
matchElms = [];
|
|
3935
|
-
}
|
|
3936
|
-
var childrenOfMatchingElms = matchElms.flatMap(function(matchElm) {
|
|
3937
|
-
return elements.filter(function(elm) {
|
|
3938
|
-
return elm["".concat(matchElm.type, "_id")] === matchElm["".concat(matchElm.type, "_id")] && elm !== matchElm;
|
|
3939
|
-
});
|
|
3940
|
-
});
|
|
3941
|
-
return applySelectorAST(childrenOfMatchingElms, right);
|
|
3942
|
-
} else {
|
|
3943
|
-
throw new Error('unsupported selector type "'.concat(left.type, '" '));
|
|
3944
|
-
}
|
|
3945
|
-
}
|
|
3946
|
-
default:
|
|
3947
|
-
{
|
|
3948
|
-
throw new Error("Couldn't apply selector AST for complex combinator \"".concat(selectorAST.combinator, '"'));
|
|
3949
|
-
}
|
|
3950
|
-
}
|
|
3951
|
-
return [];
|
|
3952
|
-
}
|
|
3953
|
-
case "compound":
|
|
3954
|
-
{
|
|
3955
|
-
var conditionsToMatch = selectorAST.list.map(function(part) {
|
|
3956
|
-
switch(part.type){
|
|
3957
|
-
case "class":
|
|
3958
|
-
{
|
|
3959
|
-
return function(elm) {
|
|
3960
|
-
return doesElmMatchClassName(elm, part.name);
|
|
3961
|
-
};
|
|
3962
|
-
}
|
|
3963
|
-
case "type":
|
|
3964
|
-
{
|
|
3965
|
-
var name = convertAbbrToType(part.name);
|
|
3966
|
-
return function(elm) {
|
|
3967
|
-
return elm.type === name;
|
|
3968
|
-
};
|
|
3969
|
-
}
|
|
3970
|
-
}
|
|
3971
|
-
});
|
|
3972
|
-
return elements.filter(function(elm) {
|
|
3973
|
-
return conditionsToMatch.every(function(condFn) {
|
|
3974
|
-
return condFn === null || condFn === void 0 ? void 0 : condFn(elm);
|
|
3975
|
-
});
|
|
3976
|
-
});
|
|
3977
|
-
}
|
|
3978
|
-
case "type":
|
|
3979
|
-
{
|
|
3980
|
-
return filterByType(elements, selectorAST.name);
|
|
3981
|
-
}
|
|
3982
|
-
case "class":
|
|
3983
|
-
{
|
|
3984
|
-
return elements.filter(function(elm) {
|
|
3985
|
-
return doesElmMatchClassName(elm, selectorAST.name);
|
|
3986
|
-
});
|
|
3987
|
-
}
|
|
3988
|
-
default:
|
|
3989
|
-
{
|
|
3990
|
-
throw new Error("Couldn't apply selector AST for type: \"".concat(selectorAST.type, '" ').concat(JSON.stringify(selectorAST, null, " ")));
|
|
3991
|
-
}
|
|
3992
|
-
}
|
|
2953
|
+
convert = function convert(value) {
|
|
2954
|
+
return new Converter(value);
|
|
3993
2955
|
};
|
|
2956
|
+
module2.exports = convert;
|
|
3994
2957
|
}
|
|
3995
2958
|
});
|
|
3996
2959
|
// node_modules/use-mouse-matrix-transform/dist/index.js
|
|
3997
|
-
var
|
|
2960
|
+
var require_dist = __commonJS({
|
|
3998
2961
|
"node_modules/use-mouse-matrix-transform/dist/index.js": function(exports2, module2) {
|
|
3999
2962
|
"use strict";
|
|
4000
2963
|
var __defProp2 = Object.defineProperty;
|
|
@@ -4053,7 +3016,7 @@ var require_dist2 = __commonJS({
|
|
|
4053
3016
|
}
|
|
4054
3017
|
});
|
|
4055
3018
|
module2.exports = __toCommonJS2(src_exports2);
|
|
4056
|
-
var
|
|
3019
|
+
var import_transformation_matrix11 = require("transformation-matrix");
|
|
4057
3020
|
var import_react21 = require("react");
|
|
4058
3021
|
var useMouseMatrixTransform2 = function() {
|
|
4059
3022
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
@@ -4062,7 +3025,7 @@ var require_dist2 = __commonJS({
|
|
|
4062
3025
|
var _props_canvasElm;
|
|
4063
3026
|
var outerCanvasElm = (_props_canvasElm = props.canvasElm) !== null && _props_canvasElm !== void 0 ? _props_canvasElm : extRef.current;
|
|
4064
3027
|
var _props_initialTransform;
|
|
4065
|
-
var _ref1 = _sliced_to_array((0, import_react21.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0,
|
|
3028
|
+
var _ref1 = _sliced_to_array((0, import_react21.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0, import_transformation_matrix11.identity)()), 2), internalTransform = _ref1[0], setInternalTransform = _ref1[1];
|
|
4066
3029
|
var _ref2 = _sliced_to_array((0, import_react21.useState)(0), 2), waitCounter = _ref2[0], setWaitCounter = _ref2[1];
|
|
4067
3030
|
var _ref3 = _sliced_to_array((0, import_react21.useReducer)(function(s) {
|
|
4068
3031
|
return s + 1;
|
|
@@ -4099,7 +3062,7 @@ var require_dist2 = __commonJS({
|
|
|
4099
3062
|
var handleMouseUp = function handleMouseUp(e) {
|
|
4100
3063
|
if (!md) return;
|
|
4101
3064
|
m1 = getMousePos(e);
|
|
4102
|
-
var new_tf = (0,
|
|
3065
|
+
var new_tf = (0, import_transformation_matrix11.compose)((0, import_transformation_matrix11.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
|
|
4103
3066
|
setTransform(new_tf);
|
|
4104
3067
|
init_tf = new_tf;
|
|
4105
3068
|
md = false;
|
|
@@ -4108,11 +3071,11 @@ var require_dist2 = __commonJS({
|
|
|
4108
3071
|
mlastrel = getMousePos(e);
|
|
4109
3072
|
if (!md) return;
|
|
4110
3073
|
m1 = getMousePos(e);
|
|
4111
|
-
setTransform((0,
|
|
3074
|
+
setTransform((0, import_transformation_matrix11.compose)((0, import_transformation_matrix11.translate)(m1.x - m0.x, m1.y - m0.y), init_tf));
|
|
4112
3075
|
};
|
|
4113
3076
|
var handleMouseWheel = function handleMouseWheel(e) {
|
|
4114
3077
|
var center = getMousePos(e);
|
|
4115
|
-
var new_tf = (0,
|
|
3078
|
+
var new_tf = (0, import_transformation_matrix11.compose)((0, import_transformation_matrix11.translate)(center.x, center.y), (0, import_transformation_matrix11.scale)(1 - e.deltaY / 1e3, 1 - e.deltaY / 1e3), (0, import_transformation_matrix11.translate)(-center.x, -center.y), init_tf);
|
|
4116
3079
|
setTransform(new_tf);
|
|
4117
3080
|
init_tf = new_tf;
|
|
4118
3081
|
e.preventDefault();
|
|
@@ -4127,7 +3090,7 @@ var require_dist2 = __commonJS({
|
|
|
4127
3090
|
}
|
|
4128
3091
|
md = false;
|
|
4129
3092
|
m1 = getMousePos(e);
|
|
4130
|
-
var new_tf = (0,
|
|
3093
|
+
var new_tf = (0, import_transformation_matrix11.compose)((0, import_transformation_matrix11.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
|
|
4131
3094
|
setTransform(new_tf);
|
|
4132
3095
|
init_tf = new_tf;
|
|
4133
3096
|
};
|
|
@@ -4182,7 +3145,7 @@ var require_dist2 = __commonJS({
|
|
|
4182
3145
|
lastDragCancelTime
|
|
4183
3146
|
]);
|
|
4184
3147
|
var applyTransformToPoint = (0, import_react21.useCallback)(function(obj) {
|
|
4185
|
-
return (0,
|
|
3148
|
+
return (0, import_transformation_matrix11.applyToPoint)(transform, obj);
|
|
4186
3149
|
}, [
|
|
4187
3150
|
transform
|
|
4188
3151
|
]);
|
|
@@ -4213,8 +3176,6 @@ __export(src_exports, {
|
|
|
4213
3176
|
module.exports = __toCommonJS(src_exports);
|
|
4214
3177
|
// src/PCBViewer.tsx
|
|
4215
3178
|
var import_react20 = require("react");
|
|
4216
|
-
var import_react_fiber = require("@tscircuit/react-fiber");
|
|
4217
|
-
var import_builder = require("@tscircuit/builder");
|
|
4218
3179
|
// src/components/CanvasElementsRenderer.tsx
|
|
4219
3180
|
var import_react16 = require("react");
|
|
4220
3181
|
// src/components/CanvasPrimitiveRenderer.tsx
|
|
@@ -5142,6 +4103,240 @@ var useGlobalStore = function(s) {
|
|
|
5142
4103
|
return (0, import_zustand.useStore)(store, s);
|
|
5143
4104
|
};
|
|
5144
4105
|
// node_modules/circuit-json/dist/index.mjs
|
|
4106
|
+
var dist_exports = {};
|
|
4107
|
+
__export(dist_exports, {
|
|
4108
|
+
all_layers: function() {
|
|
4109
|
+
return all_layers;
|
|
4110
|
+
},
|
|
4111
|
+
any_circuit_element: function() {
|
|
4112
|
+
return any_circuit_element;
|
|
4113
|
+
},
|
|
4114
|
+
any_soup_element: function() {
|
|
4115
|
+
return any_soup_element;
|
|
4116
|
+
},
|
|
4117
|
+
any_source_component: function() {
|
|
4118
|
+
return any_source_component;
|
|
4119
|
+
},
|
|
4120
|
+
cad_component: function() {
|
|
4121
|
+
return cad_component;
|
|
4122
|
+
},
|
|
4123
|
+
capacitance: function() {
|
|
4124
|
+
return capacitance;
|
|
4125
|
+
},
|
|
4126
|
+
current: function() {
|
|
4127
|
+
return current;
|
|
4128
|
+
},
|
|
4129
|
+
distance: function() {
|
|
4130
|
+
return distance;
|
|
4131
|
+
},
|
|
4132
|
+
getZodPrefixedIdWithDefault: function() {
|
|
4133
|
+
return getZodPrefixedIdWithDefault;
|
|
4134
|
+
},
|
|
4135
|
+
inductance: function() {
|
|
4136
|
+
return inductance;
|
|
4137
|
+
},
|
|
4138
|
+
layer_ref: function() {
|
|
4139
|
+
return layer_ref;
|
|
4140
|
+
},
|
|
4141
|
+
layer_string: function() {
|
|
4142
|
+
return layer_string;
|
|
4143
|
+
},
|
|
4144
|
+
length: function() {
|
|
4145
|
+
return length;
|
|
4146
|
+
},
|
|
4147
|
+
pcb_board: function() {
|
|
4148
|
+
return pcb_board;
|
|
4149
|
+
},
|
|
4150
|
+
pcb_component: function() {
|
|
4151
|
+
return pcb_component;
|
|
4152
|
+
},
|
|
4153
|
+
pcb_fabrication_note_path: function() {
|
|
4154
|
+
return pcb_fabrication_note_path;
|
|
4155
|
+
},
|
|
4156
|
+
pcb_fabrication_note_text: function() {
|
|
4157
|
+
return pcb_fabrication_note_text;
|
|
4158
|
+
},
|
|
4159
|
+
pcb_hole: function() {
|
|
4160
|
+
return pcb_hole;
|
|
4161
|
+
},
|
|
4162
|
+
pcb_hole_circle_or_square_shape: function() {
|
|
4163
|
+
return pcb_hole_circle_or_square_shape;
|
|
4164
|
+
},
|
|
4165
|
+
pcb_hole_oval_shape: function() {
|
|
4166
|
+
return pcb_hole_oval_shape;
|
|
4167
|
+
},
|
|
4168
|
+
pcb_keepout: function() {
|
|
4169
|
+
return pcb_keepout;
|
|
4170
|
+
},
|
|
4171
|
+
pcb_placement_error: function() {
|
|
4172
|
+
return pcb_placement_error;
|
|
4173
|
+
},
|
|
4174
|
+
pcb_plated_hole: function() {
|
|
4175
|
+
return pcb_plated_hole;
|
|
4176
|
+
},
|
|
4177
|
+
pcb_port: function() {
|
|
4178
|
+
return pcb_port;
|
|
4179
|
+
},
|
|
4180
|
+
pcb_port_not_matched_error: function() {
|
|
4181
|
+
return pcb_port_not_matched_error;
|
|
4182
|
+
},
|
|
4183
|
+
pcb_route_hint: function() {
|
|
4184
|
+
return pcb_route_hint;
|
|
4185
|
+
},
|
|
4186
|
+
pcb_route_hints: function() {
|
|
4187
|
+
return pcb_route_hints;
|
|
4188
|
+
},
|
|
4189
|
+
pcb_silkscreen_circle: function() {
|
|
4190
|
+
return pcb_silkscreen_circle;
|
|
4191
|
+
},
|
|
4192
|
+
pcb_silkscreen_line: function() {
|
|
4193
|
+
return pcb_silkscreen_line;
|
|
4194
|
+
},
|
|
4195
|
+
pcb_silkscreen_oval: function() {
|
|
4196
|
+
return pcb_silkscreen_oval;
|
|
4197
|
+
},
|
|
4198
|
+
pcb_silkscreen_path: function() {
|
|
4199
|
+
return pcb_silkscreen_path;
|
|
4200
|
+
},
|
|
4201
|
+
pcb_silkscreen_rect: function() {
|
|
4202
|
+
return pcb_silkscreen_rect;
|
|
4203
|
+
},
|
|
4204
|
+
pcb_silkscreen_text: function() {
|
|
4205
|
+
return pcb_silkscreen_text;
|
|
4206
|
+
},
|
|
4207
|
+
pcb_smtpad: function() {
|
|
4208
|
+
return pcb_smtpad;
|
|
4209
|
+
},
|
|
4210
|
+
pcb_text: function() {
|
|
4211
|
+
return pcb_text;
|
|
4212
|
+
},
|
|
4213
|
+
pcb_trace: function() {
|
|
4214
|
+
return pcb_trace;
|
|
4215
|
+
},
|
|
4216
|
+
pcb_trace_error: function() {
|
|
4217
|
+
return pcb_trace_error;
|
|
4218
|
+
},
|
|
4219
|
+
pcb_trace_hint: function() {
|
|
4220
|
+
return pcb_trace_hint;
|
|
4221
|
+
},
|
|
4222
|
+
pcb_trace_route_point: function() {
|
|
4223
|
+
return pcb_trace_route_point;
|
|
4224
|
+
},
|
|
4225
|
+
pcb_trace_route_point_via: function() {
|
|
4226
|
+
return pcb_trace_route_point_via;
|
|
4227
|
+
},
|
|
4228
|
+
pcb_trace_route_point_wire: function() {
|
|
4229
|
+
return pcb_trace_route_point_wire;
|
|
4230
|
+
},
|
|
4231
|
+
pcb_via: function() {
|
|
4232
|
+
return pcb_via;
|
|
4233
|
+
},
|
|
4234
|
+
point: function() {
|
|
4235
|
+
return point;
|
|
4236
|
+
},
|
|
4237
|
+
point3: function() {
|
|
4238
|
+
return point3;
|
|
4239
|
+
},
|
|
4240
|
+
position: function() {
|
|
4241
|
+
return position;
|
|
4242
|
+
},
|
|
4243
|
+
position3: function() {
|
|
4244
|
+
return position3;
|
|
4245
|
+
},
|
|
4246
|
+
resistance: function() {
|
|
4247
|
+
return resistance;
|
|
4248
|
+
},
|
|
4249
|
+
rotation: function() {
|
|
4250
|
+
return rotation;
|
|
4251
|
+
},
|
|
4252
|
+
route_hint_point: function() {
|
|
4253
|
+
return route_hint_point;
|
|
4254
|
+
},
|
|
4255
|
+
schematic_box: function() {
|
|
4256
|
+
return schematic_box;
|
|
4257
|
+
},
|
|
4258
|
+
schematic_component: function() {
|
|
4259
|
+
return schematic_component;
|
|
4260
|
+
},
|
|
4261
|
+
schematic_error: function() {
|
|
4262
|
+
return schematic_error;
|
|
4263
|
+
},
|
|
4264
|
+
schematic_line: function() {
|
|
4265
|
+
return schematic_line;
|
|
4266
|
+
},
|
|
4267
|
+
schematic_net_label: function() {
|
|
4268
|
+
return schematic_net_label;
|
|
4269
|
+
},
|
|
4270
|
+
schematic_path: function() {
|
|
4271
|
+
return schematic_path;
|
|
4272
|
+
},
|
|
4273
|
+
schematic_pin_styles: function() {
|
|
4274
|
+
return schematic_pin_styles;
|
|
4275
|
+
},
|
|
4276
|
+
schematic_port: function() {
|
|
4277
|
+
return schematic_port;
|
|
4278
|
+
},
|
|
4279
|
+
schematic_text: function() {
|
|
4280
|
+
return schematic_text;
|
|
4281
|
+
},
|
|
4282
|
+
schematic_trace: function() {
|
|
4283
|
+
return schematic_trace;
|
|
4284
|
+
},
|
|
4285
|
+
size: function() {
|
|
4286
|
+
return size;
|
|
4287
|
+
},
|
|
4288
|
+
source_component_base: function() {
|
|
4289
|
+
return source_component_base;
|
|
4290
|
+
},
|
|
4291
|
+
source_group: function() {
|
|
4292
|
+
return source_group;
|
|
4293
|
+
},
|
|
4294
|
+
source_led: function() {
|
|
4295
|
+
return source_led;
|
|
4296
|
+
},
|
|
4297
|
+
source_net: function() {
|
|
4298
|
+
return source_net;
|
|
4299
|
+
},
|
|
4300
|
+
source_port: function() {
|
|
4301
|
+
return source_port;
|
|
4302
|
+
},
|
|
4303
|
+
source_simple_bug: function() {
|
|
4304
|
+
return source_simple_bug;
|
|
4305
|
+
},
|
|
4306
|
+
source_simple_capacitor: function() {
|
|
4307
|
+
return source_simple_capacitor;
|
|
4308
|
+
},
|
|
4309
|
+
source_simple_chip: function() {
|
|
4310
|
+
return source_simple_chip;
|
|
4311
|
+
},
|
|
4312
|
+
source_simple_diode: function() {
|
|
4313
|
+
return source_simple_diode;
|
|
4314
|
+
},
|
|
4315
|
+
source_simple_ground: function() {
|
|
4316
|
+
return source_simple_ground;
|
|
4317
|
+
},
|
|
4318
|
+
source_simple_power_source: function() {
|
|
4319
|
+
return source_simple_power_source;
|
|
4320
|
+
},
|
|
4321
|
+
source_simple_resistor: function() {
|
|
4322
|
+
return source_simple_resistor;
|
|
4323
|
+
},
|
|
4324
|
+
source_trace: function() {
|
|
4325
|
+
return source_trace;
|
|
4326
|
+
},
|
|
4327
|
+
supplier_name: function() {
|
|
4328
|
+
return supplier_name;
|
|
4329
|
+
},
|
|
4330
|
+
time: function() {
|
|
4331
|
+
return time;
|
|
4332
|
+
},
|
|
4333
|
+
visible_layer: function() {
|
|
4334
|
+
return visible_layer;
|
|
4335
|
+
},
|
|
4336
|
+
voltage: function() {
|
|
4337
|
+
return voltage;
|
|
4338
|
+
}
|
|
4339
|
+
});
|
|
5145
4340
|
var import_convert_units = __toESM(require_lib(), 1);
|
|
5146
4341
|
// node_modules/zod/lib/index.mjs
|
|
5147
4342
|
var util;
|
|
@@ -5640,8 +4835,8 @@ var makeIssue = function(params) {
|
|
|
5640
4835
|
});
|
|
5641
4836
|
}
|
|
5642
4837
|
var errorMessage = "";
|
|
5643
|
-
var maps = errorMaps.filter(function(
|
|
5644
|
-
return !!
|
|
4838
|
+
var maps = errorMaps.filter(function(m2) {
|
|
4839
|
+
return !!m2;
|
|
5645
4840
|
}).slice().reverse();
|
|
5646
4841
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5647
4842
|
try {
|
|
@@ -11490,11 +10685,13 @@ var point = z.object({
|
|
|
11490
10685
|
x: distance,
|
|
11491
10686
|
y: distance
|
|
11492
10687
|
});
|
|
10688
|
+
var position = point;
|
|
11493
10689
|
var point3 = z.object({
|
|
11494
10690
|
x: distance,
|
|
11495
10691
|
y: distance,
|
|
11496
10692
|
z: distance
|
|
11497
10693
|
});
|
|
10694
|
+
var position3 = point3;
|
|
11498
10695
|
var size = z.object({
|
|
11499
10696
|
width: z.number(),
|
|
11500
10697
|
height: z.number()
|
|
@@ -12197,6 +11394,7 @@ var any_circuit_element = z.union([
|
|
|
12197
11394
|
schematic_net_label,
|
|
12198
11395
|
cad_component
|
|
12199
11396
|
]);
|
|
11397
|
+
var any_soup_element = any_circuit_element;
|
|
12200
11398
|
// src/components/CanvasPrimitiveRenderer.tsx
|
|
12201
11399
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
12202
11400
|
var CanvasPrimitiveRenderer = function(param) {
|
|
@@ -12266,8 +11464,275 @@ var CanvasPrimitiveRenderer = function(param) {
|
|
|
12266
11464
|
};
|
|
12267
11465
|
// src/components/CanvasElementsRenderer.tsx
|
|
12268
11466
|
var import_react17 = require("react");
|
|
12269
|
-
//
|
|
12270
|
-
var
|
|
11467
|
+
// node_modules/@tscircuit/soup-util/dist/index.js
|
|
11468
|
+
var import_transformation_matrix2 = require("transformation-matrix");
|
|
11469
|
+
var su = function(soup) {
|
|
11470
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
11471
|
+
var internalStore = soup._internal_store;
|
|
11472
|
+
if (!internalStore) {
|
|
11473
|
+
internalStore = {
|
|
11474
|
+
counts: {}
|
|
11475
|
+
};
|
|
11476
|
+
soup._internal_store = internalStore;
|
|
11477
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
11478
|
+
try {
|
|
11479
|
+
for(var _iterator = soup[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
11480
|
+
var elm = _step.value;
|
|
11481
|
+
var type = elm.type;
|
|
11482
|
+
var idVal = elm["".concat(type, "_id")];
|
|
11483
|
+
if (!idVal) continue;
|
|
11484
|
+
var idNum = Number.parseInt(idVal.split("_").pop());
|
|
11485
|
+
if (!Number.isNaN(idNum)) {
|
|
11486
|
+
var _internalStore_counts_type;
|
|
11487
|
+
internalStore.counts[type] = Math.max((_internalStore_counts_type = internalStore.counts[type]) !== null && _internalStore_counts_type !== void 0 ? _internalStore_counts_type : 0, idNum);
|
|
11488
|
+
}
|
|
11489
|
+
}
|
|
11490
|
+
} catch (err) {
|
|
11491
|
+
_didIteratorError = true;
|
|
11492
|
+
_iteratorError = err;
|
|
11493
|
+
} finally{
|
|
11494
|
+
try {
|
|
11495
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
11496
|
+
_iterator.return();
|
|
11497
|
+
}
|
|
11498
|
+
} finally{
|
|
11499
|
+
if (_didIteratorError) {
|
|
11500
|
+
throw _iteratorError;
|
|
11501
|
+
}
|
|
11502
|
+
}
|
|
11503
|
+
}
|
|
11504
|
+
}
|
|
11505
|
+
var su2 = new Proxy({}, {
|
|
11506
|
+
get: function(proxy_target, component_type) {
|
|
11507
|
+
if (component_type === "toArray") {
|
|
11508
|
+
return function() {
|
|
11509
|
+
return soup;
|
|
11510
|
+
};
|
|
11511
|
+
}
|
|
11512
|
+
return {
|
|
11513
|
+
get: function(id) {
|
|
11514
|
+
return soup.find(function(e) {
|
|
11515
|
+
return e.type === component_type && e["".concat(component_type, "_id")] === id;
|
|
11516
|
+
});
|
|
11517
|
+
},
|
|
11518
|
+
getUsing: function(using) {
|
|
11519
|
+
var keys = Object.keys(using);
|
|
11520
|
+
if (keys.length !== 1) {
|
|
11521
|
+
throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");
|
|
11522
|
+
}
|
|
11523
|
+
var join_key = keys[0];
|
|
11524
|
+
var join_type = join_key.replace("_id", "");
|
|
11525
|
+
var joiner = soup.find(function(e) {
|
|
11526
|
+
return e.type === join_type && e[join_key] === using[join_key];
|
|
11527
|
+
});
|
|
11528
|
+
if (!joiner) return null;
|
|
11529
|
+
return soup.find(function(e) {
|
|
11530
|
+
return e.type === component_type && e["".concat(component_type, "_id")] === joiner["".concat(component_type, "_id")];
|
|
11531
|
+
});
|
|
11532
|
+
},
|
|
11533
|
+
getWhere: function(where) {
|
|
11534
|
+
var keys = Object.keys(where);
|
|
11535
|
+
return soup.find(function(e) {
|
|
11536
|
+
return e.type === component_type && keys.every(function(key) {
|
|
11537
|
+
return e[key] === where[key];
|
|
11538
|
+
});
|
|
11539
|
+
});
|
|
11540
|
+
},
|
|
11541
|
+
list: function(where) {
|
|
11542
|
+
var keys = !where ? [] : Object.keys(where);
|
|
11543
|
+
return soup.filter(function(e) {
|
|
11544
|
+
return e.type === component_type && keys.every(function(key) {
|
|
11545
|
+
return e[key] === where[key];
|
|
11546
|
+
});
|
|
11547
|
+
});
|
|
11548
|
+
},
|
|
11549
|
+
insert: function(elm) {
|
|
11550
|
+
var _a;
|
|
11551
|
+
var _component_type;
|
|
11552
|
+
(_component_type = (_a = internalStore.counts)[component_type]) !== null && _component_type !== void 0 ? _component_type : _a[component_type] = -1;
|
|
11553
|
+
internalStore.counts[component_type]++;
|
|
11554
|
+
var index = internalStore.counts[component_type];
|
|
11555
|
+
var newElm = _object_spread(_define_property({
|
|
11556
|
+
type: component_type
|
|
11557
|
+
}, "".concat(component_type, "_id"), "".concat(component_type, "_").concat(index)), elm);
|
|
11558
|
+
if (options.validateInserts) {
|
|
11559
|
+
var _dist_exports_component_type;
|
|
11560
|
+
var parser = (_dist_exports_component_type = dist_exports[component_type]) !== null && _dist_exports_component_type !== void 0 ? _dist_exports_component_type : any_soup_element;
|
|
11561
|
+
parser.parse(newElm);
|
|
11562
|
+
}
|
|
11563
|
+
soup.push(newElm);
|
|
11564
|
+
return newElm;
|
|
11565
|
+
},
|
|
11566
|
+
delete: function(id) {
|
|
11567
|
+
var elm = soup.find(function(e) {
|
|
11568
|
+
return e["".concat(component_type, "_id")] === id;
|
|
11569
|
+
});
|
|
11570
|
+
if (!elm) return;
|
|
11571
|
+
soup.splice(soup.indexOf(elm), 1);
|
|
11572
|
+
},
|
|
11573
|
+
update: function(id, newProps) {
|
|
11574
|
+
var elm = soup.find(function(e) {
|
|
11575
|
+
return e["".concat(component_type, "_id")] === id;
|
|
11576
|
+
});
|
|
11577
|
+
if (!elm) return;
|
|
11578
|
+
Object.assign(elm, newProps);
|
|
11579
|
+
return elm;
|
|
11580
|
+
},
|
|
11581
|
+
select: function(selector) {
|
|
11582
|
+
if (component_type === "source_component") {
|
|
11583
|
+
return soup.find(function(e) {
|
|
11584
|
+
return e.type === "source_component" && e.name === selector.replace(/\./g, "");
|
|
11585
|
+
});
|
|
11586
|
+
} else if (component_type === "pcb_port" || component_type === "source_port" || component_type === "schematic_port") {
|
|
11587
|
+
var _selector_replace_split = _sliced_to_array(selector.replace(/\./g, "").split(/[\s\>]+/), 2), component_name = _selector_replace_split[0], port_selector = _selector_replace_split[1];
|
|
11588
|
+
var source_component = soup.find(function(e) {
|
|
11589
|
+
return e.type === "source_component" && e.name === component_name;
|
|
11590
|
+
});
|
|
11591
|
+
if (!source_component) return null;
|
|
11592
|
+
var source_port2 = soup.find(function(e) {
|
|
11593
|
+
var _e_port_hints;
|
|
11594
|
+
return e.type === "source_port" && e.source_component_id === source_component.source_component_id && (e.name === port_selector || ((_e_port_hints = e.port_hints) !== null && _e_port_hints !== void 0 ? _e_port_hints : []).includes(port_selector));
|
|
11595
|
+
});
|
|
11596
|
+
if (!source_port2) return null;
|
|
11597
|
+
if (component_type === "source_port") return source_port2;
|
|
11598
|
+
if (component_type === "pcb_port") {
|
|
11599
|
+
return soup.find(function(e) {
|
|
11600
|
+
return e.type === "pcb_port" && e.source_port_id === source_port2.source_port_id;
|
|
11601
|
+
});
|
|
11602
|
+
} else if (component_type === "schematic_port") {
|
|
11603
|
+
return soup.find(function(e) {
|
|
11604
|
+
return e.type === "schematic_port" && e.source_port_id === source_port2.source_port_id;
|
|
11605
|
+
});
|
|
11606
|
+
}
|
|
11607
|
+
}
|
|
11608
|
+
}
|
|
11609
|
+
};
|
|
11610
|
+
}
|
|
11611
|
+
});
|
|
11612
|
+
return su2;
|
|
11613
|
+
};
|
|
11614
|
+
su.unparsed = su;
|
|
11615
|
+
var su_default = su;
|
|
11616
|
+
var transformPCBElement = function(elm, matrix) {
|
|
11617
|
+
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
|
|
11618
|
+
var _ref = (0, import_transformation_matrix2.applyToPoint)(matrix, {
|
|
11619
|
+
x: elm.x,
|
|
11620
|
+
y: elm.y
|
|
11621
|
+
}), x = _ref.x, y = _ref.y;
|
|
11622
|
+
elm.x = x;
|
|
11623
|
+
elm.y = y;
|
|
11624
|
+
} else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
|
|
11625
|
+
elm.center = (0, import_transformation_matrix2.applyToPoint)(matrix, elm.center);
|
|
11626
|
+
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
|
|
11627
|
+
elm.anchor_position = (0, import_transformation_matrix2.applyToPoint)(matrix, elm.anchor_position);
|
|
11628
|
+
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_component") {
|
|
11629
|
+
elm.center = (0, import_transformation_matrix2.applyToPoint)(matrix, elm.center);
|
|
11630
|
+
} else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path") {
|
|
11631
|
+
elm.route = elm.route.map(function(rp) {
|
|
11632
|
+
var tp = (0, import_transformation_matrix2.applyToPoint)(matrix, rp);
|
|
11633
|
+
rp.x = tp.x;
|
|
11634
|
+
rp.y = tp.y;
|
|
11635
|
+
return rp;
|
|
11636
|
+
});
|
|
11637
|
+
} else if (elm.type === "pcb_silkscreen_line") {
|
|
11638
|
+
var p1 = {
|
|
11639
|
+
x: elm.x1,
|
|
11640
|
+
y: elm.y1
|
|
11641
|
+
};
|
|
11642
|
+
var p2 = {
|
|
11643
|
+
x: elm.x2,
|
|
11644
|
+
y: elm.y2
|
|
11645
|
+
};
|
|
11646
|
+
var p1t = (0, import_transformation_matrix2.applyToPoint)(matrix, p1);
|
|
11647
|
+
var p2t = (0, import_transformation_matrix2.applyToPoint)(matrix, p2);
|
|
11648
|
+
elm.x1 = p1t.x;
|
|
11649
|
+
elm.y1 = p1t.y;
|
|
11650
|
+
elm.x2 = p2t.x;
|
|
11651
|
+
elm.y2 = p2t.y;
|
|
11652
|
+
} else if (elm.type === "cad_component") {
|
|
11653
|
+
var newPos = (0, import_transformation_matrix2.applyToPoint)(matrix, {
|
|
11654
|
+
x: elm.position.x,
|
|
11655
|
+
y: elm.position.y
|
|
11656
|
+
});
|
|
11657
|
+
elm.position.x = newPos.x;
|
|
11658
|
+
elm.position.y = newPos.y;
|
|
11659
|
+
}
|
|
11660
|
+
return elm;
|
|
11661
|
+
};
|
|
11662
|
+
var getBoundsOfPcbElements = function(elements) {
|
|
11663
|
+
var minX = Number.POSITIVE_INFINITY;
|
|
11664
|
+
var minY = Number.POSITIVE_INFINITY;
|
|
11665
|
+
var maxX = Number.NEGATIVE_INFINITY;
|
|
11666
|
+
var maxY = Number.NEGATIVE_INFINITY;
|
|
11667
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
11668
|
+
try {
|
|
11669
|
+
for(var _iterator = elements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
11670
|
+
var elm = _step.value;
|
|
11671
|
+
if (!elm.type.startsWith("pcb_")) continue;
|
|
11672
|
+
if ("x" in elm && "y" in elm) {
|
|
11673
|
+
minX = Math.min(minX, elm.x);
|
|
11674
|
+
minY = Math.min(minY, elm.y);
|
|
11675
|
+
maxX = Math.max(maxX, elm.x);
|
|
11676
|
+
maxY = Math.max(maxY, elm.y);
|
|
11677
|
+
if ("width" in elm) {
|
|
11678
|
+
maxX = Math.max(maxX, elm.x + elm.width);
|
|
11679
|
+
}
|
|
11680
|
+
if ("height" in elm) {
|
|
11681
|
+
maxY = Math.max(maxY, elm.y + elm.height);
|
|
11682
|
+
}
|
|
11683
|
+
if ("radius" in elm) {
|
|
11684
|
+
minX = Math.min(minX, elm.x - elm.radius);
|
|
11685
|
+
minY = Math.min(minY, elm.y - elm.radius);
|
|
11686
|
+
maxX = Math.max(maxX, elm.x + elm.radius);
|
|
11687
|
+
maxY = Math.max(maxY, elm.y + elm.radius);
|
|
11688
|
+
}
|
|
11689
|
+
} else if (elm.type === "pcb_trace") {
|
|
11690
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
11691
|
+
try {
|
|
11692
|
+
for(var _iterator1 = elm.route[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
11693
|
+
var point2 = _step1.value;
|
|
11694
|
+
minX = Math.min(minX, point2.x);
|
|
11695
|
+
minY = Math.min(minY, point2.y);
|
|
11696
|
+
maxX = Math.max(maxX, point2.x);
|
|
11697
|
+
maxY = Math.max(maxY, point2.y);
|
|
11698
|
+
}
|
|
11699
|
+
} catch (err) {
|
|
11700
|
+
_didIteratorError1 = true;
|
|
11701
|
+
_iteratorError1 = err;
|
|
11702
|
+
} finally{
|
|
11703
|
+
try {
|
|
11704
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
11705
|
+
_iterator1.return();
|
|
11706
|
+
}
|
|
11707
|
+
} finally{
|
|
11708
|
+
if (_didIteratorError1) {
|
|
11709
|
+
throw _iteratorError1;
|
|
11710
|
+
}
|
|
11711
|
+
}
|
|
11712
|
+
}
|
|
11713
|
+
}
|
|
11714
|
+
}
|
|
11715
|
+
} catch (err) {
|
|
11716
|
+
_didIteratorError = true;
|
|
11717
|
+
_iteratorError = err;
|
|
11718
|
+
} finally{
|
|
11719
|
+
try {
|
|
11720
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
11721
|
+
_iterator.return();
|
|
11722
|
+
}
|
|
11723
|
+
} finally{
|
|
11724
|
+
if (_didIteratorError) {
|
|
11725
|
+
throw _iteratorError;
|
|
11726
|
+
}
|
|
11727
|
+
}
|
|
11728
|
+
}
|
|
11729
|
+
return {
|
|
11730
|
+
minX: minX,
|
|
11731
|
+
minY: minY,
|
|
11732
|
+
maxX: maxX,
|
|
11733
|
+
maxY: maxY
|
|
11734
|
+
};
|
|
11735
|
+
};
|
|
12271
11736
|
// src/lib/util/expand-stroke.ts
|
|
12272
11737
|
function getExpandedStroke(strokeInput, defaultWidth) {
|
|
12273
11738
|
if (strokeInput.length < 2) {
|
|
@@ -12349,14 +11814,14 @@ function getExpandedStroke(strokeInput, defaultWidth) {
|
|
|
12349
11814
|
// src/lib/convert-element-to-primitive.ts
|
|
12350
11815
|
var globalPcbDrawingObjectCount = 0;
|
|
12351
11816
|
var convertElementToPrimitives = function(element, allElements) {
|
|
12352
|
-
var
|
|
11817
|
+
var _su_default_pcb_port_get;
|
|
12353
11818
|
var _parent_pcb_component = "pcb_component_id" in element ? allElements.find(function(elm) {
|
|
12354
11819
|
return elm.type === "pcb_component" && elm.pcb_component_id === element.pcb_component_id;
|
|
12355
11820
|
}) : void 0;
|
|
12356
11821
|
var _parent_source_component = _parent_pcb_component && "source_component_id" in _parent_pcb_component ? allElements.find(function(elm) {
|
|
12357
11822
|
return elm.type === "source_component" && elm.source_component_id === _parent_pcb_component.source_component_id;
|
|
12358
11823
|
}) : void 0;
|
|
12359
|
-
var _source_port_id = "source_port_id" in element ? element.source_port_id : "pcb_port_id" in element ? (
|
|
11824
|
+
var _source_port_id = "source_port_id" in element ? element.source_port_id : "pcb_port_id" in element ? (_su_default_pcb_port_get = su_default(allElements).pcb_port.get(element.pcb_port_id)) === null || _su_default_pcb_port_get === void 0 ? void 0 : _su_default_pcb_port_get.source_port_id : void 0;
|
|
12360
11825
|
var _source_port = _source_port_id ? allElements.find(function(e) {
|
|
12361
11826
|
return e.type === "source_port" && e.source_port_id === _source_port_id;
|
|
12362
11827
|
}) : void 0;
|
|
@@ -12876,7 +12341,7 @@ var convertElementToPrimitives = function(element, allElements) {
|
|
|
12876
12341
|
// src/components/MouseElementTracker.tsx
|
|
12877
12342
|
var import_react6 = require("react");
|
|
12878
12343
|
var import_react7 = require("react");
|
|
12879
|
-
var
|
|
12344
|
+
var import_transformation_matrix3 = require("transformation-matrix");
|
|
12880
12345
|
// src/components/ElementOverlayBox.tsx
|
|
12881
12346
|
var import_react5 = require("react");
|
|
12882
12347
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -13014,7 +12479,7 @@ var MouseElementTracker = function(param) {
|
|
|
13014
12479
|
if (((_primitive__element = primitive._element) === null || _primitive__element === void 0 ? void 0 : _primitive__element.type) === "pcb_via") return "continue";
|
|
13015
12480
|
if (((_primitive__element1 = primitive._element) === null || _primitive__element1 === void 0 ? void 0 : _primitive__element1.type) === "pcb_component") return "continue";
|
|
13016
12481
|
if ((primitive === null || primitive === void 0 ? void 0 : primitive.layer) === "drill") return "continue";
|
|
13017
|
-
var screenPos = (0,
|
|
12482
|
+
var screenPos = (0, import_transformation_matrix3.applyToPoint)(transform, primitive);
|
|
13018
12483
|
var w = "w" in primitive ? primitive.w : "r" in primitive ? primitive.r * 2 : 0;
|
|
13019
12484
|
var h = "h" in primitive ? primitive.h : "r" in primitive ? primitive.r * 2 : 0;
|
|
13020
12485
|
var screenSize = {
|
|
@@ -13061,7 +12526,7 @@ var MouseElementTracker = function(param) {
|
|
|
13061
12526
|
var rect = e.currentTarget.getBoundingClientRect();
|
|
13062
12527
|
var x = e.clientX - rect.left;
|
|
13063
12528
|
var y = e.clientY - rect.top;
|
|
13064
|
-
var rwPoint = (0,
|
|
12529
|
+
var rwPoint = (0, import_transformation_matrix3.applyToPoint)((0, import_transformation_matrix3.inverse)(transform), {
|
|
13065
12530
|
x: x,
|
|
13066
12531
|
y: y
|
|
13067
12532
|
});
|
|
@@ -13113,11 +12578,11 @@ var MouseElementTracker = function(param) {
|
|
|
13113
12578
|
};
|
|
13114
12579
|
// src/components/DimensionOverlay.tsx
|
|
13115
12580
|
var import_react8 = require("react");
|
|
13116
|
-
var
|
|
12581
|
+
var import_transformation_matrix4 = require("transformation-matrix");
|
|
13117
12582
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
13118
12583
|
var DimensionOverlay = function(param) {
|
|
13119
12584
|
var children = param.children, transform = param.transform;
|
|
13120
|
-
if (!transform) transform = (0,
|
|
12585
|
+
if (!transform) transform = (0, import_transformation_matrix4.identity)();
|
|
13121
12586
|
var _ref = _sliced_to_array((0, import_react8.useState)(false), 2), dimensionToolVisible = _ref[0], setDimensionToolVisible = _ref[1];
|
|
13122
12587
|
var _ref1 = _sliced_to_array((0, import_react8.useState)(false), 2), dimensionToolStretching = _ref1[0], setDimensionToolStretching = _ref1[1];
|
|
13123
12588
|
var _ref2 = _sliced_to_array((0, import_react8.useState)({
|
|
@@ -13185,8 +12650,8 @@ var DimensionOverlay = function(param) {
|
|
|
13185
12650
|
}, [
|
|
13186
12651
|
containerRef
|
|
13187
12652
|
]);
|
|
13188
|
-
var screenDStart = (0,
|
|
13189
|
-
var screenDEnd = (0,
|
|
12653
|
+
var screenDStart = (0, import_transformation_matrix4.applyToPoint)(transform, dStart);
|
|
12654
|
+
var screenDEnd = (0, import_transformation_matrix4.applyToPoint)(transform, dEnd);
|
|
13190
12655
|
var arrowScreenBounds = {
|
|
13191
12656
|
left: Math.min(screenDStart.x, screenDEnd.x),
|
|
13192
12657
|
right: Math.max(screenDStart.x, screenDEnd.x),
|
|
@@ -13219,7 +12684,7 @@ var DimensionOverlay = function(param) {
|
|
|
13219
12684
|
var rect = e.currentTarget.getBoundingClientRect();
|
|
13220
12685
|
var x = e.clientX - rect.left;
|
|
13221
12686
|
var y = e.clientY - rect.top;
|
|
13222
|
-
var rwPoint = (0,
|
|
12687
|
+
var rwPoint = (0, import_transformation_matrix4.applyToPoint)((0, import_transformation_matrix4.inverse)(transform), {
|
|
13223
12688
|
x: x,
|
|
13224
12689
|
y: y
|
|
13225
12690
|
});
|
|
@@ -13381,7 +12846,7 @@ var import_css = require("@emotion/css");
|
|
|
13381
12846
|
// package.json
|
|
13382
12847
|
var package_default = {
|
|
13383
12848
|
name: "@tscircuit/pcb-viewer",
|
|
13384
|
-
version: "1.10.
|
|
12849
|
+
version: "1.10.9",
|
|
13385
12850
|
main: "dist/index.js",
|
|
13386
12851
|
repository: "tscircuit/pcb-viewer",
|
|
13387
12852
|
license: "MIT",
|
|
@@ -13404,12 +12869,10 @@ var package_default = {
|
|
|
13404
12869
|
"@storybook/nextjs": "^8.0.6",
|
|
13405
12870
|
"@storybook/react": "^8.0.6",
|
|
13406
12871
|
"@swc/core": "^1.4.12",
|
|
13407
|
-
"@tscircuit/
|
|
13408
|
-
"@tscircuit/core": "^0.0.88",
|
|
12872
|
+
"@tscircuit/core": "^0.0.106",
|
|
13409
12873
|
"@tscircuit/eagle-xml-converter": "^0.0.6",
|
|
13410
12874
|
"@tscircuit/props": "^0.0.46",
|
|
13411
|
-
"@tscircuit/
|
|
13412
|
-
"@tscircuit/soup-util": "^0.0.13",
|
|
12875
|
+
"@tscircuit/soup-util": "^0.0.32",
|
|
13413
12876
|
"@types/color": "^3.0.6",
|
|
13414
12877
|
"@types/node": "18.7.23",
|
|
13415
12878
|
"@types/react": "^18.3.3",
|
|
@@ -13426,9 +12889,8 @@ var package_default = {
|
|
|
13426
12889
|
zod: "^3.23.5"
|
|
13427
12890
|
},
|
|
13428
12891
|
peerDependencies: {
|
|
13429
|
-
|
|
13430
|
-
"@tscircuit/
|
|
13431
|
-
react: "*"
|
|
12892
|
+
react: "*",
|
|
12893
|
+
"@tscircuit/core": "*"
|
|
13432
12894
|
},
|
|
13433
12895
|
dependencies: {
|
|
13434
12896
|
"@emotion/css": "^11.11.2",
|
|
@@ -13745,7 +13207,7 @@ var ToolbarOverlay = function(param) {
|
|
|
13745
13207
|
// src/components/ErrorOverlay.tsx
|
|
13746
13208
|
var import_css2 = require("@emotion/css");
|
|
13747
13209
|
var import_react11 = require("react");
|
|
13748
|
-
var
|
|
13210
|
+
var import_transformation_matrix5 = require("transformation-matrix");
|
|
13749
13211
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
13750
13212
|
var ErrorSVG = function(param) {
|
|
13751
13213
|
var screenPort1 = param.screenPort1, screenPort2 = param.screenPort2, errorCenter = param.errorCenter, canLineBeDrawn = param.canLineBeDrawn;
|
|
@@ -13794,7 +13256,7 @@ var ErrorSVG = function(param) {
|
|
|
13794
13256
|
};
|
|
13795
13257
|
var ErrorOverlay = function(param) {
|
|
13796
13258
|
var children = param.children, transform = param.transform, elements = param.elements;
|
|
13797
|
-
if (!transform) transform = (0,
|
|
13259
|
+
if (!transform) transform = (0, import_transformation_matrix5.identity)();
|
|
13798
13260
|
var containerRef = (0, import_react11.useRef)(null);
|
|
13799
13261
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
|
|
13800
13262
|
style: {
|
|
@@ -13814,11 +13276,11 @@ var ErrorOverlay = function(param) {
|
|
|
13814
13276
|
return el2.type === "pcb_port" && el2.pcb_port_id === (pcb_port_ids === null || pcb_port_ids === void 0 ? void 0 : pcb_port_ids[1]);
|
|
13815
13277
|
});
|
|
13816
13278
|
if (!port1 || !port2) return null;
|
|
13817
|
-
var screenPort1 = (0,
|
|
13279
|
+
var screenPort1 = (0, import_transformation_matrix5.applyToPoint)(transform, {
|
|
13818
13280
|
x: port1.x,
|
|
13819
13281
|
y: port1.y
|
|
13820
13282
|
});
|
|
13821
|
-
var screenPort2 = (0,
|
|
13283
|
+
var screenPort2 = (0, import_transformation_matrix5.applyToPoint)(transform, {
|
|
13822
13284
|
x: port2.x,
|
|
13823
13285
|
y: port2.y
|
|
13824
13286
|
});
|
|
@@ -13858,7 +13320,7 @@ var ErrorOverlay = function(param) {
|
|
|
13858
13320
|
};
|
|
13859
13321
|
// src/components/EditPlacementOverlay.tsx
|
|
13860
13322
|
var import_react12 = require("react");
|
|
13861
|
-
var
|
|
13323
|
+
var import_transformation_matrix6 = require("transformation-matrix");
|
|
13862
13324
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
13863
13325
|
var isInsideOf = function(pcb_component2, point2) {
|
|
13864
13326
|
var padding = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
|
|
@@ -13872,7 +13334,7 @@ var isInsideOf = function(pcb_component2, point2) {
|
|
|
13872
13334
|
};
|
|
13873
13335
|
var EditPlacementOverlay = function(param) {
|
|
13874
13336
|
var children = param.children, disabledProp = param.disabled, transform = param.transform, soup = param.soup, cancelPanDrag = param.cancelPanDrag, onCreateEditEvent = param.onCreateEditEvent, onModifyEditEvent = param.onModifyEditEvent;
|
|
13875
|
-
if (!transform) transform = (0,
|
|
13337
|
+
if (!transform) transform = (0, import_transformation_matrix6.identity)();
|
|
13876
13338
|
var containerRef = (0, import_react12.useRef)(null);
|
|
13877
13339
|
var _ref = _sliced_to_array((0, import_react12.useState)(null), 2), activePcbComponentId = _ref[0], setActivePcbComponent = _ref[1];
|
|
13878
13340
|
var _ref1 = _sliced_to_array((0, import_react12.useState)(null), 2), dragState = _ref1[0], setDragState = _ref1[1];
|
|
@@ -13899,7 +13361,7 @@ var EditPlacementOverlay = function(param) {
|
|
|
13899
13361
|
var x = e.clientX - rect.left;
|
|
13900
13362
|
var y = e.clientY - rect.top;
|
|
13901
13363
|
if (isNaN(x) || isNaN(y)) return;
|
|
13902
|
-
var rwMousePoint = (0,
|
|
13364
|
+
var rwMousePoint = (0, import_transformation_matrix6.applyToPoint)((0, import_transformation_matrix6.inverse)(transform), {
|
|
13903
13365
|
x: x,
|
|
13904
13366
|
y: y
|
|
13905
13367
|
});
|
|
@@ -13960,7 +13422,7 @@ var EditPlacementOverlay = function(param) {
|
|
|
13960
13422
|
var x = e.clientX - rect.left;
|
|
13961
13423
|
var y = e.clientY - rect.top;
|
|
13962
13424
|
if (isNaN(x) || isNaN(y)) return;
|
|
13963
|
-
var rwMousePoint = (0,
|
|
13425
|
+
var rwMousePoint = (0, import_transformation_matrix6.applyToPoint)((0, import_transformation_matrix6.inverse)(transform), {
|
|
13964
13426
|
x: x,
|
|
13965
13427
|
y: y
|
|
13966
13428
|
});
|
|
@@ -13993,7 +13455,7 @@ var EditPlacementOverlay = function(param) {
|
|
|
13993
13455
|
return e.type === "pcb_component";
|
|
13994
13456
|
}).map(function(e) {
|
|
13995
13457
|
if (!(e === null || e === void 0 ? void 0 : e.center)) return null;
|
|
13996
|
-
var projectedCenter = (0,
|
|
13458
|
+
var projectedCenter = (0, import_transformation_matrix6.applyToPoint)(transform, e.center);
|
|
13997
13459
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
|
|
13998
13460
|
style: {
|
|
13999
13461
|
position: "absolute",
|
|
@@ -14012,9 +13474,8 @@ var EditPlacementOverlay = function(param) {
|
|
|
14012
13474
|
});
|
|
14013
13475
|
};
|
|
14014
13476
|
// src/components/EditTraceHintOverlay.tsx
|
|
14015
|
-
var import_soup_util2 = __toESM(require_dist());
|
|
14016
13477
|
var import_react15 = require("react");
|
|
14017
|
-
var
|
|
13478
|
+
var import_transformation_matrix7 = require("transformation-matrix");
|
|
14018
13479
|
// src/components/HotkeyActionMenu.tsx
|
|
14019
13480
|
var import_css3 = require("@emotion/css");
|
|
14020
13481
|
var import_react13 = require("react");
|
|
@@ -14123,7 +13584,7 @@ var isInsideOfPlatedHole = function(hole, point2) {
|
|
|
14123
13584
|
var EditTraceHintOverlay = function(param) {
|
|
14124
13585
|
var children = param.children, disabledProp = param.disabled, transform = param.transform, soup = param.soup, cancelPanDrag = param.cancelPanDrag, onCreateEditEvent = param.onCreateEditEvent, onModifyEditEvent = param.onModifyEditEvent;
|
|
14125
13586
|
var _containerRef_current;
|
|
14126
|
-
if (!transform) transform = (0,
|
|
13587
|
+
if (!transform) transform = (0, import_transformation_matrix7.identity)();
|
|
14127
13588
|
var containerRef = (0, import_react15.useRef)(null);
|
|
14128
13589
|
var containerBounds = (_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect();
|
|
14129
13590
|
var _ref = _sliced_to_array((0, import_react15.useState)(null), 2), selectedElement = _ref[0], setSelectedElement = _ref[1];
|
|
@@ -14137,8 +13598,8 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14137
13598
|
var disabled = disabledProp || !in_edit_trace_mode;
|
|
14138
13599
|
var ogCenterScreen, dragEndScreen;
|
|
14139
13600
|
if ((dragState === null || dragState === void 0 ? void 0 : dragState.originalCenter) && (dragState === null || dragState === void 0 ? void 0 : dragState.dragEnd)) {
|
|
14140
|
-
ogCenterScreen = (0,
|
|
14141
|
-
dragEndScreen = (0,
|
|
13601
|
+
ogCenterScreen = (0, import_transformation_matrix7.applyToPoint)(transform, dragState === null || dragState === void 0 ? void 0 : dragState.originalCenter);
|
|
13602
|
+
dragEndScreen = (0, import_transformation_matrix7.applyToPoint)(transform, dragState === null || dragState === void 0 ? void 0 : dragState.dragEnd);
|
|
14142
13603
|
}
|
|
14143
13604
|
(0, import_react15.useEffect)(function() {
|
|
14144
13605
|
var keyDown = function keyDown(e) {
|
|
@@ -14167,7 +13628,7 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14167
13628
|
var x = e.clientX - rect.left;
|
|
14168
13629
|
var y = e.clientY - rect.top;
|
|
14169
13630
|
if (isNaN(x) || isNaN(y)) return;
|
|
14170
|
-
var rwMousePoint = (0,
|
|
13631
|
+
var rwMousePoint = (0, import_transformation_matrix7.applyToPoint)((0, import_transformation_matrix7.inverse)(transform), {
|
|
14171
13632
|
x: x,
|
|
14172
13633
|
y: y
|
|
14173
13634
|
});
|
|
@@ -14232,7 +13693,7 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14232
13693
|
var x = e.clientX - rect.left;
|
|
14233
13694
|
var y = e.clientY - rect.top;
|
|
14234
13695
|
if (isNaN(x) || isNaN(y)) return;
|
|
14235
|
-
var rwMousePoint = (0,
|
|
13696
|
+
var rwMousePoint = (0, import_transformation_matrix7.applyToPoint)((0, import_transformation_matrix7.inverse)(transform), {
|
|
14236
13697
|
x: x,
|
|
14237
13698
|
y: y
|
|
14238
13699
|
});
|
|
@@ -14251,14 +13712,14 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14251
13712
|
var x = e.clientX - rect.left;
|
|
14252
13713
|
var y = e.clientY - rect.top;
|
|
14253
13714
|
if (isNaN(x) || isNaN(y)) return;
|
|
14254
|
-
var rwMousePoint = (0,
|
|
13715
|
+
var rwMousePoint = (0, import_transformation_matrix7.applyToPoint)((0, import_transformation_matrix7.inverse)(transform), {
|
|
14255
13716
|
x: x,
|
|
14256
13717
|
y: y
|
|
14257
13718
|
});
|
|
14258
13719
|
if (dragState) {
|
|
14259
13720
|
cancelPanDrag();
|
|
14260
13721
|
var _dragState_editEvent_route_slice_;
|
|
14261
|
-
var lastPointScreen = (0,
|
|
13722
|
+
var lastPointScreen = (0, import_transformation_matrix7.applyToPoint)(transform, (_dragState_editEvent_route_slice_ = dragState.editEvent.route.slice(-1)[0]) !== null && _dragState_editEvent_route_slice_ !== void 0 ? _dragState_editEvent_route_slice_ : dragState.originalCenter);
|
|
14262
13723
|
var distanceFromLastPoint = Math.sqrt(Math.pow(x - lastPointScreen.x, 2) + Math.pow(y - lastPointScreen.y, 2));
|
|
14263
13724
|
if (distanceFromLastPoint < 20) {
|
|
14264
13725
|
onCreateEditEvent(_object_spread_props(_object_spread({}, dragState.editEvent), {
|
|
@@ -14296,13 +13757,13 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14296
13757
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", {
|
|
14297
13758
|
stroke: "red",
|
|
14298
13759
|
d: "M ".concat(ogCenterScreen.x, " ").concat(ogCenterScreen.y, " ").concat(dragState === null || dragState === void 0 ? void 0 : dragState.editEvent.route.map(function(p) {
|
|
14299
|
-
return (0,
|
|
13760
|
+
return (0, import_transformation_matrix7.applyToPoint)(transform, p);
|
|
14300
13761
|
}).map(function(p) {
|
|
14301
13762
|
return "L ".concat(p.x, " ").concat(p.y);
|
|
14302
13763
|
}).join(" "), " L ").concat(dragEndScreen.x, " ").concat(dragEndScreen.y)
|
|
14303
13764
|
}),
|
|
14304
13765
|
dragState === null || dragState === void 0 ? void 0 : dragState.editEvent.route.map(function(r, i) {
|
|
14305
|
-
var rScreen = (0,
|
|
13766
|
+
var rScreen = (0, import_transformation_matrix7.applyToPoint)(transform, r);
|
|
14306
13767
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react15.Fragment, {
|
|
14307
13768
|
children: [
|
|
14308
13769
|
r.via && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", {
|
|
@@ -14349,8 +13810,8 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14349
13810
|
return e.type === "pcb_trace_hint";
|
|
14350
13811
|
}).map(function(e) {
|
|
14351
13812
|
var route = e.route;
|
|
14352
|
-
var pcb_port2 = (
|
|
14353
|
-
var pcb_port_screen = (0,
|
|
13813
|
+
var pcb_port2 = su_default(soup).pcb_port.get(e.pcb_port_id);
|
|
13814
|
+
var pcb_port_screen = (0, import_transformation_matrix7.applyToPoint)(transform, pcb_port2);
|
|
14354
13815
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react15.Fragment, {
|
|
14355
13816
|
children: [
|
|
14356
13817
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", {
|
|
@@ -14363,13 +13824,13 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14363
13824
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", {
|
|
14364
13825
|
stroke: "red",
|
|
14365
13826
|
d: "M ".concat(pcb_port_screen.x, " ").concat(pcb_port_screen.y, " ").concat(route.map(function(r) {
|
|
14366
|
-
return (0,
|
|
13827
|
+
return (0, import_transformation_matrix7.applyToPoint)(transform, r);
|
|
14367
13828
|
}).map(function(r) {
|
|
14368
13829
|
return "L ".concat(r.x, " ").concat(r.y);
|
|
14369
13830
|
}).join(" "))
|
|
14370
13831
|
}, "path-".concat(e.pcb_port_id)),
|
|
14371
13832
|
route.map(function(r) {
|
|
14372
|
-
return _object_spread({}, r, (0,
|
|
13833
|
+
return _object_spread({}, r, (0, import_transformation_matrix7.applyToPoint)(transform, r));
|
|
14373
13834
|
}).map(function(r, i) {
|
|
14374
13835
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react15.Fragment, {
|
|
14375
13836
|
children: [
|
|
@@ -14415,8 +13876,7 @@ var EditTraceHintOverlay = function(param) {
|
|
|
14415
13876
|
});
|
|
14416
13877
|
};
|
|
14417
13878
|
// src/components/RatsNestOverlay.tsx
|
|
14418
|
-
var
|
|
14419
|
-
var import_soup_util3 = __toESM(require_dist());
|
|
13879
|
+
var import_transformation_matrix8 = require("transformation-matrix");
|
|
14420
13880
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
14421
13881
|
var RatsNestOverlay = function(param) {
|
|
14422
13882
|
var transform = param.transform, soup = param.soup, children = param.children;
|
|
@@ -14424,14 +13884,14 @@ var RatsNestOverlay = function(param) {
|
|
|
14424
13884
|
return s.is_showing_rats_nest;
|
|
14425
13885
|
});
|
|
14426
13886
|
if (!soup || !isShowingRatsNest) return children;
|
|
14427
|
-
if (!transform) transform = (0,
|
|
14428
|
-
var sourceTraces = (
|
|
13887
|
+
if (!transform) transform = (0, import_transformation_matrix8.identity)();
|
|
13888
|
+
var sourceTraces = su_default(soup).source_trace.list();
|
|
14429
13889
|
var groups = [];
|
|
14430
13890
|
sourceTraces.forEach(function(sourceTrace) {
|
|
14431
13891
|
if (sourceTrace.connected_source_port_ids) {
|
|
14432
13892
|
var group = [];
|
|
14433
13893
|
sourceTrace.connected_source_port_ids.forEach(function(source_port_id) {
|
|
14434
|
-
var pcbPort = (
|
|
13894
|
+
var pcbPort = su_default(soup).pcb_port.getWhere({
|
|
14435
13895
|
source_port_id: source_port_id
|
|
14436
13896
|
});
|
|
14437
13897
|
if (pcbPort) group.push(pcbPort);
|
|
@@ -14458,7 +13918,7 @@ var RatsNestOverlay = function(param) {
|
|
|
14458
13918
|
},
|
|
14459
13919
|
children: groups.map(function(group, index) {
|
|
14460
13920
|
var points = group.map(function(port) {
|
|
14461
|
-
return (0,
|
|
13921
|
+
return (0, import_transformation_matrix8.applyToPoint)(transform, {
|
|
14462
13922
|
x: port.x,
|
|
14463
13923
|
y: port.y
|
|
14464
13924
|
});
|
|
@@ -14625,7 +14085,7 @@ var CanvasElementsRenderer = function(props) {
|
|
|
14625
14085
|
});
|
|
14626
14086
|
};
|
|
14627
14087
|
// src/PCBViewer.tsx
|
|
14628
|
-
var import_use_mouse_matrix_transform = __toESM(
|
|
14088
|
+
var import_use_mouse_matrix_transform = __toESM(require_dist());
|
|
14629
14089
|
// node_modules/react-use/esm/misc/util.js
|
|
14630
14090
|
var noop = function noop() {};
|
|
14631
14091
|
var isBrowser = typeof window !== "undefined";
|
|
@@ -14686,13 +14146,10 @@ var useMeasure_default = isBrowser && typeof window.ResizeObserver !== "undefine
|
|
|
14686
14146
|
];
|
|
14687
14147
|
};
|
|
14688
14148
|
// src/PCBViewer.tsx
|
|
14689
|
-
var
|
|
14690
|
-
var import_builder2 = require("@tscircuit/builder");
|
|
14149
|
+
var import_transformation_matrix10 = require("transformation-matrix");
|
|
14691
14150
|
// src/lib/apply-edit-events.ts
|
|
14692
|
-
var
|
|
14693
|
-
var import_transformation_matrix8 = require("transformation-matrix");
|
|
14151
|
+
var import_transformation_matrix9 = require("transformation-matrix");
|
|
14694
14152
|
// src/lib/apply-edit-events/apply-edit-trace-hint-event.ts
|
|
14695
|
-
var import_soup_util4 = __toESM(require_dist());
|
|
14696
14153
|
var applyTraceHintEditEvent = function(soup, edit_event) {
|
|
14697
14154
|
var existing_trace_hint = soup.find(function(th) {
|
|
14698
14155
|
return th.type === "pcb_trace_hint" && th.pcb_trace_hint_id === edit_event.pcb_trace_hint_id;
|
|
@@ -14704,7 +14161,7 @@ var applyTraceHintEditEvent = function(soup, edit_event) {
|
|
|
14704
14161
|
}) : e;
|
|
14705
14162
|
});
|
|
14706
14163
|
} else {
|
|
14707
|
-
var pcb_port2 = (
|
|
14164
|
+
var pcb_port2 = su_default(soup).pcb_port.get(edit_event.pcb_port_id);
|
|
14708
14165
|
soup = soup.filter(function(e) {
|
|
14709
14166
|
return !(e.type === "pcb_trace_hint" && e.pcb_port_id === edit_event.pcb_port_id);
|
|
14710
14167
|
}).concat([
|
|
@@ -14727,9 +14184,9 @@ var applyEditEvents = function(soup, edit_events) {
|
|
|
14727
14184
|
var _loop = function() {
|
|
14728
14185
|
var edit_event = _step.value;
|
|
14729
14186
|
if (edit_event.pcb_edit_event_type === "edit_component_location") {
|
|
14730
|
-
var mat = (0,
|
|
14187
|
+
var mat = (0, import_transformation_matrix9.translate)(edit_event.new_center.x - edit_event.original_center.x, edit_event.new_center.y - edit_event.original_center.y);
|
|
14731
14188
|
soup = soup.map(function(e) {
|
|
14732
|
-
return e.pcb_component_id !== edit_event.pcb_component_id ? e :
|
|
14189
|
+
return e.pcb_component_id !== edit_event.pcb_component_id ? e : transformPCBElement(e, mat);
|
|
14733
14190
|
});
|
|
14734
14191
|
} else if (edit_event.pcb_edit_event_type === "edit_trace_hint") {
|
|
14735
14192
|
soup = applyTraceHintEditEvent(soup, edit_event);
|
|
@@ -14753,20 +14210,28 @@ var applyEditEvents = function(soup, edit_events) {
|
|
|
14753
14210
|
return soup;
|
|
14754
14211
|
};
|
|
14755
14212
|
// src/PCBViewer.tsx
|
|
14213
|
+
var import_core = require("@tscircuit/core");
|
|
14756
14214
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
14757
|
-
var defaultTransform = (0,
|
|
14215
|
+
var defaultTransform = (0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(400, 300), (0, import_transformation_matrix10.scale)(40, -40));
|
|
14758
14216
|
var PCBViewer = function(param) {
|
|
14759
14217
|
var children = param.children, soup = param.soup, _param_height = param.height, height = _param_height === void 0 ? 600 : _param_height, initialState = param.initialState, _param_allowEditing = param.allowEditing, allowEditing = _param_allowEditing === void 0 ? true : _param_allowEditing, editEventsProp = param.editEvents, onEditEventsChanged = param.onEditEventsChanged;
|
|
14760
|
-
var _ref =
|
|
14218
|
+
var _ref = (0, import_core.useRenderedCircuit)(children), circuitJsonFromChildren = _ref.circuitJson, errorFromChildren = _ref.error;
|
|
14219
|
+
var _ref1;
|
|
14220
|
+
var stateElements = (_ref1 = circuitJsonFromChildren !== null && circuitJsonFromChildren !== void 0 ? circuitJsonFromChildren : soup) !== null && _ref1 !== void 0 ? _ref1 : [];
|
|
14761
14221
|
var _useMeasure_default = _sliced_to_array(useMeasure_default(), 2), ref = _useMeasure_default[0], refDimensions = _useMeasure_default[1];
|
|
14762
|
-
var
|
|
14763
|
-
var
|
|
14222
|
+
var _ref2 = _sliced_to_array((0, import_react20.useState)(defaultTransform), 2), transform = _ref2[0], setTransformInternal = _ref2[1];
|
|
14223
|
+
var _ref3 = (0, import_use_mouse_matrix_transform.default)({
|
|
14764
14224
|
transform: transform,
|
|
14765
14225
|
onSetTransform: setTransformInternal
|
|
14766
|
-
}), transformRef =
|
|
14767
|
-
var
|
|
14226
|
+
}), transformRef = _ref3.ref, setTransform = _ref3.setTransform, cancelPanDrag = _ref3.cancelDrag;
|
|
14227
|
+
var _ref4 = _sliced_to_array((0, import_react20.useState)([]), 2), editEvents = _ref4[0], setEditEvents = _ref4[1];
|
|
14768
14228
|
editEvents = editEventsProp !== null && editEventsProp !== void 0 ? editEventsProp : editEvents;
|
|
14769
|
-
var
|
|
14229
|
+
var _ref5 = _sliced_to_array((0, import_react20.useState)(null), 2), error = _ref5[0], setError = _ref5[1];
|
|
14230
|
+
(0, import_react20.useEffect)(function() {
|
|
14231
|
+
setError(errorFromChildren ? errorFromChildren.toString() : null);
|
|
14232
|
+
}, [
|
|
14233
|
+
errorFromChildren
|
|
14234
|
+
]);
|
|
14770
14235
|
var resetTransform = function() {
|
|
14771
14236
|
var elmBounds = (refDimensions === null || refDimensions === void 0 ? void 0 : refDimensions.width) > 0 ? refDimensions : {
|
|
14772
14237
|
width: 500,
|
|
@@ -14774,58 +14239,26 @@ var PCBViewer = function(param) {
|
|
|
14774
14239
|
};
|
|
14775
14240
|
var _ref = elements.some(function(e) {
|
|
14776
14241
|
return e.type.startsWith("pcb_");
|
|
14777
|
-
}) ? (
|
|
14242
|
+
}) ? getBoundsOfPcbElements(elements.filter(function(e) {
|
|
14778
14243
|
return e.type.startsWith("pcb_");
|
|
14779
14244
|
})) : {
|
|
14780
|
-
|
|
14781
|
-
|
|
14782
|
-
|
|
14783
|
-
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
|
|
14245
|
+
minX: -1e-3,
|
|
14246
|
+
minY: -1e-3,
|
|
14247
|
+
maxX: 1e-3,
|
|
14248
|
+
maxY: 1e-3
|
|
14249
|
+
}, minX = _ref.minX, minY = _ref.minY, maxX = _ref.maxX, maxY = _ref.maxY;
|
|
14250
|
+
var width = maxX - minX;
|
|
14251
|
+
var height2 = maxY - minY;
|
|
14252
|
+
var center = {
|
|
14253
|
+
x: (minX + maxX) / 2,
|
|
14254
|
+
y: (minY + maxY) / 2
|
|
14255
|
+
};
|
|
14787
14256
|
var _elmBounds_width, _elmBounds_height;
|
|
14788
14257
|
var scaleFactor = Math.min(((_elmBounds_width = elmBounds.width) !== null && _elmBounds_width !== void 0 ? _elmBounds_width : 0) / width, ((_elmBounds_height = elmBounds.height) !== null && _elmBounds_height !== void 0 ? _elmBounds_height : 0) / height2, 100) * 0.75;
|
|
14789
14258
|
var _elmBounds_width1, _elmBounds_height1;
|
|
14790
|
-
setTransform((0,
|
|
14791
|
-
(0,
|
|
14259
|
+
setTransform((0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(((_elmBounds_width1 = elmBounds.width) !== null && _elmBounds_width1 !== void 0 ? _elmBounds_width1 : 0) / 2, ((_elmBounds_height1 = elmBounds.height) !== null && _elmBounds_height1 !== void 0 ? _elmBounds_height1 : 0) / 2), // translate(100, 0),
|
|
14260
|
+
(0, import_transformation_matrix10.scale)(scaleFactor, -scaleFactor, 0, 0), (0, import_transformation_matrix10.translate)(-center.x, -center.y)));
|
|
14792
14261
|
};
|
|
14793
|
-
(0, import_react20.useEffect)(function() {
|
|
14794
|
-
var doRender = function doRender() {
|
|
14795
|
-
return _doRender.apply(this, arguments);
|
|
14796
|
-
};
|
|
14797
|
-
if (!children || (children === null || children === void 0 ? void 0 : children.length) === 0) return;
|
|
14798
|
-
function _doRender() {
|
|
14799
|
-
_doRender = _async_to_generator(function() {
|
|
14800
|
-
var projectBuilder;
|
|
14801
|
-
return _ts_generator(this, function(_state) {
|
|
14802
|
-
switch(_state.label){
|
|
14803
|
-
case 0:
|
|
14804
|
-
projectBuilder = (0, import_builder.createProjectBuilder)();
|
|
14805
|
-
return [
|
|
14806
|
-
4,
|
|
14807
|
-
(0, import_react_fiber.createRoot)().render(children, projectBuilder).then(function(elements2) {
|
|
14808
|
-
setStateElements(elements2);
|
|
14809
|
-
setError(null);
|
|
14810
|
-
})
|
|
14811
|
-
];
|
|
14812
|
-
case 1:
|
|
14813
|
-
_state.sent();
|
|
14814
|
-
return [
|
|
14815
|
-
2
|
|
14816
|
-
];
|
|
14817
|
-
}
|
|
14818
|
-
});
|
|
14819
|
-
});
|
|
14820
|
-
return _doRender.apply(this, arguments);
|
|
14821
|
-
}
|
|
14822
|
-
doRender().catch(function(e) {
|
|
14823
|
-
setError(e.toString());
|
|
14824
|
-
console.log(e.toString());
|
|
14825
|
-
});
|
|
14826
|
-
}, [
|
|
14827
|
-
children
|
|
14828
|
-
]);
|
|
14829
14262
|
(0, import_react20.useEffect)(function() {
|
|
14830
14263
|
if (refDimensions && refDimensions.width !== 0 && (children || soup)) {
|
|
14831
14264
|
resetTransform();
|