@effect/platform-browser 4.0.0-beta.7 → 4.0.0-beta.71

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/dist/BrowserCrypto.d.ts +81 -0
  2. package/dist/BrowserCrypto.d.ts.map +1 -0
  3. package/dist/BrowserCrypto.js +119 -0
  4. package/dist/BrowserCrypto.js.map +1 -0
  5. package/dist/BrowserHttpClient.d.ts +40 -16
  6. package/dist/BrowserHttpClient.d.ts.map +1 -1
  7. package/dist/BrowserHttpClient.js +74 -18
  8. package/dist/BrowserHttpClient.js.map +1 -1
  9. package/dist/BrowserKeyValueStore.d.ts +37 -14
  10. package/dist/BrowserKeyValueStore.d.ts.map +1 -1
  11. package/dist/BrowserKeyValueStore.js +185 -10
  12. package/dist/BrowserKeyValueStore.js.map +1 -1
  13. package/dist/BrowserPersistence.d.ts +40 -0
  14. package/dist/BrowserPersistence.d.ts.map +1 -0
  15. package/dist/BrowserPersistence.js +207 -0
  16. package/dist/BrowserPersistence.js.map +1 -0
  17. package/dist/BrowserRuntime.d.ts +79 -4
  18. package/dist/BrowserRuntime.d.ts.map +1 -1
  19. package/dist/BrowserRuntime.js +19 -1
  20. package/dist/BrowserRuntime.js.map +1 -1
  21. package/dist/BrowserSocket.d.ts +64 -6
  22. package/dist/BrowserSocket.d.ts.map +1 -1
  23. package/dist/BrowserSocket.js +64 -6
  24. package/dist/BrowserSocket.js.map +1 -1
  25. package/dist/BrowserStream.d.ts +48 -5
  26. package/dist/BrowserStream.d.ts.map +1 -1
  27. package/dist/BrowserStream.js +48 -5
  28. package/dist/BrowserStream.js.map +1 -1
  29. package/dist/BrowserWorker.d.ts +25 -4
  30. package/dist/BrowserWorker.d.ts.map +1 -1
  31. package/dist/BrowserWorker.js +62 -6
  32. package/dist/BrowserWorker.js.map +1 -1
  33. package/dist/BrowserWorkerRunner.d.ts +31 -6
  34. package/dist/BrowserWorkerRunner.d.ts.map +1 -1
  35. package/dist/BrowserWorkerRunner.js +65 -10
  36. package/dist/BrowserWorkerRunner.js.map +1 -1
  37. package/dist/Clipboard.d.ts +77 -13
  38. package/dist/Clipboard.d.ts.map +1 -1
  39. package/dist/Clipboard.js +57 -11
  40. package/dist/Clipboard.js.map +1 -1
  41. package/dist/Geolocation.d.ts +101 -24
  42. package/dist/Geolocation.d.ts.map +1 -1
  43. package/dist/Geolocation.js +69 -16
  44. package/dist/Geolocation.js.map +1 -1
  45. package/dist/IndexedDb.d.ts +89 -0
  46. package/dist/IndexedDb.d.ts.map +1 -0
  47. package/dist/IndexedDb.js +99 -0
  48. package/dist/IndexedDb.js.map +1 -0
  49. package/dist/IndexedDbDatabase.d.ts +169 -0
  50. package/dist/IndexedDbDatabase.d.ts.map +1 -0
  51. package/dist/IndexedDbDatabase.js +343 -0
  52. package/dist/IndexedDbDatabase.js.map +1 -0
  53. package/dist/IndexedDbQueryBuilder.d.ts +438 -0
  54. package/dist/IndexedDbQueryBuilder.d.ts.map +1 -0
  55. package/dist/IndexedDbQueryBuilder.js +935 -0
  56. package/dist/IndexedDbQueryBuilder.js.map +1 -0
  57. package/dist/IndexedDbTable.d.ts +191 -0
  58. package/dist/IndexedDbTable.d.ts.map +1 -0
  59. package/dist/IndexedDbTable.js +96 -0
  60. package/dist/IndexedDbTable.js.map +1 -0
  61. package/dist/IndexedDbVersion.d.ts +94 -0
  62. package/dist/IndexedDbVersion.d.ts.map +1 -0
  63. package/dist/IndexedDbVersion.js +39 -0
  64. package/dist/IndexedDbVersion.js.map +1 -0
  65. package/dist/Permissions.d.ts +76 -16
  66. package/dist/Permissions.d.ts.map +1 -1
  67. package/dist/Permissions.js +66 -11
  68. package/dist/Permissions.js.map +1 -1
  69. package/dist/index.d.ts +38 -10
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +38 -10
  72. package/dist/index.js.map +1 -1
  73. package/package.json +4 -3
  74. package/src/BrowserCrypto.ts +129 -0
  75. package/src/BrowserHttpClient.ts +84 -24
  76. package/src/BrowserKeyValueStore.ts +201 -12
  77. package/src/BrowserPersistence.ts +376 -0
  78. package/src/BrowserRuntime.ts +79 -4
  79. package/src/BrowserSocket.ts +64 -6
  80. package/src/BrowserStream.ts +48 -5
  81. package/src/BrowserWorker.ts +62 -6
  82. package/src/BrowserWorkerRunner.ts +65 -10
  83. package/src/Clipboard.ts +74 -13
  84. package/src/Geolocation.ts +97 -20
  85. package/src/IndexedDb.ts +127 -0
  86. package/src/IndexedDbDatabase.ts +664 -0
  87. package/src/IndexedDbQueryBuilder.ts +2048 -0
  88. package/src/IndexedDbTable.ts +285 -0
  89. package/src/IndexedDbVersion.ts +133 -0
  90. package/src/Permissions.ts +71 -14
  91. package/src/index.ts +45 -10
