@budarin/psw-plugin-opfs-serve-range 1.1.6 → 1.1.7

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 +153 -26
  2. package/README.ru.md +152 -27
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -165,25 +165,112 @@ Client‑side helpers are exported from the entry point `@budarin/psw-plugin-opf
165
165
 
166
166
  **Message payload**
167
167
 
168
- Each handler receives a `MessageEvent`; `event.data` is `{ type: string } & OpfsMessagePayload`, and some events add a `count` field. The exact set of fields depends on the message type (see table below). The package type `OpfsMessagePayload` is `{ url?: string; size?: number; limit?: number; reason?: string }`.
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
169
 
170
170
  **Message subscriptions**
171
171
 
172
- Each function takes a handler and returns an unsubscribe function `() => void`. The table lists only subscriptions for messages **that the service worker actually sends** in the current version; the exact `event.data` fields are in the last column.
172
+ 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.
173
173
 
174
- | Function | Signature | When it runs | Fields in `event.data` (besides `type`) |
175
- |----------|-----------|---------------|----------------------------------------|
176
- | `onOPFSQuotaExceeded` | `(handler: (event: MessageEvent) => void) => () => void` | Browser threw QuotaExceeded while writing to OPFS. | `url: string` |
177
- | `onOPFSWriteSkipped` | `(handler: (event: MessageEvent) => void) => () => void` | Write not started: file does not fit even after eviction. | `url: string`, `size: number`, `reason: string` |
178
- | `onOPFSEvictionCompleted` | `(handler: (event: MessageEvent) => void) => () => void` | Eviction finished. | `count: number` (number of files removed) |
179
- | `onOPFSWriteFailed` | `(handler: (event: MessageEvent) => void) => () => void` | Write error (network, disk, partial file removed). | `url?: string`, `reason: string` |
180
- | `onOPFSSkipQuotaExceeded` | `(handler: (event: MessageEvent) => void) => () => void` | Repeat request for a blacklisted URL (resource not cached). | `url: string` |
174
+ ```ts
175
+ type Unsubscribe = () => void;
176
+ ```
177
+
178
+ ### `onOPFSQuotaExceeded` subscribe to notification when the browser throws QuotaExceeded while writing to OPFS.
179
+
180
+ ```ts
181
+ onOPFSQuotaExceeded(handler: (event: MessageEvent) => void): Unsubscribe
182
+ ```
183
+
184
+ - `event.data`:
185
+ ```ts
186
+ {
187
+ type: string;
188
+ url: string;
189
+ }
190
+ ```
191
+
192
+ ### `onOPFSWriteSkipped` — subscribe to notification when the write was skipped (file does not fit even after eviction).
193
+
194
+ ```ts
195
+ onOPFSWriteSkipped(handler: (event: MessageEvent) => void): Unsubscribe
196
+ ```
197
+
198
+ - `event.data`:
199
+ ```ts
200
+ {
201
+ type: string;
202
+ url: string;
203
+ /** File size in bytes */
204
+ size: number;
205
+ /** Reason the write was not started */
206
+ reason: string;
207
+ }
208
+ ```
209
+
210
+ ### `onOPFSEvictionCompleted` — subscribe to notification when eviction has finished.
211
+
212
+ ```ts
213
+ onOPFSEvictionCompleted(handler: (event: MessageEvent) => void): Unsubscribe
214
+ ```
215
+
216
+ - `event.data`:
217
+ ```ts
218
+ {
219
+ type: string;
220
+ /** Number of files removed by eviction */
221
+ count: number;
222
+ }
223
+ ```
224
+
225
+ ### `onOPFSWriteFailed` — subscribe to notification on write error (network, disk, partial file removed).
226
+
227
+ ```ts
228
+ onOPFSWriteFailed(handler: (event: MessageEvent) => void): Unsubscribe
229
+ ```
230
+
231
+ - `event.data`:
232
+ ```ts
233
+ {
234
+ type: string;
235
+ url?: string;
236
+ /** Reason the write failed */
237
+ reason: string;
238
+ }
239
+ ```
240
+
241
+ ### `onOPFSSkipQuotaExceeded` — subscribe to notification on repeat request for a blacklisted URL (resource not cached).
242
+
243
+ ```ts
244
+ onOPFSSkipQuotaExceeded(handler: (event: MessageEvent) => void): Unsubscribe
245
+ ```
246
+
247
+ - `event.data`:
248
+ ```ts
249
+ {
250
+ type: string;
251
+ url: string;
252
+ }
253
+ ```
181
254
 
182
255
  **Cache management and types**
183
256
 
184
- - `listOpfsCachedResources(): Promise<OpfsCachedResource[]>` — list of cached resources; each item: `{ url, size, type?, lastModified? }`.
185
- - `hasInOpfsCache(url: string): Promise<boolean>` — whether the URL is in the cache.
186
- - `deleteFromOpfsCache(url: string): Promise<void>` — remove resource by URL from the cache.
257
+ ### `listOpfsCachedResources`returns the list of cached resources. Each item: `{ url, size, type?, lastModified? }`.
258
+
259
+ ```ts
260
+ listOpfsCachedResources(): Promise<OpfsCachedResource[]>
261
+ ```
262
+
263
+ ### `hasInOpfsCache` — checks whether a URL is in the cache.
264
+
265
+ ```ts
266
+ hasInOpfsCache(url: string): Promise<boolean>
267
+ ```
268
+
269
+ ### `deleteFromOpfsCache` — removes a resource by URL from the cache.
270
+
271
+ ```ts
272
+ deleteFromOpfsCache(url: string): Promise<void>
273
+ ```
187
274
 
188
275
  Types `OpfsMessagePayload` and `OpfsCachedResource` are exported. Message type constants (name equals the string value in `event.data.type`): `OPFS_MSG_QUOTA_EXCEEDED`, `OPFS_MSG_WRITE_SKIPPED_SIZE`, `OPFS_MSG_CACHE_LIMIT_REACHED`, `OPFS_MSG_EVICTION_COMPLETED`, `OPFS_MSG_WRITE_FAILED`, `OPFS_MSG_SKIP_QUOTA_EXCEEDED`.
189
276
 
@@ -219,20 +306,60 @@ When each message is sent: [opfs-cache-behavior.md](https://github.com/budarin/p
219
306
 
220
307
  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.
221
308
 
222
- If you need finer‑grained control (show a list of cached resources and let users delete specific ones), use the client utilities from the entry point `@budarin/psw-plugin-opfs-serve-range/client`. The list is built from metadata in the footer (each file stores its original `url`):
309
+ 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`).
223
310
 
