@codeimplants/version-control 1.0.2 → 1.0.4

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 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAsB,UAAU,CAAC,MAAM,EAAE,QAAQ,gBAuBhD"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAsB,UAAU,CAAC,MAAM,EAAE,QAAQ,gBA6BhD"}
package/dist/client.js CHANGED
@@ -1,18 +1,22 @@
1
1
  export async function fetchRules(config) {
2
2
  const controller = new AbortController();
3
3
  const id = setTimeout(() => controller.abort(), config.timeout || 8000);
4
+ const body = {
5
+ appId: config.appId || "unknown",
6
+ platform: config.platform || "web",
7
+ currentVersion: config.version || "1.0.0",
8
+ environment: "prod" // Default to prod
9
+ };
10
+ if (config.debug) {
11
+ console.log("[VC-SDK] Request Body:", body);
12
+ }
4
13
  const res = await fetch(`${config.backendUrl}/sdk/version/check`, {
5
14
  method: "POST",
6
15
  headers: {
7
16
  "Content-Type": "application/json",
8
17
  ...(config.apiKey ? { "x-api-key": config.apiKey } : {})
9
18
  },
10
- body: JSON.stringify({
11
- appId: config.appId || "unknown",
12
- platform: config.platform || "web",
13
- currentVersion: config.version || "1.0.0",
14
- environment: "prod" // Default to prod
15
- }),
19
+ body: JSON.stringify(body),
16
20
  signal: controller.signal
17
21
  });
18
22
  clearTimeout(id);
package/dist/sdk.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK/C,qBAAa,UAAU;IACnB,OAAO,CAAC,MAAM,CAAY;IAE1B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;WAczC,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI7E,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC;CAsC5C"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK/C,qBAAa,UAAU;IACnB,OAAO,CAAC,MAAM,CAAY;IAE1B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;WAczC,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI7E,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC;CAsD5C"}
package/dist/sdk.js CHANGED
@@ -30,7 +30,8 @@ export class VersionSDK {
30
30
  console.log("[VC-SDK] Checking version for:", {
31
31
  appId: this.config.appId,
32
32
  platform: this.config.platform,
33
- version: this.config.version
33
+ version: this.config.version,
34
+ url: `${this.config.backendUrl}/sdk/version/check`
34
35
  });
35
36
  }
36
37
  const response = await fetchRules(this.config);
@@ -50,7 +51,22 @@ export class VersionSDK {
50
51
  }
51
52
  catch (e) {
52
53
  if (this.config.debug) {
53
- console.error("[VC-SDK] Error:", e);
54
+ console.error("[VC-SDK] Error config:", this.config);
55
+ console.error("[VC-SDK] Error checking version:", e);
56
+ // Help user debug common Android emulator issue
57
+ if (e.message.includes("Network request failed") || e.message.includes("SDK_BACKEND_ERROR")) {
58
+ if (this.config.backendUrl.includes("localhost") || this.config.backendUrl.includes("127.0.0.1")) {
59
+ console.warn("[VC-SDK] ⚠️ WARNING: You are using 'localhost' or '127.0.0.1' in the backend URL.");
60
+ console.warn("[VC-SDK] For Android Emulator, you MUST use 'http://10.0.2.2:PORT' instead of 'localhost'.");
61
+ }
62
+ }
63
+ }
64
+ else {
65
+ // If not in debug mode, at least warn about potential setup issues if it looks like a dev environment
66
+ // @ts-ignore
67
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
68
+ console.warn("[VC-SDK] Error checking version. Enable 'debug: true' in VersionSDK config for more details.");
69
+ }
54
70
  }
55
71
  return { action: "NONE" };
56
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeimplants/version-control",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A lightweight cross-platform SDK to remotely control app version behavior such as soft update, force update, and maintenance mode using backend-driven rules, without enforcing UI.",
5
5
  "keywords": [
6
6
  "version-control",
package/src/client.ts CHANGED
@@ -4,18 +4,24 @@ export async function fetchRules(config: VCConfig) {
4
4
  const controller = new AbortController();
5
5
  const id = setTimeout(() => controller.abort(), config.timeout || 8000);
6
6
 
7
+ const body = {
8
+ appId: config.appId || "unknown",
9
+ platform: config.platform || "web",
10
+ currentVersion: config.version || "1.0.0",
11
+ environment: "prod" // Default to prod
12
+ };
13
+
14
+ if (config.debug) {
15
+ console.log("[VC-SDK] Request Body:", body);
16
+ }
17
+
7
18
  const res = await fetch(`${config.backendUrl}/sdk/version/check`, {
8
19
  method: "POST",
9
20
  headers: {
10
21
  "Content-Type": "application/json",
11
22
  ...(config.apiKey ? { "x-api-key": config.apiKey } : {})
12
23
  },
13
- body: JSON.stringify({
14
- appId: config.appId || "unknown",
15
- platform: config.platform || "web",
16
- currentVersion: config.version || "1.0.0",
17
- environment: "prod" // Default to prod
18
- }),
24
+ body: JSON.stringify(body),
19
25
  signal: controller.signal
20
26
  });
21
27
 
package/src/sdk.ts CHANGED
@@ -34,7 +34,8 @@ export class VersionSDK {
34
34
  console.log("[VC-SDK] Checking version for:", {
35
35
  appId: this.config.appId,
36
36
  platform: this.config.platform,
37
- version: this.config.version
37
+ version: this.config.version,
38
+ url: `${this.config.backendUrl}/sdk/version/check`
38
39
  });
39
40
  }
40
41
 
@@ -55,9 +56,24 @@ export class VersionSDK {
55
56
  };
56
57
 
57
58
  return decision;
58
- } catch (e) {
59
+ } catch (e: any) {
59
60
  if (this.config.debug) {
60
- console.error("[VC-SDK] Error:", e);
61
+ console.error("[VC-SDK] Error config:", this.config);
62
+ console.error("[VC-SDK] Error checking version:", e);
63
+
64
+ // Help user debug common Android emulator issue
65
+ if (e.message.includes("Network request failed") || e.message.includes("SDK_BACKEND_ERROR")) {
66
+ if (this.config.backendUrl.includes("localhost") || this.config.backendUrl.includes("127.0.0.1")) {
67
+ console.warn("[VC-SDK] ⚠️ WARNING: You are using 'localhost' or '127.0.0.1' in the backend URL.");
68
+ console.warn("[VC-SDK] For Android Emulator, you MUST use 'http://10.0.2.2:PORT' instead of 'localhost'.");
69
+ }
70
+ }
71
+ } else {
72
+ // If not in debug mode, at least warn about potential setup issues if it looks like a dev environment
73
+ // @ts-ignore
74
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
75
+ console.warn("[VC-SDK] Error checking version. Enable 'debug: true' in VersionSDK config for more details.");
76
+ }
61
77
  }
62
78
  return { action: "NONE" };
63
79
  }