@effect/platform-browser 4.0.0-beta.43 → 4.0.0-beta.44

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 (44) hide show
  1. package/dist/BrowserHttpClient.d.ts +3 -3
  2. package/dist/BrowserHttpClient.d.ts.map +1 -1
  3. package/dist/BrowserHttpClient.js +5 -5
  4. package/dist/BrowserHttpClient.js.map +1 -1
  5. package/dist/BrowserWorkerRunner.js +1 -1
  6. package/dist/BrowserWorkerRunner.js.map +1 -1
  7. package/dist/Clipboard.d.ts +5 -2
  8. package/dist/Clipboard.d.ts.map +1 -1
  9. package/dist/Clipboard.js +2 -2
  10. package/dist/Clipboard.js.map +1 -1
  11. package/dist/Geolocation.d.ts +2 -2
  12. package/dist/Geolocation.d.ts.map +1 -1
  13. package/dist/Geolocation.js +2 -2
  14. package/dist/Geolocation.js.map +1 -1
  15. package/dist/IndexedDb.d.ts +3 -3
  16. package/dist/IndexedDb.d.ts.map +1 -1
  17. package/dist/IndexedDb.js +2 -2
  18. package/dist/IndexedDb.js.map +1 -1
  19. package/dist/IndexedDbDatabase.d.ts +8 -3
  20. package/dist/IndexedDbDatabase.d.ts.map +1 -1
  21. package/dist/IndexedDbDatabase.js +38 -16
  22. package/dist/IndexedDbDatabase.js.map +1 -1
  23. package/dist/IndexedDbQueryBuilder.d.ts +115 -57
  24. package/dist/IndexedDbQueryBuilder.d.ts.map +1 -1
  25. package/dist/IndexedDbQueryBuilder.js +114 -107
  26. package/dist/IndexedDbQueryBuilder.js.map +1 -1
  27. package/dist/IndexedDbTable.d.ts +2 -3
  28. package/dist/IndexedDbTable.d.ts.map +1 -1
  29. package/dist/IndexedDbTable.js +5 -3
  30. package/dist/IndexedDbTable.js.map +1 -1
  31. package/dist/Permissions.d.ts +5 -2
  32. package/dist/Permissions.d.ts.map +1 -1
  33. package/dist/Permissions.js +2 -2
  34. package/dist/Permissions.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/BrowserHttpClient.ts +6 -6
  37. package/src/BrowserWorkerRunner.ts +1 -1
  38. package/src/Clipboard.ts +2 -2
  39. package/src/Geolocation.ts +2 -2
  40. package/src/IndexedDb.ts +2 -2
  41. package/src/IndexedDbDatabase.ts +174 -141
  42. package/src/IndexedDbQueryBuilder.ts +322 -327
  43. package/src/IndexedDbTable.ts +8 -10
  44. package/src/Permissions.ts +2 -2
@@ -20,17 +20,19 @@ export const make = options => {
20
20
  // oxlint-disable-next-line typescript/no-extraneous-class
21
21
  class Table {}
22
22
  Object.assign(Table, Proto);
23
- const readSchema = options.keyPath === undefined ? options.schema.mapFields(Struct.assign({
23
+ const readSchema = options.keyPath === undefined ? Schema.Struct({
24
+ ...options.schema.fields,
24
25
  key: IndexedDb.IDBValidKey
25
- })) : options.schema;
26
+ }) : options.schema;
26
27
  Table.tableName = options.name;
27
28
  Table.tableSchema = options.schema;
28
29
  Table.readSchema = readSchema;
29
30
  Table.arraySchema = Schema.Array(readSchema);
30
- Table.autoincrementSchema = options.autoIncrement ? options.schema.mapFields(Struct.omit([options.keyPath])) : options.schema;
31
+ Table.autoincrementSchema = options.autoIncrement ? Schema.Struct(Struct.omit(options.schema.fields, [options.keyPath])) : options.schema;
31
32
  Table.keyPath = options.keyPath;
32
33
  Table.indexes = options.indexes;
33
34
  Table.autoIncrement = options.autoIncrement === true;
35
+ Table.durability = options.durability ?? "relaxed";
34
36
  return Table;
35
37
  };
36
38
  //# sourceMappingURL=IndexedDbTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IndexedDbTable.js","names":["pipeArguments","Schema","Struct","IndexedDb","TypeId","Proto","pipe","arguments","make","options","Table","Object","assign","readSchema","keyPath","undefined","schema","mapFields","key","IDBValidKey","tableName","name","tableSchema","arraySchema","Array","autoincrementSchema","autoIncrement","omit","indexes"],"sources":["../src/IndexedDbTable.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,SAAwBA,aAAa,QAAQ,iBAAiB;AAC9D,OAAO,KAAKC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C","ignoreList":[]}