224
- - `listOpfsCachedResources(): Promise<OpfsCachedResource[]>` — list of resources in the OPFS cache (url, size, type, lastModified);
225
- - `hasInOpfsCache(url: string): Promise<boolean>` — whether the URL is cached;
226
- - `deleteFromOpfsCache(url: string): Promise<void>` — remove a single resource by URL.
311
+ ## Plugin specifications
227
312
 
228
- ## Plugin options
313
+ Global cache settings (folder name, quota fraction) are set in **configureOpfs({ folderName, maxCacheFraction })**. Below are the package plugins and their options.
229
314
 
230
- The cache folder name and quota fraction are configured via **configureOpfs({ folderName, maxCacheFraction })**.
315
+ ### `opfsServeRange` reads files from OPFS and serves requested byte ranges.
316
+
317
+ ```ts
318
+ opfsServeRange(options?: {
319
+ order?: number;
320
+ enableLogging?: boolean;
321
+ include?: string[];
322
+ exclude?: string[];
323
+ rangeResponseCacheControl?: string; // Cache-Control for 206 responses (default: max-age=31536000, immutable)
324
+ }): Plugin | undefined
325
+ ```
326
+
327
+ ### `opfsPrecache` — during SW install, fetches a list of URLs and writes them to OPFS.
328
+
329
+ ```ts
330
+ opfsPrecache(options: {
331
+ urls: string[] | (() => Promise<string[]>); // array of URLs or function
332
+ order?: number;
333
+ enableLogging?: boolean;
334
+ pinned?: string[]; // glob patterns for URLs protected from eviction (see «Pinned resources»)
335
+ }): Plugin | undefined
336
+ ```
337
+
338
+ ### `opfsRangeFromNetworkAndCache` — handles requests that opfsServeRange did not serve (resource not in cache yet): goes to the network, streams the response to the client, and optionally fills OPFS in the background.
339
+
340
+ ```ts
341
+ opfsRangeFromNetworkAndCache(options?: {
342
+ order?: number;
343
+ include?: string[];
344
+ exclude?: string[];
345
+ enableLogging?: boolean;
346
+ pinned?: string[]; // glob patterns for URLs protected from eviction
347
+ }): Plugin | undefined
348
+ ```
349
+
350
+ ### `opfsBackgroundFetch` — on successful Background Fetch completion, writes responses into OPFS; subsequent Range requests for these URLs are served by opfsServeRange.
351
+
352
+ ```ts
353
+ opfsBackgroundFetch(options?: {
354
+ order?: number;
355
+ include?: string[];
356
+ exclude?: string[];
357
+ enableLogging?: boolean;
358
+ pinned?: string[]; // glob patterns for URLs protected from eviction
359
+ }): Plugin | undefined
360
+ ```
231
361
 
