@crawlee/fs-storage 4.0.0-beta.120 → 4.0.0-beta.121

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,10 +1,18 @@
1
1
  import { opendir, readFile } from 'node:fs/promises';
2
2
  import { resolve } from 'node:path';
3
3
  import { s } from '@sapphire/shapeshift';
4
- import { FileSystemDatasetClient as NativeDatasetBackend, FileSystemKeyValueStoreClient as NativeKeyValueStoreBackend, FileSystemRequestQueueClient as NativeRequestQueueBackend, } from '@crawlee/fs-storage-native';
5
4
  import { DatasetBackend } from './resource-clients/dataset.js';
6
5
  import { KeyValueStoreBackend } from './resource-clients/key-value-store.js';
7
6
  import { RequestQueueBackend } from './resource-clients/request-queue.js';
7
+ // The native package throws at load time on platforms without a published binary (e.g.
8
+ // linux musl), and `@crawlee/core` imports this module eagerly via its service locator.
9
+ // Load it lazily so merely importing `@crawlee/fs-storage` stays safe everywhere and the
10
+ // native binding is only loaded when a file-system storage is actually used.
11
+ let nativeModule;
12
+ async function importNativeModule() {
13
+ nativeModule ??= import('@crawlee/fs-storage-native');
14
+ return nativeModule;
15
+ }
8
16
  /** The alias `@crawlee/core` opens the default (unnamed) storage under. */
9
17
  const DEFAULT_STORAGE_ALIAS = '__default__';
10
18
  /** The directory the default storage lives in, one level below `datasets` / `key_value_stores` / etc. */
@@ -68,7 +76,7 @@ export class FileSystemStorageBackend {
68
76
  if (found) {
69
77
  return found;
70
78
  }
71
- const nativeBackend = await NativeDatasetBackend.open(id, name, alias, this.localDataDirectory);
79
+ const nativeBackend = await (await importNativeModule()).FileSystemDatasetClient.open(id, name, alias, this.localDataDirectory);
72
80
  const newStore = await DatasetBackend.create({
73
81
  name: alias ? undefined : (name ?? cacheKey),
74
82
  cacheKey,
@@ -86,7 +94,7 @@ export class FileSystemStorageBackend {
86
94
  if (found) {
87
95
  return found;
88
96
  }
89
- const nativeBackend = await NativeKeyValueStoreBackend.open(id, name, alias, this.localDataDirectory);
97
+ const nativeBackend = await (await importNativeModule()).FileSystemKeyValueStoreClient.open(id, name, alias, this.localDataDirectory);
90
98
  const newStore = await KeyValueStoreBackend.create({
91
99
  name: alias ? undefined : (name ?? cacheKey),
92
100
  cacheKey,
@@ -104,7 +112,7 @@ export class FileSystemStorageBackend {
104
112
  if (found) {
105
113
  return found;
106
114
  }
107
- const nativeBackend = await NativeRequestQueueBackend.open(id, name, alias, this.localDataDirectory,
115
+ const nativeBackend = await (await importNativeModule()).FileSystemRequestQueueClient.open(id, name, alias, this.localDataDirectory,
108
116
  // useTestClock — always real wall-clock outside of native tests.
109
117
  undefined, this.requestQueueAccess);
110
118
  const newStore = await RequestQueueBackend.create({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/fs-storage",
3
- "version": "4.0.0-beta.120",
3
+ "version": "4.0.0-beta.121",
4
4
  "description": "A file-system storage implementation of the Apify API",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@crawlee/fs-storage-native": "0.1.5-beta.18",
46
- "@crawlee/types": "4.0.0-beta.120",
46
+ "@crawlee/types": "4.0.0-beta.121",
47
47
  "@sapphire/shapeshift": "^4.0.0"
48
48
  },
49
49
  "lerna": {
@@ -53,5 +53,5 @@
53
53
  }
54
54
  }
55
55
  },
56
- "gitHead": "da5d427c4c1c9dcaea95b151e9c4c7310100885d"
56
+ "gitHead": "5027317de626f5ba6de5047ae9341a898258cc5a"
57
57
  }