@jpwesselink/dotsec-core 5.0.0-feat-napi-bindings.fae85cf

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.
Files changed (3) hide show
  1. package/index.d.ts +28 -0
  2. package/index.js +48 -0
  3. package/package.json +38 -0
package/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export interface DirectiveItem {
2
+ name: string;
3
+ value: string | null;
4
+ }
5
+
6
+ export interface ParsedEntry {
7
+ key: string;
8
+ value: string;
9
+ quoteType: string;
10
+ directives: DirectiveItem[];
11
+ }
12
+
13
+ export interface ParsedValidationError {
14
+ key: string;
15
+ message: string;
16
+ }
17
+
18
+ /** Parse a .env file string and return entries with their directives. */
19
+ export declare function parse(source: string): ParsedEntry[];
20
+
21
+ /** Validate entries from a .env file string. Returns a list of validation errors. */
22
+ export declare function validate(source: string): ParsedValidationError[];
23
+
24
+ /** Convert a .env file string to JSON. */
25
+ export declare function toJson(source: string): string;
26
+
27
+ /** Roundtrip: parse a .env file string and serialize it back. */
28
+ export declare function format(source: string): string;
package/index.js ADDED
@@ -0,0 +1,48 @@
1
+ import { createRequire } from "node:module";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const require = createRequire(import.meta.url);
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+
8
+ const PLATFORMS = {
9
+ "darwin-arm64": "@jpwesselink/dotsec-core-darwin-arm64",
10
+ "darwin-x64": "@jpwesselink/dotsec-core-darwin-x64",
11
+ "linux-x64": "@jpwesselink/dotsec-core-linux-x64-gnu",
12
+ "linux-arm64": "@jpwesselink/dotsec-core-linux-arm64-gnu",
13
+ "win32-x64": "@jpwesselink/dotsec-core-win32-x64-msvc",
14
+ "win32-arm64": "@jpwesselink/dotsec-core-win32-arm64-msvc",
15
+ };
16
+
17
+ const key = `${process.platform}-${process.arch}`;
18
+ const pkg = PLATFORMS[key];
19
+
20
+ if (!pkg) {
21
+ throw new Error(
22
+ `@jpwesselink/dotsec-core: unsupported platform ${process.platform}-${process.arch}\n` +
23
+ `Supported: ${Object.keys(PLATFORMS).join(", ")}`
24
+ );
25
+ }
26
+
27
+ let nativeModule;
28
+ try {
29
+ nativeModule = require(pkg);
30
+ } catch {
31
+ try {
32
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
33
+ nativeModule = require(path.join(pkgDir, "dotsec-core.node"));
34
+ } catch {
35
+ try {
36
+ nativeModule = require(path.join(__dirname, "dotsec-core.node"));
37
+ } catch {
38
+ throw new Error(
39
+ `@jpwesselink/dotsec-core: could not load native module "${pkg}"\n\n` +
40
+ `This usually means the optional dependency was not installed.\n` +
41
+ `Try reinstalling with: npm install @jpwesselink/dotsec-core`
42
+ );
43
+ }
44
+ }
45
+ }
46
+
47
+ export const { parse, validate, toJson, format } = nativeModule;
48
+ export default nativeModule;
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@jpwesselink/dotsec-core",
3
+ "version": "5.0.0-feat-napi-bindings.fae85cf",
4
+ "description": "Native Node.js bindings for dotsec — parse, validate, and format .env files",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "napi": {
9
+ "binaryName": "dotsec-core",
10
+ "targets": [
11
+ "x86_64-apple-darwin",
12
+ "aarch64-apple-darwin",
13
+ "x86_64-unknown-linux-gnu",
14
+ "aarch64-unknown-linux-gnu",
15
+ "x86_64-pc-windows-msvc",
16
+ "aarch64-pc-windows-msvc"
17
+ ]
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts"
22
+ ],
23
+ "optionalDependencies": {
24
+ "@jpwesselink/dotsec-core-darwin-arm64": "5.0.0-feat-napi-bindings.fae85cf",
25
+ "@jpwesselink/dotsec-core-darwin-x64": "5.0.0-feat-napi-bindings.fae85cf",
26
+ "@jpwesselink/dotsec-core-linux-x64-gnu": "5.0.0-feat-napi-bindings.fae85cf",
27
+ "@jpwesselink/dotsec-core-linux-arm64-gnu": "5.0.0-feat-napi-bindings.fae85cf",
28
+ "@jpwesselink/dotsec-core-win32-x64-msvc": "5.0.0-feat-napi-bindings.fae85cf",
29
+ "@jpwesselink/dotsec-core-win32-arm64-msvc": "5.0.0-feat-napi-bindings.fae85cf"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "license": "MIT",
35
+ "engines": {
36
+ "node": ">=16.0.0"
37
+ }
38
+ }