232
- - **opfsServeRange:** `order`, `enableLogging`, `include`, `exclude`, `rangeResponseCacheControl` – to restrict which URLs are served and how 206 responses are cached by the browser.
233
- - **opfsPrecache:** `urls` (array or function returning an array), `order`, `enableLogging`, `pinned` – which URLs to fetch at SW install. `pinned` is an array of glob patterns for URLs that should not be evicted (e.g., `['/assets/media/**']`).
234
- - **opfsRangeFromNetworkAndCache:** `order` (e.g. `-10`, after `opfsServeRange`), `include`, `exclude`, `enableLogging`, `pinned` – which requests to cache; on Range requests it streams the response immediately and optionally fills OPFS in the background. `pinned` is an array of glob patterns for URLs that should not be evicted. With `enableLogging`, a warning is logged when a file already exists in OPFS but the Range response is served from network (e.g. because of If-Range mismatch or plugin ordering).
235
- - **opfsBackgroundFetch:** `order`, `include`, `exclude`, `enableLogging`, `pinned` – which URLs to write into OPFS when Background Fetch completes. `pinned` is an array of glob patterns for URLs that should not be evicted. `fail`/`abort`/`click` events are logged with `enableLogging`; you can register your own plugin with the same hooks (e.g. to show UI on fail). To trigger downloads from the client, use utilities from `@budarin/pluggable-serviceworker/client/background-fetch`.
362
+ To trigger downloads from the client: `@budarin/pluggable-serviceworker/client/background-fetch`.
236
363
 
237
364
  ### Pinned resources (eviction protection)
238
365
 
@@ -242,13 +369,13 @@ Example: mark important media files as pinned so they are never evicted, while a
242
369
 
243
370
  ```typescript
244
371
  opfsPrecache({
245
- urls: ['/assets/media/featured-video.mp4', '/assets/media/trailer.mp4'],
246
- pinned: ['/assets/media/featured-video.mp4'], // featured content won't be evicted
372
+ urls: ['/assets/media/featured-video.mp4', '/assets/media/trailer.mp4'],
373
+ pinned: ['/assets/media/featured-video.mp4'], // featured content won't be evicted
247
374
  });
248
375
 
249
376
  opfsRangeFromNetworkAndCache({
250
- include: ['*.mp4', '*.webm'],
251
- pinned: ['/assets/media/featured/**'], // featured media files won't be evicted
377
+ include: ['*.mp4', '*.webm'],
378
+ pinned: ['/assets/media/featured/**'], // featured media files won't be evicted
252
379
  });
253
380
  ```
254
381
 
package/README.ru.md CHANGED
@@ -155,25 +155,112 @@ await writeToOpfs(dir, key, response.body, metadata);
155
155
 
156
156
  **Данные в сообщениях**
157
157
 
158
- Обработчик получает `MessageEvent`; `event.data` имеет тип `{ type: string } & OpfsMessagePayload` плюс при необходимости поле `count`. Конкретный набор полей зависит от типа сообщения (см. таблицу ниже). Тип `OpfsMessagePayload` в пакете: `{ url?: string; size?: number; limit?: number; reason?: string }`.
158
+ Обработчик получает `MessageEvent`; `event.data` имеет тип `{ type: string } & OpfsMessagePayload` плюс при необходимости поле `count`. Тип `OpfsMessagePayload` в пакете: `{ url?: string; size?: number; limit?: number; reason?: string }`.
159
159
 
160
160
  **Подписки на сообщения**
161
161
 