@@ -1,23 +1,66 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Browser geolocation integration for Effect programs.
3
+ *
4
+ * This module exposes a `Geolocation` service backed by
5
+ * `navigator.geolocation`. Use it for browser features that need a single
6
+ * position fix, such as nearby search or delivery estimates, or a stream of
7
+ * position updates for navigation, tracking, and location-aware interfaces.
8
+ * Browser failures are represented as typed `GeolocationError` values instead
9
+ * of raw callback errors.
10
+ *
11
+ * **Mental model**
12
+ *
13
+ * - The service delegates to the browser Geolocation API and follows the
14
+ * browser's permission, privacy, origin, and secure-context rules.
15
+ * - `getCurrentPosition` reads one position fix from the service.
16
+ * - {@link watchPosition} turns browser position callbacks into a `Stream` and
17
+ * clears the underlying browser watch when the stream is finalized.
18
+ *
19
+ * **Common tasks**
20
+ *
21
+ * - Provide the live browser implementation with {@link layer}.
22
+ * - Read a one-shot position from the `Geolocation` service.
23
+ * - Stream position updates with {@link watchPosition}.
24
+ * - Handle denied permissions, timeouts, and unavailable position data with
25
+ * {@link GeolocationError}.
26
+ *
27
+ * **Gotchas**
28
+ *
29
+ * - Browsers may prompt the user, reject access outside secure contexts, block
30
+ * access by permissions policy, or report that position data is unavailable.
31
+ * - {@link watchPosition} uses a sliding buffer; increase `bufferSize` if slow
32
+ * consumers must not skip older positions.
33
+ *
34
+ * @since 4.0.0
3
35
  */
4
36
  import * as Cause from "effect/Cause";
37
+ import * as Context from "effect/Context";
5
38
  import * as Data from "effect/Data";
6
39
  import * as Effect from "effect/Effect";
7
40
  import * as Layer from "effect/Layer";
8
41
  import * as Queue from "effect/Queue";
9
- import * as ServiceMap from "effect/ServiceMap";
10
42
  import * as Stream from "effect/Stream";
11
43
  const TypeId = "~@effect/platform-browser/Geolocation";
12
44
  const ErrorTypeId = "~@effect/platform-browser/Geolocation/GeolocationError";
13
45
  /**
14
- * @since 1.0.0
15
- * @category Service
46
+ * Service tag for the browser `Geolocation` service.
47
+ *
48
+ * **When to use**
49
+ *
50
+ * Use when an Effect needs to access or provide geolocation capabilities
51
+ * through the context.
52
+ *
53
+ * @see {@link layer} for providing the browser-backed geolocation service
54
+ *
55
+ * @category services
56
+ * @since 4.0.0
16
57
  */
17
- export const Geolocation = /*#__PURE__*/ServiceMap.Service(TypeId);
58
+ export const Geolocation = /*#__PURE__*/Context.Service(TypeId);
18
59
  /**
19
- * @since 1.0.0
20
- * @category Errors
60
+ * Tagged error wrapping a browser geolocation failure reason.
61
+ *
62
+ * @category errors
63
+ * @since 4.0.0
21
64
  */
22
65
  export class GeolocationError extends /*#__PURE__*/Data.TaggedError("GeolocationError") {
23
66
  constructor(props) {
@@ -32,8 +75,10 @@ export class GeolocationError extends /*#__PURE__*/Data.TaggedError("Geolocation
32
75
  }
33
76
  }
34
77
  /**
35
- * @since 1.0.0
36
- * @category Errors
78
+ * Error reason for the browser geolocation `POSITION_UNAVAILABLE` failure.
79
+ *
80
+ * @category errors
81
+ * @since 4.0.0
37
82
  */
38
83
  export class PositionUnavailable extends /*#__PURE__*/Data.TaggedError("PositionUnavailable") {
39
84
  get message() {
@@ -41,8 +86,10 @@ export class PositionUnavailable extends /*#__PURE__*/Data.TaggedError("Position
41
86
  }
42
87
  }
43
88
  /**
44
- * @since 1.0.0
45
- * @category Errors
89
+ * Error reason for the browser geolocation `PERMISSION_DENIED` failure.
90
+ *
91
+ * @category errors
92
+ * @since 4.0.0
46
93
  */
47
94
  export class PermissionDenied extends /*#__PURE__*/Data.TaggedError("PermissionDenied") {
48
95
  get message() {
@@ -50,8 +97,10 @@ export class PermissionDenied extends /*#__PURE__*/Data.TaggedError("PermissionD
50
97
  }
51
98
  }
52
99
  /**
53
- * @since 1.0.0
54
- * @category Errors
100
+ * Error reason for the browser geolocation `TIMEOUT` failure.
101
+ *
102
+ * @category errors
103
+ * @since 4.0.0
55
104
  */
56
105
  export class Timeout extends /*#__PURE__*/Data.TaggedError("Timeout") {
57
106
  get message() {
@@ -83,8 +132,10 @@ const makeQueue = options => Queue.sliding(options?.bufferSize ?? 16).pipe(Effec
83
132
  }
84
133
  }, options)), handleId => Effect.sync(() => navigator.geolocation.clearWatch(handleId)))));
