@lickle/lock 0.0.1-alpha.1 → 0.0.1-alpha.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 +182 -76
- package/cjs.js +57 -57
- package/dist/cjs/core/guard.d.ts +50 -0
- package/dist/cjs/core/guard.d.ts.map +1 -0
- package/dist/cjs/{backend → core}/guard.js +43 -11
- package/dist/cjs/core/guard.js.map +1 -0
- package/dist/cjs/core/index.d.ts +8 -0
- package/dist/cjs/core/index.d.ts.map +1 -0
- package/dist/cjs/core/index.js +41 -0
- package/dist/cjs/core/index.js.map +1 -0
- package/dist/cjs/core/locking.d.ts +23 -0
- package/dist/cjs/core/locking.d.ts.map +1 -0
- package/dist/cjs/core/locking.js +93 -0
- package/dist/cjs/core/locking.js.map +1 -0
- package/dist/cjs/core/node.d.ts +19 -0
- package/dist/cjs/core/node.d.ts.map +1 -0
- package/dist/cjs/core/node.js +69 -0
- package/dist/cjs/core/node.js.map +1 -0
- package/dist/cjs/core/types.d.ts +49 -0
- package/dist/cjs/core/types.d.ts.map +1 -0
- package/dist/cjs/core/types.js +13 -0
- package/dist/cjs/core/types.js.map +1 -0
- package/dist/cjs/index.d.ts +43 -34
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +59 -39
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/core/guard.d.ts +50 -0
- package/dist/esm/core/guard.d.ts.map +1 -0
- package/dist/esm/{backend → core}/guard.js +40 -9
- package/dist/esm/core/guard.js.map +1 -0
- package/dist/esm/core/index.d.ts +8 -0
- package/dist/esm/core/index.d.ts.map +1 -0
- package/dist/esm/core/index.js +21 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/locking.d.ts +23 -0
- package/dist/esm/core/locking.d.ts.map +1 -0
- package/dist/esm/core/locking.js +56 -0
- package/dist/esm/core/locking.js.map +1 -0
- package/dist/esm/core/node.d.ts +19 -0
- package/dist/esm/core/node.d.ts.map +1 -0
- package/dist/esm/core/node.js +61 -0
- package/dist/esm/core/node.js.map +1 -0
- package/dist/esm/core/types.d.ts +49 -0
- package/dist/esm/core/types.d.ts.map +1 -0
- package/dist/esm/core/types.js +9 -0
- package/dist/esm/core/types.js.map +1 -0
- package/dist/esm/index.d.ts +43 -34
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +53 -34
- package/dist/esm/index.js.map +1 -1
- package/esm.js +58 -58
- package/index.d.ts +32 -8
- package/package.json +6 -6
- package/dist/cjs/backend/guard.d.ts +0 -31
- package/dist/cjs/backend/guard.d.ts.map +0 -1
- package/dist/cjs/backend/guard.js.map +0 -1
- package/dist/cjs/backend/index.d.ts +0 -8
- package/dist/cjs/backend/index.d.ts.map +0 -1
- package/dist/cjs/backend/index.js +0 -31
- package/dist/cjs/backend/index.js.map +0 -1
- package/dist/cjs/backend/lockable.d.ts +0 -15
- package/dist/cjs/backend/lockable.d.ts.map +0 -1
- package/dist/cjs/backend/lockable.js +0 -76
- package/dist/cjs/backend/lockable.js.map +0 -1
- package/dist/cjs/backend/node.d.ts +0 -36
- package/dist/cjs/backend/node.d.ts.map +0 -1
- package/dist/cjs/backend/node.js +0 -118
- package/dist/cjs/backend/node.js.map +0 -1
- package/dist/cjs/backend/types.d.ts +0 -36
- package/dist/cjs/backend/types.d.ts.map +0 -1
- package/dist/cjs/backend/types.js +0 -3
- package/dist/cjs/backend/types.js.map +0 -1
- package/dist/esm/backend/guard.d.ts +0 -31
- package/dist/esm/backend/guard.d.ts.map +0 -1
- package/dist/esm/backend/guard.js.map +0 -1
- package/dist/esm/backend/index.d.ts +0 -8
- package/dist/esm/backend/index.d.ts.map +0 -1
- package/dist/esm/backend/index.js +0 -13
- package/dist/esm/backend/index.js.map +0 -1
- package/dist/esm/backend/lockable.d.ts +0 -15
- package/dist/esm/backend/lockable.d.ts.map +0 -1
- package/dist/esm/backend/lockable.js +0 -39
- package/dist/esm/backend/lockable.js.map +0 -1
- package/dist/esm/backend/node.d.ts +0 -36
- package/dist/esm/backend/node.d.ts.map +0 -1
- package/dist/esm/backend/node.js +0 -109
- package/dist/esm/backend/node.js.map +0 -1
- package/dist/esm/backend/types.d.ts +0 -36
- package/dist/esm/backend/types.d.ts.map +0 -1
- package/dist/esm/backend/types.js +0 -2
- package/dist/esm/backend/types.js.map +0 -1
package/cjs.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('@lickle/lock-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('@lickle/lock-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
80
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('@lickle/lock-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('@lickle/lock-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
96
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('@lickle/lock-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('@lickle/lock-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
117
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('@lickle/lock-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('@lickle/lock-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
133
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('@lickle/lock-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('@lickle/lock-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
150
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('@lickle/lock-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('@lickle/lock-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
166
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('@lickle/lock-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('@lickle/lock-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
185
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('@lickle/lock-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('@lickle/lock-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
201
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('@lickle/lock-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('@lickle/lock-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
217
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('@lickle/lock-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('@lickle/lock-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
237
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('@lickle/lock-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('@lickle/lock-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
253
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('@lickle/lock-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('@lickle/lock-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
274
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('@lickle/lock-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('@lickle/lock-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
290
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('@lickle/lock-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('@lickle/lock-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
308
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('@lickle/lock-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('@lickle/lock-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
324
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('@lickle/lock-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('@lickle/lock-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
342
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('@lickle/lock-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('@lickle/lock-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
358
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('@lickle/lock-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('@lickle/lock-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
376
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('@lickle/lock-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('@lickle/lock-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
392
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('@lickle/lock-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('@lickle/lock-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
410
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('@lickle/lock-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('@lickle/lock-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
426
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('@lickle/lock-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('@lickle/lock-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
443
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('@lickle/lock-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('@lickle/lock-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
459
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('@lickle/lock-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('@lickle/lock-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
479
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('@lickle/lock-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('@lickle/lock-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
495
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('@lickle/lock-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('@lickle/lock-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.0.1-alpha.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.
|
|
511
|
+
if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -576,8 +576,8 @@ if (!nativeBinding) {
|
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
module.exports = nativeBinding
|
|
579
|
-
module.exports.
|
|
580
|
-
module.exports.
|
|
581
|
-
module.exports.
|
|
582
|
-
module.exports.
|
|
583
|
-
module.exports.
|
|
579
|
+
module.exports.lock = nativeBinding.lock
|
|
580
|
+
module.exports.Lock = nativeBinding.Lock
|
|
581
|
+
module.exports.lockSync = nativeBinding.lockSync
|
|
582
|
+
module.exports.tryLock = nativeBinding.tryLock
|
|
583
|
+
module.exports.tryLockSync = nativeBinding.tryLockSync
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type FileDescriptor, type FileHandle, type Locker, type LockRange } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Guard that holds a lock without owning the file handle.
|
|
4
|
+
* Releasing the guard unlocks the file but does not close it.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const guard = await lock(handle, Lock.Exclusive)
|
|
8
|
+
* try { /* work *\/ } finally { await guard.drop() }
|
|
9
|
+
*/
|
|
10
|
+
export declare class LockGuard<H extends FileDescriptor> {
|
|
11
|
+
private locking;
|
|
12
|
+
private range?;
|
|
13
|
+
private _dropped;
|
|
14
|
+
/** The file descriptor number. */
|
|
15
|
+
readonly fd: number;
|
|
16
|
+
constructor(locking: Locker, handle: H, range?: LockRange | undefined);
|
|
17
|
+
/** True if the lock has been released. */
|
|
18
|
+
get dropped(): boolean;
|
|
19
|
+
/** Release the lock. Safe to call multiple times. */
|
|
20
|
+
drop(): Promise<void>;
|
|
21
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* RAII guard that holds a file lock. Unlocks and closes the file on drop.
|
|
25
|
+
* Supports `await using` via `Symbol.asyncDispose`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* await using guard = await exclusive('/tmp/my.lock')
|
|
29
|
+
* // lock is released when guard goes out of scope
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const guard = await exclusive('/tmp/my.lock')
|
|
33
|
+
* try { /* work *\/ } finally { await guard.drop() }
|
|
34
|
+
*/
|
|
35
|
+
export declare class FileLockGuard<H extends FileHandle> {
|
|
36
|
+
private guard;
|
|
37
|
+
private hndl;
|
|
38
|
+
private _dropped;
|
|
39
|
+
/** The file descriptor number. */
|
|
40
|
+
readonly fd: number;
|
|
41
|
+
constructor(guard: LockGuard<H>, hndl: H);
|
|
42
|
+
/** The underlying file handle. Throws if the guard has been dropped. */
|
|
43
|
+
get handle(): H;
|
|
44
|
+
/** True if the lock has been released. */
|
|
45
|
+
get dropped(): boolean;
|
|
46
|
+
/** Release the lock and close the file. Safe to call multiple times. */
|
|
47
|
+
drop(): Promise<void>;
|
|
48
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../../lib/core/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAa,MAAM,YAAY,CAAA;AAEzG;;;;;;;GAOG;AACH,qBAAa,SAAS,CAAC,CAAC,SAAS,cAAc;IAM3C,OAAO,CAAC,OAAO;IAEf,OAAO,CAAC,KAAK,CAAC;IAPhB,OAAO,CAAC,QAAQ,CAA2B;IAC3C,kCAAkC;IAClC,SAAgB,EAAE,EAAE,MAAM,CAAA;gBAGhB,OAAO,EAAE,MAAM,EACvB,MAAM,EAAE,CAAC,EACD,KAAK,CAAC,EAAE,SAAS,YAAA;IAK3B,0CAA0C;IAC1C,IAAI,OAAO,YAEV;IAED,qDAAqD;IACrD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,aAAa,CAAC,CAAC,SAAS,UAAU;IAM3C,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,IAAI;IANd,OAAO,CAAC,QAAQ,CAA2B;IAC3C,kCAAkC;IAClC,SAAgB,EAAE,EAAE,MAAM,CAAA;gBAGhB,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,IAAI,EAAE,CAAC;IAKjB,wEAAwE;IACxE,IAAI,MAAM,IAAI,CAAC,CAGd;IAED,0CAA0C;IAC1C,IAAI,OAAO,YAEV;IAED,wEAAwE;IACxE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAarB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvC"}
|
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FileLockGuard = exports.LockGuard = void 0;
|
|
4
|
+
const types_js_1 = require("./types.js");
|
|
5
|
+
/**
|
|
6
|
+
* Guard that holds a lock without owning the file handle.
|
|
7
|
+
* Releasing the guard unlocks the file but does not close it.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const guard = await lock(handle, Lock.Exclusive)
|
|
11
|
+
* try { /* work *\/ } finally { await guard.drop() }
|
|
12
|
+
*/
|
|
13
|
+
class LockGuard {
|
|
14
|
+
locking;
|
|
15
|
+
range;
|
|
16
|
+
_dropped;
|
|
17
|
+
/** The file descriptor number. */
|
|
18
|
+
fd;
|
|
19
|
+
constructor(locking, handle, range) {
|
|
20
|
+
this.locking = locking;
|
|
21
|
+
this.range = range;
|
|
22
|
+
this.fd = (0, types_js_1.resolveFd)(handle);
|
|
23
|
+
}
|
|
24
|
+
/** True if the lock has been released. */
|
|
25
|
+
get dropped() {
|
|
26
|
+
return !!this._dropped;
|
|
27
|
+
}
|
|
28
|
+
/** Release the lock. Safe to call multiple times. */
|
|
29
|
+
drop() {
|
|
30
|
+
if (!this._dropped)
|
|
31
|
+
this._dropped = this.locking.unlock(this.fd, this.range);
|
|
32
|
+
return this._dropped;
|
|
33
|
+
}
|
|
34
|
+
[Symbol.asyncDispose]() {
|
|
35
|
+
return this.drop();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.LockGuard = LockGuard;
|
|
4
39
|
/**
|
|
5
40
|
* RAII guard that holds a file lock. Unlocks and closes the file on drop.
|
|
6
41
|
* Supports `await using` via `Symbol.asyncDispose`.
|
|
@@ -13,25 +48,22 @@ exports.FileGuard = void 0;
|
|
|
13
48
|
* const guard = await exclusive('/tmp/my.lock')
|
|
14
49
|
* try { /* work *\/ } finally { await guard.drop() }
|
|
15
50
|
*/
|
|
16
|
-
class
|
|
17
|
-
|
|
51
|
+
class FileLockGuard {
|
|
52
|
+
guard;
|
|
18
53
|
hndl;
|
|
19
54
|
_dropped;
|
|
20
|
-
/** The lock file path. */
|
|
21
|
-
path;
|
|
22
55
|
/** The file descriptor number. */
|
|
23
56
|
fd;
|
|
24
|
-
constructor(
|
|
25
|
-
this.
|
|
57
|
+
constructor(guard, hndl) {
|
|
58
|
+
this.guard = guard;
|
|
26
59
|
this.hndl = hndl;
|
|
27
|
-
this.path = hndl.path;
|
|
28
60
|
this.fd = hndl.fd;
|
|
29
61
|
}
|
|
30
62
|
/** The underlying file handle. Throws if the guard has been dropped. */
|
|
31
63
|
get handle() {
|
|
32
64
|
if (this._dropped)
|
|
33
65
|
throw new Error('FileGuard has been dropped');
|
|
34
|
-
return this.hndl
|
|
66
|
+
return this.hndl;
|
|
35
67
|
}
|
|
36
68
|
/** True if the lock has been released. */
|
|
37
69
|
get dropped() {
|
|
@@ -42,7 +74,7 @@ class FileGuard {
|
|
|
42
74
|
if (!this._dropped) {
|
|
43
75
|
this._dropped = (async () => {
|
|
44
76
|
try {
|
|
45
|
-
await this.
|
|
77
|
+
await this.guard.drop();
|
|
46
78
|
}
|
|
47
79
|
finally {
|
|
48
80
|
await this.hndl.close();
|
|
@@ -55,5 +87,5 @@ class FileGuard {
|
|
|
55
87
|
return this.drop();
|
|
56
88
|
}
|
|
57
89
|
}
|
|
58
|
-
exports.
|
|
90
|
+
exports.FileLockGuard = FileLockGuard;
|
|
59
91
|
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../../lib/core/guard.ts"],"names":[],"mappings":";;;AAAA,yCAAyG;AAEzG;;;;;;;GAOG;AACH,MAAa,SAAS;IAMV;IAEA;IAPF,QAAQ,CAA2B;IAC3C,kCAAkC;IAClB,EAAE,CAAQ;IAE1B,YACU,OAAe,EACvB,MAAS,EACD,KAAiB;QAFjB,YAAO,GAAP,OAAO,CAAQ;QAEf,UAAK,GAAL,KAAK,CAAY;QAEzB,IAAI,CAAC,EAAE,GAAG,IAAA,oBAAS,EAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAED,0CAA0C;IAC1C,IAAI,OAAO;QACT,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAA;IACxB,CAAC;IAED,qDAAqD;IACrD,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QAC5E,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,CAAC,MAAM,CAAC,YAAY,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAA;IACpB,CAAC;CACF;AA3BD,8BA2BC;AAED;;;;;;;;;;;GAWG;AACH,MAAa,aAAa;IAMd;IACA;IANF,QAAQ,CAA2B;IAC3C,kCAAkC;IAClB,EAAE,CAAQ;IAE1B,YACU,KAAmB,EACnB,IAAO;QADP,UAAK,GAAL,KAAK,CAAc;QACnB,SAAI,GAAJ,IAAI,CAAG;QAEf,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;IACnB,CAAC;IAED,wEAAwE;IACxE,IAAI,MAAM;QACR,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAChE,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,0CAA0C;IAC1C,IAAI,OAAO;QACT,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAA;IACxB,CAAC;IAED,wEAAwE;IACxE,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,CAAC,KAAK,IAAI,EAAE;gBAC1B,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;gBACzB,CAAC;wBAAS,CAAC;oBACT,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;gBACzB,CAAC;YACH,CAAC,CAAC,EAAE,CAAA;QACN,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,CAAC,MAAM,CAAC,YAAY,CAAC;QACnB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAA;IACpB,CAAC;CACF;AAxCD,sCAwCC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Locker, type Fs } from './types.js';
|
|
2
|
+
export { type Fs as Backend, type LockRange, type PollOptions, Lock, type FileDescriptor, type FileHandle, type Locker, type Fs, } from './types.js';
|
|
3
|
+
export * from './locking.js';
|
|
4
|
+
export * from './guard.js';
|
|
5
|
+
export * from './node.js';
|
|
6
|
+
export declare const defaultFs: () => Fs<import("node:fs/promises").FileHandle>;
|
|
7
|
+
export declare const defaultLocking: () => Locker;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,YAAY,CAAA;AAG5C,OAAO,EACL,KAAK,EAAE,IAAI,OAAO,EAClB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,IAAI,EACJ,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,EAAE,GACR,MAAM,YAAY,CAAA;AACnB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AAIzB,eAAO,MAAM,SAAS,iDAGrB,CAAA;AAID,eAAO,MAAM,cAAc,cAG1B,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.defaultLocking = exports.defaultFs = exports.Lock = void 0;
|
|
18
|
+
const node_js_1 = require("./node.js");
|
|
19
|
+
const locking_js_1 = require("./locking.js");
|
|
20
|
+
var types_js_1 = require("./types.js");
|
|
21
|
+
Object.defineProperty(exports, "Lock", { enumerable: true, get: function () { return types_js_1.Lock; } });
|
|
22
|
+
__exportStar(require("./locking.js"), exports);
|
|
23
|
+
__exportStar(require("./guard.js"), exports);
|
|
24
|
+
__exportStar(require("./node.js"), exports);
|
|
25
|
+
/** Lazily create and return the shared default Node.js filesystem singleton. */
|
|
26
|
+
let _defaultFs;
|
|
27
|
+
const defaultFs = () => {
|
|
28
|
+
if (!_defaultFs)
|
|
29
|
+
_defaultFs = (0, node_js_1.createNodeFs)();
|
|
30
|
+
return _defaultFs;
|
|
31
|
+
};
|
|
32
|
+
exports.defaultFs = defaultFs;
|
|
33
|
+
/** Lazily create and return the shared default native locker singleton. */
|
|
34
|
+
let _defaultLocking;
|
|
35
|
+
const defaultLocking = () => {
|
|
36
|
+
if (!_defaultLocking)
|
|
37
|
+
_defaultLocking = (0, locking_js_1.createLocker)(new node_js_1.NodeLockHooks());
|
|
38
|
+
return _defaultLocking;
|
|
39
|
+
};
|
|
40
|
+
exports.defaultLocking = defaultLocking;
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAA4E;AAE5E,6CAA2C;AAE3C,uCASmB;AALjB,gGAAA,IAAI,OAAA;AAMN,+CAA4B;AAC5B,6CAA0B;AAC1B,4CAAyB;AAEzB,gFAAgF;AAChF,IAAI,UAA0C,CAAA;AACvC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,IAAI,CAAC,UAAU;QAAE,UAAU,GAAG,IAAA,sBAAY,GAAE,CAAA;IAC5C,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAHY,QAAA,SAAS,aAGrB;AAED,2EAA2E;AAC3E,IAAI,eAAmC,CAAA;AAChC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,IAAI,CAAC,eAAe;QAAE,eAAe,GAAG,IAAA,yBAAY,EAAC,IAAI,uBAAa,EAAE,CAAC,CAAA;IACzE,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type FileDescriptor, type Locker } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Lifecycle hooks called when locks are acquired and released.
|
|
4
|
+
* Used by backends to track active locks for cleanup on exit or signals.
|
|
5
|
+
*/
|
|
6
|
+
export interface LockHooks {
|
|
7
|
+
/** Called after a lock is successfully acquired. */
|
|
8
|
+
register: (fd: FileDescriptor) => Promise<void>;
|
|
9
|
+
/** Called when a lock is released (even if unlock itself fails). */
|
|
10
|
+
unregister: (fd: FileDescriptor) => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create a {@link Locker} backed by native OS locks.
|
|
14
|
+
*
|
|
15
|
+
* Whole-file locks use `flock(2)` on Unix and `LockFileEx` on Windows.
|
|
16
|
+
* Range locks use `fcntl(2)` OFD locks on Linux, POSIX record locks on
|
|
17
|
+
* macOS/BSD, and ranged `LockFileEx` on Windows.
|
|
18
|
+
*
|
|
19
|
+
* If `hooks` are provided they are called after lock acquisition and on
|
|
20
|
+
* release, allowing backends to track active locks for cleanup.
|
|
21
|
+
*/
|
|
22
|
+
export declare const createLocker: (hooks?: LockHooks) => Locker;
|
|
23
|
+
//# sourceMappingURL=locking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locking.d.ts","sourceRoot":"","sources":["../../../lib/core/locking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,cAAc,EAAE,KAAK,MAAM,EAAmB,MAAM,YAAY,CAAA;AAGhH;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,oDAAoD;IACpD,QAAQ,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,oEAAoE;IACpE,UAAU,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAClD;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,SAAS,KAAG,MAqC/C,CAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createLocker = void 0;
|
|
37
|
+
const types_js_1 = require("./types.js");
|
|
38
|
+
const native = __importStar(require("#native"));
|
|
39
|
+
/**
|
|
40
|
+
* Create a {@link Locker} backed by native OS locks.
|
|
41
|
+
*
|
|
42
|
+
* Whole-file locks use `flock(2)` on Unix and `LockFileEx` on Windows.
|
|
43
|
+
* Range locks use `fcntl(2)` OFD locks on Linux, POSIX record locks on
|
|
44
|
+
* macOS/BSD, and ranged `LockFileEx` on Windows.
|
|
45
|
+
*
|
|
46
|
+
* If `hooks` are provided they are called after lock acquisition and on
|
|
47
|
+
* release, allowing backends to track active locks for cleanup.
|
|
48
|
+
*/
|
|
49
|
+
const createLocker = (hooks) => ({
|
|
50
|
+
async lock(fd, type, range, options) {
|
|
51
|
+
const d = (0, types_js_1.resolveFd)(fd);
|
|
52
|
+
await native.lock(d, toNativeLock(type), range, options);
|
|
53
|
+
try {
|
|
54
|
+
await hooks?.register(d);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
try {
|
|
58
|
+
native.lockSync(d, native.Lock.Unlock, range);
|
|
59
|
+
}
|
|
60
|
+
catch { }
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
async tryLock(fd, type, range) {
|
|
65
|
+
const d = (0, types_js_1.resolveFd)(fd);
|
|
66
|
+
const locked = await native.tryLock(d, toNativeLock(type), range);
|
|
67
|
+
if (!locked)
|
|
68
|
+
return false;
|
|
69
|
+
try {
|
|
70
|
+
await hooks?.register(d);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
try {
|
|
75
|
+
native.lockSync(d, native.Lock.Unlock, range);
|
|
76
|
+
}
|
|
77
|
+
catch { }
|
|
78
|
+
throw err;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async unlock(fd, range) {
|
|
82
|
+
const d = (0, types_js_1.resolveFd)(fd);
|
|
83
|
+
try {
|
|
84
|
+
native.lockSync(d, native.Lock.Unlock, range);
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
await hooks?.unregister(d);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
exports.createLocker = createLocker;
|
|
92
|
+
const toNativeLock = (type) => (type === types_js_1.Lock.Exclusive ? native.Lock.Exclusive : native.Lock.Shared);
|
|
93
|
+
//# sourceMappingURL=locking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locking.js","sourceRoot":"","sources":["../../../lib/core/locking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAgH;AAChH,gDAAiC;AAajC;;;;;;;;;GASG;AACI,MAAM,YAAY,GAAG,CAAC,KAAiB,EAAU,EAAE,CAAC,CAAC;IAC1D,KAAK,CAAC,IAAI,CAAC,EAAkB,EAAE,IAAU,EAAE,KAAiB,EAAE,OAAqB;QACjF,MAAM,CAAC,GAAG,IAAA,oBAAS,EAAC,EAAE,CAAC,CAAA;QACvB,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;QACxD,IAAI,CAAC;YACH,MAAM,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;QAC1B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;YAC/C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAkB,EAAE,IAAU,EAAE,KAAiB;QAC7D,MAAM,CAAC,GAAG,IAAA,oBAAS,EAAC,EAAE,CAAC,CAAA;QACvB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;QACjE,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAA;QACzB,IAAI,CAAC;YACH,MAAM,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;YACxB,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;YAC/C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAkB,EAAE,KAAiB;QAChD,MAAM,CAAC,GAAG,IAAA,oBAAS,EAAC,EAAE,CAAC,CAAA;QACvB,IAAI,CAAC;YACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QAC/C,CAAC;gBAAS,CAAC;YACT,MAAM,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;CACF,CAAC,CAAA;AArCW,QAAA,YAAY,gBAqCvB;AAEF,MAAM,YAAY,GAAG,CAAC,IAAU,EAAe,EAAE,CAAC,CAAC,IAAI,KAAK,eAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA"}
|