@spider-cloud/spider-client 0.0.37 → 0.0.38

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,4 +1,4 @@
1
- import { type SupabaseClient } from "@supabase/supabase-js";
1
+ import type { SupabaseClient } from "@supabase/supabase-js";
2
2
  export declare class Supabase {
3
3
  private static instance?;
4
4
  private static initPromise?;
package/dist/supabase.js CHANGED
@@ -24,14 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Supabase = void 0;
27
- // lazy loaded createClient
28
- let _createClient = null;
29
27
  class Supabase {
30
28
  // Initialize the Supabase client
31
29
  static async init() {
32
- if (!_createClient) {
33
- _createClient = (await Promise.resolve().then(() => __importStar(require("@supabase/supabase-js")))).createClient;
34
- }
35
30
  if (Supabase.instance) {
36
31
  return;
37
32
  }
@@ -40,21 +35,19 @@ class Supabase {
40
35
  }
41
36
  Supabase.initPromise = (async () => {
42
37
  const windowExists = typeof window !== "undefined";
38
+ const { createClient } = await Promise.resolve().then(() => __importStar(require("@supabase/supabase-js")));
43
39
  try {
44
40
  const response = await fetch("https://api.spider.cloud/data/anon_key");
45
41
  if (!response.ok) {
46
42
  throw new Error(`Failed to fetch anon key: ${response.statusText}`);
47
43
  }
48
44
  const { data } = await response.json();
49
- const client = _createClient("https://api-data.spider.cloud", String(data), {
45
+ Supabase.instance = createClient("https://api-data.spider.cloud", String(data), {
50
46
  auth: {
51
47
  persistSession: windowExists,
52
48
  autoRefreshToken: windowExists,
53
49
  },
54
50
  });
55
- if (client) {
56
- Supabase.instance = client;
57
- }
58
51
  }
59
52
  catch (error) {
60
53
  Promise.reject("Failed to initialize Supabase client: " + error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spider-cloud/spider-client",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "description": "A Javascript SDK for Spider Cloud services",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -27,7 +27,7 @@
27
27
  "@types/jest": "^29.5.12",
28
28
  "@types/node": "20.14.2",
29
29
  "dotenv": "^16.4.5",
30
- "ts-jest": "^29.1.2",
30
+ "ts-jest": "^29.1.5",
31
31
  "typescript": "5.4.5",
32
32
  "@supabase/supabase-js": "^2.44.2"
33
33
  },