1
+ {"version":3,"file":"IndexedDbTable.js","names":["pipeArguments","Schema","Struct","IndexedDb","TypeId","Proto","pipe","arguments","make","options","Table","Object","assign","readSchema","keyPath","undefined","schema","fields","key","IDBValidKey","tableName","name","tableSchema","arraySchema","Array","autoincrementSchema","autoIncrement","omit","indexes","durability"],"sources":["../src/IndexedDbTable.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,SAAwBA,aAAa,QAAQ,iBAAiB;AAC9D,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAG3C,MAAMC,MAAM,GAAG,0CAA0C;AAoHzD,MAAMC,KAAK,GAAG;EACZ,CAACD,MAAM,GAAGA,MAAM;EAChBE,IAAIA,CAAA;IACF,OAAON,aAAa,CAAC,IAAI,EAAEO,SAAS,CAAC;EACvC;CACD;AAED;;;;AAIA,OAAO,MAAMC,IAAI,GAYfC,OAcD,IAMG;EACF;EACA,MAAMC,KAAK;EACXC,MAAM,CAACC,MAAM,CAACF,KAAK,EAAEL,KAAK,CAAC;EAC3B,MAAMQ,UAAU,GAAGJ,OAAO,CAACK,OAAO,KAAKC,SAAS,GAC5Cd,MAAM,CAACC,MAAM,CAAC;IACd,GAAIO,OAAO,CAACO,MAA4B,CAACC,MAAM;IAC/CC,GAAG,EAAEf,SAAS,CAACgB;GAChB,CAAC,GACAV,OAAO,CAACO,MAAM;EAChBN,KAAa,CAACU,SAAS,GAAGX,OAAO,CAACY,IAAI;EACtCX,KAAa,CAACY,WAAW,GAAGb,OAAO,CAACO,MAAM;EAC1CN,KAAa,CAACG,UAAU,GAAGA,UAAU;EACrCH,KAAa,CAACa,WAAW,GAAGtB,MAAM,CAACuB,KAAK,CAACX,UAAiB,CAAC;EAC3DH,KAAa,CAACe,mBAAmB,GAAGhB,OAAO,CAACiB,aAAa,GACvDzB,MAAM,CAACC,MAAM,CAACA,MAAM,CAACyB,IAAI,CAAElB,OAAO,CAACO,MAA4B,CAACC,MAAM,EAAE,CAACR,OAAO,CAACK,OAAQ,CAAQ,CAAC,CAAC,GACnGL,OAAO,CAACO,MAAM;EAChBN,KAAa,CAACI,OAAO,GAAGL,OAAO,CAACK,OAAO;EACvCJ,KAAa,CAACkB,OAAO,GAAGnB,OAAO,CAACmB,OAAO;EACvClB,KAAa,CAACgB,aAAa,GAAGjB,OAAO,CAACiB,aAAa,KAAK,IAAI;EAC5DhB,KAAa,CAACmB,UAAU,GAAGpB,OAAO,CAACoB,UAAU,IAAI,SAAS;EAC5D,OAAOnB,KAAY;AACrB,CAAC","ignoreList":[]}
@@ -1,6 +1,9 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Context from "effect/Context";
1
5
  import * as Effect from "effect/Effect";
2
6
  import * as Layer from "effect/Layer";
3
- import * as ServiceMap from "effect/ServiceMap";
4
7
  declare const TypeId = "~@effect/platform-browser/Permissions";
5
8
  declare const ErrorTypeId = "~@effect/platform-browser/Permissions/PermissionsError";
6
9
  /**
@@ -68,7 +71,7 @@ export declare class PermissionsError extends PermissionsError_base<{
68
71
  * @since 1.0.0
69
72
  * @category Service
70
73
  */
71
- export declare const Permissions: ServiceMap.Service<Permissions, Permissions>;
74
+ export declare const Permissions: Context.Service<Permissions, Permissions>;
72
75
  /**
73
76
  * A layer that directly interfaces with the `navigator.permissions` api
74
77
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Permissions.d.ts","sourceRoot":"","sources":["../src/Permissions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,QAAA,MAAM,MAAM,0CAA0C,CAAA;AACtD,QAAA,MAAM,WAAW,2DAA2D,CAAA;AAE5E;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ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W,EAAE,WAAW,CAAwC,CAAA;AAE1G;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAe1C,CAAA"}
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
+ import * as Context from "effect/Context";
4
5
  import * as Data from "effect/Data";
5
6
  import * as Effect from "effect/Effect";
6
7
  import * as Layer from "effect/Layer";
7
- import * as ServiceMap from "effect/ServiceMap";
8
8
  const TypeId = "~@effect/platform-browser/Permissions";
9
9
  const ErrorTypeId = "~@effect/platform-browser/Permissions/PermissionsError";
10
10
  /**
@@ -45,7 +45,7 @@ export class PermissionsError extends /*#__PURE__*/Data.TaggedError("Permissions
45
45
  * @since 1.0.0
46
46
  * @category Service
47
47
  */
48
- export const Permissions = /*#__PURE__*/ServiceMap.Service(TypeId);
48
+ export const Permissions = /*#__PURE__*/Context.Service(TypeId);
49
49
  /**
50
50
  * A layer that directly interfaces with the `navigator.permissions` api
51
51
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Permissions.js","names":["Data","Effect","Layer","ServiceMap","TypeId","ErrorTypeId","PermissionsInvalidStateError","TaggedError","message","_tag","PermissionsTypeError","PermissionsError","constructor","props","cause","reason","Permissions","Service","layer","succeed","of","query","name","tryPromise","try","navigator","permissions","catch","DOMException"],"sources":["../src/Permissions.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAE/C,MAAMC,MAAM,GAAG,uCAAuC;AACtD,MAAMC,WAAW,GAAG,wDAAwD;AAyB5E;;;;AAIA,OAAM,MAAOC,4BAA6B,sBAAQN,IAAI,CAACO,WAAW,CAAC,mBAAmB,CAEpF;EACA,IAAaC,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACC,IAAI;EAClB;;AAGF;;;;AAIA,OAAM,MAAOC,oBAAqB,sBAAQV,IAAI,CAACO,WAAW,CAAC,WAAW,CAEpE;EACA,IAAaC,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACC,IAAI;EAClB;;AASF;;;;AAIA,OAAM,MAAOE,gBAAiB,sBAAQX,IAAI,CAACO,WAAW,CAAC,kBAAkB,CAEvE;EACAK,YAAYC,KAAkD;IAC5D,KAAK,CAAC;MACJ,GAAGA,KAAK;MACRC,KAAK,EAAED,KAAK,CAACE,MAAM,CAACD;KACd,CAAC;EACX;EAES,CAACT,WAAW,IAAIA,WAAW;EAEpC,IAAaG,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACO,MAAM,CAACP,OAAO;EAC5B;;AAGF;;;;AAIA,OAAO,MAAMQ,WAAW,gBAAiDb,UAAU,CAACc,OAAO,CAAcb,MAAM,CAAC;AAEhH;;;;;;AAMA,OAAO,MAAMc,KAAK,gBAA6BhB,KAAK,CAACiB,OAAO,CAC1DH,WAAW,eACXA,WAAW,CAACI,EAAE,CAAC;EACb,CAAChB,MAAM,GAAGA,MAAM;EAChBiB,KAAK,EAAGC,IAAI,IACVrB,MAAM,CAACsB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,WAAW,CAACL,KAAK,CAAC;MAAEC;IAAI,CAAE,CAAiB;IAChEK,KAAK,EAAGb,KAAK,IACX,IAAIH,gBAAgB,CAAC;MACnBI,MAAM,EAAED,KAAK,YAAYc,YAAY,GACjC,IAAItB,4BAA4B,CAAC;QAAEQ;MAAK,CAAE,CAAC,GAC3C,IAAIJ,oBAAoB,CAAC;QAAEI;MAAK,CAAE;KACvC;GACJ;CACJ,CAAC,CACH","ignoreList":[]}
1
+ {"version":3,"file":"Permissions.js","names":["Context","Data","Effect","Layer","TypeId","ErrorTypeId","PermissionsInvalidStateError","TaggedError","message","_tag","PermissionsTypeError","PermissionsError","constructor","props","cause","reason","Permissions","Service","layer","succeed","of","query","name","tryPromise","try","navigator","permissions","catch","DOMException"],"sources":["../src/Permissions.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,MAAMC,MAAM,GAAG,uCAAuC;AACtD,MAAMC,WAAW,GAAG,wDAAwD;AAyB5E;;;;AAIA,OAAM,MAAOC,4BAA6B,sBAAQL,IAAI,CAACM,WAAW,CAAC,mBAAmB,CAEpF;EACA,IAAaC,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACC,IAAI;EAClB;;AAGF;;;;AAIA,OAAM,MAAOC,oBAAqB,sBAAQT,IAAI,CAACM,WAAW,CAAC,WAAW,CAEpE;EACA,IAAaC,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACC,IAAI;EAClB;;AASF;;;;AAIA,OAAM,MAAOE,gBAAiB,sBAAQV,IAAI,CAACM,WAAW,CAAC,kBAAkB,CAEvE;EACAK,YAAYC,KAAkD;IAC5D,KAAK,CAAC;MACJ,GAAGA,KAAK;MACRC,KAAK,EAAED,KAAK,CAACE,MAAM,CAACD;KACd,CAAC;EACX;EAES,CAACT,WAAW,IAAIA,WAAW;EAEpC,IAAaG,OAAOA,CAAA;IAClB,OAAO,IAAI,CAACO,MAAM,CAACP,OAAO;EAC5B;;AAGF;;;;AAIA,OAAO,MAAMQ,WAAW,gBAA8ChB,OAAO,CAACiB,OAAO,CAAcb,MAAM,CAAC;AAE1G;;;;;;AAMA,OAAO,MAAMc,KAAK,gBAA6Bf,KAAK,CAACgB,OAAO,CAC1DH,WAAW,eACXA,WAAW,CAACI,EAAE,CAAC;EACb,CAAChB,MAAM,GAAGA,MAAM;EAChBiB,KAAK,EAAGC,IAAI,IACVpB,MAAM,CAACqB,UAAU,CAAC;IAChBC,GAAG,EAAEA,CAAA,KAAMC,SAAS,CAACC,WAAW,CAACL,KAAK,CAAC;MAAEC;IAAI,CAAE,CAAiB;IAChEK,KAAK,EAAGb,KAAK,IACX,IAAIH,gBAAgB,CAAC;MACnBI,MAAM,EAAED,KAAK,YAAYc,YAAY,GACjC,IAAItB,4BAA4B,CAAC;QAAEQ;MAAK,CAAE,CAAC,GAC3C,IAAIJ,oBAAoB,CAAC;QAAEI;MAAK,CAAE;KACvC;GACJ;CACJ,CAAC,CACH","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@effect/platform-browser",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.43",
4
+ "version": "4.0.0-beta.44",
5
5
  "license": "MIT",
6
6
  "description": "Platform specific implementations for the browser",
7
7
  "homepage": "https://effect.website",
@@ -45,12 +45,12 @@
45
45
  "provenance": true
46
46
  },
47
47
  "peerDependencies": {
48
- "effect": "^4.0.0-beta.43"
48
+ "effect": "^4.0.0-beta.44"
49
49
  },
50
50
  "devDependencies": {
51
51
  "mock-xmlhttprequest": "^8.4.1",
52
52
  "fake-indexeddb": "^6.2.5",
53
- "effect": "^4.0.0-beta.43"
53
+ "effect": "^4.0.0-beta.44"
54
54
  },
55
55
  "dependencies": {
56
56
  "multipasta": "^0.2.7"
@@ -2,6 +2,7 @@
2
2
  * @since 1.0.0
3
3
  */
4
4
  import * as Cause from "effect/Cause"
5
+ import * as Context from "effect/Context"
5
6
  import * as Effect from "effect/Effect"
6
7
  import type { LazyArg } from "effect/Function"
7
8
  import * as Inspectable from "effect/Inspectable"
@@ -10,7 +11,6 @@ import * as Option from "effect/Option"
10
11
  import { type Pipeable, pipeArguments } from "effect/Pipeable"
11
12
  import * as Queue from "effect/Queue"
12
13
  import type * as Schema from "effect/Schema"
13
- import * as ServiceMap from "effect/ServiceMap"
14
14
  import * as Stream from "effect/Stream"
15
15
  import * as Cookies from "effect/unstable/http/Cookies"
16
16
  import * as Headers from "effect/unstable/http/Headers"
@@ -58,7 +58,7 @@ export type XHRResponseType = "arraybuffer" | "text"
58
58
  * @since 1.0.0
59
59
  * @category References
60
60
  */
61
- export const CurrentXHRResponseType: ServiceMap.Reference<XHRResponseType> = ServiceMap.Reference(
61
+ export const CurrentXHRResponseType: Context.Reference<XHRResponseType> = Context.Reference(
62
62
  "@effect/platform-browser/BrowserHttpClient/CurrentXHRResponseType",
63
63
  { defaultValue: (): XHRResponseType => "text" }
64
64
  )
@@ -80,7 +80,7 @@ export const withXHRArrayBuffer = <A, E, R>(
80
80
  * @since 1.0.0
81
81
  * @category Services
82
82
  */
83
- export class XMLHttpRequest extends ServiceMap.Service<
83
+ export class XMLHttpRequest extends Context.Service<
84
84
  XMLHttpRequest,
85
85
  LazyArg<globalThis.XMLHttpRequest>
86
86
  >()("@effect/platform-browser/BrowserHttpClient/XMLHttpRequest") {}
@@ -90,8 +90,8 @@ const makeXhrRequest = () => new globalThis.XMLHttpRequest()
90
90
  const makeXmlHttpRequest = HttpClient.make(
91
91
  (request, url, signal, fiber) =>
92
92
  Effect.suspend(() => {
93
- const xhr = ServiceMap.getOrElse(
94
- fiber.services,
93
+ const xhr = Context.getOrElse(
94
+ fiber.context,
95
95
  XMLHttpRequest,
96
96
  () => makeXhrRequest
97
97
  )()
@@ -387,6 +387,6 @@ class ClientResponseImpl extends IncomingMessageImpl<HttpClientError.HttpClientE
387
387
  * @since 1.0.0
388
388
  * @category Layers
389
389
  */
390
- export const layerXMLHttpRequest: Layer.Layer<HttpClient.HttpClient> = HttpClient.layerMergedServices(
390
+ export const layerXMLHttpRequest: Layer.Layer<HttpClient.HttpClient> = HttpClient.layerMergedContext(
391
391
  Effect.succeed(makeXmlHttpRequest)
392
392
  )
@@ -44,7 +44,7 @@ export const make = (self: MessagePort | Window): WorkerRunner.WorkerRunnerPlatf
44
44
  Effect.scopedWith(Effect.fnUntraced(function*(scope) {
45
45
  const closeLatch = Deferred.makeUnsafe<void, WorkerError>()
46
46
  const trackFiber = Fiber.runIn(scope)
47
- const services = yield* Effect.services<R>()
47
+ const services = yield* Effect.context<R>()
48
48
  const runFork = Effect.runForkWith(services)
49
49
  const onExit = (exit: Exit.Exit<any, E>) => {
50
50
  if (exit._tag === "Failure" && !Cause.hasInterruptsOnly(exit.cause)) {
package/src/Clipboard.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
+ import * as Context from "effect/Context"
4
5
  import * as Data from "effect/Data"
5
6
  import * as Effect from "effect/Effect"
6
7
  import * as Layer from "effect/Layer"
7
- import * as ServiceMap from "effect/ServiceMap"
8
8
 
9
9
  const TypeId = "~@effect/platform-browser/Clipboard"
10
10
  const ErrorTypeId = "~@effect/platform-browser/Clipboard/ClipboardError"
@@ -38,7 +38,7 @@ export class ClipboardError extends Data.TaggedError("ClipboardError")<{
38
38
  * @since 1.0.0
39
39
  * @category Service
40
40
  */
41
- export const Clipboard: ServiceMap.Service<Clipboard, Clipboard> = ServiceMap.Service<Clipboard>(TypeId)
41
+ export const Clipboard: Context.Service<Clipboard, Clipboard> = Context.Service<Clipboard>(TypeId)
42
42
 
43
43
  /**
44
44
  * @since 1.0.0
@@ -2,11 +2,11 @@
2
2
  * @since 1.0.0
3
3
  */
4
4
  import * as Cause from "effect/Cause"
5
+ import * as Context from "effect/Context"
5
6
  import * as Data from "effect/Data"
6
7
  import * as Effect from "effect/Effect"
7
8
  import * as Layer from "effect/Layer"
8
9
  import * as Queue from "effect/Queue"
9
- import * as ServiceMap from "effect/ServiceMap"
10
10
  import * as Stream from "effect/Stream"
11
11
 
12
12
  const TypeId = "~@effect/platform-browser/Geolocation"
@@ -34,7 +34,7 @@ export interface Geolocation {
34
34
  * @since 1.0.0
35
35
  * @category Service
36
36
  */
37
- export const Geolocation: ServiceMap.Service<Geolocation, Geolocation> = ServiceMap.Service<Geolocation>(TypeId)
37
+ export const Geolocation: Context.Service<Geolocation, Geolocation> = Context.Service<Geolocation>(TypeId)
38
38
 
39
39
  /**
40
40
  * @since 1.0.0
package/src/IndexedDb.ts CHANGED
@@ -2,11 +2,11 @@
2
2
  * @since 4.0.0
3
3
  */
4
4
  import * as Config from "effect/Config"
5
+ import * as Context from "effect/Context"
5
6
  import * as Effect from "effect/Effect"
6
7
  import * as Layer from "effect/Layer"
7
8
  import * as Schema from "effect/Schema"
8
9
  import * as SchemaIssue from "effect/SchemaIssue"
9
- import * as ServiceMap from "effect/ServiceMap"
10
10
 
11
11
  const TypeId = "~@effect/platform-browser/IndexedDb"
12
12
 
@@ -24,7 +24,7 @@ export interface IndexedDb {
24
24
  * @since 4.0.0
25
25
  * @category tag
26
26
  */
27
- export const IndexedDb: ServiceMap.Service<IndexedDb, IndexedDb> = ServiceMap.Service<IndexedDb, IndexedDb>(TypeId)
27
+ export const IndexedDb: Context.Service<IndexedDb, IndexedDb> = Context.Service<IndexedDb, IndexedDb>(TypeId)
28
28
 
29
29
  /** @internal */
30
30
  const IDBFlatKey = Schema.Union([
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * @since 4.0.0
3
3
  */
4
+ import * as Context from "effect/Context"
4
5
  import * as Data from "effect/Data"
5
6
  import * as Effect from "effect/Effect"
6
7
  import * as Fiber from "effect/Fiber"
7
8
  import * as Inspectable from "effect/Inspectable"
8
9
  import * as Layer from "effect/Layer"
10
+ import * as MutableRef from "effect/MutableRef"
9
11
  import * as Pipeable from "effect/Pipeable"
10
- import * as ServiceMap from "effect/ServiceMap"
12
+ import * as Semaphore from "effect/Semaphore"
11
13
  import * as Reactivity from "effect/unstable/reactivity/Reactivity"
12
14
  import * as Utils from "effect/Utils"
13
15
  import * as IndexedDb from "./IndexedDb.ts"
@@ -74,12 +76,13 @@ export class IndexedDbDatabaseError extends Data.TaggedError(
74
76
  * @since 4.0.0
75
77
  * @category models
76
78
  */
77
- export class IndexedDbDatabase extends ServiceMap.Service<
79
+ export class IndexedDbDatabase extends Context.Service<
78
80
  IndexedDbDatabase,
79
81
  {
80
- readonly database: globalThis.IDBDatabase
82
+ readonly database: MutableRef.MutableRef<globalThis.IDBDatabase>
81
83
  readonly IDBKeyRange: typeof globalThis.IDBKeyRange
82
84
  readonly reactivity: Reactivity.Reactivity["Service"]
85
+ readonly rebuild: Effect.Effect<void, IndexedDbDatabaseError>
83
86
  }
84
87
  >()(TypeId) {}
85
88
 
@@ -255,7 +258,6 @@ export const make = <
255
258
  database,
256
259
  IDBKeyRange,
257
260
  tables: initialVersion.tables,
258
- transaction: undefined,
259
261
  reactivity
260
262
  })
261
263
  })
@@ -299,7 +301,6 @@ const makeProto = <
299
301
  database,
300
302
  IDBKeyRange,
301
303
  tables: options.version.tables,
302
- transaction: undefined,
303
304
  reactivity
304
305
  })
305
306
  })
@@ -322,8 +323,8 @@ const layer = <DatabaseName extends string>(
322
323
  Effect.gen(function*() {
323
324
  const { IDBKeyRange, indexedDB } = yield* IndexedDb.IndexedDb
324
325
  const reactivity = yield* Reactivity.Reactivity
325
- const serviceMap = yield* Effect.services()
326
- const runForkWith = Effect.runForkWith(serviceMap)
326
+ const context = yield* Effect.context()
327
+ const runForkWith = Effect.runForkWith(context)
327
328
 
328
329
  let oldVersion = 0
329
330
  const migrations: Array<Any> = []
@@ -334,145 +335,177 @@ const layer = <DatabaseName extends string>(
334
335
  }
335
336
 
336
337
  const version = migrations.length
337
- const database = yield* Effect.acquireRelease(
338
- Effect.callback<globalThis.IDBDatabase, IndexedDbDatabaseError>(
339
- (resume) => {
340
- const request = indexedDB.open(databaseName, version)
341
-
342
- request.onblocked = (event) => {
343
- resume(
344
- Effect.fail(
345
- new IndexedDbDatabaseError({
346
- reason: "Blocked",
347
- cause: event
348
- })
349
- )
338
+ const database = MutableRef.make<globalThis.IDBDatabase>(null as any)
339
+
340
+ const open = Effect.callback<
341
+ void,
342
+ IndexedDbDatabaseError
343
+ >((resume) => {
344
+ const request = indexedDB.open(databaseName, version)
345
+
346
+ request.onblocked = (event) => {
347
+ resume(
348
+ Effect.fail(
349
+ new IndexedDbDatabaseError({
350
+ reason: "Blocked",
351
+ cause: event
352
+ })
353
+ )
354
+ )
355
+ }
356
+
357
+ request.onerror = (event) => {
358
+ const idbRequest = event.target as IDBRequest<IDBDatabase>
359
+
360
+ resume(
361
+ Effect.fail(
362
+ new IndexedDbDatabaseError({
363
+ reason: "OpenError",
364
+ cause: idbRequest.error
365
+ })
366
+ )
367
+ )
368
+ }
369
+
370
+ let fiber: Fiber.Fiber<void, IndexedDbDatabaseError> | undefined
371
+ request.onupgradeneeded = (event) => {
372
+ const idbRequest = event.target as IDBRequest<IDBDatabase>
373
+ const db = idbRequest.result
374
+ const transaction = idbRequest.transaction
375
+ oldVersion = event.oldVersion
376
+
377
+ MutableRef.set(database, db)
378
+
379
+ if (transaction === null) {
380
+ return resume(
381
+ Effect.fail(
382
+ new IndexedDbDatabaseError({
383
+ reason: "TransactionError",
384
+ cause: null
385
+ })
350
386
  )
351
- }
352
-
353
- request.onerror = (event) => {
354
- const idbRequest = event.target as IDBRequest<IDBDatabase>
355
-
356
- resume(
357
- Effect.fail(
358
- new IndexedDbDatabaseError({
359
- reason: "OpenError",
360
- cause: idbRequest.error
361
- })
362
- )
387
+ )
388
+ }
389
+
390
+ transaction.onabort = (event) => {
391
+ resume(
392
+ Effect.fail(
393
+ new IndexedDbDatabaseError({
394
+ reason: "Aborted",
395
+ cause: event
396
+ })
363
397
  )
364
- }
365
-
366
- let fiber: Fiber.Fiber<void, IndexedDbDatabaseError> | undefined
367
- request.onupgradeneeded = (event) => {
368
- const idbRequest = event.target as IDBRequest<IDBDatabase>
369
- const database = idbRequest.result
370
- const transaction = idbRequest.transaction
371
- oldVersion = event.oldVersion
372
-
373
- if (transaction === null) {
374
- return resume(
375
- Effect.fail(
376
- new IndexedDbDatabaseError({
377
- reason: "TransactionError",
378
- cause: null
379
- })
380
- )
381
- )
382
- }
398
+ )
399
+ }
383
400
 
384
- transaction.onabort = (event) => {
385
- resume(
386
- Effect.fail(
387
- new IndexedDbDatabaseError({
388
- reason: "Aborted",
389
- cause: event
390
- })
391
- )
392
- )
393
- }
401
+ transaction.onerror = (event) => {
402
+ resume(
403
+ Effect.fail(
404
+ new IndexedDbDatabaseError({
405
+ reason: "TransactionError",
406
+ cause: event
407
+ })
408
+ )
409
+ )
410
+ }
394
411
 
395
- transaction.onerror = (event) => {
396
- resume(
397
- Effect.fail(
398
- new IndexedDbDatabaseError({
399
- reason: "TransactionError",
400
- cause: event
401
- })
402
- )
403
- )
412
+ const effect = Effect.forEach(
413
+ migrations.slice(oldVersion),
414
+ (untypedMigration) => {
415
+ if (untypedMigration.previous === undefined) {
416
+ const migration = untypedMigration as any as AnySchema
417
+ const api = makeTransactionProto({
418
+ database,
419
+ IDBKeyRange,
420
+ tables: migration.version.tables,
421
+ transaction,
422
+ reactivity
423
+ })
424
+ return (migration as any).migrate(api) as Effect.Effect<
425
+ void,
426
+ IndexedDbDatabaseError
427
+ >
428
+ } else if (untypedMigration.previous) {
429
+ const migration = untypedMigration as any as AnySchema
430
+ const fromApi = makeTransactionProto({
431
+ database,
432
+ IDBKeyRange,
433
+ tables: migration.fromVersion.tables,
434
+ transaction,
435
+ reactivity
436
+ })
437
+ const toApi = makeTransactionProto({
438
+ database,
439
+ IDBKeyRange,
440
+ tables: migration.version.tables,
441
+ transaction,
442
+ reactivity
443
+ })
444
+ return migration.migrate(fromApi, toApi) as Effect.Effect<
445
+ void,
446
+ IndexedDbDatabaseError
447
+ >
404
448
  }
405
449
 
406
- const effect = Effect.forEach(
407
- migrations.slice(oldVersion),
408
- (untypedMigration) => {
409
- if (untypedMigration.previous === undefined) {
410
- const migration = untypedMigration as any as AnySchema
411
- const api = makeTransactionProto({
412
- database,
413
- IDBKeyRange,
414
- tables: migration.version.tables,
415
- transaction,
416
- reactivity
417
- })
418
- return (migration as any).migrate(api) as Effect.Effect<
419
- void,
420
- IndexedDbDatabaseError
421
- >
422
- } else if (untypedMigration.previous) {
423
- const migration = untypedMigration as any as AnySchema
424
- const fromApi = makeTransactionProto({
425
- database,
426
- IDBKeyRange,
427
- tables: migration.fromVersion.tables,
428
- transaction,
429
- reactivity
430
- })
431
- const toApi = makeTransactionProto({
432
- database,
433
- IDBKeyRange,
434
- tables: migration.version.tables,
435
- transaction,
436
- reactivity
437
- })
438
- return migration.migrate(fromApi, toApi) as Effect.Effect<
439
- void,
440
- IndexedDbDatabaseError
441
- >
442
- }
443
-
444
- return Effect.die(new Error("Invalid migration"))
445
- },
446
- { discard: true }
447
- ).pipe(
448
- Effect.mapError(
449
- (cause) =>
450
- new IndexedDbDatabaseError({
451
- reason: "UpgradeError",
452
- cause
453
- })
454
- )
455
- )
456
- fiber = runForkWith(effect)
457
- fiber.currentDispatcher.flush()
458
- }
459
-
460
- request.onsuccess = (event) => {
461
- const idbRequest = event.target as IDBRequest<IDBDatabase>
462
- const database = idbRequest.result
463
- if (fiber) {
464
- // ensure migration errors are propagated
465
- resume(Effect.as(Fiber.join(fiber), database))
466
- } else {
467
- resume(Effect.succeed(database))
468
- }
469
- }
450
+ return Effect.die(new Error("Invalid migration"))
451
+ },
452
+ { discard: true }
453
+ ).pipe(
454
+ Effect.mapError(
455
+ (cause) =>
456
+ new IndexedDbDatabaseError({
457
+ reason: "UpgradeError",
458
+ cause
459
+ })
460
+ ),
461
+ Effect.provideService(IndexedDbQueryBuilder.IndexedDbTransaction, transaction)
462
+ )
463
+ fiber = runForkWith(effect)
464
+ fiber.currentDispatcher.flush()
465
+ }
466
+
467
+ request.onsuccess = (event) => {
468
+ const idbRequest = event.target as IDBRequest<IDBDatabase>
469
+ const db = idbRequest.result
470
+ MutableRef.set(database, db)
471
+ if (fiber) {
472
+ // ensure migration errors are propagated
473
+ resume(Effect.asVoid(Fiber.join(fiber)))
474
+ } else {
475
+ resume(Effect.void)
470
476
  }
471
- ),
472
- (database) => Effect.sync(() => database.close())
477
+ }
478
+ })
479
+
480
+ yield* Effect.addFinalizer(() => {
481
+ database.current?.close()
482
+ return Effect.void
483
+ })
484
+ yield* open
485
+
486
+ const rebuildLock = Semaphore.makeUnsafe(1).withPermit
487
+ const rebuild = Effect.callback<void, IndexedDbDatabaseError>((resume) => {
488
+ database.current?.close()
489
+ const request = indexedDB.deleteDatabase(databaseName)
490
+ request.onerror = (_) => {
491
+ resume(
492
+ Effect.fail(
493
+ new IndexedDbDatabaseError({
494
+ reason: "OpenError",
495
+ cause: request.error
496
+ })
497
+ )
498
+ )
499
+ }
500
+ request.onsuccess = () => {
501
+ resume(Effect.void)
502
+ }
503
+ }).pipe(
504
+ Effect.flatMap(() => open),
505
+ rebuildLock
473
506
  )
474
507
 
475
- return IndexedDbDatabase.of({ database, IDBKeyRange, reactivity })
508
+ return IndexedDbDatabase.of({ database, IDBKeyRange, rebuild, reactivity })
476
509
  })
477
510
  ).pipe(
478
511
  Layer.provide(Reactivity.layer)
@@ -493,7 +526,7 @@ const makeTransactionProto = <Source extends IndexedDbVersion.AnyWithProps>({
493
526
  transaction,
494
527
  reactivity
495
528
  }: {
496
- readonly database: globalThis.IDBDatabase
529
+ readonly database: MutableRef.MutableRef<globalThis.IDBDatabase>
497
530
  readonly IDBKeyRange: typeof globalThis.IDBKeyRange
498
531
  readonly tables: ReadonlyMap<string, IndexedDbVersion.Tables<Source>>
499
532
  readonly transaction: globalThis.IDBTransaction
@@ -503,11 +536,11 @@ const makeTransactionProto = <Source extends IndexedDbVersion.AnyWithProps>({
503
536
  database,
504
537
  IDBKeyRange,
505
538
  tables,
506
- transaction,
507
539
  reactivity
508
540
  }) as any
509
541
 
510
542
  migration.transaction = transaction
543
+
511
544
  migration.createObjectStore = Effect.fnUntraced(function*(table: string) {
512
545
  const createTable = yield* Effect.fromNullishOr(tables.get(table)).pipe(
513
546
  Effect.mapError(
@@ -521,7 +554,7 @@ const makeTransactionProto = <Source extends IndexedDbVersion.AnyWithProps>({
521
554
 
522
555
  return yield* Effect.try({
523
556
  try: () =>
524
- database.createObjectStore(createTable.tableName, {
557
+ database.current.createObjectStore(createTable.tableName, {
525
558
  keyPath: createTable.keyPath,
526
559
  autoIncrement: createTable.autoIncrement
527
560
  }),
@@ -545,7 +578,7 @@ const makeTransactionProto = <Source extends IndexedDbVersion.AnyWithProps>({
545
578
  )
546
579
 
547
580
  return yield* Effect.try({
548
- try: () => database.deleteObjectStore(createTable.tableName),
581
+ try: () => database.current.deleteObjectStore(createTable.tableName),
549
582
  catch: (cause) =>
550
583
  new IndexedDbDatabaseError({
551
584
  reason: "TransactionError",