@tscircuit/3d-viewer 0.0.339 → 0.0.341

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.
Files changed (2) hide show
  1. package/dist/index.js +55 -58
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -14670,38 +14670,6 @@ import { z as z2 } from "zod";
14670
14670
  import { z as z3 } from "zod";
14671
14671
  import { z as z4 } from "zod";
14672
14672
  import { z as z5 } from "zod";
14673
-
14674
- // node_modules/nanoid/index.js
14675
- import { webcrypto as crypto } from "crypto";
14676
-
14677
- // node_modules/nanoid/url-alphabet/index.js
14678
- var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
14679
-
14680
- // node_modules/nanoid/index.js
14681
- var POOL_SIZE_MULTIPLIER = 128;
14682
- var pool;
14683
- var poolOffset;
14684
- function fillPool(bytes) {
14685
- if (!pool || pool.length < bytes) {
14686
- pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
14687
- crypto.getRandomValues(pool);
14688
- poolOffset = 0;
14689
- } else if (poolOffset + bytes > pool.length) {
14690
- crypto.getRandomValues(pool);
14691
- poolOffset = 0;
14692
- }
14693
- poolOffset += bytes;
14694
- }
14695
- function nanoid(size2 = 21) {
14696
- fillPool(size2 |= 0);
14697
- let id = "";
14698
- for (let i = poolOffset - size2; i < poolOffset; i++) {
14699
- id += urlAlphabet[pool[i] & 63];
14700
- }
14701
- return id;
14702
- }
14703
-
14704
- // node_modules/circuit-json/dist/index.mjs
14705
14673
  import { z as z6 } from "zod";
14706
14674
  import { z as z9 } from "zod";
14707
14675
  import { z as z7 } from "zod";
@@ -15052,8 +15020,15 @@ var size = z4.object({
15052
15020
  height: z4.number()
15053
15021
  });
15054
15022
  expectTypesMatch(true);
15023
+ var randomId = (length4) => {
15024
+ const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
15025
+ return Array.from(
15026
+ { length: length4 },
15027
+ () => chars[Math.floor(Math.random() * chars.length)]
15028
+ ).join("");
15029
+ };
15055
15030
  var getZodPrefixedIdWithDefault = (prefix) => {
15056
- return z5.string().optional().default(() => `${prefix}_${nanoid(10)}`);
15031
+ return z5.string().optional().default(() => `${prefix}_${randomId(10)}`);
15057
15032
  };
