oc-tweaks 0.5.0 → 0.5.2

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 +14 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -552,18 +552,20 @@ function calculatePosition(slotIndex, config) {
552
552
  const height = config.height;
553
553
  const gap = config.gap ?? 12;
554
554
  const margin = config.screenMargin ?? 20;
555
- const screenWidthExpr = typeof config.screenWidth === "number" ? `${config.screenWidth}` : "[System.Windows.SystemParameters]::PrimaryScreenWidth";
556
- const screenHeightExpr = typeof config.screenHeight === "number" ? `${config.screenHeight}` : "[System.Windows.SystemParameters]::PrimaryScreenHeight";
557
- const leftExpr = `(${screenWidthExpr} - ${width} - ${margin})`;
555
+ const screenLeftExpr = typeof config.screenLeft === "number" ? `${config.screenLeft}` : "($targetScreen.Left)";
556
+ const screenTopExpr = typeof config.screenTop === "number" ? `${config.screenTop}` : "($targetScreen.Top)";
557
+ const screenRightExpr = typeof config.screenWidth === "number" ? `(${screenLeftExpr} + ${config.screenWidth})` : "($targetScreen.Right)";
558
+ const screenBottomExpr = typeof config.screenHeight === "number" ? `(${screenTopExpr} + ${config.screenHeight})` : "($targetScreen.Bottom)";
559
+ const leftExpr = `(${screenRightExpr} - ${width} - ${margin})`;
558
560
  if (position === "bottom-right") {
559
- const topExpr2 = `(${screenHeightExpr} - ${margin} - ((${slotIndex} + 1) * (${height} + ${gap})))`;
561
+ const topExpr2 = `(${screenBottomExpr} - ${margin} - ((${slotIndex} + 1) * (${height} + ${gap})))`;
560
562
  return {
561
563
  startupLocation: "Manual",
562
564
  leftExpr,
563
565
  topExpr: topExpr2
564
566
  };
565
567
  }
566
- const topExpr = `(${margin} + (${slotIndex} * (${height} + ${gap})))`;
568
+ const topExpr = `(${screenTopExpr} + ${margin} + (${slotIndex} * (${height} + ${gap})))`;
567
569
  return {
568
570
  startupLocation: "Manual",
569
571
  leftExpr,
@@ -660,6 +662,7 @@ async function runWpfNotification($, shellCommand, title, message, tag, style, p
660
662
  const shadow = style?.shadow !== false;
661
663
  const idleColor = style?.idleColor ?? "#4ADE80";
662
664
  const errorColor = style?.errorColor ?? "#EF4444";
665
+ const contentMaxWidth = Math.max(160, width - 120);
663
666
  const accentColor = renderOptions?.accentColor ?? (tag === "Error" ? errorColor : idleColor);
664
667
  const icon = renderOptions?.icon ?? (tag === "Error" ? "❌" : "✅");
665
668
  const showDismissHint = renderOptions?.showDismissHint !== false;
@@ -682,7 +685,7 @@ async function runWpfNotification($, shellCommand, title, message, tag, style, p
682
685
  ` WindowStyle="None" AllowsTransparency="True" Background="Transparent"`,
683
686
  ` Topmost="True" ShowInTaskbar="False" ShowActivated="False"`,
684
687
  ` WindowStartupLocation="${startupLocation}"`,
685
- ` Width="${width}" Height="${height}">`,
688
+ ` SizeToContent="Height" Width="${width}" MinHeight="${height}">`,
686
689
  ` <Border CornerRadius="${borderRadius}" Margin="10">`,
687
690
  ` <Border.Background>`,
688
691
  ` <SolidColorBrush Color="${backgroundColor}" Opacity="${backgroundOpacity}"/>`,
@@ -690,10 +693,10 @@ async function runWpfNotification($, shellCommand, title, message, tag, style, p
690
693
  ` ${shadowXaml}`,
691
694
  ` <Grid>`,
692
695
  ` <Border CornerRadius="${borderRadius},0,0,${borderRadius}" Width="${colorBarWidth}" HorizontalAlignment="Left" Name="ColorBar"/>`,
693
- ` <StackPanel Orientation="Horizontal" Margin="22,0,16,0" VerticalAlignment="Center">`,
696
+ ` <StackPanel Orientation="Horizontal" Margin="22,12,16,12" VerticalAlignment="Center">`,
694
697
  ` <TextBlock Name="IconText" FontSize="${iconFontSize}" VerticalAlignment="Center" Margin="0,0,15,0" Foreground="White"/>`,
695
- ` <StackPanel VerticalAlignment="Center" MaxWidth="320">`,
696
- ` <TextBlock Name="TitleText" FontSize="${titleFontSize}" FontWeight="SemiBold"/>`,
698
+ ` <StackPanel VerticalAlignment="Center" MaxWidth="${contentMaxWidth}">`,
699
+ ` <TextBlock Name="TitleText" FontSize="${titleFontSize}" FontWeight="SemiBold" TextWrapping="Wrap"/>`,
697
700
  ` <TextBlock Name="ContentText" Foreground="${textColor}" FontSize="${contentFontSize}" Margin="0,4,0,0" TextWrapping="Wrap"/>`,
698
701
  dismissHintXaml,
699
702
  ` </StackPanel>`,
@@ -712,6 +715,8 @@ async function runWpfNotification($, shellCommand, title, message, tag, style, p
712
715
  "Add-Type -AssemblyName PresentationFramework",
713
716
  "Add-Type -AssemblyName PresentationCore",
714
717
  "Add-Type -AssemblyName WindowsBase",
718
+ "Add-Type -AssemblyName System.Windows.Forms",
719
+ "$targetScreen = [System.Windows.Forms.Screen]::FromPoint([System.Windows.Forms.Cursor]::Position).WorkingArea",
715
720
  "",
716
721
  "Add-Type -TypeDefinition @'",
717
722
  "using System;",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-tweaks",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"