@guidelytech/sveltekit 0.0.0-stage → 0.1.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 CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # @guidelytech/sveltekit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ SvelteKit helpers: creates the client in the browser only and calls `page()` after every
4
+ navigation. Re-exports everything from `@guidelytech/svelte`.
5
+
6
+ ```bash
7
+ pnpm add @guidelytech/sveltekit
8
+ ```
9
+
10
+ ```svelte
11
+ <!-- src/routes/+layout.svelte -->
12
+ <script lang="ts">
13
+ import { initGuidely, guidelyEnv } from "@guidelytech/sveltekit";
14
+ initGuidely({ ...guidelyEnv(import.meta.env), debug: import.meta.env.DEV });
15
+ </script>
16
+
17
+ <slot />
18
+ ```
19
+
20
+ | Export | Description |
21
+ |---|---|
22
+ | `initGuidely(options)` | Call once during root layout initialisation. Returns the client in the browser, `null` on the server. Uses `afterNavigate` from `$app/navigation` to call `page()` and destroys the client when the layout is destroyed. |
23
+ | `guidelyEnv(import.meta.env)` | Reads `VITE_GUIDELY_PROJECT_ID`, `VITE_GUIDELY_ENV`, `VITE_GUIDELY_API_URL`. |
24
+ | everything from `@guidelytech/svelte` | stores, actions and context helpers. |
package/dist/index.cjs ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ guidelyEnv: () => guidelyEnv,
25
+ initGuidely: () => initGuidely
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var import_environment = require("$app/environment");
29
+ var import_navigation = require("$app/navigation");
30
+ var import_svelte = require("@guidelytech/svelte");
31
+ var import_svelte2 = require("svelte");
32
+ __reExport(index_exports, require("@guidelytech/svelte"), module.exports);
33
+ function initGuidely(options) {
34
+ if (!import_environment.browser) {
35
+ (0, import_svelte.setGuidelyContext)(null);
36
+ return null;
37
+ }
38
+ const client = (0, import_svelte.createGuidely)(options);
39
+ (0, import_svelte.setGuidelyContext)(client);
40
+ (0, import_navigation.afterNavigate)((nav) => {
41
+ if (nav.type !== "enter") client.page(window.location.href);
42
+ });
43
+ (0, import_svelte2.onDestroy)(() => {
44
+ if (guidelyStoreIs(client)) (0, import_svelte.destroyGuidely)();
45
+ });
46
+ return client;
47
+ }
48
+ function guidelyStoreIs(client) {
49
+ let current = null;
50
+ import_svelte.guidely.subscribe((c) => current = c)();
51
+ return current === client;
52
+ }
53
+ function guidelyEnv(env) {
54
+ return {
55
+ projectId: env.VITE_GUIDELY_PROJECT_ID ?? "",
56
+ environment: env.VITE_GUIDELY_ENV ?? void 0,
57
+ apiUrl: env.VITE_GUIDELY_API_URL || void 0
58
+ };
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ guidelyEnv,
63
+ initGuidely,
64
+ ...require("@guidelytech/svelte")
65
+ });
66
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { browser } from \"$app/environment\";\nimport { afterNavigate } from \"$app/navigation\";\nimport { createGuidely, destroyGuidely, guidely, setGuidelyContext, type GuidelyClient, type GuidelyOptions } from \"@guidelytech/svelte\";\nimport { onDestroy } from \"svelte\";\n\nexport * from \"@guidelytech/svelte\";\n\n/**\n * Call once from the root `+layout.svelte` (during component initialisation). Creates the client\n * in the browser only, calls `page()` after every SvelteKit navigation and destroys the client\n * when the layout unmounts (HMR). Returns `null` on the server.\n */\nexport function initGuidely(options: GuidelyOptions): GuidelyClient | null {\n if (!browser) {\n setGuidelyContext(null);\n return null;\n }\n const client = createGuidely(options);\n setGuidelyContext(client);\n afterNavigate((nav) => {\n if (nav.type !== \"enter\") client.page(window.location.href);\n });\n onDestroy(() => {\n if (guidelyStoreIs(client)) destroyGuidely();\n });\n return client;\n}\n\nfunction guidelyStoreIs(client: GuidelyClient): boolean {\n let current: GuidelyClient | null = null;\n guidely.subscribe((c) => (current = c))();\n return current === client;\n}\n\n/** Reads the public `VITE_GUIDELY_*` variables into client options. */\nexport function guidelyEnv(env: Record<string, string | undefined>): Pick<GuidelyOptions, \"projectId\" | \"environment\" | \"apiUrl\"> {\n return {\n projectId: env.VITE_GUIDELY_PROJECT_ID ?? \"\",\n environment: (env.VITE_GUIDELY_ENV as GuidelyOptions[\"environment\"]) ?? undefined,\n apiUrl: env.VITE_GUIDELY_API_URL || undefined,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwB;AACxB,wBAA8B;AAC9B,oBAAmH;AACnH,IAAAA,iBAA0B;AAE1B,0BAAc,gCALd;AAYO,SAAS,YAAY,SAA+C;AACzE,MAAI,CAAC,4BAAS;AACZ,yCAAkB,IAAI;AACtB,WAAO;AAAA,EACT;AACA,QAAM,aAAS,6BAAc,OAAO;AACpC,uCAAkB,MAAM;AACxB,uCAAc,CAAC,QAAQ;AACrB,QAAI,IAAI,SAAS,QAAS,QAAO,KAAK,OAAO,SAAS,IAAI;AAAA,EAC5D,CAAC;AACD,gCAAU,MAAM;AACd,QAAI,eAAe,MAAM,EAAG,mCAAe;AAAA,EAC7C,CAAC;AACD,SAAO;AACT;AAEA,SAAS,eAAe,QAAgC;AACtD,MAAI,UAAgC;AACpC,wBAAQ,UAAU,CAAC,MAAO,UAAU,CAAE,EAAE;AACxC,SAAO,YAAY;AACrB;AAGO,SAAS,WAAW,KAAuG;AAChI,SAAO;AAAA,IACL,WAAW,IAAI,2BAA2B;AAAA,IAC1C,aAAc,IAAI,oBAAsD;AAAA,IACxE,QAAQ,IAAI,wBAAwB;AAAA,EACtC;AACF;","names":["import_svelte"]}
@@ -0,0 +1,13 @@
1
+ import { GuidelyOptions, GuidelyClient } from '@guidelytech/svelte';
2
+ export * from '@guidelytech/svelte';
3
+
4
+ /**
5
+ * Call once from the root `+layout.svelte` (during component initialisation). Creates the client
6
+ * in the browser only, calls `page()` after every SvelteKit navigation and destroys the client
7
+ * when the layout unmounts (HMR). Returns `null` on the server.
8
+ */
9
+ declare function initGuidely(options: GuidelyOptions): GuidelyClient | null;
10
+ /** Reads the public `VITE_GUIDELY_*` variables into client options. */
11
+ declare function guidelyEnv(env: Record<string, string | undefined>): Pick<GuidelyOptions, "projectId" | "environment" | "apiUrl">;
12
+
13
+ export { guidelyEnv, initGuidely };
@@ -0,0 +1,13 @@
1
+ import { GuidelyOptions, GuidelyClient } from '@guidelytech/svelte';
2
+ export * from '@guidelytech/svelte';
3
+
4
+ /**
5
+ * Call once from the root `+layout.svelte` (during component initialisation). Creates the client
6
+ * in the browser only, calls `page()` after every SvelteKit navigation and destroys the client
7
+ * when the layout unmounts (HMR). Returns `null` on the server.
8
+ */
9
+ declare function initGuidely(options: GuidelyOptions): GuidelyClient | null;
10
+ /** Reads the public `VITE_GUIDELY_*` variables into client options. */
11
+ declare function guidelyEnv(env: Record<string, string | undefined>): Pick<GuidelyOptions, "projectId" | "environment" | "apiUrl">;
12
+
13
+ export { guidelyEnv, initGuidely };
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ // src/index.ts
2
+ import { browser } from "$app/environment";
3
+ import { afterNavigate } from "$app/navigation";
4
+ import { createGuidely, destroyGuidely, guidely, setGuidelyContext } from "@guidelytech/svelte";
5
+ import { onDestroy } from "svelte";
6
+ export * from "@guidelytech/svelte";
7
+ function initGuidely(options) {
8
+ if (!browser) {
9
+ setGuidelyContext(null);
10
+ return null;
11
+ }
12
+ const client = createGuidely(options);
13
+ setGuidelyContext(client);
14
+ afterNavigate((nav) => {
15
+ if (nav.type !== "enter") client.page(window.location.href);
16
+ });
17
+ onDestroy(() => {
18
+ if (guidelyStoreIs(client)) destroyGuidely();
19
+ });
20
+ return client;
21
+ }
22
+ function guidelyStoreIs(client) {
23
+ let current = null;
24
+ guidely.subscribe((c) => current = c)();
25
+ return current === client;
26
+ }
27
+ function guidelyEnv(env) {
28
+ return {
29
+ projectId: env.VITE_GUIDELY_PROJECT_ID ?? "",
30
+ environment: env.VITE_GUIDELY_ENV ?? void 0,
31
+ apiUrl: env.VITE_GUIDELY_API_URL || void 0
32
+ };
33
+ }
34
+ export {
35
+ guidelyEnv,
36
+ initGuidely
37
+ };
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { browser } from \"$app/environment\";\nimport { afterNavigate } from \"$app/navigation\";\nimport { createGuidely, destroyGuidely, guidely, setGuidelyContext, type GuidelyClient, type GuidelyOptions } from \"@guidelytech/svelte\";\nimport { onDestroy } from \"svelte\";\n\nexport * from \"@guidelytech/svelte\";\n\n/**\n * Call once from the root `+layout.svelte` (during component initialisation). Creates the client\n * in the browser only, calls `page()` after every SvelteKit navigation and destroys the client\n * when the layout unmounts (HMR). Returns `null` on the server.\n */\nexport function initGuidely(options: GuidelyOptions): GuidelyClient | null {\n if (!browser) {\n setGuidelyContext(null);\n return null;\n }\n const client = createGuidely(options);\n setGuidelyContext(client);\n afterNavigate((nav) => {\n if (nav.type !== \"enter\") client.page(window.location.href);\n });\n onDestroy(() => {\n if (guidelyStoreIs(client)) destroyGuidely();\n });\n return client;\n}\n\nfunction guidelyStoreIs(client: GuidelyClient): boolean {\n let current: GuidelyClient | null = null;\n guidely.subscribe((c) => (current = c))();\n return current === client;\n}\n\n/** Reads the public `VITE_GUIDELY_*` variables into client options. */\nexport function guidelyEnv(env: Record<string, string | undefined>): Pick<GuidelyOptions, \"projectId\" | \"environment\" | \"apiUrl\"> {\n return {\n projectId: env.VITE_GUIDELY_PROJECT_ID ?? \"\",\n environment: (env.VITE_GUIDELY_ENV as GuidelyOptions[\"environment\"]) ?? undefined,\n apiUrl: env.VITE_GUIDELY_API_URL || undefined,\n };\n}\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,eAAe,gBAAgB,SAAS,yBAAkE;AACnH,SAAS,iBAAiB;AAE1B,cAAc;AAOP,SAAS,YAAY,SAA+C;AACzE,MAAI,CAAC,SAAS;AACZ,sBAAkB,IAAI;AACtB,WAAO;AAAA,EACT;AACA,QAAM,SAAS,cAAc,OAAO;AACpC,oBAAkB,MAAM;AACxB,gBAAc,CAAC,QAAQ;AACrB,QAAI,IAAI,SAAS,QAAS,QAAO,KAAK,OAAO,SAAS,IAAI;AAAA,EAC5D,CAAC;AACD,YAAU,MAAM;AACd,QAAI,eAAe,MAAM,EAAG,gBAAe;AAAA,EAC7C,CAAC;AACD,SAAO;AACT;AAEA,SAAS,eAAe,QAAgC;AACtD,MAAI,UAAgC;AACpC,UAAQ,UAAU,CAAC,MAAO,UAAU,CAAE,EAAE;AACxC,SAAO,YAAY;AACrB;AAGO,SAAS,WAAW,KAAuG;AAChI,SAAO;AAAA,IACL,WAAW,IAAI,2BAA2B;AAAA,IAC1C,aAAc,IAAI,oBAAsD;AAAA,IACxE,QAAQ,IAAI,wBAAwB;AAAA,EACtC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@guidelytech/sveltekit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "SvelteKit helpers for Guidely",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "dependencies": {
23
+ "@guidelytech/sdk-core": "0.1.0",
24
+ "@guidelytech/svelte": "0.1.0"
25
+ },
26
+ "devDependencies": {
27
+ "tsup": "^8.5.1",
28
+ "typescript": "^5.9.3",
29
+ "vitest": "^3.2.7",
30
+ "happy-dom": "^17.6.3",
31
+ "eslint": "^9.39.5",
32
+ "@eslint/js": "^9.39.5",
33
+ "typescript-eslint": "^8.46.0",
34
+ "svelte": "^5.57.2",
35
+ "@sveltejs/kit": "^2.70.3"
36
+ },
37
+ "peerDependencies": {
38
+ "svelte": ">=4.0.0",
39
+ "@sveltejs/kit": ">=2.0.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/parmarg/Guidely.git",
47
+ "directory": "packages/sveltekit"
48
+ },
49
+ "homepage": "https://github.com/parmarg/Guidely/tree/main/packages/sveltekit#readme",
50
+ "bugs": {
51
+ "url": "https://github.com/parmarg/Guidely/issues"
52
+ },
53
+ "keywords": [
54
+ "guidely",
55
+ "product-adoption",
56
+ "onboarding",
57
+ "product-tour",
58
+ "in-app-guidance",
59
+ "sveltekit"
60
+ ],
61
+ "scripts": {
62
+ "build": "tsup",
63
+ "dev": "tsup --watch",
64
+ "typecheck": "tsc --noEmit",
65
+ "test": "vitest run",
66
+ "lint": "eslint src",
67
+ "clean": "rm -rf dist"
68
+ }
6
69
  }