15058
15033
  var ninePointAnchor = z6.enum([
15059
15034
  "top_left",
@@ -16475,17 +16450,38 @@ var cad_component = z93.object({
16475
16450
  model_jscad: z93.any().optional()
16476
16451
  }).describe("Defines a component on the PCB");
16477
16452
  expectTypesMatch(true);
16478
- var simulation_voltage_source = z94.object({
16453
+ var wave_shape = z94.enum(["sinewave", "square", "triangle", "sawtooth"]);
16454
+ var simulation_dc_voltage_source = z94.object({
16479
16455
  type: z94.literal("simulation_voltage_source"),
16480
16456
  simulation_voltage_source_id: getZodPrefixedIdWithDefault(
16481
16457
  "simulation_voltage_source"
16482
16458
  ),
16483
- positive_source_port_id: z94.string(),
16484
- negative_source_port_id: z94.string(),
16485
- positive_source_net_id: z94.string(),
16486
- negative_source_net_id: z94.string(),
16459
+ is_dc_source: z94.literal(true).optional().default(true),
16460
+ positive_source_port_id: z94.string().optional(),
16461
+ negative_source_port_id: z94.string().optional(),
16462
+ positive_source_net_id: z94.string().optional(),
16463
+ negative_source_net_id: z94.string().optional(),
16487
16464
  voltage
16488
- }).describe("Defines a voltage source for simulation");
16465
+ }).describe("Defines a DC voltage source for simulation");
16466
+ var simulation_ac_voltage_source = z94.object({
16467
+ type: z94.literal("simulation_voltage_source"),
16468
+ simulation_voltage_source_id: getZodPrefixedIdWithDefault(
16469
+ "simulation_voltage_source"
16470
+ ),
16471
+ is_dc_source: z94.literal(false),
16472
+ terminal1_source_port_id: z94.string().optional(),
16473
+ terminal2_source_port_id: z94.string().optional(),
16474
+ terminal1_source_net_id: z94.string().optional(),
16475
+ terminal2_source_net_id: z94.string().optional(),
16476
+ voltage: voltage.optional(),
16477
+ frequency: frequency.optional(),
16478
+ peak_to_peak_voltage: voltage.optional(),
16479
+ wave_shape: wave_shape.optional(),
16480
+ phase: rotation.optional()
16481
+ }).describe("Defines an AC voltage source for simulation");
16482
+ var simulation_voltage_source = z94.union([simulation_dc_voltage_source, simulation_ac_voltage_source]).describe("Defines a voltage source for simulation");
16483
+ expectTypesMatch(true);
16484
+ expectTypesMatch(true);
16489
16485
  expectTypesMatch(true);
16490
16486
  var any_circuit_element = z95.union([
16491
16487
  source_trace,
@@ -25344,7 +25340,7 @@ import * as THREE9 from "three";
25344
25340
  // package.json
25345
25341
  var package_default = {
25346
25342
  name: "@tscircuit/3d-viewer",
25347
- version: "0.0.338",
25343
+ version: "0.0.340",
25348
25344
  main: "./dist/index.js",
25349
25345
  module: "./dist/index.js",
25350
25346
  type: "module",
@@ -25373,7 +25369,6 @@ var package_default = {
25373
25369
  dependencies: {
25374
25370
  "@jscad/regl-renderer": "^2.6.12",
25375
25371
  "@jscad/stl-serializer": "^2.1.20",
25376
- "manifold-3d": "3.1.0",
25377
25372
  three: "^0.165.0",
25378
25373
  "three-stdlib": "^2.36.0",
25379
25374
  "troika-three-text": "^0.52.4"
@@ -25402,12 +25397,13 @@ var package_default = {
25402
25397
  "@vitejs/plugin-react": "^4.3.4",
25403
25398
  "bun-match-svg": "^0.0.9",
25404
25399
  "bun-types": "1.2.1",
25405
- "circuit-json": "^0.0.230",
25400
+ "circuit-json": "^0.0.232",
25406
25401
  "circuit-to-svg": "^0.0.176",
25407
25402
  debug: "^4.4.0",
25408
25403
  "jscad-electronics": "^0.0.33",
25409
25404
  "jscad-planner": "^0.0.13",
25410
25405
  jsdom: "^26.0.0",
25406
+ "manifold-3d": "^3.2.1",
25411
25407
  "react-use-gesture": "^9.1.3",
25412
25408
  semver: "^7.7.0",
25413
25409
  "strip-ansi": "^7.1.0",
@@ -27516,7 +27512,6 @@ var CadViewerJscad = forwardRef3(
27516
27512
 
27517
27513
  // src/CadViewerManifold.tsx
27518
27514
  import { su as su13 } from "@tscircuit/circuit-json-util";
27519
- import ManifoldModule from "manifold-3d";
27520
27515
  import { useEffect as useEffect19, useMemo as useMemo19, useState as useState13 } from "react";
27521
27516
 
27522
27517
  // src/hooks/useManifoldBoardBuilder.ts
@@ -28575,22 +28570,24 @@ var CadViewerManifold = ({
28575
28570
  const [manifoldJSModule, setManifoldJSModule] = useState13(null);
28576
28571
  const [manifoldLoadingError, setManifoldLoadingError] = useState13(null);
28577
28572
  useEffect19(() => {
28578
- const loadManifoldWasmFromCDN = async () => {
28573
+ const loadManifoldFromCDN = async () => {
28579
28574
  try {
28580
- const wasmUrl = `${MANIFOLD_CDN_BASE_URL}/manifold.wasm`;
28581
- const manifoldConfig = {
28582
- locateFile: (path, scriptDirectory) => {
28583
- if (path === "manifold.wasm") {
28584
- return wasmUrl;
28585
- }
28586
- return scriptDirectory + path;
28587
- }
28588
- };
28589
- const loadedModule = await ManifoldModule(
28590
- manifoldConfig
28575
+ const manifoldURL = `${MANIFOLD_CDN_BASE_URL}/manifold.js`;
28576
+ const { default: ManifoldModule } = await import(
28577
+ /* @vite-ignore */
28578
+ manifoldURL
28591
28579
  );
28592
- loadedModule.setup();
28593
- setManifoldJSModule(loadedModule);
28580
+ if (ManifoldModule) {
28581
+ const loadedModule = await ManifoldModule({
28582
+ locateFile: () => `${MANIFOLD_CDN_BASE_URL}/manifold.wasm`
28583
+ });
28584
+ loadedModule.setup();
28585
+ setManifoldJSModule(loadedModule);
28586
+ } else {
28587
+ throw new Error(
28588
+ "ManifoldModule not found in dynamically imported module"
28589
+ );
28590
+ }
28594
28591
  } catch (error) {
28595
28592
  console.error("Failed to load Manifold from CDN:", error);
28596
28593
  setManifoldLoadingError(
@@ -28598,7 +28595,7 @@ var CadViewerManifold = ({
28598
28595
  );
28599
28596
  }
28600
28597
  };
28601
- loadManifoldWasmFromCDN();
28598
+ loadManifoldFromCDN();
28602
28599
  }, []);
28603
28600
  const {
28604
28601
  geoms,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.339",
3
+ "version": "0.0.341",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -29,7 +29,6 @@
29
29
  "dependencies": {
30
30
  "@jscad/regl-renderer": "^2.6.12",
31
31
  "@jscad/stl-serializer": "^2.1.20",
32
- "manifold-3d": "3.1.0",
33
32
  "three": "^0.165.0",
34
33
  "three-stdlib": "^2.36.0",
35
34
  "troika-three-text": "^0.52.4"
@@ -58,12 +57,13 @@
58
57
  "@vitejs/plugin-react": "^4.3.4",
59
58
  "bun-match-svg": "^0.0.9",
60
59
  "bun-types": "1.2.1",
61
- "circuit-json": "^0.0.230",
60
+ "circuit-json": "^0.0.232",
62
61
  "circuit-to-svg": "^0.0.176",
63
62
  "debug": "^4.4.0",
64
63
  "jscad-electronics": "^0.0.33",
65
64
  "jscad-planner": "^0.0.13",
66
65
  "jsdom": "^26.0.0",
66
+ "manifold-3d": "^3.2.1",
67
67
  "react-use-gesture": "^9.1.3",
68
68
  "semver": "^7.7.0",
69
69
  "strip-ansi": "^7.1.0",