@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.
Files changed (91) hide show
  1. package/README.md +182 -76
  2. package/cjs.js +57 -57
  3. package/dist/cjs/core/guard.d.ts +50 -0
  4. package/dist/cjs/core/guard.d.ts.map +1 -0
  5. package/dist/cjs/{backend → core}/guard.js +43 -11
  6. package/dist/cjs/core/guard.js.map +1 -0
  7. package/dist/cjs/core/index.d.ts +8 -0
  8. package/dist/cjs/core/index.d.ts.map +1 -0
  9. package/dist/cjs/core/index.js +41 -0
  10. package/dist/cjs/core/index.js.map +1 -0
  11. package/dist/cjs/core/locking.d.ts +23 -0
  12. package/dist/cjs/core/locking.d.ts.map +1 -0
  13. package/dist/cjs/core/locking.js +93 -0
  14. package/dist/cjs/core/locking.js.map +1 -0
  15. package/dist/cjs/core/node.d.ts +19 -0
  16. package/dist/cjs/core/node.d.ts.map +1 -0
  17. package/dist/cjs/core/node.js +69 -0
  18. package/dist/cjs/core/node.js.map +1 -0
  19. package/dist/cjs/core/types.d.ts +49 -0
  20. package/dist/cjs/core/types.d.ts.map +1 -0
  21. package/dist/cjs/core/types.js +13 -0
  22. package/dist/cjs/core/types.js.map +1 -0
  23. package/dist/cjs/index.d.ts +43 -34
  24. package/dist/cjs/index.d.ts.map +1 -1
  25. package/dist/cjs/index.js +59 -39
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/esm/core/guard.d.ts +50 -0
  28. package/dist/esm/core/guard.d.ts.map +1 -0
  29. package/dist/esm/{backend → core}/guard.js +40 -9
  30. package/dist/esm/core/guard.js.map +1 -0
  31. package/dist/esm/core/index.d.ts +8 -0
  32. package/dist/esm/core/index.d.ts.map +1 -0
  33. package/dist/esm/core/index.js +21 -0
  34. package/dist/esm/core/index.js.map +1 -0
  35. package/dist/esm/core/locking.d.ts +23 -0
  36. package/dist/esm/core/locking.d.ts.map +1 -0
  37. package/dist/esm/core/locking.js +56 -0
  38. package/dist/esm/core/locking.js.map +1 -0
  39. package/dist/esm/core/node.d.ts +19 -0
  40. package/dist/esm/core/node.d.ts.map +1 -0
  41. package/dist/esm/core/node.js +61 -0
  42. package/dist/esm/core/node.js.map +1 -0
  43. package/dist/esm/core/types.d.ts +49 -0
  44. package/dist/esm/core/types.d.ts.map +1 -0
  45. package/dist/esm/core/types.js +9 -0
  46. package/dist/esm/core/types.js.map +1 -0
  47. package/dist/esm/index.d.ts +43 -34
  48. package/dist/esm/index.d.ts.map +1 -1
  49. package/dist/esm/index.js +53 -34
  50. package/dist/esm/index.js.map +1 -1
  51. package/esm.js +58 -58
  52. package/index.d.ts +32 -8
  53. package/package.json +6 -6
  54. package/dist/cjs/backend/guard.d.ts +0 -31
  55. package/dist/cjs/backend/guard.d.ts.map +0 -1
  56. package/dist/cjs/backend/guard.js.map +0 -1
  57. package/dist/cjs/backend/index.d.ts +0 -8
  58. package/dist/cjs/backend/index.d.ts.map +0 -1
  59. package/dist/cjs/backend/index.js +0 -31
  60. package/dist/cjs/backend/index.js.map +0 -1
  61. package/dist/cjs/backend/lockable.d.ts +0 -15
  62. package/dist/cjs/backend/lockable.d.ts.map +0 -1
  63. package/dist/cjs/backend/lockable.js +0 -76
  64. package/dist/cjs/backend/lockable.js.map +0 -1
  65. package/dist/cjs/backend/node.d.ts +0 -36
  66. package/dist/cjs/backend/node.d.ts.map +0 -1
  67. package/dist/cjs/backend/node.js +0 -118
  68. package/dist/cjs/backend/node.js.map +0 -1
  69. package/dist/cjs/backend/types.d.ts +0 -36
  70. package/dist/cjs/backend/types.d.ts.map +0 -1
  71. package/dist/cjs/backend/types.js +0 -3
  72. package/dist/cjs/backend/types.js.map +0 -1
  73. package/dist/esm/backend/guard.d.ts +0 -31
  74. package/dist/esm/backend/guard.d.ts.map +0 -1
  75. package/dist/esm/backend/guard.js.map +0 -1
  76. package/dist/esm/backend/index.d.ts +0 -8
  77. package/dist/esm/backend/index.d.ts.map +0 -1
  78. package/dist/esm/backend/index.js +0 -13
  79. package/dist/esm/backend/index.js.map +0 -1
  80. package/dist/esm/backend/lockable.d.ts +0 -15
  81. package/dist/esm/backend/lockable.d.ts.map +0 -1
  82. package/dist/esm/backend/lockable.js +0 -39
  83. package/dist/esm/backend/lockable.js.map +0 -1
  84. package/dist/esm/backend/node.d.ts +0 -36
  85. package/dist/esm/backend/node.d.ts.map +0 -1
  86. package/dist/esm/backend/node.js +0 -109
  87. package/dist/esm/backend/node.js.map +0 -1
  88. package/dist/esm/backend/types.d.ts +0 -36
  89. package/dist/esm/backend/types.d.ts.map +0 -1
  90. package/dist/esm/backend/types.js +0 -2
  91. package/dist/esm/backend/types.js.map +0 -1
