diff --git a/README.md b/README.md index e3df59d..bf3bb87 100644 --- a/README.md +++ b/README.md @@ -57,16 +57,28 @@ code --install-extension build_extension/plecs-diff-viewer-0.2.0.vsix ### 3. Build the VSIX package: +**Mac/Linux:** ```bash ./build.sh ``` +**Windows (PowerShell):** +```powershell +.\build.ps1 +``` + Optional: set a temporary package version for that build only: +**Mac/Linux:** ```bash ./build.sh --version 0.2.0 ``` +**Windows:** +```powershell +.\build.ps1 -version 0.2.0 +``` + ## How To Use diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..974e1fe --- /dev/null +++ b/build.ps1 @@ -0,0 +1,67 @@ +<# +.SYNOPSIS +Builds the PLECS Diff Viewer extension into a VSIX package. + +.DESCRIPTION +This script is the Windows equivalent of build.sh. +It installs dependencies, builds the code, and packages it using vsce. + +.PARAMETER version +Override extension version only for this build (e.g., 0.2.0) +#> +param ( + [string]$version = "" +) + +$ErrorActionPreference = "Stop" + +$scriptDir = $PSScriptRoot +$outputDir = Join-Path $scriptDir "build_extension" +$packageJsonPath = Join-Path $scriptDir "package.json" +$backupJsonPath = Join-Path $scriptDir "package.json.bak" + +if ($version -and $version -notmatch '^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$') { + Write-Error "Invalid version '$version'. Expected format like 0.2.0" + exit 1 +} + +try { + if ($version) { + Write-Host "Using build version override: $version" + Copy-Item $packageJsonPath $backupJsonPath -Force + # Update version using node to preserve formatting + node -e "const fs=require('fs'); const p=process.argv[1]; const v=process.argv[2]; const pkg=JSON.parse(fs.readFileSync(p,'utf8')); pkg.version=v; fs.writeFileSync(p, JSON.stringify(pkg, null, 2) + '\n');" "$packageJsonPath" "$version" + } + + # Clean output directory + if (Test-Path $outputDir) { + Remove-Item -Path $outputDir -Recurse -Force + } + New-Item -Path $outputDir -ItemType Directory -Force | Out-Null + + # Install dependencies + Write-Host "Installing dependencies..." + & npm --prefix "$scriptDir" install + + # Bundle TypeScript with esbuild + Write-Host "Building extension..." + & npm --prefix "$scriptDir" run build -- --minify + + # Package as VSIX + Write-Host "Packaging VSIX..." + + # Needs npx.cmd on windows + & npx.cmd --yes @vscode/vsce package --allow-missing-repository --readme-path "README.md" --out "$outputDir/" --baseImagesUrl "https://github.com/jaeyeon302/PLECS-diff/raw/main/" + + + $vsixFile = Get-ChildItem -Path "$outputDir\*.vsix" | Select-Object -First 1 + if ($vsixFile) { + Write-Host "`nBuild complete: build_extension/$($vsixFile.Name)" + Write-Host "Install with: code --install-extension build_extension/$($vsixFile.Name)" + } +} +finally { + if (Test-Path $backupJsonPath) { + Move-Item $backupJsonPath $packageJsonPath -Force + } +} diff --git a/build.sh b/build.sh index 5db9d03..2cefbbb 100755 --- a/build.sh +++ b/build.sh @@ -72,7 +72,8 @@ npm --prefix "$SCRIPT_DIR" run build -- --minify # Package as VSIX echo "Packaging VSIX..." -npx @vscode/vsce package --allow-missing-repository --readme-path "README.md" --out "$OUTPUT_DIR/" +npx --yes @vscode/vsce package --allow-missing-repository --readme-path "README.md" --out "$OUTPUT_DIR/" --baseImagesUrl "https://github.com/jaeyeon302/PLECS-diff/raw/main/" + VSIX_FILE=$(ls "$OUTPUT_DIR"/*.vsix 2>/dev/null | head -1) echo "" diff --git a/build_extension/plecs-diff-viewer-0.2.1.vsix b/build_extension/plecs-diff-viewer-0.2.1.vsix index 8334654..4e6ca7c 100644 Binary files a/build_extension/plecs-diff-viewer-0.2.1.vsix and b/build_extension/plecs-diff-viewer-0.2.1.vsix differ diff --git a/new.plecs b/new.plecs new file mode 100644 index 0000000..760d6fd --- /dev/null +++ b/new.plecs @@ -0,0 +1,458 @@ +Plecs { + Name "boost_converter" + Version "4.9" + CircuitModel "ContStateSpace" + StartTime "0.0" + TimeSpan "0.01" + Timeout "" + Solver "dopri" + MaxStep "1e-3" + InitStep "-1" + FixedStep "1e-3" + Refine "5" + ZCStepSize "1e-9" + RelTol "1e-3" + AbsTol "-1" + TurnOnThreshold "0" + NonIdealSwitchResistance "1" + SyncFixedStepTasks "2" + UseSingleCommonBaseRate "2" + LossVariableLimitExceededMsg "3" + NegativeSwitchLossMsg "3" + DivisionByZeroMsg "2" + DatatypeOverflowMsg "2" + DatatypeInheritanceConflictMsg "1" + ContSampleTimeConflictMsg "1" + StiffnessDetectionMsg "2" + MaxConsecutiveZCs "1000" + AlgebraicLoopWithStateMachineMsg "2" + AssertionAction "1" + FixedPointDatatypeOverride "1" + InitializationCommands "" + InitialState "1" + SystemState "" + TaskingMode "1" + TaskConfigurations "" + CodeGenParameterInlining "2" + CodeGenFloatingPointFormat "2" + CodeGenAbsTimeUsageMsg "3" + CodeGenBaseName "" + CodeGenOutputDir "" + CodeGenExtraOpts "" + CodeGenTarget "Generic" + CodeGenTargetSettings "" + ExtendedMatrixPrecision "1" + MatrixSignificanceCheck "2" + RemoveUnusedStateSpaceOutputs "1" + EnableStateSpaceSplitting "2" + DisplayStateSpaceSplitting "1" + DiscretizationMethod "2" + ExternalModeSettings "" + AlgebraicLoopMethod "1" + AlgebraicLoopTolerance "1e-6" + ScriptsDialogGeometry "" + ScriptsDialogSplitterPos "0" + Schematic { + Location [46, 59; 596, 332] + ZoomFactor 1 + SliderPosition [0, 0] + ShowBrowser off + BrowserWidth 100 + Component { + Type DCVoltageSource + Name "V_dc" + Show off + Position [40, 140] + Direction down + Flipped on + LabelPosition east + Parameter { + Variable "V" + Value "10" + Show on + } + } + Component { + Type Diode + Name "D1" + Show off + Position [345, 95] + Direction right + Flipped on + LabelPosition north + Parameter { + Variable "Vf" + Value "0" + Show off + } + Parameter { + Variable "Ron" + Value "0" + Show off + } + Parameter { + Variable "thermal" + Value "" + Show off + } + Parameter { + Variable "Rth" + Value "0" + Show off + } + Parameter { + Variable "T_init" + Value "0" + Show off + } + Parameter { + Variable "SwitchModel" + Value "1" + Show off + } + Parameter { + Variable "f_grid" + Value "0" + Show off + } + } + Component { + Type Mosfet + Name "T1" + Show off + Position [195, 140] + Direction up + Flipped off + LabelPosition east + Parameter { + Variable "Ron" + Value "0" + Show off + } + Parameter { + Variable "s_init" + Value "0" + Show off + } + Parameter { + Variable "thermal" + Value "" + Show off + } + Parameter { + Variable "Rth" + Value "0" + Show off + } + Parameter { + Variable "T_init" + Value "0" + Show off + } + } + Component { + Type Inductor + Name "L1" + Show off + Position [100, 95] + Direction left + Flipped off + LabelPosition north + Parameter { + Variable "L" + Value "0.0001" + Show on + } + Parameter { + Variable "i_init" + Value "0" + Show off + } + } + Component { + Type Resistor + Name "R1" + Show off + Position [445, 140] + Direction down + Flipped off + LabelPosition west + Parameter { + Variable "R" + Value "4" + Show on + } + } + Component { + Type Capacitor + Name "C1" + Show off + Position [390, 140] + Direction down + Flipped on + LabelPosition west + Parameter { + Variable "C" + Value "100e-6" + Show on + } + Parameter { + Variable "v_init" + Value "0" + Show off + } + } + Component { + Type Ammeter + Name "Am1" + Show off + Position [155, 95] + Direction left + Flipped off + LabelPosition south + } + Component { + Type Voltmeter + Name "Vm1" + Show off + Position [485, 140] + Direction up + Flipped off + LabelPosition west + } + Component { + Type Scope + Name "Scope" + Show on + Position [545, 75] + Direction up + Flipped off + LabelPosition south + Location [551, 53; 1045, 554] + State "AAAA/wAAAAD9AAAAAgAAAAEAAAAAAAAAAPwCAAAAA/sAAAAQAFoAbwBvA" +"G0AQQByAGUAYQAAAAAA/////wAAAFwA////+wAAABQAUwBhAHYAZQBkAFYAaQBlAHcAcwAAAAAA//" +"///wAAAGYA////+wAAAAwAVAByAGEAYwBlAHMAAAAAAP////8AAABmAP///wAAAAMAAAGQAAAAU/w" +"BAAAAAfsAAAAUAEQAYQB0AGEAVwBpAGQAZwBlAHQAAAAAAAAAAZAAAAA+AP///wAAAe4AAAHZAAAA" +"BAAAAAQAAAAIAAAACPwAAAABAAAAAgAAAAEAAAAOAFQAbwBvAGwAQgBhAHIBAAAAAP////8AAAAAA" +"AAAAA==" + SavedViews "AAAAAgAAAAA=" + HeaderState "AAAA/wAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAL/gMAAAAJAAAAC" +"QAAAGQAAAAIAAAAZAAAAAMAAABkAAAAAgAAAGQAAAABAAAAZAAAAAcAAABkAAAABgAAAGQAAAAFAA" +"AAZAAAAAQAAABkAAAAmQAAAAsBAAABAAAAAAAAAAAAAAAAZP////8AAACBAAAAAAAAAAsAAACGAAA" +"AAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAA" +"AAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAA" +"AATAAAAAQAAAAAAAAPoAAAAABM=" + PlotPalettes "AAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAA" +"AEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + Axes "2" + TimeRange "0" + ScrollingMode "1" + SingleTimeAxis "1" + Open "1" + Ts "-1" + SampleLimit "0" + XAxisLabel "Time / s" + ShowLegend "1" + Axis { + Name "Inductor Current " + AutoScale 1 + MinValue 0 + MaxValue 1 + Signals {} + SignalTypes [ ] + AxisLabel "Current / A" + Untangle 0 + KeepBaseline off + BaselineValue 0 + } + Axis { + Name "Load Voltage" + AutoScale 1 + MinValue 0 + MaxValue 1 + Signals {} + SignalTypes [ ] + AxisLabel "Voltage / V" + Untangle 0 + KeepBaseline off + BaselineValue 0 + } + Fourier { + SingleXAxis on + AxisLabel "Frequency" + Scaling 0 + PhaseDisplay 0 + ShowFourierLegend off + Axis { + Name "" + AutoScale 1 + MinValue 0 + MaxValue 1 + Signals {} + Untangle 0 + KeepBaseline off + BaselineValue 0 + } + Axis { + Name "" + AutoScale 1 + MinValue 0 + MaxValue 1 + Signals {} + Untangle 0 + KeepBaseline off + BaselineValue 0 + } + } + } + Component { + Type PulseGenerator + Name "Pulse\nGenerator" + Show off + Position [120, 140] + Direction right + Flipped off + LabelPosition south + Parameter { + Variable "Hi" + Value "1" + Show off + } + Parameter { + Variable "Lo" + Value "0" + Show off + } + Parameter { + Variable "f" + Value "5000" + Show off + } + Parameter { + Variable "DutyCycle" + Value "0.3" + Show on + } + Parameter { + Variable "Delay" + Value "0" + Show off + } + Parameter { + Variable "DataType" + Value "10" + Show off + } + } + Connection { + Type Wire + SrcComponent "T1" + SrcTerminal 2 + Points [195, 180] + Branch { + Points [390, 180] + Branch { + Points [445, 180] + Branch { + DstComponent "R1" + DstTerminal 1 + } + Branch { + Points [485, 180] + DstComponent "Vm1" + DstTerminal 2 + } + } + Branch { + DstComponent "C1" + DstTerminal 2 + } + } + Branch { + Points [40, 180] + DstComponent "V_dc" + DstTerminal 2 + } + } + Connection { + Type Wire + SrcComponent "C1" + SrcTerminal 1 + Points [390, 95] + Branch { + Points [445, 95] + Branch { + Points [485, 95] + DstComponent "Vm1" + DstTerminal 1 + } + Branch { + DstComponent "R1" + DstTerminal 2 + } + } + Branch { + DstComponent "D1" + DstTerminal 2 + } + } + Connection { + Type Wire + SrcComponent "V_dc" + SrcTerminal 1 + Points [40, 95] + DstComponent "L1" + DstTerminal 1 + } + Connection { + Type Wire + SrcComponent "L1" + SrcTerminal 2 + DstComponent "Am1" + DstTerminal 1 + } + Connection { + Type Wire + SrcComponent "Am1" + SrcTerminal 2 + Points [195, 95] + Branch { + DstComponent "T1" + DstTerminal 1 + } + Branch { + DstComponent "D1" + DstTerminal 1 + } + } + Connection { + Type Signal + SrcComponent "Pulse\nGenerator" + SrcTerminal 1 + DstComponent "T1" + DstTerminal 3 + } + Connection { + Type Signal + SrcComponent "Am1" + SrcTerminal 3 + Points [155, 70] + DstComponent "Scope" + DstTerminal 1 + } + Connection { + Type Signal + SrcComponent "Vm1" + SrcTerminal 3 + Points [505, 140; 505, 80] + DstComponent "Scope" + DstTerminal 2 + } + Annotation { + Name "\n

Boost Converter

" + Position [115, 30] + } + } +} +DemoSignature "7SpBz+3CPYfEZfuvHai/ISwkvkuAKJq7nfN6PsIQJwM=" diff --git a/old.plecs b/old.plecs new file mode 100644 index 0000000..6106e75 Binary files /dev/null and b/old.plecs differ diff --git a/package-lock.json b/package-lock.json index d2163d1..c8dbcdf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "plecs-diff-viewer", - "version": "0.2.0", + "version": "0.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "plecs-diff-viewer", - "version": "0.2.0", + "version": "0.2.1", "devDependencies": { "@types/node": "^20.0.0", "@types/vscode": "^1.85.0",