@photostax/core 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -1,158 +1,158 @@
1
- # @photostax/core
2
-
3
- **Node.js binding for the photostax library — access Epson FastFoto repositories from TypeScript/JavaScript.**
4
-
5
- [![npm](https://img.shields.io/npm/v/@photostax/core.svg)](https://www.npmjs.com/package/@photostax/core)
6
- [![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue)](../../LICENSE-MIT)
7
-
8
- ## Overview
9
-
10
- Epson FastFoto scanners produce multiple files per scanned photo:
11
-
12
- | File Pattern | Description |
13
- |--------------|-------------|
14
- | `<name>.jpg` or `<name>.tif` | Original front scan |
15
- | `<name>_a.jpg` or `<name>_a.tif` | Enhanced version (color-corrected) |
16
- | `<name>_b.jpg` or `<name>_b.tif` | Back of the photo |
17
-
18
- This library groups these files into `PhotoStack` objects and provides access to their metadata from EXIF, XMP, and a sidecar database.
19
-
20
- ## Installation
21
-
22
- ```bash
23
- npm install @photostax/core
24
- ```
25
-
26
- ## Quick Start
27
-
28
- ```typescript
29
- import { PhotostaxRepository } from '@photostax/core';
30
-
31
- // Open a directory containing FastFoto scans
32
- const repo = new PhotostaxRepository('/path/to/photos');
33
-
34
- // Scan for all photo stacks
35
- const stacks = repo.scan();
36
-
37
- for (const stack of stacks) {
38
- console.log(`Photo: ${stack.id}`);
39
- console.log(` Original: ${stack.original}`);
40
- console.log(` Enhanced: ${stack.enhanced}`);
41
- console.log(` Back: ${stack.back}`);
42
- console.log(` EXIF Make: ${stack.metadata.exifTags['Make']}`);
43
- }
44
- ```
45
-
46
- ## API Overview
47
-
48
- ### PhotostaxRepository
49
-
50
- The main class for accessing photo stacks.
51
-
52
- | Method | Description |
53
- |--------|-------------|
54
- | `scan()` | Discover all photo stacks in the repository |
55
- | `getStack(id)` | Get a specific stack by ID |
56
- | `readImage(path)` | Read raw image bytes as Buffer |
57
- | `writeMetadata(id, metadata)` | Write metadata to a stack |
58
- | `search(query)` | Find stacks matching a query |
59
-
60
- ### PhotoStack
61
-
62
- ```typescript
63
- interface PhotoStack {
64
- id: string; // Base filename identifier
65
- original: string | null; // Path to original scan
66
- enhanced: string | null; // Path to enhanced scan
67
- back: string | null; // Path to back scan
68
- metadata: Metadata;
69
- }
70
- ```
71
-
72
- ### Metadata
73
-
74
- ```typescript
75
- interface Metadata {
76
- exifTags: Record<string, string>; // EXIF tags from image
77
- xmpTags: Record<string, string>; // XMP metadata
78
- customTags: Record<string, unknown>; // Custom JSON metadata
79
- }
80
- ```
81
-
82
- ### SearchQuery
83
-
84
- ```typescript
85
- interface SearchQuery {
86
- text?: string; // Free-text search
87
- exifFilters?: KeyValueFilter[]; // EXIF tag filters
88
- customFilters?: KeyValueFilter[]; // Custom tag filters
89
- hasBack?: boolean; // Filter by back scan presence
90
- hasEnhanced?: boolean; // Filter by enhanced scan presence
91
- }
92
- ```
93
-
94
- ### Utility Functions
95
-
96
- | Function | Description |
97
- |----------|-------------|
98
- | `isNativeAvailable()` | Check if native addon loaded successfully |
99
- | `getNativeLoadError()` | Get error if native addon failed to load |
100
-
101
- ## Building from Source
102
-
103
- ### Prerequisites
104
-
105
- - [Rust toolchain](https://rustup.rs/) (1.70+)
106
- - [Node.js 18+](https://nodejs.org/) with npm
107
- - Python 3.x (for node-gyp)
108
- - C++ compiler (Visual Studio Build Tools on Windows, GCC/Clang on Unix)
109
-
110
- ### Build Steps
111
-
112
- ```bash
113
- # Clone the repository
114
- git clone https://github.com/JeromySt/photostax.git
115
- cd photostax/bindings/typescript
116
-
117
- # Install dependencies
118
- npm install
119
-
120
- # Build the native addon
121
- npm run build
122
-
123
- # Run tests
124
- npm test
125
- ```
126
-
127
- ### Development Build
128
-
129
- For faster iteration during development:
130
-
131
- ```bash
132
- npm run build:debug
133
- ```
134
-
135
- ## Supported Platforms
136
-
137
- Pre-built binaries are published for:
138
-
139
- | Platform | Architectures |
140
- |----------|---------------|
141
- | Windows | x64, arm64 |
142
- | macOS | x64, arm64 |
143
- | Linux | x64, arm64, musl |
144
-
145
- ## File Format Support
146
-
147
- | Format | Extensions | EXIF | XMP |
148
- |--------|------------|------|-----|
149
- | JPEG | `.jpg`, `.jpeg` | ✓ | Embedded |
150
- | TIFF | `.tif`, `.tiff` | ✓ | Embedded or sidecar |
151
-
152
- ## License
153
-
154
- Licensed under either of [Apache License, Version 2.0](../../LICENSE-APACHE) or [MIT license](../../LICENSE-MIT) at your option.
155
-
156
- ---
157
-
158
- [← Back to main README](../../README.md) | [FFI Documentation](../../ffi/README.md)
1
+ # @photostax/core
2
+
3
+ **Node.js binding for the photostax library — access Epson FastFoto repositories from TypeScript/JavaScript.**
4
+
5
+ [![npm](https://img.shields.io/npm/v/@photostax/core.svg)](https://www.npmjs.com/package/@photostax/core)
6
+ [![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue)](../../LICENSE-MIT)
7
+
8
+ ## Overview
9
+
10
+ Epson FastFoto scanners produce multiple files per scanned photo:
11
+
12
+ | File Pattern | Description |
13
+ |--------------|-------------|
14
+ | `<name>.jpg` or `<name>.tif` | Original front scan |
15
+ | `<name>_a.jpg` or `<name>_a.tif` | Enhanced version (color-corrected) |
16
+ | `<name>_b.jpg` or `<name>_b.tif` | Back of the photo |
17
+
18
+ This library groups these files into `PhotoStack` objects and provides access to their metadata from EXIF, XMP, and a sidecar database.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install @photostax/core
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ```typescript
29
+ import { PhotostaxRepository } from '@photostax/core';
30
+
31
+ // Open a directory containing FastFoto scans
32
+ const repo = new PhotostaxRepository('/path/to/photos');
33
+
34
+ // Scan for all photo stacks
35
+ const stacks = repo.scan();
36
+
37
+ for (const stack of stacks) {
38
+ console.log(`Photo: ${stack.id}`);
39
+ console.log(` Original: ${stack.original}`);
40
+ console.log(` Enhanced: ${stack.enhanced}`);
41
+ console.log(` Back: ${stack.back}`);
42
+ console.log(` EXIF Make: ${stack.metadata.exifTags['Make']}`);
43
+ }
44
+ ```
45
+
46
+ ## API Overview
47
+
48
+ ### PhotostaxRepository
49
+
50
+ The main class for accessing photo stacks.
51
+
52
+ | Method | Description |
53
+ |--------|-------------|
54
+ | `scan()` | Discover all photo stacks in the repository |
55
+ | `getStack(id)` | Get a specific stack by ID |
56
+ | `readImage(path)` | Read raw image bytes as Buffer |
57
+ | `writeMetadata(id, metadata)` | Write metadata to a stack |
58
+ | `search(query)` | Find stacks matching a query |
59
+
60
+ ### PhotoStack
61
+
62
+ ```typescript
63
+ interface PhotoStack {
64
+ id: string; // Base filename identifier
65
+ original: string | null; // Path to original scan
66
+ enhanced: string | null; // Path to enhanced scan
67
+ back: string | null; // Path to back scan
68
+ metadata: Metadata;
69
+ }
70
+ ```
71
+
72
+ ### Metadata
73
+
74
+ ```typescript
75
+ interface Metadata {
76
+ exifTags: Record<string, string>; // EXIF tags from image
77
+ xmpTags: Record<string, string>; // XMP metadata
78
+ customTags: Record<string, unknown>; // Custom JSON metadata
79
+ }
80
+ ```
81
+
82
+ ### SearchQuery
83
+
84
+ ```typescript
85
+ interface SearchQuery {
86
+ text?: string; // Free-text search
87
+ exifFilters?: KeyValueFilter[]; // EXIF tag filters
88
+ customFilters?: KeyValueFilter[]; // Custom tag filters
89
+ hasBack?: boolean; // Filter by back scan presence
90
+ hasEnhanced?: boolean; // Filter by enhanced scan presence
91
+ }
92
+ ```
93
+
94
+ ### Utility Functions
95
+
96
+ | Function | Description |
97
+ |----------|-------------|
98
+ | `isNativeAvailable()` | Check if native addon loaded successfully |
99
+ | `getNativeLoadError()` | Get error if native addon failed to load |
100
+
101
+ ## Building from Source
102
+
103
+ ### Prerequisites
104
+
105
+ - [Rust toolchain](https://rustup.rs/) (1.70+)
106
+ - [Node.js 18+](https://nodejs.org/) with npm
107
+ - Python 3.x (for node-gyp)
108
+ - C++ compiler (Visual Studio Build Tools on Windows, GCC/Clang on Unix)
109
+
110
+ ### Build Steps
111
+
112
+ ```bash
113
+ # Clone the repository
114
+ git clone https://github.com/JeromySt/photostax.git
115
+ cd photostax/bindings/typescript
116
+
117
+ # Install dependencies
118
+ npm install
119
+
120
+ # Build the native addon
121
+ npm run build
122
+
123
+ # Run tests
124
+ npm test
125
+ ```
126
+
127
+ ### Development Build
128
+
129
+ For faster iteration during development:
130
+
131
+ ```bash
132
+ npm run build:debug
133
+ ```
134
+
135
+ ## Supported Platforms
136
+
137
+ Pre-built binaries are published for:
138
+
139
+ | Platform | Architectures |
140
+ |----------|---------------|
141
+ | Windows | x64, arm64 |
142
+ | macOS | x64, arm64 |
143
+ | Linux | x64, arm64, musl |
144
+
145
+ ## File Format Support
146
+
147
+ | Format | Extensions | EXIF | XMP |
148
+ |--------|------------|------|-----|
149
+ | JPEG | `.jpg`, `.jpeg` | ✓ | Embedded |
150
+ | TIFF | `.tif`, `.tiff` | ✓ | Embedded or sidecar |
151
+
152
+ ## License
153
+
154
+ Licensed under either of [Apache License, Version 2.0](../../LICENSE-APACHE) or [MIT license](../../LICENSE-MIT) at your option.
155
+
156
+ ---
157
+
158
+ [← Back to main README](../../README.md) | [FFI Documentation](../../ffi/README.md)
package/index.d.ts CHANGED
@@ -1,131 +1,131 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /* auto-generated by NAPI-RS */
5
-
6
- /**
7
- * Metadata associated with a photo stack.
8
- *
9
- * Combines EXIF tags (from image files), XMP tags (embedded or sidecar),
10
- * and custom tags (from the sidecar database) into a unified view.
11
- */
12
- export interface JsMetadata {
13
- /** Standard EXIF tags from the image file (Make, Model, DateTime, etc.) */
14
- exifTags: Record<string, string>
15
- /** XMP/Dublin Core metadata tags */
16
- xmpTags: Record<string, string>
17
- /** Custom application metadata stored in the sidecar database */
18
- customTags: Record<string, any>
19
- }
20
- /**
21
- * A unified representation of a single scanned photo from an Epson FastFoto scanner.
22
- *
23
- * Groups the original scan, enhanced version, and back-of-photo image into
24
- * a single logical unit with associated metadata.
25
- */
26
- export interface JsPhotoStack {
27
- /** Unique identifier derived from the base filename */
28
- id: string
29
- /** Path to the original front scan (may be null) */
30
- original?: string
31
- /** Path to the enhanced/color-corrected scan (may be null) */
32
- enhanced?: string
33
- /** Path to the back-of-photo scan (may be null) */
34
- back?: string
35
- /** Combined metadata from all sources */
36
- metadata: JsMetadata
37
- }
38
- /** A key-value pair for search filters. */
39
- export interface JsKeyValue {
40
- /** The tag name to filter on */
41
- key: string
42
- /** The value substring to search for */
43
- value: string
44
- }
45
- /**
46
- * Query parameters for searching photo stacks.
47
- *
48
- * All filters use AND logic - a stack must match all specified criteria.
49
- */
50
- export interface JsSearchQuery {
51
- /** Free-text search across ID and all metadata */
52
- text?: string
53
- /** EXIF tag filters (all must match) */
54
- exifFilters?: Array<JsKeyValue>
55
- /** Custom tag filters (all must match) */
56
- customFilters?: Array<JsKeyValue>
57
- /** Filter by presence of back scan */
58
- hasBack?: boolean
59
- /** Filter by presence of enhanced scan */
60
- hasEnhanced?: boolean
61
- }
62
- /** Options for creating a PhotostaxRepository. */
63
- export interface RepositoryOptions {
64
- /**
65
- * Whether to recurse into subdirectories (default: false).
66
- *
67
- * Set to `true` when the photo library uses FastFoto's folder-based
68
- * organisation (e.g. `1984_Mexico/`, `SteveJones/`).
69
- */
70
- recursive?: boolean
71
- }
72
- /**
73
- * A repository for accessing Epson FastFoto photo stacks from a local directory.
74
- *
75
- * Provides methods to scan, retrieve, and modify photo stacks and their metadata.
76
- */
77
- export declare class PhotostaxRepository {
78
- /**
79
- * Create a new repository rooted at the given directory path.
80
- *
81
- * @param directoryPath - Path to the directory containing FastFoto photo files
82
- * @param options - Optional configuration (e.g. `{ recursive: true }`)
83
- * @throws Error if the path is invalid
84
- */
85
- constructor(directoryPath: string, options?: RepositoryOptions | undefined | null)
86
- /**
87
- * Scan the repository and return all discovered photo stacks.
88
- *
89
- * Groups files by FastFoto naming convention and enriches each stack
90
- * with EXIF, XMP, and sidecar metadata.
91
- *
92
- * @returns Array of photo stacks found in the repository
93
- * @throws Error if the directory cannot be accessed
94
- */
95
- scan(): Array<JsPhotoStack>
96
- /**
97
- * Retrieve a single photo stack by its ID.
98
- *
99
- * @param id - The stack identifier (base filename without suffix)
100
- * @returns The photo stack with the given ID
101
- * @throws Error if the stack is not found or cannot be accessed
102
- */
103
- getStack(id: string): JsPhotoStack
104
- /**
105
- * Read the raw bytes of an image file.
106
- *
107
- * @param path - Path to the image file (from a PhotoStack)
108
- * @returns Buffer containing the image bytes
109
- * @throws Error if the file cannot be read
110
- */
111
- readImage(path: string): Buffer
112
- /**
113
- * Write metadata tags to a photo stack.
114
- *
115
- * XMP tags are written to the image file (or sidecar for TIFF).
116
- * Custom and EXIF tags are stored in the sidecar database.
117
- *
118
- * @param stackId - The ID of the stack to update
119
- * @param metadata - The metadata to write
120
- * @throws Error if the stack is not found or metadata cannot be written
121
- */
122
- writeMetadata(stackId: string, metadata: JsMetadata): void
123
- /**
124
- * Search for photo stacks matching the given query.
125
- *
126
- * @param query - Search criteria (all filters are AND'd together)
127
- * @returns Array of matching photo stacks
128
- * @throws Error if the repository cannot be scanned
129
- */
130
- search(query: JsSearchQuery): Array<JsPhotoStack>
131
- }
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ /**
7
+ * Metadata associated with a photo stack.
8
+ *
9
+ * Combines EXIF tags (from image files), XMP tags (embedded or sidecar),
10
+ * and custom tags (from the sidecar database) into a unified view.
11
+ */
12
+ export interface JsMetadata {
13
+ /** Standard EXIF tags from the image file (Make, Model, DateTime, etc.) */
14
+ exifTags: Record<string, string>
15
+ /** XMP/Dublin Core metadata tags */
16
+ xmpTags: Record<string, string>
17
+ /** Custom application metadata stored in the sidecar database */
18
+ customTags: Record<string, any>
19
+ }
20
+ /**
21
+ * A unified representation of a single scanned photo from an Epson FastFoto scanner.
22
+ *
23
+ * Groups the original scan, enhanced version, and back-of-photo image into
24
+ * a single logical unit with associated metadata.
25
+ */
26
+ export interface JsPhotoStack {
27
+ /** Unique identifier derived from the base filename */
28
+ id: string
29
+ /** Path to the original front scan (may be null) */
30
+ original?: string
31
+ /** Path to the enhanced/color-corrected scan (may be null) */
32
+ enhanced?: string
33
+ /** Path to the back-of-photo scan (may be null) */
34
+ back?: string
35
+ /** Combined metadata from all sources */
36
+ metadata: JsMetadata
37
+ }
38
+ /** A key-value pair for search filters. */
39
+ export interface JsKeyValue {
40
+ /** The tag name to filter on */
41
+ key: string
42
+ /** The value substring to search for */
43
+ value: string
44
+ }
45
+ /**
46
+ * Query parameters for searching photo stacks.
47
+ *
48
+ * All filters use AND logic - a stack must match all specified criteria.
49
+ */
50
+ export interface JsSearchQuery {
51
+ /** Free-text search across ID and all metadata */
52
+ text?: string
53
+ /** EXIF tag filters (all must match) */
54
+ exifFilters?: Array<JsKeyValue>
55
+ /** Custom tag filters (all must match) */
56
+ customFilters?: Array<JsKeyValue>
57
+ /** Filter by presence of back scan */
58
+ hasBack?: boolean
59
+ /** Filter by presence of enhanced scan */
60
+ hasEnhanced?: boolean
61
+ }
62
+ /** Options for creating a PhotostaxRepository. */
63
+ export interface RepositoryOptions {
64
+ /**
65
+ * Whether to recurse into subdirectories (default: false).
66
+ *
67
+ * Set to `true` when the photo library uses FastFoto's folder-based
68
+ * organisation (e.g. `1984_Mexico/`, `SteveJones/`).
69
+ */
70
+ recursive?: boolean
71
+ }
72
+ /**
73
+ * A repository for accessing Epson FastFoto photo stacks from a local directory.
74
+ *
75
+ * Provides methods to scan, retrieve, and modify photo stacks and their metadata.
76
+ */
77
+ export declare class PhotostaxRepository {
78
+ /**
79
+ * Create a new repository rooted at the given directory path.
80
+ *
81
+ * @param directoryPath - Path to the directory containing FastFoto photo files
82
+ * @param options - Optional configuration (e.g. `{ recursive: true }`)
83
+ * @throws Error if the path is invalid
84
+ */
85
+ constructor(directoryPath: string, options?: RepositoryOptions | undefined | null)
86
+ /**
87
+ * Scan the repository and return all discovered photo stacks.
88
+ *
89
+ * Groups files by FastFoto naming convention and enriches each stack
90
+ * with EXIF, XMP, and sidecar metadata.
91
+ *
92
+ * @returns Array of photo stacks found in the repository
93
+ * @throws Error if the directory cannot be accessed
94
+ */
95
+ scan(): Array<JsPhotoStack>
96
+ /**
97
+ * Retrieve a single photo stack by its ID.
98
+ *
99
+ * @param id - The stack identifier (base filename without suffix)
100
+ * @returns The photo stack with the given ID
101
+ * @throws Error if the stack is not found or cannot be accessed
102
+ */
103
+ getStack(id: string): JsPhotoStack
104
+ /**
105
+ * Read the raw bytes of an image file.
106
+ *
107
+ * @param path - Path to the image file (from a PhotoStack)
108
+ * @returns Buffer containing the image bytes
109
+ * @throws Error if the file cannot be read
110
+ */
111
+ readImage(path: string): Buffer
112
+ /**
113
+ * Write metadata tags to a photo stack.
114
+ *
115
+ * XMP tags are written to the image file (or sidecar for TIFF).
116
+ * Custom and EXIF tags are stored in the sidecar database.
117
+ *
118
+ * @param stackId - The ID of the stack to update
119
+ * @param metadata - The metadata to write
120
+ * @throws Error if the stack is not found or metadata cannot be written
121
+ */
122
+ writeMetadata(stackId: string, metadata: JsMetadata): void
123
+ /**
124
+ * Search for photo stacks matching the given query.
125
+ *
126
+ * @param query - Search criteria (all filters are AND'd together)
127
+ * @returns Array of matching photo stacks
128
+ * @throws Error if the repository cannot be scanned
129
+ */
130
+ search(query: JsSearchQuery): Array<JsPhotoStack>
131
+ }
package/index.js CHANGED
@@ -1,315 +1,315 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /* prettier-ignore */
4
-
5
- /* auto-generated by NAPI-RS */
6
-
7
- const { existsSync, readFileSync } = require('fs')
8
- const { join } = require('path')
9
-
10
- const { platform, arch } = process
11
-
12
- let nativeBinding = null
13
- let localFileExisted = false
14
- let loadError = null
15
-
16
- function isMusl() {
17
- // For Node 10
18
- if (!process.report || typeof process.report.getReport !== 'function') {
19
- try {
20
- const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
- return readFileSync(lddPath, 'utf8').includes('musl')
22
- } catch (e) {
23
- return true
24
- }
25
- } else {
26
- const { glibcVersionRuntime } = process.report.getReport().header
27
- return !glibcVersionRuntime
28
- }
29
- }
30
-
31
- switch (platform) {
32
- case 'android':
33
- switch (arch) {
34
- case 'arm64':
35
- localFileExisted = existsSync(join(__dirname, 'photostax.android-arm64.node'))
36
- try {
37
- if (localFileExisted) {
38
- nativeBinding = require('./photostax.android-arm64.node')
39
- } else {
40
- nativeBinding = require('@photostax/core-android-arm64')
41
- }
42
- } catch (e) {
43
- loadError = e
44
- }
45
- break
46
- case 'arm':
47
- localFileExisted = existsSync(join(__dirname, 'photostax.android-arm-eabi.node'))
48
- try {
49
- if (localFileExisted) {
50
- nativeBinding = require('./photostax.android-arm-eabi.node')
51
- } else {
52
- nativeBinding = require('@photostax/core-android-arm-eabi')
53
- }
54
- } catch (e) {
55
- loadError = e
56
- }
57
- break
58
- default:
59
- throw new Error(`Unsupported architecture on Android ${arch}`)
60
- }
61
- break
62
- case 'win32':
63
- switch (arch) {
64
- case 'x64':
65
- localFileExisted = existsSync(
66
- join(__dirname, 'photostax.win32-x64-msvc.node')
67
- )
68
- try {
69
- if (localFileExisted) {
70
- nativeBinding = require('./photostax.win32-x64-msvc.node')
71
- } else {
72
- nativeBinding = require('@photostax/core-win32-x64-msvc')
73
- }
74
- } catch (e) {
75
- loadError = e
76
- }
77
- break
78
- case 'ia32':
79
- localFileExisted = existsSync(
80
- join(__dirname, 'photostax.win32-ia32-msvc.node')
81
- )
82
- try {
83
- if (localFileExisted) {
84
- nativeBinding = require('./photostax.win32-ia32-msvc.node')
85
- } else {
86
- nativeBinding = require('@photostax/core-win32-ia32-msvc')
87
- }
88
- } catch (e) {
89
- loadError = e
90
- }
91
- break
92
- case 'arm64':
93
- localFileExisted = existsSync(
94
- join(__dirname, 'photostax.win32-arm64-msvc.node')
95
- )
96
- try {
97
- if (localFileExisted) {
98
- nativeBinding = require('./photostax.win32-arm64-msvc.node')
99
- } else {
100
- nativeBinding = require('@photostax/core-win32-arm64-msvc')
101
- }
102
- } catch (e) {
103
- loadError = e
104
- }
105
- break
106
- default:
107
- throw new Error(`Unsupported architecture on Windows: ${arch}`)
108
- }
109
- break
110
- case 'darwin':
111
- localFileExisted = existsSync(join(__dirname, 'photostax.darwin-universal.node'))
112
- try {
113
- if (localFileExisted) {
114
- nativeBinding = require('./photostax.darwin-universal.node')
115
- } else {
116
- nativeBinding = require('@photostax/core-darwin-universal')
117
- }
118
- break
119
- } catch {}
120
- switch (arch) {
121
- case 'x64':
122
- localFileExisted = existsSync(join(__dirname, 'photostax.darwin-x64.node'))
123
- try {
124
- if (localFileExisted) {
125
- nativeBinding = require('./photostax.darwin-x64.node')
126
- } else {
127
- nativeBinding = require('@photostax/core-darwin-x64')
128
- }
129
- } catch (e) {
130
- loadError = e
131
- }
132
- break
133
- case 'arm64':
134
- localFileExisted = existsSync(
135
- join(__dirname, 'photostax.darwin-arm64.node')
136
- )
137
- try {
138
- if (localFileExisted) {
139
- nativeBinding = require('./photostax.darwin-arm64.node')
140
- } else {
141
- nativeBinding = require('@photostax/core-darwin-arm64')
142
- }
143
- } catch (e) {
144
- loadError = e
145
- }
146
- break
147
- default:
148
- throw new Error(`Unsupported architecture on macOS: ${arch}`)
149
- }
150
- break
151
- case 'freebsd':
152
- if (arch !== 'x64') {
153
- throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
154
- }
155
- localFileExisted = existsSync(join(__dirname, 'photostax.freebsd-x64.node'))
156
- try {
157
- if (localFileExisted) {
158
- nativeBinding = require('./photostax.freebsd-x64.node')
159
- } else {
160
- nativeBinding = require('@photostax/core-freebsd-x64')
161
- }
162
- } catch (e) {
163
- loadError = e
164
- }
165
- break
166
- case 'linux':
167
- switch (arch) {
168
- case 'x64':
169
- if (isMusl()) {
170
- localFileExisted = existsSync(
171
- join(__dirname, 'photostax.linux-x64-musl.node')
172
- )
173
- try {
174
- if (localFileExisted) {
175
- nativeBinding = require('./photostax.linux-x64-musl.node')
176
- } else {
177
- nativeBinding = require('@photostax/core-linux-x64-musl')
178
- }
179
- } catch (e) {
180
- loadError = e
181
- }
182
- } else {
183
- localFileExisted = existsSync(
184
- join(__dirname, 'photostax.linux-x64-gnu.node')
185
- )
186
- try {
187
- if (localFileExisted) {
188
- nativeBinding = require('./photostax.linux-x64-gnu.node')
189
- } else {
190
- nativeBinding = require('@photostax/core-linux-x64-gnu')
191
- }
192
- } catch (e) {
193
- loadError = e
194
- }
195
- }
196
- break
197
- case 'arm64':
198
- if (isMusl()) {
199
- localFileExisted = existsSync(
200
- join(__dirname, 'photostax.linux-arm64-musl.node')
201
- )
202
- try {
203
- if (localFileExisted) {
204
- nativeBinding = require('./photostax.linux-arm64-musl.node')
205
- } else {
206
- nativeBinding = require('@photostax/core-linux-arm64-musl')
207
- }
208
- } catch (e) {
209
- loadError = e
210
- }
211
- } else {
212
- localFileExisted = existsSync(
213
- join(__dirname, 'photostax.linux-arm64-gnu.node')
214
- )
215
- try {
216
- if (localFileExisted) {
217
- nativeBinding = require('./photostax.linux-arm64-gnu.node')
218
- } else {
219
- nativeBinding = require('@photostax/core-linux-arm64-gnu')
220
- }
221
- } catch (e) {
222
- loadError = e
223
- }
224
- }
225
- break
226
- case 'arm':
227
- if (isMusl()) {
228
- localFileExisted = existsSync(
229
- join(__dirname, 'photostax.linux-arm-musleabihf.node')
230
- )
231
- try {
232
- if (localFileExisted) {
233
- nativeBinding = require('./photostax.linux-arm-musleabihf.node')
234
- } else {
235
- nativeBinding = require('@photostax/core-linux-arm-musleabihf')
236
- }
237
- } catch (e) {
238
- loadError = e
239
- }
240
- } else {
241
- localFileExisted = existsSync(
242
- join(__dirname, 'photostax.linux-arm-gnueabihf.node')
243
- )
244
- try {
245
- if (localFileExisted) {
246
- nativeBinding = require('./photostax.linux-arm-gnueabihf.node')
247
- } else {
248
- nativeBinding = require('@photostax/core-linux-arm-gnueabihf')
249
- }
250
- } catch (e) {
251
- loadError = e
252
- }
253
- }
254
- break
255
- case 'riscv64':
256
- if (isMusl()) {
257
- localFileExisted = existsSync(
258
- join(__dirname, 'photostax.linux-riscv64-musl.node')
259
- )
260
- try {
261
- if (localFileExisted) {
262
- nativeBinding = require('./photostax.linux-riscv64-musl.node')
263
- } else {
264
- nativeBinding = require('@photostax/core-linux-riscv64-musl')
265
- }
266
- } catch (e) {
267
- loadError = e
268
- }
269
- } else {
270
- localFileExisted = existsSync(
271
- join(__dirname, 'photostax.linux-riscv64-gnu.node')
272
- )
273
- try {
274
- if (localFileExisted) {
275
- nativeBinding = require('./photostax.linux-riscv64-gnu.node')
276
- } else {
277
- nativeBinding = require('@photostax/core-linux-riscv64-gnu')
278
- }
279
- } catch (e) {
280
- loadError = e
281
- }
282
- }
283
- break
284
- case 's390x':
285
- localFileExisted = existsSync(
286
- join(__dirname, 'photostax.linux-s390x-gnu.node')
287
- )
288
- try {
289
- if (localFileExisted) {
290
- nativeBinding = require('./photostax.linux-s390x-gnu.node')
291
- } else {
292
- nativeBinding = require('@photostax/core-linux-s390x-gnu')
293
- }
294
- } catch (e) {
295
- loadError = e
296
- }
297
- break
298
- default:
299
- throw new Error(`Unsupported architecture on Linux: ${arch}`)
300
- }
301
- break
302
- default:
303
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
304
- }
305
-
306
- if (!nativeBinding) {
307
- if (loadError) {
308
- throw loadError
309
- }
310
- throw new Error(`Failed to load native binding`)
311
- }
312
-
313
- const { PhotostaxRepository } = nativeBinding
314
-
315
- module.exports.PhotostaxRepository = PhotostaxRepository
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /* prettier-ignore */
4
+
5
+ /* auto-generated by NAPI-RS */
6
+
7
+ const { existsSync, readFileSync } = require('fs')
8
+ const { join } = require('path')
9
+
10
+ const { platform, arch } = process
11
+
12
+ let nativeBinding = null
13
+ let localFileExisted = false
14
+ let loadError = null
15
+
16
+ function isMusl() {
17
+ // For Node 10
18
+ if (!process.report || typeof process.report.getReport !== 'function') {
19
+ try {
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
+ return readFileSync(lddPath, 'utf8').includes('musl')
22
+ } catch (e) {
23
+ return true
24
+ }
25
+ } else {
26
+ const { glibcVersionRuntime } = process.report.getReport().header
27
+ return !glibcVersionRuntime
28
+ }
29
+ }
30
+
31
+ switch (platform) {
32
+ case 'android':
33
+ switch (arch) {
34
+ case 'arm64':
35
+ localFileExisted = existsSync(join(__dirname, 'photostax.android-arm64.node'))
36
+ try {
37
+ if (localFileExisted) {
38
+ nativeBinding = require('./photostax.android-arm64.node')
39
+ } else {
40
+ nativeBinding = require('@photostax/core-android-arm64')
41
+ }
42
+ } catch (e) {
43
+ loadError = e
44
+ }
45
+ break
46
+ case 'arm':
47
+ localFileExisted = existsSync(join(__dirname, 'photostax.android-arm-eabi.node'))
48
+ try {
49
+ if (localFileExisted) {
50
+ nativeBinding = require('./photostax.android-arm-eabi.node')
51
+ } else {
52
+ nativeBinding = require('@photostax/core-android-arm-eabi')
53
+ }
54
+ } catch (e) {
55
+ loadError = e
56
+ }
57
+ break
58
+ default:
59
+ throw new Error(`Unsupported architecture on Android ${arch}`)
60
+ }
61
+ break
62
+ case 'win32':
63
+ switch (arch) {
64
+ case 'x64':
65
+ localFileExisted = existsSync(
66
+ join(__dirname, 'photostax.win32-x64-msvc.node')
67
+ )
68
+ try {
69
+ if (localFileExisted) {
70
+ nativeBinding = require('./photostax.win32-x64-msvc.node')
71
+ } else {
72
+ nativeBinding = require('@photostax/core-win32-x64-msvc')
73
+ }
74
+ } catch (e) {
75
+ loadError = e
76
+ }
77
+ break
78
+ case 'ia32':
79
+ localFileExisted = existsSync(
80
+ join(__dirname, 'photostax.win32-ia32-msvc.node')
81
+ )
82
+ try {
83
+ if (localFileExisted) {
84
+ nativeBinding = require('./photostax.win32-ia32-msvc.node')
85
+ } else {
86
+ nativeBinding = require('@photostax/core-win32-ia32-msvc')
87
+ }
88
+ } catch (e) {
89
+ loadError = e
90
+ }
91
+ break
92
+ case 'arm64':
93
+ localFileExisted = existsSync(
94
+ join(__dirname, 'photostax.win32-arm64-msvc.node')
95
+ )
96
+ try {
97
+ if (localFileExisted) {
98
+ nativeBinding = require('./photostax.win32-arm64-msvc.node')
99
+ } else {
100
+ nativeBinding = require('@photostax/core-win32-arm64-msvc')
101
+ }
102
+ } catch (e) {
103
+ loadError = e
104
+ }
105
+ break
106
+ default:
107
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
108
+ }
109
+ break
110
+ case 'darwin':
111
+ localFileExisted = existsSync(join(__dirname, 'photostax.darwin-universal.node'))
112
+ try {
113
+ if (localFileExisted) {
114
+ nativeBinding = require('./photostax.darwin-universal.node')
115
+ } else {
116
+ nativeBinding = require('@photostax/core-darwin-universal')
117
+ }
118
+ break
119
+ } catch {}
120
+ switch (arch) {
121
+ case 'x64':
122
+ localFileExisted = existsSync(join(__dirname, 'photostax.darwin-x64.node'))
123
+ try {
124
+ if (localFileExisted) {
125
+ nativeBinding = require('./photostax.darwin-x64.node')
126
+ } else {
127
+ nativeBinding = require('@photostax/core-darwin-x64')
128
+ }
129
+ } catch (e) {
130
+ loadError = e
131
+ }
132
+ break
133
+ case 'arm64':
134
+ localFileExisted = existsSync(
135
+ join(__dirname, 'photostax.darwin-arm64.node')
136
+ )
137
+ try {
138
+ if (localFileExisted) {
139
+ nativeBinding = require('./photostax.darwin-arm64.node')
140
+ } else {
141
+ nativeBinding = require('@photostax/core-darwin-arm64')
142
+ }
143
+ } catch (e) {
144
+ loadError = e
145
+ }
146
+ break
147
+ default:
148
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
149
+ }
150
+ break
151
+ case 'freebsd':
152
+ if (arch !== 'x64') {
153
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
154
+ }
155
+ localFileExisted = existsSync(join(__dirname, 'photostax.freebsd-x64.node'))
156
+ try {
157
+ if (localFileExisted) {
158
+ nativeBinding = require('./photostax.freebsd-x64.node')
159
+ } else {
160
+ nativeBinding = require('@photostax/core-freebsd-x64')
161
+ }
162
+ } catch (e) {
163
+ loadError = e
164
+ }
165
+ break
166
+ case 'linux':
167
+ switch (arch) {
168
+ case 'x64':
169
+ if (isMusl()) {
170
+ localFileExisted = existsSync(
171
+ join(__dirname, 'photostax.linux-x64-musl.node')
172
+ )
173
+ try {
174
+ if (localFileExisted) {
175
+ nativeBinding = require('./photostax.linux-x64-musl.node')
176
+ } else {
177
+ nativeBinding = require('@photostax/core-linux-x64-musl')
178
+ }
179
+ } catch (e) {
180
+ loadError = e
181
+ }
182
+ } else {
183
+ localFileExisted = existsSync(
184
+ join(__dirname, 'photostax.linux-x64-gnu.node')
185
+ )
186
+ try {
187
+ if (localFileExisted) {
188
+ nativeBinding = require('./photostax.linux-x64-gnu.node')
189
+ } else {
190
+ nativeBinding = require('@photostax/core-linux-x64-gnu')
191
+ }
192
+ } catch (e) {
193
+ loadError = e
194
+ }
195
+ }
196
+ break
197
+ case 'arm64':
198
+ if (isMusl()) {
199
+ localFileExisted = existsSync(
200
+ join(__dirname, 'photostax.linux-arm64-musl.node')
201
+ )
202
+ try {
203
+ if (localFileExisted) {
204
+ nativeBinding = require('./photostax.linux-arm64-musl.node')
205
+ } else {
206
+ nativeBinding = require('@photostax/core-linux-arm64-musl')
207
+ }
208
+ } catch (e) {
209
+ loadError = e
210
+ }
211
+ } else {
212
+ localFileExisted = existsSync(
213
+ join(__dirname, 'photostax.linux-arm64-gnu.node')
214
+ )
215
+ try {
216
+ if (localFileExisted) {
217
+ nativeBinding = require('./photostax.linux-arm64-gnu.node')
218
+ } else {
219
+ nativeBinding = require('@photostax/core-linux-arm64-gnu')
220
+ }
221
+ } catch (e) {
222
+ loadError = e
223
+ }
224
+ }
225
+ break
226
+ case 'arm':
227
+ if (isMusl()) {
228
+ localFileExisted = existsSync(
229
+ join(__dirname, 'photostax.linux-arm-musleabihf.node')
230
+ )
231
+ try {
232
+ if (localFileExisted) {
233
+ nativeBinding = require('./photostax.linux-arm-musleabihf.node')
234
+ } else {
235
+ nativeBinding = require('@photostax/core-linux-arm-musleabihf')
236
+ }
237
+ } catch (e) {
238
+ loadError = e
239
+ }
240
+ } else {
241
+ localFileExisted = existsSync(
242
+ join(__dirname, 'photostax.linux-arm-gnueabihf.node')
243
+ )
244
+ try {
245
+ if (localFileExisted) {
246
+ nativeBinding = require('./photostax.linux-arm-gnueabihf.node')
247
+ } else {
248
+ nativeBinding = require('@photostax/core-linux-arm-gnueabihf')
249
+ }
250
+ } catch (e) {
251
+ loadError = e
252
+ }
253
+ }
254
+ break
255
+ case 'riscv64':
256
+ if (isMusl()) {
257
+ localFileExisted = existsSync(
258
+ join(__dirname, 'photostax.linux-riscv64-musl.node')
259
+ )
260
+ try {
261
+ if (localFileExisted) {
262
+ nativeBinding = require('./photostax.linux-riscv64-musl.node')
263
+ } else {
264
+ nativeBinding = require('@photostax/core-linux-riscv64-musl')
265
+ }
266
+ } catch (e) {
267
+ loadError = e
268
+ }
269
+ } else {
270
+ localFileExisted = existsSync(
271
+ join(__dirname, 'photostax.linux-riscv64-gnu.node')
272
+ )
273
+ try {
274
+ if (localFileExisted) {
275
+ nativeBinding = require('./photostax.linux-riscv64-gnu.node')
276
+ } else {
277
+ nativeBinding = require('@photostax/core-linux-riscv64-gnu')
278
+ }
279
+ } catch (e) {
280
+ loadError = e
281
+ }
282
+ }
283
+ break
284
+ case 's390x':
285
+ localFileExisted = existsSync(
286
+ join(__dirname, 'photostax.linux-s390x-gnu.node')
287
+ )
288
+ try {
289
+ if (localFileExisted) {
290
+ nativeBinding = require('./photostax.linux-s390x-gnu.node')
291
+ } else {
292
+ nativeBinding = require('@photostax/core-linux-s390x-gnu')
293
+ }
294
+ } catch (e) {
295
+ loadError = e
296
+ }
297
+ break
298
+ default:
299
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
300
+ }
301
+ break
302
+ default:
303
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
304
+ }
305
+
306
+ if (!nativeBinding) {
307
+ if (loadError) {
308
+ throw loadError
309
+ }
310
+ throw new Error(`Failed to load native binding`)
311
+ }
312
+
313
+ const { PhotostaxRepository } = nativeBinding
314
+
315
+ module.exports.PhotostaxRepository = PhotostaxRepository
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@photostax/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Unified photo stack library for Epson FastFoto repositories - Node.js binding",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -45,8 +45,8 @@
45
45
  "jpeg"
46
46
  ],
47
47
  "optionalDependencies": {
48
- "@photostax/core-win32-x64-msvc": "0.1.0",
49
- "@photostax/core-darwin-x64": "0.1.0",
50
- "@photostax/core-linux-x64-gnu": "0.1.0"
48
+ "@photostax/core-win32-x64-msvc": "0.1.2",
49
+ "@photostax/core-darwin-x64": "0.1.2",
50
+ "@photostax/core-linux-x64-gnu": "0.1.2"
51
51
  }
52
52
  }
Binary file
Binary file