@fencyai/js 0.1.37 → 0.1.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,5 +1,14 @@
1
1
  /**
2
- * Get the current package version from package.json
2
+ * Get the current package version
3
3
  * @returns The package version as a string
4
4
  */
5
5
  export declare function getPackageVersion(): string;
6
+ /**
7
+ * Override the SDK version (useful for testing or custom builds)
8
+ * @param version - The version to use
9
+ */
10
+ export declare function setPackageVersion(version: string): void;
11
+ /**
12
+ * Reset the version to the default build-time version
13
+ */
14
+ export declare function resetPackageVersion(): void;
@@ -1,29 +1,26 @@
1
- import { readFileSync } from 'fs';
2
- import { dirname, join } from 'path';
3
- import { fileURLToPath } from 'url';
4
- // Cache the version to avoid reading the file multiple times
5
- let cachedVersion = null;
1
+ // Browser-compatible version utility
2
+ // The version is set at build time and can be overridden if needed
3
+ // Build-time version constant - this should be updated during the build process
4
+ const SDK_VERSION = '0.1.37';
5
+ // Allow runtime override if needed
6
+ let versionOverride = null;
6
7
  /**
7
- * Get the current package version from package.json
8
+ * Get the current package version
8
9
  * @returns The package version as a string
9
10
  */
10
11
  export function getPackageVersion() {
11
- if (cachedVersion !== null) {
12
- return cachedVersion;
13
- }
14
- try {
15
- // Get the directory of the current file
16
- const __filename = fileURLToPath(import.meta.url);
17
- const __dirname = dirname(__filename);
18
- // Navigate to the package.json file (2 levels up: utils -> src -> js -> package.json)
19
- const packageJsonPath = join(__dirname, '../../package.json');
20
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
21
- return packageJson.version;
22
- }
23
- catch (error) {
24
- // Fallback to a default version if we can't read the package.json
25
- console.warn('Could not read package version, using fallback:', error);
26
- cachedVersion = '0.1.35';
27
- return cachedVersion;
28
- }
12
+ return versionOverride || SDK_VERSION;
13
+ }
14
+ /**
15
+ * Override the SDK version (useful for testing or custom builds)
16
+ * @param version - The version to use
17
+ */
18
+ export function setPackageVersion(version) {
19
+ versionOverride = version;
20
+ }
21
+ /**
22
+ * Reset the version to the default build-time version
23
+ */
24
+ export function resetPackageVersion() {
25
+ versionOverride = null;
29
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fencyai/js",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "> TODO: description",
5
5
  "author": "staklau <steinaageklaussen@gmail.com>",
6
6
  "homepage": "",
@@ -39,5 +39,5 @@
39
39
  "ts-jest": "^29.1.1",
40
40
  "typescript": "^5.3.3"
41
41
  },
42
- "gitHead": "dec184b1288042cf37fa26c8fbf2f648f7ce533e"
42
+ "gitHead": "13bb1e815dadeb5800be355190ce8486121db136"
43
43
  }