@nekm/svelte-core 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Svelte Core
2
+
3
+ [![Build Status](https://circleci.com/gh/Ekman/Svelte-Core.svg?style=svg)](https://app.circleci.com/pipelines/github/Ekman/Svelte-Core)
4
+
5
+ Code that I find myself rewriting over and over. May as well import it from a
6
+ lib instead.
7
+
8
+ ## Installation
9
+
10
+ Install with your favorite package manager:
11
+
12
+ ```bash
13
+ npm install --save @nekm/svelte-core
14
+ ```
15
+
16
+ ## Versioning
17
+
18
+ This project complies with [Semantic Versioning](https://semver.org/).
19
+
20
+ ## Changelog
21
+
22
+ For a complete list of changes, and how to migrate between major versions, see
23
+ [releases page](https://github.com/Ekman/Svelte-Core/releases).
@@ -0,0 +1,7 @@
1
+ declare global {
2
+ interface Window {
3
+ gtag(...args: unknown[]): void;
4
+ dataLayer: unknown[];
5
+ }
6
+ }
7
+ export declare function gtag(event: string, params?: Record<string, unknown>): void;
@@ -0,0 +1,5 @@
1
+ import { browserAssert } from "@nekm/core";
2
+ export function gtag(event, params) {
3
+ browserAssert();
4
+ window.gtag("event", event, params);
5
+ }
@@ -0,0 +1,34 @@
1
+ <script lang="ts">
2
+ import {onMount} from "svelte";
3
+ import {assets} from "$app/paths";
4
+ import {browserImportScript} from "@nekm/core";
5
+ import {page} from "$app/state";
6
+
7
+ interface Props {
8
+ /**
9
+ * Google Analytics tracking ID.
10
+ */
11
+ readonly id: string;
12
+
13
+ /**
14
+ * Base URL to the site.
15
+ * @default assets
16
+ */
17
+ readonly baseUrl?: URL;
18
+ }
19
+
20
+ const { id, baseUrl: baseUrlProps }: Props = $props();
21
+ const baseUrl = baseUrlProps ?? new URL(assets);
22
+
23
+ onMount(() => {
24
+ window.dataLayer = window.dataLayer || [];
25
+ window.gtag = function () {
26
+ window.dataLayer.push(arguments);
27
+ }
28
+ window.gtag("js", new Date());
29
+ const config = page.url.hostname !== baseUrl.hostname ? { debug_mode: true } : {};
30
+ window.gtag("config", id, config);
31
+
32
+ return browserImportScript(`https://www.googletagmanager.com/gtag/js?id=${id}`);
33
+ });
34
+ </script>
@@ -0,0 +1,14 @@
1
+ interface Props {
2
+ /**
3
+ * Google Analytics tracking ID.
4
+ */
5
+ readonly id: string;
6
+ /**
7
+ * Base URL to the site.
8
+ * @default assets
9
+ */
10
+ readonly baseUrl?: URL;
11
+ }
12
+ declare const GoogleAnalytics: import("svelte").Component<Props, {}, "">;
13
+ type GoogleAnalytics = ReturnType<typeof GoogleAnalytics>;
14
+ export default GoogleAnalytics;
@@ -0,0 +1,2 @@
1
+ export * from "./google-analytics.svelte";
2
+ export * from "./google-analytics.js";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./google-analytics.svelte";
2
+ export * from "./google-analytics.js";
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@nekm/svelte-core",
3
+ "version": "1.0.0",
4
+ "scripts": {
5
+ "dev": "vite dev",
6
+ "build": "vite build && npm run prepack",
7
+ "preview": "vite preview",
8
+ "prepare": "svelte-kit sync || echo ''",
9
+ "prepack": "svelte-kit sync && svelte-package && publint",
10
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "!dist/**/*.test.*",
16
+ "!dist/**/*.spec.*"
17
+ ],
18
+ "sideEffects": [
19
+ "**/*.css"
20
+ ],
21
+ "svelte": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "svelte": "./dist/index.js"
28
+ }
29
+ },
30
+ "peerDependencies": {
31
+ "svelte": "^5.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@sveltejs/adapter-auto": "^6.0.0",
35
+ "@sveltejs/kit": "^2.16.0",
36
+ "@sveltejs/package": "^2.0.0",
37
+ "@sveltejs/vite-plugin-svelte": "^5.0.0",
38
+ "publint": "^0.3.2",
39
+ "svelte": "^5.0.0",
40
+ "svelte-check": "^4.0.0",
41
+ "typescript": "^5.0.0",
42
+ "vite": "^6.2.6",
43
+ "vite-plugin-devtools-json": "^0.2.0"
44
+ },
45
+ "keywords": [
46
+ "svelte"
47
+ ],
48
+ "dependencies": {
49
+ "@nekm/core": "^1.0.0"
50
+ }
51
+ }