85
134
  /**
86
- * @since 1.0.0
87
- * @category Layers
135
+ * Layer that provides `Geolocation` using `navigator.geolocation`, with watched positions buffered in a sliding queue.
136
+ *
137
+ * @category layers
138
+ * @since 4.0.0
88
139
  */
89
140
  export const layer = /*#__PURE__*/Layer.succeed(Geolocation, /*#__PURE__*/Geolocation.of({
90
141
  [TypeId]: TypeId,
@@ -92,8 +143,10 @@ export const layer = /*#__PURE__*/Layer.succeed(Geolocation, /*#__PURE__*/Geoloc
92
143
  watchPosition: options => makeQueue(options).pipe(Effect.map(Stream.fromQueue), Stream.unwrap)
93
144
  }));
94
145
  /**
95
- * @since 1.0.0
146
+ * Streams positions from the `Geolocation` service using `watchPosition`, with an optional sliding buffer size.
147
+ *
96
148
  * @category Accessors
149
+ * @since 4.0.0
97
150
  */
98
151
  export const watchPosition = options => Stream.unwrap(Effect.map(Effect.service(Geolocation), geolocation => geolocation.watchPosition(options)));
99
152
  //# sourceMappingURL=Geolocation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Geolocation.js","names":["Cause","Data","Effect","Layer","Queue","ServiceMap","Stream","TypeId","ErrorTypeId","Geolocation","Service","GeolocationError","TaggedError","constructor","props","cause","reason","message","PositionUnavailable","_tag","PermissionDenied","Timeout","makeQueue","options","sliding","bufferSize","pipe","tap","queue","acquireRelease","sync","navigator","geolocation","watchPosition","position","offerUnsafe","code","PERMISSION_DENIED","error","failCauseUnsafe","fail","TIMEOUT","POSITION_UNAVAILABLE","handleId","clearWatch","layer","succeed","of","getCurrentPosition","flatMap","take","scoped","map","fromQueue","unwrap","service"],"sources":["../src/Geolocation.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAC/C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,MAAMC,MAAM,GAAG,uCAAuC;AACtD,MAAMC,WAAW,GAAG,wDAAwD;AAoB5E;;;;AAIA,OAAO,MAAMC,WAAW,gBAAiDJ,UAAU,CAACK,OAAO,CAAcH,MAAM,CAAC;AAEhH;;;;AAIA,OAAM,MAAOI,gBAAiB,sBAAQV,IAAI,CAACW,WAAW,CAAC,kBAAkB,CAEvE;EACAC,YAAYC,KAEX;IACC,KAAK,CAAC;MACJ,GAAGA,KAAK;MACRC,KAAK,EAAED,KAAK,CAACE,MAAM,CAACD;KACd,CAAC;EACX;EAES,CAACP,WAAW,IAAIA,WAAW;EAEpC,IAAaS,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACD,MAAM,CAACC,OAAO;EAC5B;;AAGF;;;;AAIA,OAAM,MAAOC,mBAAoB,sBAAQjB,IAAI,CAACW,WAAW,CAAC,qBAAqB,CAE7E;EACA,IAAaK,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACE,IAAI;EAClB;;AAGF;;;;AAIA,OAAM,MAAOC,gBAAiB,sBAAQnB,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,oBAAoB,EAAE;IACpD,MAAMJ,KAAK,GAAG,IAAI3B,gBAAgB,CAAC;MACjCK,MAAM,EAAE,IAAIE,mBAAmB,CAAC;QAAEH;MAAK,CAAE;KAC1C,CAAC;IACFX,KAAK,CAACmC,eAAe,CAACX,KAAK,EAAE5B,KAAK,CAACwC,IAAI,CAACF,KAAK,CAAC,CAAC;EACjD;AACF,CAAC,EACDf,OAAO,CACR,CACF,EACAoB,QAAQ,IAAKzC,MAAM,CAAC4B,IAAI,CAAC,MAAMC,SAAS,CAACC,WAAW,CAACY,UAAU,CAACD,QAAQ,CAAC,CAAC,CAC5E,CACF,CACF;AAEH;;;;AAIA,OAAO,MAAME,KAAK,gBAA6B1C,KAAK,CAAC2C,OAAO,CAC1DrC,WAAW,eACXA,WAAW,CAACsC,EAAE,CAAC;EACb,CAACxC,MAAM,GAAGA,MAAM;EAChByC,kBAAkB,EAAGzB,OAAO,IAC1BD,SAAS,CAACC,OAAO,CAAC,CAACG,IAAI,CACrBxB,MAAM,CAAC+C,OAAO,CAAC7C,KAAK,CAAC8C,IAAI,CAAC,EAC1BhD,MAAM,CAACiD,MAAM,CACd;EACHlB,aAAa,EAAGV,OAAO,IACrBD,SAAS,CAACC,OAAO,CAAC,CAACG,IAAI,CACrBxB,MAAM,CAACkD,GAAG,CAAC9C,MAAM,CAAC+C,SAAS,CAAC,EAC5B/C,MAAM,CAACgD,MAAM;CAElB,CAAC,CACH;AAED;;;;AAIA,OAAO,MAAMrB,aAAa,GACxBV,OAIa,IAEbjB,MAAM,CAACgD,MAAM,CAACpD,MAAM,CAACkD,GAAG,CACtBlD,MAAM,CAACqD,OAAO,CAAC9C,WAAW,CAAC,EAC1BuB,WAAW,IAAKA,WAAW,CAACC,aAAa,CAACV,OAAO,CAAC,CACpD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Geolocation.js","names":["Cause","Context","Data","Effect","Layer","Queue","Stream","TypeId","ErrorTypeId","Geolocation","Service","GeolocationError","TaggedError","constructor","props","cause","reason","message","PositionUnavailable","_tag","PermissionDenied","Timeout","makeQueue","options","sliding","bufferSize","pipe","tap","queue","acquireRelease","sync","navigator","geolocation","watchPosition","position","offerUnsafe","code","PERMISSION_DENIED","error","failCauseUnsafe","fail","TIMEOUT","POSITION_UNAVAILABLE","handleId","clearWatch","layer","succeed","of","getCurrentPosition","flatMap","take","scoped","map","fromQueue","unwrap","service"],"sources":["../src/Geolocation.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,MAAMC,MAAM,GAAG,uCAAuC;AACtD,MAAMC,WAAW,GAAG,wDAAwD;AA0C5E;;;;;;;;;;;;;AAaA,OAAO,MAAMC,WAAW,gBAA8CR,OAAO,CAACS,OAAO,CAAcH,MAAM,CAAC;AAE1G;;;;;;AAMA,OAAM,MAAOI,gBAAiB,sBAAQT,IAAI,CAACU,WAAW,CAAC,kBAAkB,CAEvE;EACAC,YAAYC,KAEX;IACC,KAAK,CAAC;MACJ,GAAGA,KAAK;MACRC,KAAK,EAAED,KAAK,CAACE,MAAM,CAACD;KACd,CAAC;EACX;EAES,CAACP,WAAW,IAAIA,WAAW;EAEpC,IAAaS,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACD,MAAM,CAACC,OAAO;EAC5B;;AAGF;;;;;;AAMA,OAAM,MAAOC,mBAAoB,sBAAQhB,IAAI,CAACU,WAAW,CAAC,qBAAqB,CAE7E;EACA,IAAaK,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACE,IAAI;EAClB;;AAGF;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ications.
3
+ *
4
+ * This module is the low-level bridge used by the platform-browser IndexedDB
5
+ * integration. It provides an `IndexedDb` service around the browser
6
+ * `indexedDB` factory and `IDBKeyRange` constructor, a `layerWindow` layer for
7
+ * wiring those primitives from `window`, and schemas for the key shapes accepted
8
+ * by IndexedDB object stores and indexes.
9
+ *
10
+ * Use it when building typed local persistence for browser caches,
11
+ * offline-first state, background queues, drafts, or other client-side data
12
+ * that should be validated before it reaches IndexedDB. Higher-level database,
13
+ * version, table, and query modules build on these primitives for migrations
14
+ * and typed transactions.
15
+ *
16
+ * IndexedDB still follows the browser rules: schema changes happen only during
17
+ * version upgrades, upgrades may be blocked by other open tabs or connections,
18
+ * and reads or writes must run in transactions scoped to the object stores they
19
+ * touch. The `layerWindow` constructor should be used only where browser
20
+ * globals are available, and code that also runs during SSR or in restricted
21
+ * browser contexts should account for `indexedDB` or `IDBKeyRange` being
22
+ * missing.
23
+ *
24
+ * @since 4.0.0
25
+ */
26
+ import * as Context from "effect/Context";
27
+ import * as Layer from "effect/Layer";
28
+ import * as Schema from "effect/Schema";
29
+ declare const TypeId = "~@effect/platform-browser/IndexedDb";
30
+ /**
31
+ * Service interface that provides the browser `indexedDB` factory and `IDBKeyRange` constructor.
32
+ *
33
+ * @category models
34
+ * @since 4.0.0
35
+ */
36
+ export interface IndexedDb {
37
+ readonly [TypeId]: typeof TypeId;
38
+ readonly indexedDB: globalThis.IDBFactory;
39
+ readonly IDBKeyRange: typeof globalThis.IDBKeyRange;
40
+ }
41
+ /**
42
+ * Service tag for browser IndexedDB primitives.
43
+ *
44
+ * @category tag
45
+ * @since 4.0.0
46
+ */
47
+ export declare const IndexedDb: Context.Service<IndexedDb, IndexedDb>;
48
+ /**
49
+ * Schema for IndexedDB keys: strings, non-NaN numbers, valid dates, buffer sources, or arrays of those flat key values.
50
+ *
51
+ * @category schemas
52
+ * @since 4.0.0
53
+ */
54
+ export declare const IDBValidKey: Schema.Union<readonly [Schema.Union<readonly [Schema.String, Schema.Number, Schema.DateValid, Schema.declare<BufferSource, unknown>]>, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number, Schema.DateValid, Schema.declare<BufferSource, unknown>]>>]>;
55
+ /**
56
+ * Schema for auto-incremented IndexedDB keys, accepting integers from 1 through `2 ** 53`.
57
+ *
58
+ * **When to use**
59
+ *
60
+ * Use when defining numeric key-path fields for `IndexedDbTable` definitions
61
+ * that use IndexedDB auto-increment keys.
62
+ *
63
+ * **Details**
64
+ *
65
+ * The schema accepts integer values from `1` through `2 ** 53`, matching the
66
+ * range used for generated IndexedDB auto-increment keys.
67
+ *
68
+ * @see {@link IDBValidKey} for the broader IndexedDB key schema
69
+ *
70
+ * @category schemas
71
+ * @since 4.0.0
72
+ */
73
+ export declare const AutoIncrement: Schema.Int;
74
+ /**
75
+ * Creates an `IndexedDb` service from an `IDBFactory` and `IDBKeyRange` constructor.
76
+ *
77
+ * @category constructors
78
+ * @since 4.0.0
79
+ */
80
+ export declare const make: (impl: Omit<IndexedDb, typeof TypeId>) => IndexedDb;
81
+ /**
82
+ * Layer that provides `IndexedDb` from `window.indexedDB` and `window.IDBKeyRange`, failing with a config error when they are unavailable.
83
+ *
84
+ * @category constructors
85
+ * @since 4.0.0
86
+ */
87
+ export declare const layerWindow: Layer.Layer<IndexedDb>;
88
+ export {};
89
+ //# sourceMappingURL=IndexedDb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexedDb.d.ts","sourceRoot":"","sources":["../src/IndexedDb.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,QAAA,MAAM,MAAM,wCAAwC,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;IAChC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,UAAU,CAAA;IACzC,QAAQ,CAAC,WAAW,EAAE,OAAO,UAAU,CAAC,WAAW,CAAA;CACpD;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAiD,CAAA;AAc7G;;;;;GAKG;AACH,eAAO,MAAM,WAAW,wQAAuD,CAAA;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,YAMxB,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,SAAS,EAAE,OAAO,MAAM,CAAC,KAAG,SAAwD,CAAA;AAEpH;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAc9C,CAAA"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Browser IndexedDB primitives and key schemas for Effect applications.
3
+ *
4
+ * This module is the low-level bridge used by the platform-browser IndexedDB
5
+ * integration. It provides an `IndexedDb` service around the browser
6
+ * `indexedDB` factory and `IDBKeyRange` constructor, a `layerWindow` layer for
7
+ * wiring those primitives from `window`, and schemas for the key shapes accepted
8
+ * by IndexedDB object stores and indexes.
9
+ *
10
+ * Use it when building typed local persistence for browser caches,
11
+ * offline-first state, background queues, drafts, or other client-side data
12
+ * that should be validated before it reaches IndexedDB. Higher-level database,
13
+ * version, table, and query modules build on these primitives for migrations
14
+ * and typed transactions.
15
+ *
16
+ * IndexedDB still follows the browser rules: schema changes happen only during
17
+ * version upgrades, upgrades may be blocked by other open tabs or connections,
18
+ * and reads or writes must run in transactions scoped to the object stores they
19
+ * touch. The `layerWindow` constructor should be used only where browser
20
+ * globals are available, and code that also runs during SSR or in restricted
21
+ * browser contexts should account for `indexedDB` or `IDBKeyRange` being
22
+ * missing.
23
+ *
24
+ * @since 4.0.0
25
+ */
26
+ import * as Context from "effect/Context";
27
+ import * as Effect from "effect/Effect";
28
+ import * as Layer from "effect/Layer";
29
+ import * as Schema from "effect/Schema";
30
+ const TypeId = "~@effect/platform-browser/IndexedDb";
31
+ /**
32
+ * Service tag for browser IndexedDB primitives.
33
+ *
34
+ * @category tag
35
+ * @since 4.0.0
36
+ */
37
+ export const IndexedDb = /*#__PURE__*/Context.Service(TypeId);
38
+ /** @internal */
39
+ const IDBFlatKey = /*#__PURE__*/Schema.Union([Schema.String, /*#__PURE__*/Schema.Number.check(/*#__PURE__*/Schema.makeFilter(input => !Number.isNaN(input))), Schema.DateValid, /*#__PURE__*/Schema.declare(input => input instanceof ArrayBuffer || ArrayBuffer.isView(input) && input.buffer instanceof ArrayBuffer)]);
40
+ /**
41
+ * Schema for IndexedDB keys: strings, non-NaN numbers, valid dates, buffer sources, or arrays of those flat key values.
42
+ *
43
+ * @category schemas
44
+ * @since 4.0.0
45
+ */
46
+ export const IDBValidKey = /*#__PURE__*/Schema.Union([IDBFlatKey, /*#__PURE__*/Schema.Array(IDBFlatKey)]);
47
+ /**
48
+ * Schema for auto-incremented IndexedDB keys, accepting integers from 1 through `2 ** 53`.
49
+ *
50
+ * **When to use**
51
+ *
52
+ * Use when defining numeric key-path fields for `IndexedDbTable` definitions
53
+ * that use IndexedDB auto-increment keys.
54
+ *
55
+ * **Details**
56
+ *
57
+ * The schema accepts integer values from `1` through `2 ** 53`, matching the
58
+ * range used for generated IndexedDB auto-increment keys.
59
+ *
60
+ * @see {@link IDBValidKey} for the broader IndexedDB key schema
61
+ *
62
+ * @category schemas
63
+ * @since 4.0.0
64
+ */
65
+ export const AutoIncrement = /*#__PURE__*/Schema.Int.check(Schema.isBetween({
66
+ minimum: 1,
67
+ maximum: 2 ** 53
68
+ })).annotate({
69
+ identifier: "AutoIncrement",
70
+ title: "autoIncrement",
71
+ description: "Defines a valid autoIncrement key path for the IndexedDb table"
72
+ });
73
+ /**
74
+ * Creates an `IndexedDb` service from an `IDBFactory` and `IDBKeyRange` constructor.
75
+ *
76
+ * @category constructors
77
+ * @since 4.0.0
78
+ */
79
+ export const make = impl => IndexedDb.of({
80
+ [TypeId]: TypeId,
81
+ ...impl
82
+ });
83
+ /**
84
+ * Layer that provides `IndexedDb` from `window.indexedDB` and `window.IDBKeyRange`, failing with a config error when they are unavailable.
85
+ *
86
+ * @category constructors
87
+ * @since 4.0.0
88
+ */
89
+ export const layerWindow = /*#__PURE__*/Layer.effect(IndexedDb, /*#__PURE__*/Effect.suspend(() => {
90
+ if (window.indexedDB && window.IDBKeyRange) {
91
+ return Effect.succeed(make({
92
+ indexedDB: window.indexedDB,
93
+ IDBKeyRange: window.IDBKeyRange
94
+ }));
95
+ } else {
96
+ return Effect.die(new Error("window.indexedDB is not available"));
97
+ }
98
+ }));
99
+ //# sourceMappingURL=IndexedDb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexedDb.js","names":["Context","Effect","Layer","Schema","TypeId","IndexedDb","Service","IDBFlatKey","Union","String","Number","check","makeFilter","input","isNaN","DateValid","declare","ArrayBuffer","isView","buffer","IDBValidKey","Array","AutoIncrement","Int","isBetween","minimum","maximum","annotate","identifier","title","description","make","impl","of","layerWindow","effect","suspend","window","indexedDB","IDBKeyRange","succeed","die","Error"],"sources":["../src/IndexedDb.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,MAAMC,MAAM,GAAG,qCAAqC;AAcpD;;;;;;AAMA,OAAO,MAAMC,SAAS,gBAA0CL,OAAO,CAACM,OAAO,CAAuBF,MAAM,CAAC;AAE7G;AACA,MAAMG,UAAU,gBAAGJ,MAAM,CAACK,KAAK,CAAC,CAC9BL,MAAM,CAACM,MAAM,eACbN,MAAM,CAAC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ACH;EACH,CAAC,MAAM;IACL,OAAOtC,MAAM,CAACwC,GAAG,CAAC,IAAIC,KAAK,CAAC,mCAAmC,CAAC,CAAC;EACnE;AACF,CAAC,CAAC,CACH","ignoreList":[]}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Builds and opens typed IndexedDB databases from versioned schema migrations.
3
+ *
4
+ * This module turns an `IndexedDbVersion` migration chain into an
5
+ * `IndexedDbDatabase` layer. The layer opens the browser database, runs any
6
+ * pending upgrade migrations, provides a query builder for the current schema,
7
+ * and exposes a `rebuild` effect that deletes and reopens the database. It is
8
+ * the database-level companion to the table, version, and query builder
9
+ * modules.
10
+ *
11
+ * Use it for browser-local persistence such as offline-first application
12
+ * state, cached server data, background queues, drafts, and other client-side
13
+ * stores that need typed reads and writes backed by IndexedDB transactions.
14
+ *
15
+ * IndexedDB schema changes can only happen inside upgrade transactions, so
16
+ * every call to `make` or `.add` represents the next browser database version
17
+ * and only migrations after the existing browser version are run. Table and
18
+ * index definitions type the migration and query APIs, but object stores and
19
+ * indexes still need to be created or removed explicitly with the migration
20
+ * transaction helpers. Include the complete target table set in each version,
21
+ * create indexes before querying them, and treat key path or auto-increment
22
+ * changes as store migrations that copy data into a replacement object store.
23
+ * Upgrades can be blocked by other open connections, and all migration reads,
24
+ * writes, store changes, and index changes share the single upgrade
25
+ * transaction supplied by the browser.
26
+ *
27
+ * @since 4.0.0
28
+ */
29
+ import * as Context from "effect/Context";
30
+ import * as Effect from "effect/Effect";
31
+ import * as Layer from "effect/Layer";
32
+ import * as MutableRef from "effect/MutableRef";
33
+ import * as Reactivity from "effect/unstable/reactivity/Reactivity";
34
+ import * as IndexedDb from "./IndexedDb.ts";
35
+ import * as IndexedDbQueryBuilder from "./IndexedDbQueryBuilder.ts";
36
+ import type * as IndexedDbTable from "./IndexedDbTable.ts";
37
+ import type * as IndexedDbVersion from "./IndexedDbVersion.ts";
38
+ declare const ErrorTypeId = "~@effect/platform-browser/IndexedDbDatabase/IndexedDbDatabaseError";
39
+ /**
40
+ * String union describing the failure categories for IndexedDB database opening, migration, and schema operations.
41
+ *
42
+ * @category errors
43
+ * @since 4.0.0
44
+ */
45
+ export type ErrorReason = "TransactionError" | "MissingTable" | "OpenError" | "UpgradeError" | "Aborted" | "Blocked" | "MissingIndex";
46
+ declare const IndexedDbDatabaseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
47
+ readonly _tag: "IndexedDbDatabaseError";
48
+ } & Readonly<A>;
49
+ /**
50
+ * Tagged error for IndexedDB database operations, carrying a database error reason and the original cause.
51
+ *
52
+ * @category errors
53
+ * @since 4.0.0
54
+ */
55
+ export declare class IndexedDbDatabaseError extends IndexedDbDatabaseError_base<{
56
+ reason: ErrorReason;
57
+ cause: unknown;
58
+ }> {
59
+ /**
60
+ * Marks this value as an IndexedDB database error for runtime guards.
61
+ *
62
+ * @since 4.0.0
63
+ */
64
+ readonly [ErrorTypeId]: typeof ErrorTypeId;
65
+ readonly message: ErrorReason;
66
+ }
67
+ declare const IndexedDbDatabase_base: Context.ServiceClass<IndexedDbDatabase, "~@effect/platform-browser/IndexedDbDatabase", {
68
+ readonly database: MutableRef.MutableRef<globalThis.IDBDatabase>;
69
+ readonly IDBKeyRange: typeof globalThis.IDBKeyRange;
70
+ readonly reactivity: Reactivity.Reactivity["Service"];
71
+ readonly rebuild: Effect.Effect<void, IndexedDbDatabaseError>;
72
+ }>;
73
+ /**
74
+ * Service tag for an open IndexedDB database, its `IDBKeyRange` constructor, reactivity service, and rebuild effect.
75
+ *
76
+ * **When to use**
77
+ *
78
+ * Use when an effect needs access to the live database service after an
79
+ * `IndexedDbSchema` layer has been provided, especially for `rebuild` or
80
+ * lower-level database primitives.
81
+ *
82
+ * **Details**
83
+ *
84
+ * `database` is a mutable reference to the current `IDBDatabase`. `IDBKeyRange`
85
+ * and `reactivity` are shared with query builders created from the schema.
86
+ *
87
+ * **Gotchas**
88
+ *
89
+ * `rebuild` closes and deletes the browser database, then reopens it and reruns
90
+ * migrations. Records not recreated by migrations are removed.
91
+ *
92
+ * @see {@link IndexedDb.IndexedDb} for the lower-level browser IndexedDB primitives
93
+ * @see {@link make} for creating a schema that provides this service as a layer
94
+ *
95
+ * @category models
96
+ * @since 4.0.0
97
+ */
98
+ export declare class IndexedDbDatabase extends IndexedDbDatabase_base {
99
+ }
100
+ /**
101
+ * Describes an IndexedDB schema version and its migrations, and acts as an effect that yields a query builder for the target version.
102
+ *
103
+ * @category models
104
+ * @since 4.0.0
105
+ */
106
+ export interface IndexedDbSchema<in out FromVersion extends IndexedDbVersion.AnyWithProps, in out ToVersion extends IndexedDbVersion.AnyWithProps, out Error = never> extends Effect.Effect<IndexedDbQueryBuilder.IndexedDbQueryBuilder<ToVersion>, never, IndexedDbDatabase> {
107
+ new (_: never): {};
108
+ readonly previous: [FromVersion] extends [never] ? undefined : IndexedDbSchema<never, FromVersion, Error>;
109
+ readonly fromVersion: FromVersion;
110
+ readonly version: ToVersion;
111
+ readonly migrate: [FromVersion] extends [never] ? (query: Transaction<ToVersion>) => Effect.Effect<void, Error> : (fromQuery: Transaction<FromVersion>, toQuery: Transaction<ToVersion>) => Effect.Effect<void, Error>;
112
+ readonly add: <Version extends IndexedDbVersion.AnyWithProps, MigrationError>(version: Version, migrate: (fromQuery: Transaction<ToVersion>, toQuery: Transaction<Version>) => Effect.Effect<void, MigrationError>) => IndexedDbSchema<ToVersion, Version, MigrationError | Error>;
113
+ readonly getQueryBuilder: Effect.Effect<IndexedDbQueryBuilder.IndexedDbQueryBuilder<ToVersion>, never, IndexedDbDatabase>;
114
+ readonly layer: (databaseName: string) => Layer.Layer<IndexedDbDatabase, IndexedDbDatabaseError, IndexedDb.IndexedDb>;
115
+ }
116
+ /**
117
+ * Query builder available during a database migration, extended with object-store and index management helpers for the active `IDBTransaction`.
118
+ *
119
+ * @category models
120
+ * @since 4.0.0
121
+ */
122
+ export interface Transaction<Source extends IndexedDbVersion.AnyWithProps = never> extends Omit<IndexedDbQueryBuilder.IndexedDbQueryBuilder<Source>, "transaction"> {
123
+ readonly transaction: globalThis.IDBTransaction;
124
+ readonly createObjectStore: <A extends IndexedDbTable.TableName<IndexedDbVersion.Tables<Source>>>(table: A) => Effect.Effect<globalThis.IDBObjectStore, IndexedDbDatabaseError>;
125
+ readonly deleteObjectStore: <A extends IndexedDbTable.TableName<IndexedDbVersion.Tables<Source>>>(table: A) => Effect.Effect<void, IndexedDbDatabaseError>;
126
+ readonly createIndex: <Name extends IndexedDbTable.TableName<IndexedDbVersion.Tables<Source>>>(table: Name, indexName: IndexFromTableName<Source, Name>, options?: IDBIndexParameters) => Effect.Effect<globalThis.IDBIndex, IndexedDbDatabaseError>;
127
+ readonly deleteIndex: <Name extends IndexedDbTable.TableName<IndexedDbVersion.Tables<Source>>>(table: Name, indexName: IndexFromTableName<Source, Name>) => Effect.Effect<void, IndexedDbDatabaseError>;
128
+ }
129
+ /**
130
+ * Extracts the string-literal index names defined by an `IndexedDbTable`.
131
+ *
132
+ * @category models
133
+ * @since 4.0.0
134
+ */
135
+ export type IndexFromTable<Table extends IndexedDbTable.AnyWithProps> = IsStringLiteral<Extract<keyof IndexedDbTable.Indexes<Table>, string>> extends true ? Extract<keyof IndexedDbTable.Indexes<Table>, string> : never;
136
+ /**
137
+ * Extracts the valid index names for a table name within an IndexedDB version.
138
+ *
139
+ * @category models
140
+ * @since 4.0.0
141
+ */
142
+ export type IndexFromTableName<Version extends IndexedDbVersion.AnyWithProps, Table extends string> = IndexFromTable<IndexedDbTable.WithName<IndexedDbVersion.Tables<Version>, Table>>;
143
+ /**
144
+ * Type-erased IndexedDB schema shape used when traversing schema migration chains.
145
+ *
146
+ * @category models
147
+ * @since 4.0.0
148
+ */
149
+ export interface Any {
150
+ readonly previous?: Any | undefined;
151
+ readonly layer: (databaseName: string) => Layer.Layer<IndexedDbDatabase, IndexedDbDatabaseError, IndexedDb.IndexedDb>;
152
+ }
153
+ /**
154
+ * Type-erased `IndexedDbSchema` covering any source version, target version, and migration error type.
155
+ *
156
+ * @category models
157
+ * @since 4.0.0
158
+ */
159
+ export type AnySchema = IndexedDbSchema<IndexedDbVersion.AnyWithProps, IndexedDbVersion.AnyWithProps, any>;
160
+ /**
161
+ * Creates the initial `IndexedDbSchema` from a version and an initialization migration run during database upgrade.
162
+ *
163
+ * @category constructors
164
+ * @since 4.0.0
165
+ */
166
+ export declare const make: <InitialVersion extends IndexedDbVersion.AnyWithProps, Error>(initialVersion: InitialVersion, init: (toQuery: Transaction<InitialVersion>) => Effect.Effect<void, Error>) => IndexedDbSchema<never, InitialVersion, Error>;
167
+ type IsStringLiteral<T> = T extends string ? string extends T ? false : true : false;
168
+ export {};
169
+ //# sourceMappingURL=IndexedDbDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexedDbDatabase.d.ts","sourceRoot":"","sources":["../src/IndexedDbDatabase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA;AACnE,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAG9D,QAAA,MAAM,WAAW,uEAAuE,CAAA;AA2CxF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACnB,kBAAkB,GAClB,cAAc,GACd,WAAW,GACX,cAAc,GACd,SAAS,GACT,SAAS,GACT,c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