@nekm/svelte-core 1.9.4 → 1.9.5

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.
@@ -2,6 +2,8 @@
2
2
  import {onMount} from "svelte";
3
3
  import {browserImportScript} from "@nekm/core";
4
4
  import {page} from "$app/state";
5
+ import { dev } from "$app/environment";
6
+ import { debug } from "node:console";
5
7
 
6
8
  export interface GoogleAnalyticsProps {
7
9
  /**
@@ -10,29 +12,20 @@
10
12
  readonly id: string;
11
13
 
12
14
  /**
13
- * Base domain to the production site. If the current domain does not match
14
- * this, then Google Analytics will send debug data only.
15
+ * Activate debug mode. Defaults to true during dev
15
16
  */
16
- readonly productionDomain?: string | URL;
17
+ readonly debugMode?: boolean;
17
18
  }
18
19
 
19
- interface GoogleAnalyticsConfig {
20
- readonly debug_mode?: boolean;
21
- }
22
-
23
- const { id, productionDomain }: GoogleAnalyticsProps = $props();
20
+ const { id, debugMode = dev }: GoogleAnalyticsProps = $props();
24
21
 
25
22
  const url = "https://www.googletagmanager.com";
26
23
 
27
- const productionDomainStr = $derived(productionDomain instanceof URL ? productionDomain.hostname : productionDomain);
28
-
29
24
  onMount(() => {
30
- let config: GoogleAnalyticsConfig = { debug_mode: true };
25
+ let config: { readonly debug_mode?: boolean } = { };
31
26
 
32
- if (productionDomain) {
33
- if (page.url.hostname === productionDomainStr) {
34
- config = {};
35
- }
27
+ if (debugMode) {
28
+ config = { debug_mode: true };
36
29
  }
37
30
 
38
31
  window.dataLayer = window.dataLayer || [];
@@ -4,10 +4,9 @@ export interface GoogleAnalyticsProps {
4
4
  */
5
5
  readonly id: string;
6
6
  /**
7
- * Base domain to the production site. If the current domain does not match
8
- * this, then Google Analytics will send debug data only.
7
+ * Activate debug mode. Defaults to true during dev
9
8
  */
10
- readonly productionDomain?: string | URL;
9
+ readonly debugMode?: boolean;
11
10
  }
12
11
  declare const GoogleAnalytics: import("svelte").Component<GoogleAnalyticsProps, {}, "">;
13
12
  type GoogleAnalytics = ReturnType<typeof GoogleAnalytics>;
package/dist/index.d.ts CHANGED
@@ -14,3 +14,4 @@ export * from "./ld-json.svelte";
14
14
  export { default as ExternalLink } from "./external-link.svelte";
15
15
  export * from "./external-link.svelte";
16
16
  export * from "./hooks.js";
17
+ export * from "./timer.svelte.js";
package/dist/index.js CHANGED
@@ -14,3 +14,4 @@ export * from "./ld-json.svelte";
14
14
  export { default as ExternalLink } from "./external-link.svelte";
15
15
  export * from "./external-link.svelte";
16
16
  export * from "./hooks.js";
17
+ export * from "./timer.svelte.js";
@@ -0,0 +1,2 @@
1
+ export declare function effectTimer(waitMs: number, fn: () => void | Promise<void>): void;
2
+ export declare function effectInterval(waitMs: number, fn: () => void | Promise<void>): void;
@@ -0,0 +1,10 @@
1
+ import { interval } from "@nekm/core";
2
+ export function effectTimer(waitMs, fn) {
3
+ $effect(() => {
4
+ const timeoutId = setTimeout(fn, waitMs);
5
+ return () => clearTimeout(timeoutId);
6
+ });
7
+ }
8
+ export function effectInterval(waitMs, fn) {
9
+ $effect(() => interval(waitMs, fn));
10
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@nekm/svelte-core",
3
3
  "description": "Code I find myself re-writing over-and-over, Svelte edition.",
4
4
  "license": "MIT",
5
- "version": "1.9.4",
5
+ "version": "1.9.5",
6
6
  "scripts": {
7
7
  "dev": "vite dev",
8
8
  "build": "vite build && npm run prepack",