162
- Каждая функция принимает обработчик и возвращает функцию отписки `() => void`. В таблице только те подписки, **сообщения которых сервис-воркер реально отправляет** в текущей версии пакета; точный состав `event.data` — в последней колонке.
162
+ Каждая функция принимает обработчик и возвращает функцию отписки (вызов снимает подписку). Ниже перечислены подписки, сообщения которых сервис-воркер реально отправляет в текущей версии.
163
163
 
164
- | Функция | Сигнатура | Когда вызывается | Поля в `event.data` (кроме `type`) |
165
- |--------|-----------|-------------------|------------------------------------|
166
- | `onOPFSQuotaExceeded` | `(handler: (event: MessageEvent) => void) => () => void` | При записи в OPFS браузер вернул QuotaExceeded. | `url: string` |
167
- | `onOPFSWriteSkipped` | `(handler: (event: MessageEvent) => void) => () => void` | Запись не начата: файл не влезает даже после эвикции. | `url: string`, `size: number`, `reason: string` |
168
- | `onOPFSEvictionCompleted` | `(handler: (event: MessageEvent) => void) => () => void` | Эвикция завершена. | `count: number` (число удалённых файлов) |
169
- | `onOPFSWriteFailed` | `(handler: (event: MessageEvent) => void) => () => void` | Ошибка записи (сеть, диск, удалён частичный файл). | `url?: string`, `reason: string` |
170
- | `onOPFSSkipQuotaExceeded` | `(handler: (event: MessageEvent) => void) => () => void` | Повторный запрос к URL из чёрного списка (ресурс не кешируем). | `url: string` |
164
+ ```ts
165
+ type Unsubscribe = () => void;
166
+ ```
167
+
168
+ ### `onOPFSQuotaExceeded` подписка на уведомление об исчерпании квоты при записи в OPFS.
169
+
170
+ ```ts
171
+ onOPFSQuotaExceeded(handler: (event: MessageEvent) => void): Unsubscribe
172
+ ```
173
+
174
+ - `event.data`:
175
+ ```ts
176
+ {
177
+ type: string;
178
+ url: string;
179
+ }
180
+ ```
181
+
182
+ ### `onOPFSWriteSkipped` — подписка на уведомление о пропуске записи (файл не влезает даже после эвикции).
183
+
184
+ ```ts
185
+ onOPFSWriteSkipped(handler: (event: MessageEvent) => void): Unsubscribe
186
+ ```
187
+
188
+ - `event.data`:
189
+ ```ts
190
+ {
191
+ type: string;
192
+ url: string;
193
+ /** Размер файла в байтах */
194
+ size: number;
195
+ /** Причина (почему запись не начата) */
196
+ reason: string;
197
+ }
198
+ ```
199
+
200
+ ### `onOPFSEvictionCompleted` — подписка на уведомление о завершении эвикции.
201
+
202
+ ```ts
203
+ onOPFSEvictionCompleted(handler: (event: MessageEvent) => void): Unsubscribe
204
+ ```
205
+
206
+ - `event.data`:
207
+ ```ts
208
+ {
209
+ type: string;
210
+ /** Число удалённых при эвикции файлов */
211
+ count: number;
212
+ }
213
+ ```
214
+
215
+ ### `onOPFSWriteFailed` — подписка на уведомление об ошибке записи (сеть, диск, удалён частичный файл).
216
+
217
+ ```ts
218
+ onOPFSWriteFailed(handler: (event: MessageEvent) => void): Unsubscribe
219
+ ```
220
+
221
+ - `event.data`:
222
+ ```ts
223
+ {
224
+ type: string;
225
+ url?: string;
226
+ /** Причина ошибки записи */
227
+ reason: string;
228
+ }
229
+ ```
230
+
231
+ ### `onOPFSSkipQuotaExceeded` — подписка на уведомление о повторном запросе к URL из чёрного списка (ресурс не кешируем).
232
+
233
+ ```ts
234
+ onOPFSSkipQuotaExceeded(handler: (event: MessageEvent) => void): Unsubscribe
235
+ ```
236
+
237
+ - `event.data`:
238
+ ```ts
239
+ {
240
+ type: string;
241
+ url: string;
242
+ }
243
+ ```
171
244
 
172
245
  **Управление кешем и типы**
173
246
 
