-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌿 Fern Regeneration -- March 4, 2024 (#13)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6216aab
commit 4091a52
Showing
12 changed files
with
2,420 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./fetcher"; | ||
export * from "./runtime"; | ||
export * as serialization from "./schemas"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { RUNTIME } from "./runtime"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
interface DenoGlobal { | ||
version: { | ||
deno: string; | ||
}; | ||
} | ||
|
||
interface BunGlobal { | ||
version: string; | ||
} | ||
|
||
declare const Deno: DenoGlobal; | ||
declare const Bun: BunGlobal; | ||
|
||
/** | ||
* A constant that indicates whether the environment the code is running is a Web Browser. | ||
*/ | ||
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined"; | ||
|
||
/** | ||
* A constant that indicates whether the environment the code is running is a Web Worker. | ||
*/ | ||
const isWebWorker = | ||
typeof self === "object" && | ||
// @ts-ignore | ||
typeof self?.importScripts === "function" && | ||
(self.constructor?.name === "DedicatedWorkerGlobalScope" || | ||
self.constructor?.name === "ServiceWorkerGlobalScope" || | ||
self.constructor?.name === "SharedWorkerGlobalScope"); | ||
|
||
/** | ||
* A constant that indicates whether the environment the code is running is Deno. | ||
*/ | ||
const isDeno = | ||
typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined"; | ||
|
||
/** | ||
* A constant that indicates whether the environment the code is running is Bun.sh. | ||
*/ | ||
const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined"; | ||
|
||
/** | ||
* A constant that indicates whether the environment the code is running is Node.JS. | ||
*/ | ||
const isNode = | ||
typeof process !== "undefined" && | ||
Boolean(process.version) && | ||
Boolean(process.versions?.node) && | ||
// Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions | ||
!isDeno && | ||
!isBun; | ||
|
||
/** | ||
* A constant that indicates whether the environment the code is running is in React-Native. | ||
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js | ||
*/ | ||
const isReactNative = typeof navigator !== "undefined" && navigator?.product === "ReactNative"; | ||
|
||
/** | ||
* A constant that indicates which environment and version the SDK is running in. | ||
*/ | ||
export const RUNTIME: Runtime = evaluateRuntime(); | ||
|
||
export interface Runtime { | ||
type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown"; | ||
version?: string; | ||
} | ||
|
||
function evaluateRuntime(): Runtime { | ||
if (isBrowser) { | ||
return { | ||
type: "browser", | ||
version: window.navigator.userAgent, | ||
}; | ||
} | ||
|
||
if (isWebWorker) { | ||
return { | ||
type: "web-worker", | ||
}; | ||
} | ||
|
||
if (isDeno) { | ||
return { | ||
type: "deno", | ||
version: Deno.version.deno, | ||
}; | ||
} | ||
|
||
if (isBun) { | ||
return { | ||
type: "bun", | ||
version: Bun.version, | ||
}; | ||
} | ||
|
||
if (isNode) { | ||
return { | ||
type: "node", | ||
version: process.versions.node, | ||
}; | ||
} | ||
|
||
if (isReactNative) { | ||
return { | ||
type: "react-native", | ||
}; | ||
} | ||
|
||
return { | ||
type: "unknown", | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* This is a test file for the SDK. | ||
* | ||
* Add any tests here and make sure to mark this file | ||
* in `.fernignore`. | ||
*/ | ||
describe("test", () => { | ||
it("default", () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.