@budarin/psw-plugin-opfs-serve-range 1.1.9 → 1.1.11

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 (3) hide show
  1. package/README.md +6 -12
  2. package/README.ru.md +6 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -163,10 +163,6 @@ The response may not have a `Content-Length` header – when writing the full bo
163
163
 
164
164
  Client‑side helpers are exported from the entry point `@budarin/psw-plugin-opfs-serve-range/client`. This section gives signatures, types, and examples; [opfs-cache-behavior.md](https://github.com/budarin/psw-plugin-opfs-serve-range/blob/master/docs/opfs-cache-behavior.md) only describes **when** the service worker sends messages (limits, LRU, eviction), not the API.
165
165
 
166
- ### Message payload
167
-
168
- Each handler receives a `MessageEvent`; `event.data` is `{ type: string } & OpfsMessagePayload`, and some events add a `count` field. The package type `OpfsMessagePayload` is `{ url?: string; size?: number; limit?: number; reason?: string }`.
169
-
170
166
  ### Message subscriptions
171
167
 
172
168
  Each function takes a handler and returns an unsubscribe function (call it to remove the subscription). Below are the subscriptions for messages that the service worker actually sends in the current version.
@@ -233,15 +229,11 @@ type Unsubscribe = () => void;
233
229
  onOPFSSkipQuotaExceeded(handler: (event: MessageEvent<EventData>) => void): Unsubscribe
234
230
  ```
235
231
 
236
- ### Cache management and types
232
+ ### Cache management utilities
237
233
 
238
- - **`listOpfsCachedResources`** returns the list of cached resources.
239
-
240
- ```ts
241
- listOpfsCachedResources(): Promise<OpfsCachedResource[]>
242
- ```
234
+ Functions to list cached resources, check by URL, and remove by URL. Called from the client (page); use when you need to show the user what is cached and let them delete selected items.
243
235
 
244
- Each array element:
236
+ - **`listOpfsCachedResources`** — returns the list of cached resources.
245
237
 
246
238
  ```ts
247
239
  interface OpfsCachedResource {
@@ -250,6 +242,8 @@ type Unsubscribe = () => void;
250
242
  type: string | undefined;
251
243
  lastModified: string | undefined;
252
244
  }
245
+
246
+ listOpfsCachedResources(): Promise<OpfsCachedResource[]>
253
247
  ```
254
248
 
255
249
  - **`hasInOpfsCache`** — checks whether a URL is in the cache.
@@ -296,7 +290,7 @@ When each message is sent: [opfs-cache-behavior.md](https://github.com/budarin/p
296
290
 
297
291
  ### Clearing the cache and managing individual resources
298
292
 
299
- To wipe the whole cache (e.g. from a UI button or on logout), call `clearOpfsCache()` from the service worker or client – the entire cache directory will be deleted.
293
+ To wipe the whole cache (e.g. from a UI button or on logout), call **clearOpfsCache()** from the service worker or client – the entire cache directory will be deleted.
300
294
 
301
295
  If you need finer‑grained control (show a list of cached resources and let users delete specific ones), use the client utilities from `@budarin/psw-plugin-opfs-serve-range/client`: `listOpfsCachedResources`, `hasInOpfsCache`, `deleteFromOpfsCache` (see above). The list is built from metadata in the footer (each file stores its original `url`).
302
296
 
package/README.ru.md CHANGED
@@ -153,10 +153,6 @@ await writeToOpfs(dir, key, response.body, metadata);
153
153
 
154
154
  Клиентские хелперы экспортируются из entry point `@budarin/psw-plugin-opfs-serve-range/client`. В этом разделе — сигнатуры, типы и примеры; в [opfs-cache-behavior.ru.md](https://github.com/budarin/psw-plugin-opfs-serve-range/blob/master/docs/opfs-cache-behavior.ru.md) описано только **когда** сервис-воркер шлёт сообщения (лимиты, LRU, эвикция), не API.
155
155
 
156
- ### Данные в сообщениях
157
-
158
- Обработчик получает `MessageEvent`; `event.data` имеет тип `{ type: string } & OpfsMessagePayload` плюс при необходимости поле `count`. Тип `OpfsMessagePayload` в пакете: `{ url?: string; size?: number; limit?: number; reason?: string }`.
159
-
160
156
  ### Подписки на сообщения
161
157
 
162
158
  Каждая функция принимает обработчик и возвращает функцию отписки (вызов снимает подписку). Ниже перечислены подписки, сообщения которых сервис-воркер реально отправляет в текущей версии.
@@ -223,15 +219,11 @@ type Unsubscribe = () => void;
223
219
  onOPFSSkipQuotaExceeded(handler: (event: MessageEvent<EventData>) => void): Unsubscribe
224
220
  ```
225
221
 
226
- ### Управление кешем и типы
222
+ ### Утилиты управления кэшем
227
223
 
228
- - **`listOpfsCachedResources`** возвращает список закешированных ресурсов.
229
-
230
- ```ts
231
- listOpfsCachedResources(): Promise<OpfsCachedResource[]>
232
- ```
224
+ Функции для получения списка закешированных ресурсов, проверки по URL и удаления по URL. Вызываются на клиенте (страница); нужны, когда надо показать пользователю, что в кэше, и дать удалить выбранное.
233
225
 
234
- Элемент массива:
226
+ - **`listOpfsCachedResources`** — возвращает список закешированных ресурсов.
235
227
 
236
228
  ```ts
237
229
  interface OpfsCachedResource {
@@ -240,6 +232,8 @@ type Unsubscribe = () => void;
240
232
  type: string | undefined;
241
233
  lastModified: string | undefined;
242
234
  }
235
+
236
+ listOpfsCachedResources(): Promise<OpfsCachedResource[]>
243
237
  ```
244
238
 
245
239
  - **`hasInOpfsCache`** — проверяет наличие URL в кеше.
@@ -286,7 +280,7 @@ const unsubSkip = onOPFSSkipQuotaExceeded((event: MessageEvent) => {
286
280
 
287
281
  ### Очистка кеша и управление отдельными ресурсами
288
282
 
289
- Когда нужно сбросить весь кеш (например, по кнопке в UI или при логауте), можно вызвать `clearOpfsCache()` из сервис-воркера или клиента — будет удалена вся папка кеша.
283
+ Когда нужно сбросить весь кеш (например, по кнопке в UI или при логауте), можно вызвать **clearOpfsCache()** из сервис-воркера или клиента — будет удалена вся папка кеша.
290
284
 
291
285
  Если нужно работать с отдельными ресурсами (показать пользователю список сохранённых файлов и дать удалить что-то выборочно), используйте клиентские утилиты из entry point `@budarin/psw-plugin-opfs-serve-range/client`: `listOpfsCachedResources`, `hasInOpfsCache`, `deleteFromOpfsCache` (см. выше). Список в кеше строится по метаданным в футере (там хранится исходный url каждого ресурса).
292
286
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budarin/psw-plugin-opfs-serve-range",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "Service Worker plugin: serve HTTP Range requests from OPFS files",
5
5
  "keywords": [
6
6
  "service-worker",