@lls/offline 24.24.0-4f552474 → 24.24.0-5156b44b

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.
@@ -63,13 +63,6 @@ var makeSyncHandler = a(
63
63
  );
64
64
  var jsonToBuf = (json) => new TextEncoder().encode(JSON.stringify(json));
65
65
  var openCache = async (mode) => caches.open(`LLS_OFFLINE_${mode}`);
66
- var isStoryZip = (name) => /story-.*?\.zip/.test(name);
67
- var isValidZipName = (name) => {
68
- return /lecture-cp\.zip/.test(name) || isStoryZip(name);
69
- };
70
- var isValidS3Zip = (response) => {
71
- return Number(response?.headers.get("Content-Length")) >= 1e4 || isStoryZip(response.url);
72
- };
73
66
 
74
67
  // src/worker/swFetchScreenCall.ts
75
68
  var zipSlugName = (str) => str.replace(/[^a-zA-Z0-9-.]/g, "");
@@ -309,9 +302,6 @@ var putInCache = async (request, response) => {
309
302
  var onlineFirst = async (request, event) => {
310
303
  try {
311
304
  const responseFromNetwork = await fetch(request);
312
- if (isValidZipName(request.url) && !isValidS3Zip(responseFromNetwork)) {
313
- throw new Error(`zip is invalid: got ${responseFromNetwork.headers.get("Content-Length")} bytes`);
314
- }
315
305
  const cached = putInCache(request, responseFromNetwork.clone());
316
306
  if (request.url.endsWith(".zip")) {
317
307
  await cached;
@@ -94,13 +94,6 @@ var concatArrayBuffers = (buffers) => {
94
94
  }
95
95
  return concatenated.buffer;
96
96
  };
97
- var isStoryZip = (name) => /story-.*?\.zip/.test(name);
98
- var isValidZipName = (name) => {
99
- return /lecture-cp\.zip/.test(name) || isStoryZip(name);
100
- };
101
- var isValidS3Zip = (response) => {
102
- return Number(response?.headers.get("Content-Length")) >= 1e4 || isStoryZip(response.url);
103
- };
104
97
 
105
98
  // src/worker/wwApi.ts
106
99
  var STATE = {
@@ -924,11 +917,6 @@ var fetchZipFile = async (zipUrl, { forceRefresh } = {}) => {
924
917
  }
925
918
  const response = await fetch(zipUrl);
926
919
  const contentLength = +response.headers.get("Content-Length");
927
- if (!isValidS3Zip(response)) {
928
- const error = `likely ${zipUrl} was not fetched ${contentLength}`;
929
- console.debug(error);
930
- throw new Error(error);
931
- }
932
920
  const reader = response.body.getReader();
933
921
  let position = 0;
934
922
  const arrayBuffer = new Uint8Array(contentLength);
@@ -946,6 +934,11 @@ var fetchZipFile = async (zipUrl, { forceRefresh } = {}) => {
946
934
  self.postMessage({ methodName: "opfsProgress", arg: { total: contentLength, bytes: position } });
947
935
  }
948
936
  }
937
+ if (arrayBuffer.byteLength < 1e4) {
938
+ const error = `likely ${zipUrl} was not fetched ${arrayBuffer.byteLength}`;
939
+ console.debug(error);
940
+ throw new Error(error);
941
+ }
949
942
  if (STORAGE === "native") {
950
943
  await sender.nativeWriteFile({ fname: fileName, buffer: arrayBuffer });
951
944
  } else if (STORAGE === "opfs") {
@@ -1059,7 +1052,9 @@ var loadBooks = async ({ primaryOnly = false } = {}) => {
1059
1052
  } else {
1060
1053
  const cache = await openCache(CONF_ENV);
1061
1054
  const keys = await cache.keys();
1062
- const zips = keys.filter((key2) => isValidZipName(key2.url));
1055
+ const zips = keys.filter((key2) => {
1056
+ return key2.url.match(/lecture-cp\.zip|story-.*?\.zip/);
1057
+ });
1063
1058
  entries = zips.map((zip) => ({ name: String(zip.url.split("/").pop()) }));
1064
1059
  }
1065
1060
  for await (const entry of entries) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lls/offline",
3
- "version": "24.24.0-4f552474",
3
+ "version": "24.24.0-5156b44b",
4
4
  "description": "offline",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",
@@ -52,7 +52,7 @@
52
52
  "vite": "7.0.0",
53
53
  "vite-tsconfig-paths": "5.1.4",
54
54
  "zod": "3.25.50",
55
- "@lls/vitescripts": "24.24.0-4f552474"
55
+ "@lls/vitescripts": "24.24.0-5156b44b"
56
56
  },
57
57
  "dependencies": {
58
58
  "fflate": "0.8.2"