@streamscloud/kit 0.0.1-1770820176986 → 0.0.1-1770823200886

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.
@@ -1,5 +1,7 @@
1
+ type Toast = typeof import('svelte-sonner').toast;
1
2
  export declare class ToasterHost {
2
- private static _ready;
3
+ private static _toast;
3
4
  private static _mountPromise;
4
- static ensure(): Promise<void>;
5
+ static ensure(): Promise<Toast>;
5
6
  }
7
+ export {};
@@ -1,20 +1,20 @@
1
1
  import { AppTheme } from '../theme';
2
2
  import { mount, tick } from 'svelte';
3
- import { Toaster } from 'svelte-sonner';
4
3
  export class ToasterHost {
5
- static _ready = false;
4
+ static _toast = null;
6
5
  static _mountPromise = null;
7
6
  static async ensure() {
8
- if (this._ready) {
9
- return;
7
+ if (this._toast) {
8
+ return this._toast;
10
9
  }
11
10
  if (this._mountPromise) {
12
11
  return this._mountPromise;
13
12
  }
14
13
  if (typeof document === 'undefined') {
15
- return;
14
+ throw new Error('ToasterHost requires a browser environment');
16
15
  }
17
16
  this._mountPromise = (async () => {
17
+ const { Toaster, toast } = await import('svelte-sonner');
18
18
  const container = document.createElement('div');
19
19
  container.id = 'toastr-container';
20
20
  document.body.appendChild(container);
@@ -33,7 +33,8 @@ export class ToasterHost {
33
33
  }
34
34
  });
35
35
  await tick();
36
- this._ready = true;
36
+ this._toast = toast;
37
+ return toast;
37
38
  })();
38
39
  return this._mountPromise;
39
40
  }
@@ -1,24 +1,23 @@
1
1
  import { ToasterHost } from './toaster-host.svelte';
2
- import { toast } from 'svelte-sonner';
3
2
  export class Toastr {
4
3
  static async error(message, options) {
5
- await ToasterHost.ensure();
4
+ const toast = await ToasterHost.ensure();
6
5
  toast.error(message, patchOptions(options));
7
6
  }
8
7
  static async success(message, options) {
9
- await ToasterHost.ensure();
8
+ const toast = await ToasterHost.ensure();
10
9
  toast.success(message, patchOptions(options));
11
10
  }
12
11
  static async warning(message, options) {
13
- await ToasterHost.ensure();
12
+ const toast = await ToasterHost.ensure();
14
13
  toast.warning(message, patchOptions(options));
15
14
  }
16
15
  static async info(message, options) {
17
- await ToasterHost.ensure();
16
+ const toast = await ToasterHost.ensure();
18
17
  toast.info(message, patchOptions(options));
19
18
  }
20
19
  static async promise(promise, messages) {
21
- await ToasterHost.ensure();
20
+ const toast = await ToasterHost.ensure();
22
21
  toast.promise(promise, messages);
23
22
  }
24
23
  }
@@ -6,11 +6,11 @@ let hasError = $state(false);
6
6
  const imageState = $derived(calculateImageState(src, hasError, showStubOnError));
7
7
  const onLoad = () => {
8
8
  hasError = false;
9
- on?.load(true);
9
+ on?.load?.(true);
10
10
  };
11
11
  const onLoadError = () => {
12
12
  hasError = true;
13
- on?.load(false);
13
+ on?.load?.(false);
14
14
  };
15
15
  </script>
16
16
 
@@ -4,7 +4,7 @@ type Props = {
4
4
  alt?: string;
5
5
  showStubOnError?: boolean;
6
6
  on?: {
7
- load: (loadedSuccessfully: boolean) => void;
7
+ load?: (loadedSuccessfully: boolean) => void;
8
8
  };
9
9
  stub?: Snippet;
10
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.0.1-1770820176986",
3
+ "version": "0.0.1-1770823200886",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",