package/esm.js CHANGED
@@ -81,8 +81,8 @@ function requireNative() {
81
81
  try {
82
82
  const binding = require('@lickle/lock-android-arm64')
83
83
  const bindingPackageVersion = require('@lickle/lock-android-arm64/package.json').version
84
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
84
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ 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.`)
86
86
  }
87
87
  return binding
88
88
  } catch (e) {
@@ -97,8 +97,8 @@ function requireNative() {
97
97
  try {
98
98
  const binding = require('@lickle/lock-android-arm-eabi')
99
99
  const bindingPackageVersion = require('@lickle/lock-android-arm-eabi/package.json').version
100
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ 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.`)
102
102
  }
103
103
  return binding
104
104
  } catch (e) {
@@ -118,8 +118,8 @@ function requireNative() {
118
118
  try {
119
119
  const binding = require('@lickle/lock-win32-x64-gnu')
120
120
  const bindingPackageVersion = require('@lickle/lock-win32-x64-gnu/package.json').version
121
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
121
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
+ 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.`)
123
123
  }
124
124
  return binding
125
125
  } catch (e) {
@@ -134,8 +134,8 @@ function requireNative() {
134
134
  try {
135
135
  const binding = require('@lickle/lock-win32-x64-msvc')
136
136
  const bindingPackageVersion = require('@lickle/lock-win32-x64-msvc/package.json').version
137
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ 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.`)
139
139
  }
140
140
  return binding
141
141
  } catch (e) {
@@ -151,8 +151,8 @@ function requireNative() {
151
151
  try {
152
152
  const binding = require('@lickle/lock-win32-ia32-msvc')
153
153
  const bindingPackageVersion = require('@lickle/lock-win32-ia32-msvc/package.json').version
154
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
+ 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.`)
156
156
  }
157
157
  return binding
158
158
  } catch (e) {
@@ -167,8 +167,8 @@ function requireNative() {
167
167
  try {
168
168
  const binding = require('@lickle/lock-win32-arm64-msvc')
169
169
  const bindingPackageVersion = require('@lickle/lock-win32-arm64-msvc/package.json').version
170
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ 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.`)
172
172
  }
173
173
  return binding
174
174
  } catch (e) {
@@ -186,8 +186,8 @@ function requireNative() {
186
186
  try {
187
187
  const binding = require('@lickle/lock-darwin-universal')
188
188
  const bindingPackageVersion = require('@lickle/lock-darwin-universal/package.json').version
189
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
+ 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.`)
191
191
  }
192
192
  return binding
193
193
  } catch (e) {
@@ -202,8 +202,8 @@ function requireNative() {
202
202
  try {
203
203
  const binding = require('@lickle/lock-darwin-x64')
204
204
  const bindingPackageVersion = require('@lickle/lock-darwin-x64/package.json').version
205
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ 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.`)
207
207
  }
208
208
  return binding
209
209
  } catch (e) {
@@ -218,8 +218,8 @@ function requireNative() {
218
218
  try {
219
219
  const binding = require('@lickle/lock-darwin-arm64')
220
220
  const bindingPackageVersion = require('@lickle/lock-darwin-arm64/package.json').version
221
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ 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.`)
223
223
  }
224
224
  return binding
225
225
  } catch (e) {
@@ -238,8 +238,8 @@ function requireNative() {
238
238
  try {
239
239
  const binding = require('@lickle/lock-freebsd-x64')
240
240
  const bindingPackageVersion = require('@lickle/lock-freebsd-x64/package.json').version
241
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
+ 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.`)
243
243
  }
244
244
  return binding
245
245
  } catch (e) {
@@ -254,8 +254,8 @@ function requireNative() {
254
254
  try {
255
255
  const binding = require('@lickle/lock-freebsd-arm64')
256
256
  const bindingPackageVersion = require('@lickle/lock-freebsd-arm64/package.json').version
257
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ 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.`)
259
259
  }
260
260
  return binding
261
261
  } catch (e) {
@@ -275,8 +275,8 @@ function requireNative() {
275
275
  try {
276
276
  const binding = require('@lickle/lock-linux-x64-musl')
277
277
  const bindingPackageVersion = require('@lickle/lock-linux-x64-musl/package.json').version
278
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
+ 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.`)
280
280
  }
281
281
  return binding
282
282
  } catch (e) {
@@ -291,8 +291,8 @@ function requireNative() {
291
291
  try {
292
292
  const binding = require('@lickle/lock-linux-x64-gnu')
293
293
  const bindingPackageVersion = require('@lickle/lock-linux-x64-gnu/package.json').version
294
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
294
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ 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.`)
296
296
  }
297
297
  return binding
298
298
  } catch (e) {
@@ -309,8 +309,8 @@ function requireNative() {
309
309
  try {
310
310
  const binding = require('@lickle/lock-linux-arm64-musl')
311
311
  const bindingPackageVersion = require('@lickle/lock-linux-arm64-musl/package.json').version
312
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
+ 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.`)
314
314
  }
315
315
  return binding
316
316
  } catch (e) {
@@ -325,8 +325,8 @@ function requireNative() {
325
325
  try {
326
326
  const binding = require('@lickle/lock-linux-arm64-gnu')
327
327
  const bindingPackageVersion = require('@lickle/lock-linux-arm64-gnu/package.json').version
328
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ 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.`)
330
330
  }
331
331
  return binding
332
332
  } catch (e) {
@@ -343,8 +343,8 @@ function requireNative() {
343
343
  try {
344
344
  const binding = require('@lickle/lock-linux-arm-musleabihf')
345
345
  const bindingPackageVersion = require('@lickle/lock-linux-arm-musleabihf/package.json').version
346
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
+ 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.`)
348
348
  }
349
349
  return binding
350
350
  } catch (e) {
@@ -359,8 +359,8 @@ function requireNative() {
359
359
  try {
360
360
  const binding = require('@lickle/lock-linux-arm-gnueabihf')
361
361
  const bindingPackageVersion = require('@lickle/lock-linux-arm-gnueabihf/package.json').version
362
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
362
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ 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.`)
364
364
  }
365
365
  return binding
366
366
  } catch (e) {
@@ -377,8 +377,8 @@ function requireNative() {
377
377
  try {
378
378
  const binding = require('@lickle/lock-linux-loong64-musl')
379
379
  const bindingPackageVersion = require('@lickle/lock-linux-loong64-musl/package.json').version
380
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
+ 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.`)
382
382
  }
383
383
  return binding
384
384
  } catch (e) {
@@ -393,8 +393,8 @@ function requireNative() {
393
393
  try {
394
394
  const binding = require('@lickle/lock-linux-loong64-gnu')
395
395
  const bindingPackageVersion = require('@lickle/lock-linux-loong64-gnu/package.json').version
396
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
+ 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.`)
398
398
  }
399
399
  return binding
400
400
  } catch (e) {
@@ -411,8 +411,8 @@ function requireNative() {
411
411
  try {
412
412
  const binding = require('@lickle/lock-linux-riscv64-musl')
413
413
  const bindingPackageVersion = require('@lickle/lock-linux-riscv64-musl/package.json').version
414
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
+ 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.`)
416
416
  }
417
417
  return binding
418
418
  } catch (e) {
@@ -427,8 +427,8 @@ function requireNative() {
427
427
  try {
428
428
  const binding = require('@lickle/lock-linux-riscv64-gnu')
429
429
  const bindingPackageVersion = require('@lickle/lock-linux-riscv64-gnu/package.json').version
430
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ 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.`)
432
432
  }
433
433
  return binding
434
434
  } catch (e) {
@@ -444,8 +444,8 @@ function requireNative() {
444
444
  try {
445
445
  const binding = require('@lickle/lock-linux-ppc64-gnu')
446
446
  const bindingPackageVersion = require('@lickle/lock-linux-ppc64-gnu/package.json').version
447
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
447
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ 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.`)
449
449
  }
450
450
  return binding
451
451
  } catch (e) {
@@ -460,8 +460,8 @@ function requireNative() {
460
460
  try {
461
461
  const binding = require('@lickle/lock-linux-s390x-gnu')
462
462
  const bindingPackageVersion = require('@lickle/lock-linux-s390x-gnu/package.json').version
463
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
463
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ 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.`)
465
465
  }
466
466
  return binding
467
467
  } catch (e) {
@@ -480,8 +480,8 @@ function requireNative() {
480
480
  try {
481
481
  const binding = require('@lickle/lock-openharmony-arm64')
482
482
  const bindingPackageVersion = require('@lickle/lock-openharmony-arm64/package.json').version
483
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
483
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
+ 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.`)
485
485
  }
486
486
  return binding
487
487
  } catch (e) {
@@ -496,8 +496,8 @@ function requireNative() {
496
496
  try {
497
497
  const binding = require('@lickle/lock-openharmony-x64')
498
498
  const bindingPackageVersion = require('@lickle/lock-openharmony-x64/package.json').version
499
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
499
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
+ 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.`)
501
501
  }
502
502
  return binding
503
503
  } catch (e) {
@@ -512,8 +512,8 @@ function requireNative() {
512
512
  try {
513
513
  const binding = require('@lickle/lock-openharmony-arm')
514
514
  const bindingPackageVersion = require('@lickle/lock-openharmony-arm/package.json').version
515
- if (bindingPackageVersion !== '0.0.1-alpha.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
- throw new Error(`Native binding package version mismatch, expected 0.0.1-alpha.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ if (bindingPackageVersion !== '0.0.1-alpha.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ 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.`)
517
517
  }
518
518
  return binding
519
519
  } catch (e) {
@@ -579,9 +579,9 @@ if (!nativeBinding) {
579
579
  throw new Error(`Failed to load native binding`)
580
580
  }
581
581
 
582
- const { exclusive, shared, tryExclusive, tryShared, unlock } = nativeBinding
583
- export { exclusive }
584
- export { shared }
585
- export { tryExclusive }
586
- export { tryShared }
587
- export { unlock }
582
+ const { lock, Lock, lockSync, tryLock, tryLockSync } = nativeBinding
583
+ export { lock }
584
+ export { Lock }
585
+ export { lockSync }
586
+ export { tryLock }
587
+ export { tryLockSync }
package/index.d.ts CHANGED
@@ -1,16 +1,40 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
- export declare function exclusive(fd: FileDescriptor, options?: PollFlockOptions | undefined | null): Promise<void>
3
+ /** Acquire a lock, polling until available or timeout is reached. */
4
+ export declare function lock(fd: FileDescriptor, lock: Lock, range?: LockRange | undefined | null, options?: PollOptions | undefined | null): Promise<void>
4
5
 
5
- export interface PollFlockOptions {
6
- pollMs?: number
7
- timeout?: number
6
+ /** Lock mode passed to the native OS locking call. */
7
+ export declare enum Lock {
8
+ Exclusive = 0,
9
+ Shared = 1,
10
+ Unlock = 2
11
+ }
12
+
13
+ /**
14
+ * Byte range within a file. Offset and length are signed to allow
15
+ * validation at the Rust boundary before casting to the OS types.
16
+ */
17
+ export interface LockRange {
18
+ offset: number
19
+ length: number
8
20
  }
9
21
 
10
- export declare function shared(fd: FileDescriptor, options?: PollFlockOptions | undefined | null): Promise<void>
22
+ /** Acquire a lock synchronously (blocks the thread). */
23
+ export declare function lockSync(fd: FileDescriptor, lock: Lock, range?: LockRange | undefined | null): void
11
24
 
12
- export declare function tryExclusive(fd: FileDescriptor): Promise<boolean>
25
+ /** Options for the polling lock loop. */
26
+ export interface PollOptions {
27
+ pollMs?: number
28
+ timeout?: number
29
+ /**
30
+ * Multiplier applied to the poll interval after each failed attempt.
31
+ * For example, `2.0` doubles the delay each iteration (exponential backoff).
32
+ */
33
+ backoff?: number
34
+ }
13
35
 
14
- export declare function tryShared(fd: FileDescriptor): Promise<boolean>
36
+ /** Try to acquire a lock without waiting. Returns `true` if acquired. */
37
+ export declare function tryLock(fd: FileDescriptor, mode: Lock, range?: LockRange | undefined | null): Promise<boolean>
15
38
 
16
- export declare function unlock(fd: FileDescriptor): void
39
+ /** Synchronous non-blocking lock attempt. Returns `true` if acquired. */
40
+ export declare function tryLockSync(fd: FileDescriptor, lock: Lock, range?: LockRange | undefined | null): boolean
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lickle/lock",
3
- "version": "0.0.1-alpha.1",
4
- "description": "File-based locking for Node.js using native OS locks (flock on Unix, LockFileEx on Windows). Exclusive and shared locks with cross-process coordination.",
3
+ "version": "0.0.1-alpha.2",
4
+ "description": "File-based locking for Node.js using native OS locks (`flock` on Unix, `LockFileEx` on Windows).",
5
5
  "author": "Dan Beaven <dm.beaven@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -92,9 +92,9 @@
92
92
  "arrowParens": "always"
93
93
  },
94
94
  "optionalDependencies": {
95
- "@lickle/lock-win32-x64-msvc": "0.0.1-alpha.1",
96
- "@lickle/lock-darwin-x64": "0.0.1-alpha.1",
97
- "@lickle/lock-linux-x64-gnu": "0.0.1-alpha.1",
98
- "@lickle/lock-darwin-arm64": "0.0.1-alpha.1"
95
+ "@lickle/lock-win32-x64-msvc": "0.0.1-alpha.2",
96
+ "@lickle/lock-darwin-x64": "0.0.1-alpha.2",
97
+ "@lickle/lock-linux-x64-gnu": "0.0.1-alpha.2",
98
+ "@lickle/lock-darwin-arm64": "0.0.1-alpha.2"
99
99
  }
100
100
  }
@@ -1,31 +0,0 @@
1
- import type { Backend, FileHandle } from './index.js';
2
- /**
3
- * RAII guard that holds a file lock. Unlocks and closes the file on drop.
4
- * Supports `await using` via `Symbol.asyncDispose`.
5
- *
6
- * @example
7
- * await using guard = await exclusive('/tmp/my.lock')
8
- * // lock is released when guard goes out of scope
9
- *
10
- * @example
11
- * const guard = await exclusive('/tmp/my.lock')
12
- * try { /* work *\/ } finally { await guard.drop() }
13
- */
14
- export declare class FileGuard<H extends FileHandle> {
15
- private backend;
16
- private hndl;
17
- private _dropped;
18
- /** The lock file path. */
19
- readonly path: string;
20
- /** The file descriptor number. */
21
- readonly fd: number;
22
- constructor(backend: Backend<H>, hndl: H);
23
- /** The underlying file handle. Throws if the guard has been dropped. */
24
- get handle(): H['handle'];
25
- /** True if the lock has been released. */
26
- get dropped(): boolean;
27
- /** Release the lock and close the file. Safe to call multiple times. */
28
- drop(): Promise<void>;
29
- [Symbol.asyncDispose](): Promise<void>;
30
- }
31
- //# sourceMappingURL=guard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../../lib/backend/guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAErD;;;;;;;;;;;GAWG;AACH,qBAAa,SAAS,CAAC,CAAC,SAAS,UAAU;IAQvC,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,IAAI;IARd,OAAO,CAAC,QAAQ,CAA2B;IAC3C,0BAA0B;IAC1B,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,kCAAkC;IAClC,SAAgB,EAAE,EAAE,MAAM,CAAA;gBAGhB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,IAAI,EAAE,CAAC;IAMjB,wEAAwE;IACxE,IAAI,MAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,CAGxB;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 +0,0 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../../../lib/backend/guard.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACH,MAAa,SAAS;IAQV;IACA;IARF,QAAQ,CAA2B;IAC3C,0BAA0B;IACV,IAAI,CAAQ;IAC5B,kCAAkC;IAClB,EAAE,CAAQ;IAE1B,YACU,OAAmB,EACnB,IAAO;QADP,YAAO,GAAP,OAAO,CAAY;QACnB,SAAI,GAAJ,IAAI,CAAG;QAEf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACrB,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,CAAC,MAAM,CAAA;IACzB,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,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACtC,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;AA3CD,8BA2CC"}
@@ -1,8 +0,0 @@
1
- import { NodeFileHandle } from './node.js';
2
- import { type Backend } from './types.js';
3
- export * from './lockable.js';
4
- export * from './types.js';
5
- export * from './guard.js';
6
- export * from './node.js';
7
- export declare const defaultBackend: () => Backend<NodeFileHandle>;
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/backend/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,cAAc,EAAE,MAAM,WAAW,CAAA;AAC7D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AAIzB,eAAO,MAAM,cAAc,+BAG1B,CAAA"}
@@ -1,31 +0,0 @@
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.defaultBackend = void 0;
18
- const node_js_1 = require("./node.js");
19
- __exportStar(require("./lockable.js"), exports);
20
- __exportStar(require("./types.js"), exports);
21
- __exportStar(require("./guard.js"), exports);
22
- __exportStar(require("./node.js"), exports);
23
- /** Return the shared default Node backend singleton. */
24
- let _defaultBackend;
25
- const defaultBackend = () => {
26
- if (!_defaultBackend)
27
- _defaultBackend = (0, node_js_1.createNodeBackend)();
28
- return _defaultBackend;
29
- };
30
- exports.defaultBackend = defaultBackend;
31
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/backend/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAA6D;AAG7D,gDAA6B;AAC7B,6CAA0B;AAC1B,6CAA0B;AAC1B,4CAAyB;AAEzB,wDAAwD;AACxD,IAAI,eAAoD,CAAA;AACjD,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,IAAI,CAAC,eAAe;QAAE,eAAe,GAAG,IAAA,2BAAiB,GAAE,CAAA;IAC3D,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B"}
@@ -1,15 +0,0 @@
1
- import type { FileHandle, Lockable } from '../index.js';
2
- /** Lifecycle hooks called when locks are acquired and released. */
3
- export interface LockHooks<H extends FileHandle> {
4
- register: (handle: H) => Promise<void>;
5
- unregister: (handle: H) => Promise<void>;
6
- }
7
- /**
8
- * Create a `Lockable` using native OS lock bindings (flock on Unix, LockFileEx on Windows).
9
- * Optional hooks are notified on lock/unlock for cleanup tracking.
10
- *
11
- * @example
12
- * const lockable = createLockable(myHooks)
13
- */
14
- export declare const createLockable: <H extends FileHandle>(hooks?: LockHooks<H>) => Lockable<H>;
15
- //# sourceMappingURL=lockable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lockable.d.ts","sourceRoot":"","sources":["../../../lib/backend/lockable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAIvD,mEAAmE;AACnE,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,UAAU;IAC7C,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,UAAU,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACzC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,EAAE,QAAQ,SAAS,CAAC,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,CA0BrF,CAAA"}
@@ -1,76 +0,0 @@
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.createLockable = void 0;
37
- const native = __importStar(require("#native"));
38
- /**
39
- * Create a `Lockable` using native OS lock bindings (flock on Unix, LockFileEx on Windows).
40
- * Optional hooks are notified on lock/unlock for cleanup tracking.
41
- *
42
- * @example
43
- * const lockable = createLockable(myHooks)
44
- */
45
- const createLockable = (hooks) => {
46
- const lock = (handle, mode, options) => {
47
- if (mode === 'exclusive')
48
- return native.exclusive(handle.fd, options);
49
- else
50
- return native.shared(handle.fd, options);
51
- };
52
- const tryLock = (handle, mode) => {
53
- if (mode === 'exclusive')
54
- return native.tryExclusive(handle.fd);
55
- else
56
- return native.tryShared(handle.fd);
57
- };
58
- return {
59
- async lock(handle, mode, options) {
60
- await lock(handle, mode, options);
61
- await hooks?.register(handle);
62
- },
63
- async tryLock(handle, mode) {
64
- const locked = await tryLock(handle, mode);
65
- if (locked)
66
- await hooks?.register(handle);
67
- return locked;
68
- },
69
- async unlock(handle) {
70
- await hooks?.unregister(handle);
71
- await native.unlock(handle.fd);
72
- },
73
- };
74
- };
75
- exports.createLockable = createLockable;
76
- //# sourceMappingURL=lockable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lockable.js","sourceRoot":"","sources":["../../../lib/backend/lockable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gDAAiC;AAQjC;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,CAAuB,KAAoB,EAAe,EAAE;IACxF,MAAM,IAAI,GAAG,CAAC,MAAS,EAAE,IAA4B,EAAE,OAAiC,EAAiB,EAAE;QACzG,IAAI,IAAI,KAAK,WAAW;YAAE,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;;YAChE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAC/C,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,CAAC,MAAS,EAAE,IAA4B,EAAoB,EAAE;QAC5E,IAAI,IAAI,KAAK,WAAW;YAAE,OAAO,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;;YAC1D,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACzC,CAAC,CAAA;IAED,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,MAAS,EAAE,IAA4B,EAAE,OAAiC;YACnF,MAAM,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;YACjC,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC/B,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,MAAS,EAAE,IAA4B;YACnD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YAC1C,IAAI,MAAM;gBAAE,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;YACzC,OAAO,MAAM,CAAA;QACf,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,MAAS;YACpB,MAAM,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;YAC/B,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAChC,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AA1BY,QAAA,cAAc,kBA0B1B"}
@@ -1,36 +0,0 @@
1
- import fs from 'node:fs';
2
- import { type LockHooks } from './lockable.js';
3
- import type { Backend, FileHandle } from './types.js';
4
- /**
5
- * Create the default Node.js backend using native OS locks (flock on Unix, LockFileEx on Windows).
6
- * Registers cleanup hooks for process exit, signals, and GC.
7
- *
8
- * @example
9
- * const backend = createNodeBackend()
10
- * await exclusive('/tmp/my.lock', { backend })
11
- */
12
- export declare const createNodeBackend: () => Backend<NodeFileHandle>;
13
- /** Wraps a Node.js `fs.promises.FileHandle` to satisfy the `FileHandle` interface. */
14
- export declare class NodeFileHandle implements FileHandle {
15
- readonly handle: fs.promises.FileHandle;
16
- readonly path: string;
17
- constructor(handle: fs.promises.FileHandle, path: string);
18
- get fd(): number;
19
- close(): Promise<void>;
20
- }
21
- /**
22
- * Track active locks and ensure they are released on process exit,
23
- * SIGINT, SIGTERM, and GC finalization.
24
- */
25
- export declare class NodeLockHooks implements LockHooks<FileHandle> {
26
- private _active;
27
- private _handlingSignal;
28
- private _finalizer;
29
- register(handle: FileHandle): Promise<void>;
30
- unregister(handle: FileHandle): Promise<void>;
31
- private _listen;
32
- private _unlisten;
33
- private _onExit;
34
- private _onSignal;
35
- }
36
- //# sourceMappingURL=node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../lib/backend/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAA;AAExB,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,eAAe,CAAA;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,QAAO,OAAO,CAAC,cAAc,CAU1D,CAAA;AAED,sFAAsF;AACtF,qBAAa,cAAe,YAAW,UAAU;IAE7C,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,EAC9B,IAAI,EAAE,MAAM;IAGvB,IAAI,EAAE,WAEL;IAED,KAAK;CAGN;AAED;;;GAGG;AACH,qBAAa,aAAc,YAAW,SAAS,CAAC,UAAU,CAAC;IACzD,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,eAAe,CAAQ;IAE/B,OAAO,CAAC,UAAU,CAMhB;IAEI,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3C,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnD,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,OAAO,CASd;IAED,OAAO,CAAC,SAAS,CAWhB;CACF"}