diff --git a/src/core/BaseFile.res b/src/core/BaseFile.res deleted file mode 100644 index 550338e6..00000000 --- a/src/core/BaseFile.res +++ /dev/null @@ -1,37 +0,0 @@ -/** -A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The WebApiFile interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. -[See Blob on MDN](https://developer.mozilla.org/docs/Web/API/Blob) -*/ -@editor.completeFrom(BaseFile.Blob) -type blob = private { - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/size) - */ - size: int, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/type) - */ - @as("type") - type_: string, -} - -/** -Provides information about files and allows JavaScript in a web page to access their content. -[See WebApiFile on MDN](https://developer.mozilla.org/docs/Web/API/File) -*/ -@editor.completeFrom(BaseFile.File) -type file = private { - ...blob, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/File/name) - */ - name: string, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/File/lastModified) - */ - lastModified: int, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/File/webkitRelativePath) - */ - webkitRelativePath: string, -} diff --git a/src/core/DOM.res b/src/core/DOM.res index ad43997f..6d00468f 100644 --- a/src/core/DOM.res +++ b/src/core/DOM.res @@ -163,8 +163,29 @@ type predefinedColorSpace = | @as("display-p3") DisplayP3 | @as("srgb") Srgb +/** +A file-like object of immutable, raw data. +[See Blob on MDN](https://developer.mozilla.org/docs/Web/API/Blob) +*/ +type blob = private { + size: int, + @as("type") + type_: string, +} + +/** +Provides information about a file selected by or available to the user. +[See File on MDN](https://developer.mozilla.org/docs/Web/API/File) +*/ +type file = private { + ...blob, + name: string, + lastModified: int, + webkitRelativePath: string, +} + type shareData = { - mutable files?: array, + mutable files?: array, mutable title?: string, mutable text?: string, mutable url?: string, diff --git a/src/file/FileTypes.res b/src/file/FileTypes.res index 17f8d09e..c1833496 100644 --- a/src/file/FileTypes.res +++ b/src/file/FileTypes.res @@ -20,7 +20,7 @@ A file-like object of immutable, raw data. Blobs represent data that isn't neces [See Blob on MDN](https://developer.mozilla.org/docs/Web/API/Blob) */ @editor.completeFrom(Blob) -type blob = BaseFile.blob = private { +type blob = DOM.blob = private { /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Blob/size) */ @@ -71,7 +71,7 @@ Provides information about files and allows JavaScript in a web page to access t [See WebApiFile on MDN](https://developer.mozilla.org/docs/Web/API/File) */ @editor.completeFrom(WebApiFile) -type file = BaseFile.file = private { +type file = DOM.file = private { ...blob, /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/File/name) diff --git a/src/storage/Cache.res b/src/storage/Cache.res index 98dbe342..0ee4970c 100644 --- a/src/storage/Cache.res +++ b/src/storage/Cache.res @@ -3,9 +3,9 @@ */ @send external match: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: FetchTypes.request, - ~options: WebWorkersTypes.cacheQueryOptions=?, + ~options: CacheTypes.cacheQueryOptions=?, ) => Nullable.t = "match" /** @@ -13,9 +13,9 @@ external match: ( */ @send external match2: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: string, - ~options: WebWorkersTypes.cacheQueryOptions=?, + ~options: CacheTypes.cacheQueryOptions=?, ) => Nullable.t = "match" /** @@ -23,9 +23,9 @@ external match2: ( */ @send external matchAll: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: FetchTypes.request=?, - ~options: WebWorkersTypes.cacheQueryOptions=?, + ~options: CacheTypes.cacheQueryOptions=?, ) => promise> = "matchAll" /** @@ -33,35 +33,35 @@ external matchAll: ( */ @send external matchAll2: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: string=?, - ~options: WebWorkersTypes.cacheQueryOptions=?, + ~options: CacheTypes.cacheQueryOptions=?, ) => promise> = "matchAll" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Cache/add) */ @send -external add: (WebWorkersTypes.cache, FetchTypes.request) => promise = "add" +external add: (CacheTypes.cache, FetchTypes.request) => promise = "add" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Cache/add) */ @send -external add2: (WebWorkersTypes.cache, string) => promise = "add" +external add2: (CacheTypes.cache, string) => promise = "add" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Cache/addAll) */ @send -external addAll: (WebWorkersTypes.cache, array) => promise = "addAll" +external addAll: (CacheTypes.cache, array) => promise = "addAll" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Cache/put) */ @send external put: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: FetchTypes.request, ~response: FetchTypes.response, ) => promise = "put" @@ -71,7 +71,7 @@ external put: ( */ @send external put2: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: string, ~response: FetchTypes.response, ) => promise = "put" @@ -81,9 +81,9 @@ external put2: ( */ @send external delete: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: FetchTypes.request, - ~options: WebWorkersTypes.cacheQueryOptions=?, + ~options: CacheTypes.cacheQueryOptions=?, ) => promise = "delete" /** @@ -91,9 +91,9 @@ external delete: ( */ @send external delete2: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: string, - ~options: WebWorkersTypes.cacheQueryOptions=?, + ~options: CacheTypes.cacheQueryOptions=?, ) => promise = "delete" /** @@ -101,9 +101,9 @@ external delete2: ( */ @send external keys: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: FetchTypes.request=?, - ~options: WebWorkersTypes.cacheQueryOptions=?, + ~options: CacheTypes.cacheQueryOptions=?, ) => promise> = "keys" /** @@ -111,7 +111,7 @@ external keys: ( */ @send external keys2: ( - WebWorkersTypes.cache, + CacheTypes.cache, ~request: string=?, - ~options: WebWorkersTypes.cacheQueryOptions=?, + ~options: CacheTypes.cacheQueryOptions=?, ) => promise> = "keys" diff --git a/src/storage/CacheStorage.res b/src/storage/CacheStorage.res index f77aa9e6..33da7746 100644 --- a/src/storage/CacheStorage.res +++ b/src/storage/CacheStorage.res @@ -3,9 +3,9 @@ */ @send external match: ( - WebWorkersTypes.cacheStorage, + CacheTypes.cacheStorage, ~request: FetchTypes.request, - ~options: WebWorkersTypes.multiCacheQueryOptions=?, + ~options: CacheTypes.multiCacheQueryOptions=?, ) => Nullable.t = "match" /** @@ -13,31 +13,31 @@ external match: ( */ @send external match2: ( - WebWorkersTypes.cacheStorage, + CacheTypes.cacheStorage, ~request: string, - ~options: WebWorkersTypes.multiCacheQueryOptions=?, + ~options: CacheTypes.multiCacheQueryOptions=?, ) => Nullable.t = "match" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/has) */ @send -external has: (WebWorkersTypes.cacheStorage, string) => promise = "has" +external has: (CacheTypes.cacheStorage, string) => promise = "has" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */ @send -external open_: (WebWorkersTypes.cacheStorage, string) => promise = "open" +external open_: (CacheTypes.cacheStorage, string) => promise = "open" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/delete) */ @send -external delete: (WebWorkersTypes.cacheStorage, string) => promise = "delete" +external delete: (CacheTypes.cacheStorage, string) => promise = "delete" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/keys) */ @send -external keys: WebWorkersTypes.cacheStorage => promise> = "keys" +external keys: CacheTypes.cacheStorage => promise> = "keys" diff --git a/src/storage/CacheTypes.res b/src/storage/CacheTypes.res new file mode 100644 index 00000000..58e17f51 --- /dev/null +++ b/src/storage/CacheTypes.res @@ -0,0 +1,24 @@ +/** +Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the Service Worker life cycle. The Cache interface is also available in window contexts. +[See Cache on MDN](https://developer.mozilla.org/docs/Web/API/Cache) +*/ +@editor.completeFrom(Cache) +type cache = private {} + +/** +The storage for Cache objects. +[See CacheStorage on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage) +*/ +@editor.completeFrom(CacheStorage) +type cacheStorage = private {} + +type cacheQueryOptions = { + mutable ignoreSearch?: bool, + mutable ignoreMethod?: bool, + mutable ignoreVary?: bool, +} + +type multiCacheQueryOptions = { + ...cacheQueryOptions, + mutable cacheName?: string, +} diff --git a/src/window/DomGlobal.res b/src/window/DomGlobal.res index 21582fc0..650512e0 100644 --- a/src/window/DomGlobal.res +++ b/src/window/DomGlobal.res @@ -212,7 +212,7 @@ external performance: PerformanceTypes.performance = "performance" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/caches) */ -external caches: WebWorkersTypes.cacheStorage = "caches" +external caches: CacheTypes.cacheStorage = "caches" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/sessionStorage) diff --git a/src/window/Window.res b/src/window/Window.res index 02ae7e59..fa7630d1 100644 --- a/src/window/Window.res +++ b/src/window/Window.res @@ -266,7 +266,7 @@ external performance: t => PerformanceTypes.performance = "performance" [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/caches) */ @get -external caches: t => WebWorkersTypes.cacheStorage = "caches" +external caches: t => CacheTypes.cacheStorage = "caches" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/sessionStorage) diff --git a/src/storage/WebWorkersTypes.res b/src/workers/WebWorkersTypes.res similarity index 65% rename from src/storage/WebWorkersTypes.res rename to src/workers/WebWorkersTypes.res index daf78021..def18f39 100644 --- a/src/storage/WebWorkersTypes.res +++ b/src/workers/WebWorkersTypes.res @@ -1,28 +1,3 @@ -/** -Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the WebApiServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec. -[See Cache on MDN](https://developer.mozilla.org/docs/Web/API/Cache) -*/ -@editor.completeFrom(Cache) -type cache = private {} - -/** -The storage for Cache objects. -[See CacheStorage on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage) -*/ -@editor.completeFrom(CacheStorage) -type cacheStorage = private {} - -type cacheQueryOptions = { - mutable ignoreSearch?: bool, - mutable ignoreMethod?: bool, - mutable ignoreVary?: bool, -} - -type multiCacheQueryOptions = { - ...cacheQueryOptions, - mutable cacheName?: string, -} - type sharedWorker /** @@ -38,7 +13,7 @@ type workerGlobalScope = private { /** [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/caches) */ - caches: cacheStorage, + caches: CacheTypes.cacheStorage, /** [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/crossOriginIsolated) */