@tscircuit/pcb-viewer 1.10.10 → 1.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1167 -600
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -408,6 +408,20 @@ 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
|
+
}
|
|
411
425
|
var _loop = function(letter) {
|
|
412
426
|
lineAlphabet[letter] = [];
|
|
413
427
|
var segs = svgAlphabet[letter].split("M").slice(1).map(function(seg) {
|
|
@@ -2945,19 +2959,1042 @@ var require_lib = __commonJS({
|
|
|
2945
2959
|
possibilities = possibilities.concat(keys(units));
|
|
2946
2960
|
});
|
|
2947
2961
|
}
|
|
2948
|
-
return possibilities;
|
|
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;
|
|
3886
|
+
});
|
|
3887
|
+
}
|
|
3888
|
+
return transformedElms;
|
|
2949
3889
|
};
|
|
2950
|
-
|
|
2951
|
-
|
|
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;
|
|
2952
3901
|
};
|
|
2953
|
-
|
|
2954
|
-
|
|
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);
|
|
3911
|
+
};
|
|
3912
|
+
var doesElmMatchClassName = function(elm, className) {
|
|
3913
|
+
var _elm_port_hints;
|
|
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));
|
|
3915
|
+
};
|
|
3916
|
+
var applySelectorAST = function(elements, selectorAST) {
|
|
3917
|
+
switch(selectorAST.type){
|
|
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
|
+
}
|
|
2955
3993
|
};
|
|
2956
|
-
module2.exports = convert;
|
|
2957
3994
|
}
|
|
2958
3995
|
});
|
|
2959
3996
|
// node_modules/use-mouse-matrix-transform/dist/index.js
|
|
2960
|
-
var
|
|
3997
|
+
var require_dist2 = __commonJS({
|
|
2961
3998
|
"node_modules/use-mouse-matrix-transform/dist/index.js": function(exports2, module2) {
|
|
2962
3999
|
"use strict";
|
|
2963
4000
|
var __defProp2 = Object.defineProperty;
|
|
@@ -3016,7 +4053,7 @@ var require_dist = __commonJS({
|
|
|
3016
4053
|
}
|
|
3017
4054
|
});
|
|
3018
4055
|
module2.exports = __toCommonJS2(src_exports2);
|
|
3019
|
-
var
|
|
4056
|
+
var import_transformation_matrix10 = require("transformation-matrix");
|
|
3020
4057
|
var import_react21 = require("react");
|
|
3021
4058
|
var useMouseMatrixTransform2 = function() {
|
|
3022
4059
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
@@ -3025,7 +4062,7 @@ var require_dist = __commonJS({
|
|
|
3025
4062
|
var _props_canvasElm;
|
|
3026
4063
|
var outerCanvasElm = (_props_canvasElm = props.canvasElm) !== null && _props_canvasElm !== void 0 ? _props_canvasElm : extRef.current;
|
|
3027
4064
|
var _props_initialTransform;
|
|
3028
|
-
var _ref1 = _sliced_to_array((0, import_react21.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0,
|
|
4065
|
+
var _ref1 = _sliced_to_array((0, import_react21.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0, import_transformation_matrix10.identity)()), 2), internalTransform = _ref1[0], setInternalTransform = _ref1[1];
|
|
3029
4066
|
var _ref2 = _sliced_to_array((0, import_react21.useState)(0), 2), waitCounter = _ref2[0], setWaitCounter = _ref2[1];
|
|
3030
4067
|
var _ref3 = _sliced_to_array((0, import_react21.useReducer)(function(s) {
|
|
3031
4068
|
return s + 1;
|
|
@@ -3062,7 +4099,7 @@ var require_dist = __commonJS({
|
|
|
3062
4099
|
var handleMouseUp = function handleMouseUp(e) {
|
|
3063
4100
|
if (!md) return;
|
|
3064
4101
|
m1 = getMousePos(e);
|
|
3065
|
-
var new_tf = (0,
|
|
4102
|
+
var new_tf = (0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
|
|
3066
4103
|
setTransform(new_tf);
|
|
3067
4104
|
init_tf = new_tf;
|
|
3068
4105
|
md = false;
|
|
@@ -3071,11 +4108,11 @@ var require_dist = __commonJS({
|
|
|
3071
4108
|
mlastrel = getMousePos(e);
|
|
3072
4109
|
if (!md) return;
|
|
3073
4110
|
m1 = getMousePos(e);
|
|
3074
|
-
setTransform((0,
|
|
4111
|
+
setTransform((0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(m1.x - m0.x, m1.y - m0.y), init_tf));
|
|
3075
4112
|
};
|
|
3076
4113
|
var handleMouseWheel = function handleMouseWheel(e) {
|
|
3077
4114
|
var center = getMousePos(e);
|
|
3078
|
-
var new_tf = (0,
|
|
4115
|
+
var new_tf = (0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(center.x, center.y), (0, import_transformation_matrix10.scale)(1 - e.deltaY / 1e3, 1 - e.deltaY / 1e3), (0, import_transformation_matrix10.translate)(-center.x, -center.y), init_tf);
|
|
3079
4116
|
setTransform(new_tf);
|
|
3080
4117
|
init_tf = new_tf;
|
|
3081
4118
|
e.preventDefault();
|
|
@@ -3090,7 +4127,7 @@ var require_dist = __commonJS({
|
|
|
3090
4127
|
}
|
|
3091
4128
|
md = false;
|
|
3092
4129
|
m1 = getMousePos(e);
|
|
3093
|
-
var new_tf = (0,
|
|
4130
|
+
var new_tf = (0, import_transformation_matrix10.compose)((0, import_transformation_matrix10.translate)(m1.x - m0.x, m1.y - m0.y), init_tf);
|
|
3094
4131
|
setTransform(new_tf);
|
|
3095
4132
|
init_tf = new_tf;
|
|
3096
4133
|
};
|
|
@@ -3145,7 +4182,7 @@ var require_dist = __commonJS({
|
|
|
3145
4182
|
lastDragCancelTime
|
|
3146
4183
|
]);
|
|
3147
4184
|
var applyTransformToPoint = (0, import_react21.useCallback)(function(obj) {
|
|
3148
|
-
return (0,
|
|
4185
|
+
return (0, import_transformation_matrix10.applyToPoint)(transform, obj);
|
|
3149
4186
|
}, [
|
|
3150
4187
|
transform
|
|
3151
4188
|
]);
|
|
@@ -3176,6 +4213,8 @@ __export(src_exports, {
|
|
|
3176
4213
|
module.exports = __toCommonJS(src_exports);
|
|
3177
4214
|
// src/PCBViewer.tsx
|
|
3178
4215
|
var import_react20 = require("react");
|
|
4216
|
+
var import_react_fiber = require("@tscircuit/react-fiber");
|
|
4217
|
+
var import_builder = require("@tscircuit/builder");
|
|
3179
4218
|
// src/components/CanvasElementsRenderer.tsx
|
|
3180
4219
|
var import_react16 = require("react");
|
|
3181
4220
|
// src/components/CanvasPrimitiveRenderer.tsx
|
|
@@ -4103,240 +5142,6 @@ var useGlobalStore = function(s) {
|
|
|
4103
5142
|
return (0, import_zustand.useStore)(store, s);
|
|
4104
5143
|
};
|
|
4105
5144
|
// 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
|
-
});
|
|
4340
5145
|
var import_convert_units = __toESM(require_lib(), 1);
|
|
4341
5146
|
// node_modules/zod/lib/index.mjs
|
|
4342
5147
|
var util;
|
|
@@ -4835,8 +5640,8 @@ var makeIssue = function(params) {
|
|
|
4835
5640
|
});
|
|
4836
5641
|
}
|
|
4837
5642
|
var errorMessage = "";
|
|
4838
|
-
var maps = errorMaps.filter(function(
|
|
4839
|
-
return !!
|
|
5643
|
+
var maps = errorMaps.filter(function(m) {
|
|
5644
|
+
return !!m;
|
|
4840
5645
|
}).slice().reverse();
|
|
4841
5646
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4842
5647
|
try {
|
|
@@ -10685,13 +11490,11 @@ var point = z.object({
|
|
|
10685
11490
|
x: distance,
|
|
10686
11491
|
y: distance
|
|
10687
11492
|
});
|
|
10688
|
-
var position = point;
|
|
10689
11493
|
var point3 = z.object({
|
|
10690
11494
|
x: distance,
|
|
10691
11495
|
y: distance,
|
|
10692
11496
|
z: distance
|
|
10693
11497
|
});
|
|
10694
|
-
var position3 = point3;
|
|
10695
11498
|
var size = z.object({
|
|
10696
11499
|
width: z.number(),
|
|
10697
11500
|
height: z.number()
|
|
@@ -11394,7 +12197,6 @@ var any_circuit_element = z.union([
|
|
|
11394
12197
|
schematic_net_label,
|
|
11395
12198
|
cad_component
|
|
11396
12199
|
]);
|
|
11397
|
-
var any_soup_element = any_circuit_element;
|
|
11398
12200
|
// src/components/CanvasPrimitiveRenderer.tsx
|
|
11399
12201
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
11400
12202
|
var CanvasPrimitiveRenderer = function(param) {
|
|
@@ -11464,275 +12266,8 @@ var CanvasPrimitiveRenderer = function(param) {
|
|
|
11464
12266
|
};
|
|
11465
12267
|
// src/components/CanvasElementsRenderer.tsx
|
|
11466
12268
|
var import_react17 = require("react");
|
|
11467
|
-
//
|
|
11468
|
-
var
|
|
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
|
-
};
|
|
12269
|
+
// src/lib/convert-element-to-primitive.ts
|
|
12270
|
+
var import_soup_util = __toESM(require_dist());
|
|
11736
12271
|
// src/lib/util/expand-stroke.ts
|
|
11737
12272
|
function getExpandedStroke(strokeInput, defaultWidth) {
|
|
11738
12273
|
if (strokeInput.length < 2) {
|
|
@@ -11814,14 +12349,14 @@ function getExpandedStroke(strokeInput, defaultWidth) {
|
|
|
11814
12349
|
// src/lib/convert-element-to-primitive.ts
|
|
11815
12350
|
var globalPcbDrawingObjectCount = 0;
|
|
11816
12351
|
var convertElementToPrimitives = function(element, allElements) {
|
|
11817
|
-
var
|
|
12352
|
+
var _pcb_port_get;
|
|
11818
12353
|
var _parent_pcb_component = "pcb_component_id" in element ? allElements.find(function(elm) {
|
|
11819
12354
|
return elm.type === "pcb_component" && elm.pcb_component_id === element.pcb_component_id;
|
|
11820
12355
|
}) : void 0;
|
|
11821
12356
|
var _parent_source_component = _parent_pcb_component && "source_component_id" in _parent_pcb_component ? allElements.find(function(elm) {
|
|
11822
12357
|
return elm.type === "source_component" && elm.source_component_id === _parent_pcb_component.source_component_id;
|
|
11823
12358
|
}) : void 0;
|
|
11824
|
-
var _source_port_id = "source_port_id" in element ? element.source_port_id : "pcb_port_id" in element ? (
|
|
12359
|
+
var _source_port_id = "source_port_id" in element ? element.source_port_id : "pcb_port_id" in element ? (_pcb_port_get = (0, import_soup_util.su)(allElements).pcb_port.get(element.pcb_port_id)) === null || _pcb_port_get === void 0 ? void 0 : _pcb_port_get.source_port_id : void 0;
|
|
11825
12360
|
var _source_port = _source_port_id ? allElements.find(function(e) {
|
|
11826
12361
|
return e.type === "source_port" && e.source_port_id === _source_port_id;
|
|
11827
12362
|
}) : void 0;
|
|
@@ -12341,7 +12876,7 @@ var convertElementToPrimitives = function(element, allElements) {
|
|
|
12341
12876
|
// src/components/MouseElementTracker.tsx
|
|
12342
12877
|
var import_react6 = require("react");
|
|
12343
12878
|
var import_react7 = require("react");
|
|
12344
|
-
var
|
|
12879
|
+
var import_transformation_matrix2 = require("transformation-matrix");
|
|
12345
12880
|
// src/components/ElementOverlayBox.tsx
|
|
12346
12881
|
var import_react5 = require("react");
|
|
12347
12882
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -12479,7 +13014,7 @@ var MouseElementTracker = function(param) {
|
|
|
12479
13014
|
if (((_primitive__element = primitive._element) === null || _primitive__element === void 0 ? void 0 : _primitive__element.type) === "pcb_via") return "continue";
|
|
12480
13015
|
if (((_primitive__element1 = primitive._element) === null || _primitive__element1 === void 0 ? void 0 : _primitive__element1.type) === "pcb_component") return "continue";
|
|
12481
13016
|
if ((primitive === null || primitive === void 0 ? void 0 : primitive.layer) === "drill") return "continue";
|
|
12482
|
-
var screenPos = (0,
|
|
13017
|
+
var screenPos = (0, import_transformation_matrix2.applyToPoint)(transform, primitive);
|
|
12483
13018
|
var w = "w" in primitive ? primitive.w : "r" in primitive ? primitive.r * 2 : 0;
|
|
12484
13019
|
var h = "h" in primitive ? primitive.h : "r" in primitive ? primitive.r * 2 : 0;
|
|
12485
13020
|
var screenSize = {
|
|
@@ -12526,7 +13061,7 @@ var MouseElementTracker = function(param) {
|
|
|
12526
13061
|
var rect = e.currentTarget.getBoundingClientRect();
|
|
12527
13062
|
var x = e.clientX - rect.left;
|
|
12528
13063
|
var y = e.clientY - rect.top;
|
|
12529
|
-
var rwPoint = (0,
|
|
13064
|
+
var rwPoint = (0, import_transformation_matrix2.applyToPoint)((0, import_transformation_matrix2.inverse)(transform), {
|
|
12530
13065
|
x: x,
|
|
12531
13066
|
y: y
|
|
12532
13067
|
});
|
|
@@ -12578,11 +13113,11 @@ var MouseElementTracker = function(param) {
|
|
|
12578
13113
|
};
|
|
12579
13114
|
// src/components/DimensionOverlay.tsx
|
|
12580
13115
|
var import_react8 = require("react");
|
|
12581
|
-
var
|
|
13116
|
+
var import_transformation_matrix3 = require("transformation-matrix");
|
|
12582
13117
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
12583
13118
|
var DimensionOverlay = function(param) {
|
|
12584
13119
|
var children = param.children, transform = param.transform;
|
|
12585
|
-
if (!transform) transform = (0,
|
|
13120
|
+
if (!transform) transform = (0, import_transformation_matrix3.identity)();
|
|
12586
13121
|
var _ref = _sliced_to_array((0, import_react8.useState)(false), 2), dimensionToolVisible = _ref[0], setDimensionToolVisible = _ref[1];
|
|
12587
13122
|
var _ref1 = _sliced_to_array((0, import_react8.useState)(false), 2), dimensionToolStretching = _ref1[0], setDimensionToolStretching = _ref1[1];
|
|
12588
13123
|
var _ref2 = _sliced_to_array((0, import_react8.useState)({
|
|
@@ -12650,8 +13185,8 @@ var DimensionOverlay = function(param) {
|
|
|
12650
13185
|
}, [
|
|
12651
13186
|
containerRef
|
|
12652
13187
|
]);
|
|
12653
|
-
var screenDStart = (0,
|
|
12654
|
-
var screenDEnd = (0,
|
|
13188
|
+
var screenDStart = (0, import_transformation_matrix3.applyToPoint)(transform, dStart);
|
|
13189
|
+
var screenDEnd = (0, import_transformation_matrix3.applyToPoint)(transform, dEnd);
|
|
12655
13190
|
var arrowScreenBounds = {
|
|
12656
13191
|
left: Math.min(screenDStart.x, screenDEnd.x),
|
|
12657
13192
|
right: Math.max(screenDStart.x, screenDEnd.x),
|
|
@@ -12684,7 +13219,7 @@ var DimensionOverlay = function(param) {
|
|
|
12684
13219
|
var rect = e.currentTarget.getBoundingClientRect();
|
|
12685
13220
|
var x = e.clientX - rect.left;
|
|
12686
13221
|
var y = e.clientY - rect.top;
|
|
12687
|
-
var rwPoint = (0,
|
|
13222
|
+
var rwPoint = (0, import_transformation_matrix3.applyToPoint)((0, import_transformation_matrix3.inverse)(transform), {
|
|
12688
13223
|
x: x,
|
|
12689
13224
|
y: y
|
|
12690
13225
|
});
|
|
@@ -12846,7 +13381,7 @@ var import_css = require("@emotion/css");
|
|
|
12846
13381
|
// package.json
|
|
12847
13382
|
var package_default = {
|
|
12848
13383
|
name: "@tscircuit/pcb-viewer",
|
|
12849
|
-
version: "1.10.
|
|
13384
|
+
version: "1.10.10",
|
|
12850
13385
|
main: "dist/index.js",
|
|
12851
13386
|
repository: "tscircuit/pcb-viewer",
|
|
12852
13387
|
license: "MIT",
|
|
@@ -12869,10 +13404,12 @@ var package_default = {
|
|
|
12869
13404
|
"@storybook/nextjs": "^8.0.6",
|
|
12870
13405
|
"@storybook/react": "^8.0.6",
|
|
12871
13406
|
"@swc/core": "^1.4.12",
|
|
12872
|
-
"@tscircuit/
|
|
13407
|
+
"@tscircuit/builder": "^1.11.4",
|
|
13408
|
+
"@tscircuit/core": "^0.0.88",
|
|
12873
13409
|
"@tscircuit/eagle-xml-converter": "^0.0.6",
|
|
12874
13410
|
"@tscircuit/props": "^0.0.46",
|
|
12875
|
-
"@tscircuit/
|
|
13411
|
+
"@tscircuit/react-fiber": "^1.1.25",
|
|
13412
|
+
"@tscircuit/soup-util": "^0.0.13",
|
|
12876
13413
|
"@types/color": "^3.0.6",
|
|
12877
13414
|
"@types/node": "18.7.23",
|
|
12878
13415
|
"@types/react": "^18.3.3",
|
|
@@ -12889,8 +13426,9 @@ var package_default = {
|
|
|
12889
13426
|
zod: "^3.23.5"
|
|
12890
13427
|
},
|
|
12891
13428
|
peerDependencies: {
|
|
12892
|
-
|
|
12893
|
-
"@tscircuit/
|
|
13429
|
+
"@tscircuit/builder": "*",
|
|
13430
|
+
"@tscircuit/react-fiber": "*",
|
|
13431
|
+
react: "*"
|
|
12894
13432
|
},
|
|
12895
13433
|
dependencies: {
|
|
12896
13434
|
"@emotion/css": "^11.11.2",
|
|
@@ -13207,7 +13745,7 @@ var ToolbarOverlay = function(param) {
|
|
|
13207
13745
|
// src/components/ErrorOverlay.tsx
|
|
13208
13746
|
var import_css2 = require("@emotion/css");
|
|
13209
13747
|
var import_react11 = require("react");
|
|
13210
|
-
var
|
|
13748
|
+
var import_transformation_matrix4 = require("transformation-matrix");
|
|
13211
13749
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
13212
13750
|
var ErrorSVG = function(param) {
|
|
13213
13751
|
var screenPort1 = param.screenPort1, screenPort2 = param.screenPort2, errorCenter = param.errorCenter, canLineBeDrawn = param.canLineBeDrawn;
|
|
@@ -13256,7 +13794,7 @@ var ErrorSVG = function(param) {
|
|
|
13256
13794
|
};
|
|
13257
13795
|
var ErrorOverlay = function(param) {
|
|
13258
13796
|
var children = param.children, transform = param.transform, elements = param.elements;
|
|
13259
|
-
if (!transform) transform = (0,
|
|
13797
|
+
if (!transform) transform = (0, import_transformation_matrix4.identity)();
|
|
13260
13798
|
var containerRef = (0, import_react11.useRef)(null);
|
|
13261
13799
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
|
|
13262
13800
|
style: {
|
|
@@ -13276,11 +13814,11 @@ var ErrorOverlay = function(param) {
|
|
|
13276
13814
|
return el2.type === "pcb_port" && el2.pcb_port_id === (pcb_port_ids === null || pcb_port_ids === void 0 ? void 0 : pcb_port_ids[1]);
|
|
13277
13815
|
});
|
|
13278
13816
|
if (!port1 || !port2) return null;
|
|
13279
|
-
var screenPort1 = (0,
|
|
13817
|
+
var screenPort1 = (0, import_transformation_matrix4.applyToPoint)(transform, {
|
|
13280
13818
|
x: port1.x,
|
|
13281
13819
|
y: port1.y
|
|
13282
13820
|
});
|
|
13283
|
-
var screenPort2 = (0,
|
|
13821
|
+
var screenPort2 = (0, import_transformation_matrix4.applyToPoint)(transform, {
|
|
13284
13822
|
x: port2.x,
|
|
13285
13823
|
y: port2.y
|
|
13286
13824
|
});
|
|
@@ -13320,7 +13858,7 @@ var ErrorOverlay = function(param) {
|
|
|
13320
13858
|
};
|
|
13321
13859
|
// src/components/EditPlacementOverlay.tsx
|
|
13322
13860
|
var import_react12 = require("react");
|
|
13323
|
-
var
|
|
13861
|
+
var import_transformation_matrix5 = require("transformation-matrix");
|
|
13324
13862
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
13325
13863
|
var isInsideOf = function(pcb_component2, point2) {
|
|
13326
13864
|
var padding = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
|
|
@@ -13334,7 +13872,7 @@ var isInsideOf = function(pcb_component2, point2) {
|
|
|
13334
13872
|
};
|
|
13335
13873
|
var EditPlacementOverlay = function(param) {
|
|
13336
13874
|
var children = param.children, disabledProp = param.disabled, transform = param.transform, soup = param.soup, cancelPanDrag = param.cancelPanDrag, onCreateEditEvent = param.onCreateEditEvent, onModifyEditEvent = param.onModifyEditEvent;
|
|
13337
|
-
if (!transform) transform = (0,
|
|
13875
|
+
if (!transform) transform = (0, import_transformation_matrix5.identity)();
|
|
13338
13876
|
var containerRef = (0, import_react12.useRef)(null);
|
|
13339
13877
|
var _ref = _sliced_to_array((0, import_react12.useState)(null), 2), activePcbComponentId = _ref[0], setActivePcbComponent = _ref[1];
|
|
13340
13878
|
var _ref1 = _sliced_to_array((0, import_react12.useState)(null), 2), dragState = _ref1[0], setDragState = _ref1[1];
|
|
@@ -13361,7 +13899,7 @@ var EditPlacementOverlay = function(param) {
|
|
|
13361
13899
|
var x = e.clientX - rect.left;
|
|
13362
13900
|
var y = e.clientY - rect.top;
|
|
13363
13901
|
if (isNaN(x) || isNaN(y)) return;
|
|
13364
|
-
var rwMousePoint = (0,
|
|
13902
|
+
var rwMousePoint = (0, import_transformation_matrix5.applyToPoint)((0, import_transformation_matrix5.inverse)(transform), {
|
|
13365
13903
|
x: x,
|
|
13366
13904
|
y: y
|
|
13367
13905
|
});
|
|
@@ -13422,7 +13960,7 @@ var EditPlacementOverlay = function(param) {
|
|
|
13422
13960
|
var x = e.clientX - rect.left;
|
|
13423
13961
|
var y = e.clientY - rect.top;
|
|
13424
13962
|
if (isNaN(x) || isNaN(y)) return;
|
|
13425
|
-
var rwMousePoint = (0,
|
|
13963
|
+
var rwMousePoint = (0, import_transformation_matrix5.applyToPoint)((0, import_transformation_matrix5.inverse)(transform), {
|
|
13426
13964
|
x: x,
|
|
13427
13965
|
y: y
|
|
13428
13966
|
});
|
|
@@ -13455,7 +13993,7 @@ var EditPlacementOverlay = function(param) {
|
|
|
13455
13993
|
return e.type === "pcb_component";
|
|
13456
13994
|
}).map(function(e) {
|
|
13457
13995
|
if (!(e === null || e === void 0 ? void 0 : e.center)) return null;
|
|
13458
|
-
var projectedCenter = (0,
|
|
13996
|
+
var projectedCenter = (0, import_transformation_matrix5.applyToPoint)(transform, e.center);
|
|
13459
13997
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
|
|
13460
13998
|
style: {
|
|
13461
13999
|
position: "absolute",
|
|
@@ -13474,8 +14012,9 @@ var EditPlacementOverlay = function(param) {
|
|
|
13474
14012
|
});
|
|
13475
14013
|
};
|
|
13476
14014
|
// src/components/EditTraceHintOverlay.tsx
|
|
14015
|
+
var import_soup_util2 = __toESM(require_dist());
|
|
13477
14016
|
var import_react15 = require("react");
|
|
13478
|
-
var
|
|
14017
|
+
var import_transformation_matrix6 = require("transformation-matrix");
|
|
13479
14018
|
// src/components/HotkeyActionMenu.tsx
|
|
13480
14019
|
var import_css3 = require("@emotion/css");
|
|
13481
14020
|
var import_react13 = require("react");
|
|
@@ -13584,7 +14123,7 @@ var isInsideOfPlatedHole = function(hole, point2) {
|
|
|
13584
14123
|
var EditTraceHintOverlay = function(param) {
|
|
13585
14124
|
var children = param.children, disabledProp = param.disabled, transform = param.transform, soup = param.soup, cancelPanDrag = param.cancelPanDrag, onCreateEditEvent = param.onCreateEditEvent, onModifyEditEvent = param.onModifyEditEvent;
|
|
13586
14125
|
var _containerRef_current;
|
|
13587
|
-
if (!transform) transform = (0,
|
|
14126
|
+
if (!transform) transform = (0, import_transformation_matrix6.identity)();
|
|
13588
14127
|
var containerRef = (0, import_react15.useRef)(null);
|
|
13589
14128
|
var containerBounds = (_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect();
|
|
13590
14129
|
var _ref = _sliced_to_array((0, import_react15.useState)(null), 2), selectedElement = _ref[0], setSelectedElement = _ref[1];
|
|
@@ -13598,8 +14137,8 @@ var EditTraceHintOverlay = function(param) {
|
|
|
13598
14137
|
var disabled = disabledProp || !in_edit_trace_mode;
|
|
13599
14138
|
var ogCenterScreen, dragEndScreen;
|
|
13600
14139
|
if ((dragState === null || dragState === void 0 ? void 0 : dragState.originalCenter) && (dragState === null || dragState === void 0 ? void 0 : dragState.dragEnd)) {
|
|
13601
|
-
ogCenterScreen = (0,
|
|
13602
|
-
dragEndScreen = (0,
|
|
14140
|
+
ogCenterScreen = (0, import_transformation_matrix6.applyToPoint)(transform, dragState === null || dragState === void 0 ? void 0 : dragState.originalCenter);
|
|
14141
|
+
dragEndScreen = (0, import_transformation_matrix6.applyToPoint)(transform, dragState === null || dragState === void 0 ? void 0 : dragState.dragEnd);
|
|
13603
14142
|
}
|
|
13604
14143
|
(0, import_react15.useEffect)(function() {
|
|
13605
14144
|
var keyDown = function keyDown(e) {
|
|
@@ -13628,7 +14167,7 @@ var EditTraceHintOverlay = function(param) {
|
|
|
13628
14167
|
var x = e.clientX - rect.left;
|
|
13629
14168
|
var y = e.clientY - rect.top;
|
|
13630
14169
|
if (isNaN(x) || isNaN(y)) return;
|
|
13631
|
-
var rwMousePoint = (0,
|
|
14170
|
+
var rwMousePoint = (0, import_transformation_matrix6.applyToPoint)((0, import_transformation_matrix6.inverse)(transform), {
|
|
13632
14171
|
x: x,
|
|
13633
14172
|
y: y
|
|
13634
14173
|
});
|
|
@@ -13693,7 +14232,7 @@ var EditTraceHintOverlay = function(param) {
|
|
|
13693
14232
|
var x = e.clientX - rect.left;
|
|
13694
14233
|
var y = e.clientY - rect.top;
|
|
13695
14234
|
if (isNaN(x) || isNaN(y)) return;
|
|
13696
|
-
var rwMousePoint = (0,
|
|
14235
|
+
var rwMousePoint = (0, import_transformation_matrix6.applyToPoint)((0, import_transformation_matrix6.inverse)(transform), {
|
|
13697
14236
|
x: x,
|
|
13698
14237
|
y: y
|
|
13699
14238
|
});
|
|
@@ -13712,14 +14251,14 @@ var EditTraceHintOverlay = function(param) {
|
|
|
13712
14251
|
var x = e.clientX - rect.left;
|
|
13713
14252
|
var y = e.clientY - rect.top;
|
|
13714
14253
|
if (isNaN(x) || isNaN(y)) return;
|
|
13715
|
-
var rwMousePoint = (0,
|
|
14254
|
+
var rwMousePoint = (0, import_transformation_matrix6.applyToPoint)((0, import_transformation_matrix6.inverse)(transform), {
|
|
13716
14255
|
x: x,
|
|
13717
14256
|
y: y
|
|
13718
14257
|
});
|
|
13719
14258
|
if (dragState) {
|
|
13720
14259
|
cancelPanDrag();
|
|
13721
14260
|
var _dragState_editEvent_route_slice_;
|
|
13722
|
-
var lastPointScreen = (0,
|
|
14261
|
+
var lastPointScreen = (0, import_transformation_matrix6.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);
|
|
13723
14262
|
var distanceFromLastPoint = Math.sqrt(Math.pow(x - lastPointScreen.x, 2) + Math.pow(y - lastPointScreen.y, 2));
|
|
13724
14263
|
if (distanceFromLastPoint < 20) {
|
|
13725
14264
|
onCreateEditEvent(_object_spread_props(_object_spread({}, dragState.editEvent), {
|
|
@@ -13757,13 +14296,13 @@ var EditTraceHintOverlay = function(param) {
|
|
|
13757
14296
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", {
|
|
13758
14297
|
stroke: "red",
|
|
13759
14298
|
d: "M ".concat(ogCenterScreen.x, " ").concat(ogCenterScreen.y, " ").concat(dragState === null || dragState === void 0 ? void 0 : dragState.editEvent.route.map(function(p) {
|
|
13760
|
-
return (0,
|
|
14299
|
+
return (0, import_transformation_matrix6.applyToPoint)(transform, p);
|
|
13761
14300
|
}).map(function(p) {
|
|
13762
14301
|
return "L ".concat(p.x, " ").concat(p.y);
|
|
13763
14302
|
}).join(" "), " L ").concat(dragEndScreen.x, " ").concat(dragEndScreen.y)
|
|
13764
14303
|
}),
|
|
13765
14304
|
dragState === null || dragState === void 0 ? void 0 : dragState.editEvent.route.map(function(r, i) {
|
|
13766
|
-
var rScreen = (0,
|
|
14305
|
+
var rScreen = (0, import_transformation_matrix6.applyToPoint)(transform, r);
|
|
13767
14306
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react15.Fragment, {
|
|
13768
14307
|
children: [
|
|
13769
14308
|
r.via && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", {
|
|
@@ -13810,8 +14349,8 @@ var EditTraceHintOverlay = function(param) {
|
|
|
13810
14349
|
return e.type === "pcb_trace_hint";
|
|
13811
14350
|
}).map(function(e) {
|
|
13812
14351
|
var route = e.route;
|
|
13813
|
-
var pcb_port2 =
|
|
13814
|
-
var pcb_port_screen = (0,
|
|
14352
|
+
var pcb_port2 = (0, import_soup_util2.su)(soup).pcb_port.get(e.pcb_port_id);
|
|
14353
|
+
var pcb_port_screen = (0, import_transformation_matrix6.applyToPoint)(transform, pcb_port2);
|
|
13815
14354
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react15.Fragment, {
|
|
13816
14355
|
children: [
|
|
13817
14356
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", {
|
|
@@ -13824,13 +14363,13 @@ var EditTraceHintOverlay = function(param) {
|
|
|
13824
14363
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", {
|
|
13825
14364
|
stroke: "red",
|
|
13826
14365
|
d: "M ".concat(pcb_port_screen.x, " ").concat(pcb_port_screen.y, " ").concat(route.map(function(r) {
|
|
13827
|
-
return (0,
|
|
14366
|
+
return (0, import_transformation_matrix6.applyToPoint)(transform, r);
|
|
13828
14367
|
}).map(function(r) {
|
|
13829
14368
|
return "L ".concat(r.x, " ").concat(r.y);
|
|
13830
14369
|
}).join(" "))
|
|
13831
14370
|
}, "path-".concat(e.pcb_port_id)),
|
|
13832
14371
|
route.map(function(r) {
|
|
13833
|
-
return _object_spread({}, r, (0,
|
|
14372
|
+
return _object_spread({}, r, (0, import_transformation_matrix6.applyToPoint)(transform, r));
|
|
13834
14373
|
}).map(function(r, i) {
|
|
13835
14374
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react15.Fragment, {
|
|
13836
14375
|
children: [
|
|
@@ -13876,7 +14415,8 @@ var EditTraceHintOverlay = function(param) {
|
|
|
13876
14415
|
});
|
|
13877
14416
|
};
|
|
13878
14417
|
// src/components/RatsNestOverlay.tsx
|
|
13879
|
-
var
|
|
14418
|
+
var import_transformation_matrix7 = require("transformation-matrix");
|
|
14419
|
+
var import_soup_util3 = __toESM(require_dist());
|
|
13880
14420
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
13881
14421
|
var RatsNestOverlay = function(param) {
|
|
13882
14422
|
var transform = param.transform, soup = param.soup, children = param.children;
|
|
@@ -13884,14 +14424,14 @@ var RatsNestOverlay = function(param) {
|
|
|
13884
14424
|
return s.is_showing_rats_nest;
|
|
13885
14425
|
});
|
|
13886
14426
|
if (!soup || !isShowingRatsNest) return children;
|
|
13887
|
-
if (!transform) transform = (0,
|
|
13888
|
-
var sourceTraces =
|
|
14427
|
+
if (!transform) transform = (0, import_transformation_matrix7.identity)();
|
|
14428
|
+
var sourceTraces = (0, import_soup_util3.su)(soup).source_trace.list();
|
|
13889
14429
|
var groups = [];
|
|
13890
14430
|
sourceTraces.forEach(function(sourceTrace) {
|
|
13891
14431
|
if (sourceTrace.connected_source_port_ids) {
|
|
13892
14432
|
var group = [];
|
|
13893
14433
|
sourceTrace.connected_source_port_ids.forEach(function(source_port_id) {
|
|
13894
|
-
var pcbPort =
|
|
14434
|
+
var pcbPort = (0, import_soup_util3.su)(soup).pcb_port.getWhere({
|
|
13895
14435
|
source_port_id: source_port_id
|
|
13896
14436
|
});
|
|
13897
14437
|
if (pcbPort) group.push(pcbPort);
|
|
@@ -13918,7 +14458,7 @@ var RatsNestOverlay = function(param) {
|
|
|
13918
14458
|
},
|
|
13919
14459
|
children: groups.map(function(group, index) {
|
|
13920
14460
|
var points = group.map(function(port) {
|
|
13921
|
-
return (0,
|
|
14461
|
+
return (0, import_transformation_matrix7.applyToPoint)(transform, {
|
|
13922
14462
|
x: port.x,
|
|
13923
14463
|
y: port.y
|
|
13924
14464
|
});
|
|
@@ -14085,7 +14625,7 @@ var CanvasElementsRenderer = function(props) {
|
|
|
14085
14625
|
});
|
|
14086
14626
|
};
|
|
14087
14627
|
// src/PCBViewer.tsx
|
|
14088
|
-
var import_use_mouse_matrix_transform = __toESM(
|
|
14628
|
+
var import_use_mouse_matrix_transform = __toESM(require_dist2());
|
|
14089
14629
|
// node_modules/react-use/esm/misc/util.js
|
|
14090
14630
|
var noop = function noop() {};
|
|
14091
14631
|
var isBrowser = typeof window !== "undefined";
|
|
@@ -14146,10 +14686,13 @@ var useMeasure_default = isBrowser && typeof window.ResizeObserver !== "undefine
|
|
|
14146
14686
|
];
|
|
14147
14687
|
};
|
|
14148
14688
|
// src/PCBViewer.tsx
|
|
14149
|
-
var import_transformation_matrix10 = require("transformation-matrix");
|
|
14150
|
-
// src/lib/apply-edit-events.ts
|
|
14151
14689
|
var import_transformation_matrix9 = require("transformation-matrix");
|
|
14690
|
+
var import_builder2 = require("@tscircuit/builder");
|
|
14691
|
+
// src/lib/apply-edit-events.ts
|
|
14692
|
+
var import_soup_util5 = __toESM(require_dist());
|
|
14693
|
+
var import_transformation_matrix8 = require("transformation-matrix");
|
|
14152
14694
|
// src/lib/apply-edit-events/apply-edit-trace-hint-event.ts
|
|
14695
|
+
var import_soup_util4 = __toESM(require_dist());
|
|
14153
14696
|
var applyTraceHintEditEvent = function(soup, edit_event) {
|
|
14154
14697
|
var existing_trace_hint = soup.find(function(th) {
|
|
14155
14698
|
return th.type === "pcb_trace_hint" && th.pcb_trace_hint_id === edit_event.pcb_trace_hint_id;
|
|
@@ -14161,7 +14704,7 @@ var applyTraceHintEditEvent = function(soup, edit_event) {
|
|
|
14161
14704
|
}) : e;
|
|
14162
14705
|
});
|
|
14163
14706
|
} else {
|
|
14164
|
-
var pcb_port2 =
|
|
14707
|
+
var pcb_port2 = (0, import_soup_util4.su)(soup).pcb_port.get(edit_event.pcb_port_id);
|
|
14165
14708
|
soup = soup.filter(function(e) {
|
|
14166
14709
|
return !(e.type === "pcb_trace_hint" && e.pcb_port_id === edit_event.pcb_port_id);
|
|
14167
14710
|
}).concat([
|
|
@@ -14184,9 +14727,9 @@ var applyEditEvents = function(soup, edit_events) {
|
|
|
14184
14727
|
var _loop = function() {
|
|
14185
14728
|
var edit_event = _step.value;
|
|
14186
14729
|
if (edit_event.pcb_edit_event_type === "edit_component_location") {
|
|
14187
|
-
var mat = (0,
|
|
14730
|
+
var mat = (0, import_transformation_matrix8.translate)(edit_event.new_center.x - edit_event.original_center.x, edit_event.new_center.y - edit_event.original_center.y);
|
|
14188
14731
|
soup = soup.map(function(e) {
|
|
14189
|
-
return e.pcb_component_id !== edit_event.pcb_component_id ? e : transformPCBElement(e, mat);
|
|
14732
|
+
return e.pcb_component_id !== edit_event.pcb_component_id ? e : (0, import_soup_util5.transformPCBElement)(e, mat);
|
|
14190
14733
|
});
|
|
14191
14734
|
} else if (edit_event.pcb_edit_event_type === "edit_trace_hint") {
|
|
14192
14735
|
soup = applyTraceHintEditEvent(soup, edit_event);
|
|
@@ -14210,28 +14753,20 @@ var applyEditEvents = function(soup, edit_events) {
|
|
|
14210
14753
|
return soup;
|
|
14211
14754
|
};
|
|
14212
14755
|
// src/PCBViewer.tsx
|
|
14213
|
-
var import_core = require("@tscircuit/core");
|
|
14214
14756
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
14215
|
-
var defaultTransform = (0,
|
|
14757
|
+
var defaultTransform = (0, import_transformation_matrix9.compose)((0, import_transformation_matrix9.translate)(400, 300), (0, import_transformation_matrix9.scale)(40, -40));
|
|
14216
14758
|
var PCBViewer = function(param) {
|
|
14217
14759
|
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;
|
|
14218
|
-
var _ref = (0,
|
|
14219
|
-
var _ref1;
|
|
14220
|
-
var stateElements = (_ref1 = circuitJsonFromChildren !== null && circuitJsonFromChildren !== void 0 ? circuitJsonFromChildren : soup) !== null && _ref1 !== void 0 ? _ref1 : [];
|
|
14760
|
+
var _ref = _sliced_to_array((0, import_react20.useState)([]), 2), stateElements = _ref[0], setStateElements = _ref[1];
|
|
14221
14761
|
var _useMeasure_default = _sliced_to_array(useMeasure_default(), 2), ref = _useMeasure_default[0], refDimensions = _useMeasure_default[1];
|
|
14222
|
-
var
|
|
14223
|
-
var
|
|
14762
|
+
var _ref1 = _sliced_to_array((0, import_react20.useState)(defaultTransform), 2), transform = _ref1[0], setTransformInternal = _ref1[1];
|
|
14763
|
+
var _ref2 = (0, import_use_mouse_matrix_transform.default)({
|
|
14224
14764
|
transform: transform,
|
|
14225
14765
|
onSetTransform: setTransformInternal
|
|
14226
|
-
}), transformRef =
|
|
14227
|
-
var
|
|
14766
|
+
}), transformRef = _ref2.ref, setTransform = _ref2.setTransform, cancelPanDrag = _ref2.cancelDrag;
|
|
14767
|
+
var _ref3 = _sliced_to_array((0, import_react20.useState)([]), 2), editEvents = _ref3[0], setEditEvents = _ref3[1];
|
|
14228
14768
|
editEvents = editEventsProp !== null && editEventsProp !== void 0 ? editEventsProp : editEvents;
|
|
14229
|
-
var
|
|
14230
|
-
(0, import_react20.useEffect)(function() {
|
|
14231
|
-
setError(errorFromChildren ? errorFromChildren.toString() : null);
|
|
14232
|
-
}, [
|
|
14233
|
-
errorFromChildren
|
|
14234
|
-
]);
|
|
14769
|
+
var _ref4 = _sliced_to_array((0, import_react20.useState)(null), 2), error = _ref4[0], setError = _ref4[1];
|
|
14235
14770
|
var resetTransform = function() {
|
|
14236
14771
|
var elmBounds = (refDimensions === null || refDimensions === void 0 ? void 0 : refDimensions.width) > 0 ? refDimensions : {
|
|
14237
14772
|
width: 500,
|
|
@@ -14239,26 +14774,58 @@ var PCBViewer = function(param) {
|
|
|
14239
14774
|
};
|
|
14240
14775
|
var _ref = elements.some(function(e) {
|
|
14241
14776
|
return e.type.startsWith("pcb_");
|
|
14242
|
-
}) ?
|
|
14777
|
+
}) ? (0, import_builder2.findBoundsAndCenter)(elements.filter(function(e) {
|
|
14243
14778
|
return e.type.startsWith("pcb_");
|
|
14244
14779
|
})) : {
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
var center = {
|
|
14253
|
-
x: (minX + maxX) / 2,
|
|
14254
|
-
y: (minY + maxY) / 2
|
|
14255
|
-
};
|
|
14780
|
+
center: {
|
|
14781
|
+
x: 0,
|
|
14782
|
+
y: 0
|
|
14783
|
+
},
|
|
14784
|
+
width: 1e-3,
|
|
14785
|
+
height: 1e-3
|
|
14786
|
+
}, center = _ref.center, width = _ref.width, height2 = _ref.height;
|
|
14256
14787
|
var _elmBounds_width, _elmBounds_height;
|
|
14257
14788
|
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;
|
|
14258
14789
|
var _elmBounds_width1, _elmBounds_height1;
|
|
14259
|
-
setTransform((0,
|
|
14260
|
-
(0,
|
|
14790
|
+
setTransform((0, import_transformation_matrix9.compose)((0, import_transformation_matrix9.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),
|
|
14791
|
+
(0, import_transformation_matrix9.scale)(scaleFactor, -scaleFactor, 0, 0), (0, import_transformation_matrix9.translate)(-center.x, -center.y)));
|
|
14261
14792
|
};
|
|
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
|
+
]);
|
|
14262
14829
|
(0, import_react20.useEffect)(function() {
|
|
14263
14830
|
if (refDimensions && refDimensions.width !== 0 && (children || soup)) {
|
|
14264
14831
|
resetTransform();
|