@effect-native/libcrsql 0.16.3-1 → 0.16.301
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/LICENSE +22 -0
- package/README.md +41 -152
- package/dist/cjs/browser-unsupported.js +14 -0
- package/dist/cjs/browser-unsupported.js.map +1 -0
- package/dist/cjs/index.js +77 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/paths.js +45 -0
- package/dist/cjs/paths.js.map +1 -0
- package/dist/cjs/platform.js +61 -0
- package/dist/cjs/platform.js.map +1 -0
- package/dist/cjs/version.js +12 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/dts/browser-unsupported.d.ts +7 -0
- package/dist/dts/browser-unsupported.d.ts.map +1 -0
- package/dist/dts/index.d.ts +44 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/paths.d.ts +38 -0
- package/dist/dts/paths.d.ts.map +1 -0
- package/dist/dts/platform.d.ts +30 -0
- package/dist/dts/platform.d.ts.map +1 -0
- package/dist/dts/version.d.ts +6 -0
- package/dist/dts/version.d.ts.map +1 -0
- package/dist/esm/browser-unsupported.js +10 -0
- package/dist/esm/browser-unsupported.js.map +1 -0
- package/dist/esm/index.js +68 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +8 -0
- package/dist/esm/paths.js +38 -0
- package/dist/esm/paths.js.map +1 -0
- package/dist/esm/platform.js +52 -0
- package/dist/esm/platform.js.map +1 -0
- package/dist/esm/version.js +6 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/lib/darwin-aarch64/libcrsqlite.dylib +0 -0
- package/{lib/crsqlite-darwin-x86_64.dylib → dist/lib/darwin-x86_64/libcrsqlite.dylib} +0 -0
- package/dist/lib/linux-aarch64/libcrsqlite.so +0 -0
- package/dist/lib/linux-x86_64/libcrsqlite.so +0 -0
- package/dist/lib/win-i686/crsqlite.dll +0 -0
- package/dist/lib/win-x86_64/crsqlite.dll +0 -0
- package/effect/package.json +6 -0
- package/package.json +55 -59
- package/paths/package.json +6 -0
- package/src/browser-unsupported.ts +9 -0
- package/src/effect.ts +117 -0
- package/src/index.ts +87 -0
- package/src/paths.ts +47 -0
- package/src/platform.ts +75 -0
- package/src/version.ts +5 -0
- package/bin/libcrsql-extension-path.js +0 -10
- package/index.d.ts +0 -16
- package/index.js +0 -67
- package/lib/crsqlite-darwin-aarch64.dylib +0 -0
- package/react-native.d.ts +0 -13
- package/react-native.js +0 -32
package/src/platform.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform detection and mapping utilities for @effect-native/libcrsql.
|
|
3
|
+
* @since 0.16.300
|
|
4
|
+
*/
|
|
5
|
+
// Platform detection and mapping
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Supported platform-arch identifiers.
|
|
9
|
+
* @since 0.16.300
|
|
10
|
+
*/
|
|
11
|
+
export type Platform =
|
|
12
|
+
| "darwin-aarch64"
|
|
13
|
+
| "darwin-x86_64"
|
|
14
|
+
| "linux-aarch64"
|
|
15
|
+
| "linux-x86_64"
|
|
16
|
+
| "win-x86_64"
|
|
17
|
+
| "win-i686"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* List of supported platforms.
|
|
21
|
+
* @since 0.16.300
|
|
22
|
+
*/
|
|
23
|
+
export const SUPPORTED_PLATFORMS: ReadonlyArray<Platform> = [
|
|
24
|
+
"darwin-aarch64",
|
|
25
|
+
"darwin-x86_64",
|
|
26
|
+
"linux-aarch64",
|
|
27
|
+
"linux-x86_64",
|
|
28
|
+
"win-x86_64",
|
|
29
|
+
"win-i686"
|
|
30
|
+
] as const
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* True if the given string is a supported platform.
|
|
34
|
+
* @since 0.16.300
|
|
35
|
+
*/
|
|
36
|
+
export const isSupportedPlatform = (p: string): p is Platform =>
|
|
37
|
+
(SUPPORTED_PLATFORMS as ReadonlyArray<string>).includes(p)
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Detect current platform string.
|
|
41
|
+
* @since 0.16.300
|
|
42
|
+
*/
|
|
43
|
+
export const detectPlatform = (): string => {
|
|
44
|
+
const platform = process.platform
|
|
45
|
+
const arch = process.arch
|
|
46
|
+
// Map Node.js platform/arch to our strings
|
|
47
|
+
if (platform === "darwin" && arch === "arm64") return "darwin-aarch64"
|
|
48
|
+
if (platform === "darwin" && arch === "x64") return "darwin-x86_64"
|
|
49
|
+
if (platform === "linux" && arch === "arm64") return "linux-aarch64"
|
|
50
|
+
if (platform === "linux" && arch === "x64") return "linux-x86_64"
|
|
51
|
+
if (platform === "win32" && arch === "x64") return "win-x86_64"
|
|
52
|
+
if (platform === "win32" && arch === "ia32") return "win-i686"
|
|
53
|
+
return `${platform}-${arch}`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Build relative path to the cr-sqlite binary within the package.
|
|
58
|
+
* @since 0.16.300
|
|
59
|
+
*/
|
|
60
|
+
export const buildRelativeLibraryPath = (platform: Platform): string => {
|
|
61
|
+
switch (platform) {
|
|
62
|
+
case "darwin-aarch64":
|
|
63
|
+
case "darwin-x86_64":
|
|
64
|
+
return `lib/${platform}/libcrsqlite.dylib`
|
|
65
|
+
case "linux-aarch64":
|
|
66
|
+
case "linux-x86_64":
|
|
67
|
+
return `lib/${platform}/libcrsqlite.so`
|
|
68
|
+
case "win-x86_64":
|
|
69
|
+
case "win-i686":
|
|
70
|
+
return `lib/${platform}/crsqlite.dll`
|
|
71
|
+
}
|
|
72
|
+
// Exhaustiveness note: if a new Platform variant is added, TypeScript will error
|
|
73
|
+
// unless it is handled above. This fallback exists only for type safety.
|
|
74
|
+
return platform satisfies never
|
|
75
|
+
}
|
package/src/version.ts
ADDED
package/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the absolute path to the bundled CR-SQLite extension
|
|
3
|
-
* @returns Absolute path to crsqlite.dylib/.so
|
|
4
|
-
*/
|
|
5
|
-
export declare function getExtensionPath(): string;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Path to CR-SQLite extension - for use with db.loadExtension()
|
|
9
|
-
*/
|
|
10
|
-
export declare const pathToCRSQLiteExtension: string;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Default export - same as pathToCRSQLiteExtension
|
|
14
|
-
*/
|
|
15
|
-
declare const _default: string;
|
|
16
|
-
export default _default;
|
package/index.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { dirname, resolve } from 'node:path';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
|
|
5
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Get the absolute path to the bundled CR-SQLite extension
|
|
9
|
-
* Automatically detects platform and architecture
|
|
10
|
-
* @returns {string} Absolute path to crsqlite.dylib/.so
|
|
11
|
-
*/
|
|
12
|
-
export function getExtensionPath() {
|
|
13
|
-
// Browser check - prevent misuse in browsers
|
|
14
|
-
if (typeof window !== 'undefined') {
|
|
15
|
-
throw new Error(
|
|
16
|
-
'@effect-native/libcrsql is for Node.js server environments only. ' +
|
|
17
|
-
'For browsers, use sql.js or a server-side database API.'
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Detect current platform and architecture
|
|
22
|
-
const platform = process.platform === 'darwin' ? 'darwin' : 'linux';
|
|
23
|
-
const arch = process.arch === 'arm64' ? 'aarch64' : 'x86_64';
|
|
24
|
-
const ext = platform === 'darwin' ? 'dylib' : 'so';
|
|
25
|
-
|
|
26
|
-
const libDir = resolve(__dirname, 'lib');
|
|
27
|
-
|
|
28
|
-
// Try platform-specific extension first (highest priority)
|
|
29
|
-
const specificExt = resolve(libDir, `crsqlite-${platform}-${arch}.${ext}`);
|
|
30
|
-
if (existsSync(specificExt)) {
|
|
31
|
-
return specificExt;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Fallback to any available extension for the current platform
|
|
35
|
-
const fallbackCandidates = [
|
|
36
|
-
resolve(libDir, `crsqlite.${ext}`), // Generic for platform
|
|
37
|
-
resolve(libDir, 'crsqlite.dylib'), // macOS generic
|
|
38
|
-
resolve(libDir, 'crsqlite.so'), // Linux generic
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
for (const candidate of fallbackCandidates) {
|
|
42
|
-
if (existsSync(candidate)) {
|
|
43
|
-
return candidate;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Helpful error message with available platforms
|
|
48
|
-
const availablePlatforms = [];
|
|
49
|
-
const expectedExt = `crsqlite-${platform}-${arch}.${ext}`;
|
|
50
|
-
throw new Error(
|
|
51
|
-
`CR-SQLite extension not found for ${platform}/${arch}. ` +
|
|
52
|
-
`Expected: ${expectedExt}. ` +
|
|
53
|
-
`Available platforms: ${availablePlatforms.join(', ')}. ` +
|
|
54
|
-
`This package supports: Intel/AMD Linux (Docker, most servers), ARM64 Linux (Raspberry Pi 4+, AWS Graviton), Intel Mac, Apple Silicon Mac (M1/M2/M3)`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Path to CR-SQLite extension - for use with db.loadExtension()
|
|
60
|
-
* Automatically detects your platform and returns the right extension
|
|
61
|
-
*/
|
|
62
|
-
export const pathToCRSQLiteExtension = getExtensionPath();
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Default export - same as pathToCRSQLiteExtension
|
|
66
|
-
*/
|
|
67
|
-
export default pathToCRSQLiteExtension;
|
|
Binary file
|
package/react-native.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Native placeholder for getExtensionPath
|
|
3
|
-
* @throws Always throws with helpful message for React Native users
|
|
4
|
-
*/
|
|
5
|
-
export declare function getExtensionPath(): never;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* React Native placeholder for pathToCRSQLiteExtension
|
|
9
|
-
* @throws Always throws with helpful message for React Native users
|
|
10
|
-
*/
|
|
11
|
-
export declare const pathToCRSQLiteExtension: never;
|
|
12
|
-
|
|
13
|
-
export default pathToCRSQLiteExtension;
|
package/react-native.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// React Native specific entry point
|
|
2
|
-
// CR-SQLite extensions don't work in React Native
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* React Native placeholder for getExtensionPath
|
|
6
|
-
* @throws Always throws with helpful message for React Native users
|
|
7
|
-
*/
|
|
8
|
-
export function getExtensionPath() {
|
|
9
|
-
throw new Error(
|
|
10
|
-
'\u{1f6ab} @effect-native/libcrsql is for Node.js / Bun server environments only.\n\n' +
|
|
11
|
-
'\u{1f4f1} For React Native, use one of these instead:\n' +
|
|
12
|
-
' \u2022 @op-engineering/op-sqlite: https://www.npmjs.com/package/@op-engineering/op-sqlite\n' +
|
|
13
|
-
' \u2022 expo-sqlite: https://docs.expo.dev/versions/latest/sdk/sqlite/\n' +
|
|
14
|
-
'\u{1f4a1} This package provides native CR-SQLite extensions for Node.js / Bun servers, not mobile apps.'
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* React Native placeholder for pathToCRSQLiteExtension
|
|
20
|
-
* @throws Always throws with helpful message
|
|
21
|
-
*/
|
|
22
|
-
export const pathToCRSQLiteExtension = (() => {
|
|
23
|
-
throw new Error(
|
|
24
|
-
'\u{1f6ab} @effect-native/libcrsql is for Node.js / Bun server environments only.\n\n' +
|
|
25
|
-
'\u{1f4f1} For React Native, use one of these instead:\n' +
|
|
26
|
-
' \u2022 @op-engineering/op-sqlite: https://www.npmjs.com/package/@op-engineering/op-sqlite\n' +
|
|
27
|
-
' \u2022 expo-sqlite: https://docs.expo.dev/versions/latest/sdk/sqlite/\n' +
|
|
28
|
-
'\u{1f4a1} This package provides native CR-SQLite extensions for Node.js / Bun servers, not mobile apps.'
|
|
29
|
-
);
|
|
30
|
-
})();
|
|
31
|
-
|
|
32
|
-
export default pathToCRSQLiteExtension;
|