174
- - `listOpfsCachedResources(): Promise<OpfsCachedResource[]>` — список закешированных ресурсов; элемент: `{ url, size, type?, lastModified? }`.
175
- - `hasInOpfsCache(url: string): Promise<boolean>` — есть ли URL в кеше.
176
- - `deleteFromOpfsCache(url: string): Promise<void>` — удалить ресурс по URL из кеша.
247
+ ### `listOpfsCachedResources`возвращает список закешированных ресурсов. Элемент: `{ url, size, type?, lastModified? }`.
248
+
249
+ ```ts
250
+ listOpfsCachedResources(): Promise<OpfsCachedResource[]>
251
+ ```
252
+
253
+ ### `hasInOpfsCache` — проверяет наличие URL в кеше.
254
+
255
+ ```ts
256
+ hasInOpfsCache(url: string): Promise<boolean>
257
+ ```
258
+
259
+ ### `deleteFromOpfsCache` — удаляет ресурс по URL из кеша.
260
+
261
+ ```ts
262
+ deleteFromOpfsCache(url: string): Promise<void>
263
+ ```
177
264
 
178
265
  Типы `OpfsMessagePayload` и `OpfsCachedResource` экспортируются из пакета. Константы типов сообщений (имя совпадает со строковым значением в `event.data.type`): `OPFS_MSG_QUOTA_EXCEEDED`, `OPFS_MSG_WRITE_SKIPPED_SIZE`, `OPFS_MSG_CACHE_LIMIT_REACHED`, `OPFS_MSG_EVICTION_COMPLETED`, `OPFS_MSG_WRITE_FAILED`, `OPFS_MSG_SKIP_QUOTA_EXCEEDED`.
179
266
 
@@ -209,22 +296,60 @@ const unsubSkip = onOPFSSkipQuotaExceeded((event: MessageEvent) => {
209
296
 
210
297
  Когда нужно сбросить весь кеш (например, по кнопке в UI или при логауте), можно вызвать `clearOpfsCache()` из сервис-воркера или клиента — будет удалена вся папка кеша.
211
298
 
212
- Если нужно работать с отдельными ресурсами (показать пользователю список сохранённых файлов и дать удалить что-то выборочно), можно использовать клиентские утилиты из entry point `@budarin/psw-plugin-opfs-serve-range/client`. Список в кеше строится по метаданным в футере (там теперь хранится исходный url каждого ресурса).
299
+ Если нужно работать с отдельными ресурсами (показать пользователю список сохранённых файлов и дать удалить что-то выборочно), используйте клиентские утилиты из entry point `@budarin/psw-plugin-opfs-serve-range/client`: `listOpfsCachedResources`, `hasInOpfsCache`, `deleteFromOpfsCache` (см. выше). Список в кеше строится по метаданным в футере (там хранится исходный url каждого ресурса).
300
+
301
+ ## Спецификации плагинов
302
+
303
+ Общая настройка кеша (имя папки, доля квоты) задаётся в **configureOpfs({ folderName, maxCacheFraction })**. Ниже — плагины пакета и их опции.
213
304
 
214
- Основные сценарии:
305
+ ### `opfsServeRange` — читает файлы из OPFS и отдаёт запрошенные диапазоны байтов.
215
306
 
216
- - `listOpfsCachedResources(): Promise<OpfsCachedResource[]>` — список ресурсов в OPFS-кеше (url, size, type, lastModified);
217
- - `hasInOpfsCache(url: string): Promise<boolean>` — есть ли URL в кеше;
218
- - `deleteFromOpfsCache(url: string): Promise<void>` — удалить один ресурс по URL.
307
+ ```ts
308
+ opfsServeRange(options?: {
309
+ order?: number;
310
+ enableLogging?: boolean;
311
+ include?: string[];
312
+ exclude?: string[];
313
+ rangeResponseCacheControl?: string; // Cache-Control для ответов 206 (по умолчанию max-age=31536000, immutable)
314
+ }): Plugin | undefined
315
+ ```
316
+
317
+ ### `opfsPrecache` — при установке сервис-воркера загружает список URL и записывает их в OPFS.
219
318
 
220
- ## Опции плагинов
319
+ ```ts
320
+ opfsPrecache(options: {
321
+ urls: string[] | (() => Promise<string[]>); // список URL или функция
322
+ order?: number;
323
+ enableLogging?: boolean;
324
+ pinned?: string[]; // glob-паттерны URL, защищённых от эвикции (см. «Закреплённые ресурсы»)
325
+ }): Plugin | undefined
326
+ ```
221
327
 
222
- Имя папки и доля квоты задаются в **configureOpfs({ folderName, maxCacheFraction })**.
328
+ ### `opfsRangeFromNetworkAndCache` обрабатывает запросы, которые opfsServeRange не обслужил (ресурс ещё не в кеше): идёт в сеть, отдаёт ответ клиенту и при необходимости догружает файл в OPFS в фоне.
329
+
330
+ ```ts
331
+ opfsRangeFromNetworkAndCache(options?: {
332
+ order?: number;
333
+ include?: string[];
334
+ exclude?: string[];
335
+ enableLogging?: boolean;
336
+ pinned?: string[]; // glob-паттерны URL, защищённых от эвикции
337
+ }): Plugin | undefined
338
+ ```
339
+
340
+ ### `opfsBackgroundFetch` — при успешном завершении загрузки через Background Fetch API записывает ответы в OPFS; дальнейшие range‑запросы по этим URL обслуживает opfsServeRange.
341
+
342
+ ```ts
343
+ opfsBackgroundFetch(options?: {
344
+ order?: number;
345
+ include?: string[];
346
+ exclude?: string[];
347
+ enableLogging?: boolean;
348
+ pinned?: string[]; // glob-паттерны URL, защищённых от эвикции
349
+ }): Plugin | undefined
350
+ ```
223
351
 
224
- - **opfsServeRange:** `order`, `enableLogging`, `include`, `exclude`, `rangeResponseCacheControl` — чтобы ограничить URL и кеш ответов 206.
225
- - **opfsPrecache:** `urls` (список или функция, возвращающая список), `order`, `enableLogging`, `pinned` — какие URL загружать при установке SW. `pinned` — массив glob-паттернов для URL, которые нельзя эвиктить (например, `['/assets/media/**']`).
226
- - **opfsRangeFromNetworkAndCache:** `order` (например -10, после opfsServeRange), `include`, `exclude`, `enableLogging`, `pinned` — какие запросы кешировать; при запросе с Range отдаёт ответ сразу и при необходимости догружает файл в OPFS в фоне. `pinned` — массив glob-паттернов для URL, которые нельзя эвиктить. При `enableLogging` в консоль пишется предупреждение, если файл уже есть в OPFS, но ответ по Range отдан с сети (например, из‑за If-Range или порядка плагинов).
227
- - **opfsBackgroundFetch:** `order`, `include`, `exclude`, `enableLogging`, `pinned` — какие URL писать в OPFS по завершении Background Fetch. `pinned` — массив glob-паттернов для URL, которые нельзя эвиктить. События fail/abort/click при `enableLogging` логируются; можно зарегистрировать свой плагин с теми же хуками (например, показать уведомление при fail). Запуск загрузки с клиента — утилиты из `@budarin/pluggable-serviceworker/client/background-fetch`.
352
+ Запуск загрузки с клиента: утилиты из `@budarin/pluggable-serviceworker/client/background-fetch`.
228
353
 
229
354
  ### Закреплённые ресурсы (защита от эвикции)
230
355
 
@@ -234,13 +359,13 @@ const unsubSkip = onOPFSSkipQuotaExceeded((event: MessageEvent) => {
234
359
 
235
360
  ```typescript
236
361
  opfsPrecache({
237
- urls: ['/assets/media/featured-video.mp4', '/assets/media/trailer.mp4'],
238
- pinned: ['/assets/media/featured-video.mp4'], // важный контент не будет эвиктиться
362
+ urls: ['/assets/media/featured-video.mp4', '/assets/media/trailer.mp4'],
363
+ pinned: ['/assets/media/featured-video.mp4'], // важный контент не будет эвиктиться
239
364
  });
240
365
 
241
366
  opfsRangeFromNetworkAndCache({
242
- include: ['*.mp4', '*.webm'],
243
- pinned: ['/assets/media/featured/**'], // важные медиафайлы не будут эвиктиться
367
+ include: ['*.mp4', '*.webm'],
368
+ pinned: ['/assets/media/featured/**'], // важные медиафайлы не будут эвиктиться
244
369
  });
245
370
  ```
246
371
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budarin/psw-plugin-opfs-serve-range",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Service Worker plugin: serve HTTP Range requests from OPFS files",
5
5
  "keywords": [
6
6
  "service-worker",