k99 0.2.0 → 0.3.0-beta.1

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 (154) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -0
  3. package/README.zh.md +8 -0
  4. package/browser/package.json +8 -0
  5. package/browser/types.d.ts +20 -0
  6. package/cli/command/create.js +1 -2
  7. package/cli/command/index.js +1 -2
  8. package/cli/command/init.js +3 -5
  9. package/cli/command/start.js +9 -10
  10. package/cli/index.js +3 -4
  11. package/cli/opt/bind.js +1 -2
  12. package/cli/opt/index.js +1 -2
  13. package/cli/opt/listen.js +1 -2
  14. package/cli/opt/path.js +1 -2
  15. package/cli/opt/port.js +1 -2
  16. package/cli/opt/show-router.js +1 -2
  17. package/dist/k99.browser.js +3110 -0
  18. package/dist/k99.browser.min.js +6 -0
  19. package/dist/k99.esm.js +3082 -0
  20. package/dist/k99.esm.min.js +6 -0
  21. package/dist/k99.js +3104 -0
  22. package/dist/k99.mjs +3082 -0
  23. package/dist/k99Browser.browser.js +490 -0
  24. package/dist/k99Browser.browser.min.js +6 -0
  25. package/dist/k99Browser.esm.js +475 -0
  26. package/dist/k99Browser.esm.min.js +6 -0
  27. package/dist/k99Browser.js +484 -0
  28. package/dist/k99Browser.mjs +475 -0
  29. package/dist/k99Services.browser.js +145 -0
  30. package/dist/k99Services.browser.min.js +6 -0
  31. package/dist/k99Services.esm.js +136 -0
  32. package/dist/k99Services.esm.min.js +6 -0
  33. package/dist/k99Services.js +141 -0
  34. package/dist/k99Services.mjs +136 -0
  35. package/node/index.js +1386 -0
  36. package/node/index.mjs +1350 -0
  37. package/node/package.json +5 -0
  38. package/node/types.d.ts +166 -0
  39. package/package.json +77 -11
  40. package/services/package.json +8 -0
  41. package/services/types.d.ts +22 -0
  42. package/starter.js +0 -1
  43. package/types.d.ts +748 -0
  44. package/Container.d.ts +0 -92
  45. package/Container.js +0 -242
  46. package/Container.js.map +0 -1
  47. package/Controller/index.d.ts +0 -178
  48. package/Controller/index.js +0 -576
  49. package/Controller/index.js.map +0 -1
  50. package/Controller/patch/cookie.d.ts +0 -33
  51. package/Controller/patch/cookie.js +0 -168
  52. package/Controller/patch/cookie.js.map +0 -1
  53. package/Controller/patch/index.d.ts +0 -7
  54. package/Controller/patch/index.js +0 -26
  55. package/Controller/patch/index.js.map +0 -1
  56. package/Controller/patch/render.d.ts +0 -5
  57. package/Controller/patch/render.js +0 -24
  58. package/Controller/patch/render.js.map +0 -1
  59. package/ExitSignal.d.ts +0 -14
  60. package/ExitSignal.js +0 -29
  61. package/ExitSignal.js.map +0 -1
  62. package/Extension.d.ts +0 -56
  63. package/Extension.js +0 -93
  64. package/Extension.js.map +0 -1
  65. package/ExtensionContainer.d.ts +0 -55
  66. package/ExtensionContainer.js +0 -105
  67. package/ExtensionContainer.js.map +0 -1
  68. package/Plugin.d.ts +0 -52
  69. package/Plugin.js +0 -278
  70. package/Plugin.js.map +0 -1
  71. package/Preprocessor.d.ts +0 -86
  72. package/Preprocessor.js +0 -135
  73. package/Preprocessor.js.map +0 -1
  74. package/Router/assets.d.ts +0 -33
  75. package/Router/assets.js +0 -106
  76. package/Router/assets.js.map +0 -1
  77. package/Router/callback.d.ts +0 -9
  78. package/Router/callback.js +0 -152
  79. package/Router/callback.js.map +0 -1
  80. package/Router/extendsInterface.d.ts +0 -8
  81. package/Router/extendsInterface.js +0 -43
  82. package/Router/extendsInterface.js.map +0 -1
  83. package/Router/index.d.ts +0 -184
  84. package/Router/index.js +0 -615
  85. package/Router/index.js.map +0 -1
  86. package/Router/log.d.ts +0 -23
  87. package/Router/log.js +0 -120
  88. package/Router/log.js.map +0 -1
  89. package/Router/order.d.ts +0 -14
  90. package/Router/order.js +0 -71
  91. package/Router/order.js.map +0 -1
  92. package/Router/register.d.ts +0 -9
  93. package/Router/register.js +0 -252
  94. package/Router/register.js.map +0 -1
  95. package/Router/registerManager.d.ts +0 -22
  96. package/Router/registerManager.js +0 -102
  97. package/Router/registerManager.js.map +0 -1
  98. package/Router/scan.d.ts +0 -2
  99. package/Router/scan.js +0 -72
  100. package/Router/scan.js.map +0 -1
  101. package/Router/setHandleItem.d.ts +0 -3
  102. package/Router/setHandleItem.js +0 -94
  103. package/Router/setHandleItem.js.map +0 -1
  104. package/Router/settings.d.ts +0 -12
  105. package/Router/settings.js +0 -74
  106. package/Router/settings.js.map +0 -1
  107. package/Router/start.d.ts +0 -3
  108. package/Router/start.js +0 -270
  109. package/Router/start.js.map +0 -1
  110. package/Router/vars.d.ts +0 -10
  111. package/Router/vars.js +0 -40
  112. package/Router/vars.js.map +0 -1
  113. package/Service.d.ts +0 -12
  114. package/Service.js +0 -20
  115. package/Service.js.map +0 -1
  116. package/cli/command/create.d.ts +0 -7
  117. package/cli/command/create.js.map +0 -1
  118. package/cli/command/index.d.ts +0 -7
  119. package/cli/command/index.js.map +0 -1
  120. package/cli/command/init.d.ts +0 -6
  121. package/cli/command/init.js.map +0 -1
  122. package/cli/command/start.d.ts +0 -6
  123. package/cli/command/start.js.map +0 -1
  124. package/cli/index.d.ts +0 -2
  125. package/cli/index.js.map +0 -1
  126. package/cli/opt/bind.d.ts +0 -3
  127. package/cli/opt/bind.js.map +0 -1
  128. package/cli/opt/index.d.ts +0 -16
  129. package/cli/opt/index.js.map +0 -1
  130. package/cli/opt/listen.d.ts +0 -3
  131. package/cli/opt/listen.js.map +0 -1
  132. package/cli/opt/path.d.ts +0 -3
  133. package/cli/opt/path.js.map +0 -1
  134. package/cli/opt/port.d.ts +0 -3
  135. package/cli/opt/port.js.map +0 -1
  136. package/cli/opt/show-router.d.ts +0 -3
  137. package/cli/opt/show-router.js.map +0 -1
  138. package/index.d.ts +0 -354
  139. package/index.js +0 -155
  140. package/index.js.map +0 -1
  141. package/setOptions.d.ts +0 -12
  142. package/setOptions.js +0 -60
  143. package/setOptions.js.map +0 -1
  144. package/starter.d.ts +0 -2
  145. package/starter.js.map +0 -1
  146. package/symbols.d.ts +0 -13
  147. package/symbols.js +0 -31
  148. package/symbols.js.map +0 -1
  149. package/util/index.d.ts +0 -5
  150. package/util/index.js +0 -92
  151. package/util/index.js.map +0 -1
  152. package/util/stream.d.ts +0 -19
  153. package/util/stream.js +0 -66
  154. package/util/stream.js.map +0 -1
@@ -0,0 +1,490 @@
1
+ /*!
2
+ * k99 v0.3.0-beta.1
3
+ * (c) 2019-2022 Fierflame
4
+ * @license MIT
5
+ */
6
+ (function (global, factory) {
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
8
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.k99Browser = {}));
10
+ }(this, (function (exports) { 'use strict';
11
+
12
+ function createFsAssetsApi(name) {
13
+ const cachePromise = caches.open(name);
14
+ return {
15
+ async read(path, encoding) {
16
+ path = `/${path}`;
17
+ const cache = await cachePromise;
18
+ const response = await cache.match(path);
19
+
20
+ if (!response) {
21
+ return null;
22
+ }
23
+
24
+ if (encoding) {
25
+ return response.text();
26
+ }
27
+
28
+ return response.arrayBuffer();
29
+ },
30
+
31
+ async write(path, data) {
32
+ path = `/${path}`;
33
+ const cache = await cachePromise;
34
+ await cache.put(path, new Response(data));
35
+ return true;
36
+ },
37
+
38
+ async delete(path) {
39
+ path = `/${path}`;
40
+ const cache = await cachePromise;
41
+ return cache.delete(path);
42
+ },
43
+
44
+ stat() {
45
+ return null;
46
+ }
47
+
48
+ };
49
+ }
50
+
51
+ function createCacheLogApi(name) {
52
+ const cachePromise = caches.open(name);
53
+ return {
54
+ async read(path) {
55
+ path = `/${path}`;
56
+ const cache = await cachePromise;
57
+ const response = await cache.match(path);
58
+ return response ? response.text() : '';
59
+ },
60
+
61
+ async write(path, log) {
62
+ path = `/${path}`;
63
+ const cache = await cachePromise;
64
+ const response = await cache.match(path);
65
+ const text = response ? `${await response.text()}${log}` : log;
66
+ await cache.put(path, new Response(text));
67
+ return true;
68
+ },
69
+
70
+ async clear(path) {
71
+ path = `/${path}`;
72
+ const cache = await cachePromise;
73
+ await cache.delete(path);
74
+ }
75
+
76
+ };
77
+ }
78
+
79
+ function createCacheSettingsApi(name) {
80
+ const cachePromise = caches.open(name);
81
+ return {
82
+ async read(path) {
83
+ path = `/${path}`;
84
+ const cache = await cachePromise;
85
+ const response = await cache.match(path);
86
+
87
+ if (!response) {
88
+ return undefined;
89
+ }
90
+
91
+ return response.json();
92
+ },
93
+
94
+ async write(path, cfg) {
95
+ path = `/${path}`;
96
+ const cache = await cachePromise;
97
+
98
+ if (cfg === undefined) {
99
+ return cache.delete(path);
100
+ }
101
+
102
+ await cache.put(path, new Response(JSON.stringify(cfg)));
103
+ return true;
104
+ }
105
+
106
+ };
107
+ }
108
+
109
+ function buff2str(buffer) {
110
+ const code = new Uint8Array(buffer);
111
+ let ret = [];
112
+ let index = 0;
113
+
114
+ while (index < code.length) {
115
+ let c = code[index++] | 0;
116
+ let length = 0;
117
+
118
+ if (c >= 0b11110000) {
119
+ length = 3;
120
+ } else if (c >= 0b11100000) {
121
+ length = 2;
122
+ } else if (c >= 0b11000000) {
123
+ length = 1;
124
+ }
125
+
126
+ if (length) {
127
+ c &= (1 << 6 - length) - 1;
128
+ }
129
+
130
+ while (length--) {
131
+ c = c << 6 | code[index++] & 0x3F;
132
+ }
133
+
134
+ ret.push(c);
135
+ }
136
+
137
+ return ret.map(x => String.fromCharCode(x)).join('');
138
+ }
139
+
140
+ function createBufferRead(request) {
141
+ let arrayBuffer;
142
+
143
+ function read(size = 0, encoding = false) {
144
+ if (!arrayBuffer) {
145
+ arrayBuffer = request.arrayBuffer().then(t => [t, t, 0]);
146
+ }
147
+
148
+ arrayBuffer = arrayBuffer.then(v => {
149
+ if (!v) {
150
+ return null;
151
+ }
152
+
153
+ let [, buff, index] = v;
154
+
155
+ if (index >= buff.byteLength) {
156
+ return null;
157
+ }
158
+
159
+ if (!size || size + index >= buff.byteLength) {
160
+ return [buff.slice(index), buff, buff.byteLength];
161
+ }
162
+
163
+ let end = index + size;
164
+ return [buff.slice(index, end), buff, end];
165
+ });
166
+ return arrayBuffer.then(v => {
167
+ if (!v) {
168
+ return null;
169
+ }
170
+
171
+ const [value] = v;
172
+
173
+ if (encoding) {
174
+ return buff2str(value);
175
+ }
176
+
177
+ return value;
178
+ });
179
+ }
180
+
181
+ return read;
182
+ }
183
+
184
+ function createStreamRead(readableStream) {
185
+ let reader;
186
+ let currentEncoding = false;
187
+ let current = 0;
188
+ let cb = null;
189
+ let end = false;
190
+ const dataList = [];
191
+ let dataSize = 0;
192
+ const list = [];
193
+
194
+ function get() {
195
+ if (!current || dataSize <= current) {
196
+ const chunk = new Uint8Array(dataSize);
197
+ let index = 0;
198
+
199
+ for (const item of dataList) {
200
+ for (let i = 0; i < item.byteLength; i++, index++) {
201
+ chunk[index] = item[i];
202
+ }
203
+ }
204
+
205
+ dataSize = 0;
206
+ dataList.length = 0;
207
+ return chunk;
208
+ }
209
+
210
+ let item = dataList.shift();
211
+
212
+ if (!item) {
213
+ return null;
214
+ }
215
+
216
+ const chunk = new Uint8Array(current);
217
+ let index = 0;
218
+ let i = 0;
219
+ let len = item.length;
220
+
221
+ while (index < current) {
222
+ if (i >= length) {
223
+ item = dataList.shift();
224
+
225
+ if (!item) {
226
+ break;
227
+ }
228
+
229
+ i = 0;
230
+ len = item.length;
231
+ }
232
+
233
+ chunk[index] = item[i];
234
+ i++;
235
+ index++;
236
+ }
237
+
238
+ if (item && i < len) {
239
+ dataList.unshift(new Uint8Array(item.buffer.slice(i)));
240
+ }
241
+
242
+ dataSize -= current;
243
+ return chunk;
244
+ }
245
+
246
+ function add(data) {
247
+ dataSize += data.length || 0;
248
+ dataList.push(data);
249
+ return dataSize;
250
+ }
251
+
252
+ function runCb() {
253
+ if (!cb) {
254
+ return;
255
+ }
256
+
257
+ const v = dataSize ? get() : null;
258
+
259
+ if (v && currentEncoding) {
260
+ cb(buff2str(v));
261
+ } else {
262
+ cb(v);
263
+ }
264
+
265
+ [current, currentEncoding, cb] = list.shift() || [0, false, null];
266
+ }
267
+
268
+ async function run() {
269
+
270
+ for (;;) {
271
+ if (!cb) {
272
+ break;
273
+ }
274
+
275
+ if (end) {
276
+ runCb();
277
+ continue;
278
+ }
279
+
280
+ if (dataSize && (!current || dataSize >= current)) {
281
+ runCb();
282
+ continue;
283
+ }
284
+
285
+ const {
286
+ value,
287
+ done
288
+ } = await reader.read();
289
+
290
+ if (done) {
291
+ end = true;
292
+ continue;
293
+ }
294
+
295
+ add(value);
296
+
297
+ if (dataSize && (!current || dataSize >= current)) {
298
+ runCb();
299
+ continue;
300
+ }
301
+ }
302
+ }
303
+
304
+ function read(size = 0, encoding = false) {
305
+ return new Promise(resolve => {
306
+ if (!reader) {
307
+ reader = readableStream.getReader();
308
+ }
309
+
310
+ size = Math.max(size, 0);
311
+
312
+ if (cb) {
313
+ list.push([size, encoding, resolve]);
314
+ return;
315
+ }
316
+
317
+ currentEncoding = encoding;
318
+ current = size;
319
+ cb = resolve;
320
+ run();
321
+ });
322
+ }
323
+
324
+ return read;
325
+ }
326
+
327
+ function createRead(request) {
328
+ const {
329
+ body
330
+ } = request;
331
+
332
+ if (body) {
333
+ return createStreamRead(body);
334
+ }
335
+
336
+ return createBufferRead(request);
337
+ }
338
+
339
+ function getNameValue(s) {
340
+ const index = s.indexOf('=');
341
+
342
+ if (index < 0) {
343
+ return [decodeURIComponent(s), ''];
344
+ }
345
+
346
+ return [decodeURIComponent(s.substring(0, index)), decodeURIComponent(s.substring(index + 1))];
347
+ }
348
+
349
+ function parseQuery(s) {
350
+ const query = {};
351
+
352
+ for (const k of s.split('&').filter(Boolean)) {
353
+ const [index, value] = getNameValue(k);
354
+
355
+ if (index in query) {
356
+ query[index] = [query[index], value].flat();
357
+ } else {
358
+ query[index] = [value];
359
+ }
360
+ }
361
+
362
+ return query;
363
+ }
364
+
365
+ function getHeaders(h) {
366
+ const headers = {};
367
+
368
+ for (const [k, v] of h.entries()) {
369
+ headers[k.toLowerCase()] = v;
370
+ }
371
+
372
+ return headers;
373
+ }
374
+
375
+ function createRequest(request) {
376
+ const url = new URL(request.url);
377
+ return {
378
+ method: (request.method || 'GET').toUpperCase(),
379
+ url: `${url.pathname}${url.search}` || '/',
380
+ headers: getHeaders(request.headers),
381
+ pathname: url.pathname || '/',
382
+ search: url.search || '',
383
+ query: parseQuery(url.search.substring(1)),
384
+ read: createRead(request)
385
+ };
386
+ }
387
+
388
+ function str2buff(str) {
389
+ let out = [];
390
+
391
+ for (let c of str.split('').map(ch => ch.charCodeAt(0))) {
392
+ if (c < 0x80) {
393
+ out.push(c);
394
+ } else if (c < 0x800) {
395
+ out.push(0xC0 | 0x1F & c >> 6);
396
+ out.push(0x80 | 0x3F & c);
397
+ } else {
398
+ out.push(0xE0 | 0x0F & c >> 12);
399
+ out.push(0x80 | 0x3F & c >> 6);
400
+ out.push(0x80 | 0x3F & c);
401
+ }
402
+ }
403
+
404
+ return new Uint8Array(out);
405
+ }
406
+
407
+ function toUint8Array(value) {
408
+ if (typeof value === 'string') {
409
+ return str2buff(value);
410
+ }
411
+
412
+ if (ArrayBuffer.isView(value)) {
413
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
414
+ }
415
+
416
+ return new Uint8Array(value);
417
+ }
418
+
419
+ function createHeaders(target) {
420
+ const headers = new Headers();
421
+
422
+ for (const [k, v] of Object.entries(target.headers)) {
423
+ for (const it of [v].flat()) {
424
+ headers.append(k.toLowerCase(), String(it));
425
+ }
426
+ }
427
+
428
+ return headers;
429
+ }
430
+
431
+ function createResponse(target) {
432
+ const iterator = target[Symbol.asyncIterator]();
433
+ return new Response(new ReadableStream({
434
+ async pull(controller) {
435
+ const {
436
+ value,
437
+ done
438
+ } = await iterator.next();
439
+
440
+ if (done) {
441
+ controller.close();
442
+ } else {
443
+ controller.enqueue(toUint8Array(value));
444
+ }
445
+ }
446
+
447
+ }), {
448
+ status: target.statusCode,
449
+ headers: createHeaders(target)
450
+ });
451
+ }
452
+
453
+ function createFetch(app, notFound) {
454
+ if (notFound) {
455
+ return async function fetch(input, init) {
456
+ const request = new Request(input, init);
457
+ const r = await app.request(createRequest(request));
458
+
459
+ if (r) {
460
+ return createResponse(r);
461
+ }
462
+
463
+ return notFound(request);
464
+ };
465
+ }
466
+
467
+ return async function fetch(input, init) {
468
+ const request = new Request(input, init);
469
+ const r = await app.request(createRequest(request));
470
+
471
+ if (r) {
472
+ return createResponse(r);
473
+ }
474
+
475
+ return new Response(null, {
476
+ status: 404
477
+ });
478
+ };
479
+ }
480
+
481
+ exports.createCacheAssetsApi = createFsAssetsApi;
482
+ exports.createCacheLogApi = createCacheLogApi;
483
+ exports.createCacheSettingsApi = createCacheSettingsApi;
484
+ exports.createFetch = createFetch;
485
+ exports.createRequest = createRequest;
486
+ exports.createResponse = createResponse;
487
+
488
+ Object.defineProperty(exports, '__esModule', { value: true });
489
+
490
+ })));
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * k99 v0.3.0-beta.1
3
+ * (c) 2019-2022 Fierflame
4
+ * @license MIT
5
+ */
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).k99Browser={})}(this,(function(e){"use strict";function t(e){const t=new Uint8Array(e);let n=[],r=0;for(;r<t.length;){let e=0|t[r++],o=0;for(e>=240?o=3:e>=224?o=2:e>=192&&(o=1),o&&(e&=(1<<6-o)-1);o--;)e=e<<6|63&t[r++];n.push(e)}return n.map((e=>String.fromCharCode(e))).join("")}function n(e){let n,r=!1,o=0,a=null,s=!1;const u=[];let c=0;const i=[];function f(){if(!a)return;const e=c?function(){if(!o||c<=o){const e=new Uint8Array(c);let t=0;for(const n of u)for(let r=0;r<n.byteLength;r++,t++)e[t]=n[r];return c=0,u.length=0,e}let e=u.shift();if(!e)return null;const t=new Uint8Array(o);let n=0,r=0,a=e.length;for(;n<o;){if(r>=length){if(e=u.shift(),!e)break;r=0,a=e.length}t[n]=e[r],r++,n++}return e&&r<a&&u.unshift(new Uint8Array(e.buffer.slice(r))),c-=o,t}():null;a(e&&r?t(e):e),[o,r,a]=i.shift()||[0,!1,null]}return function(t=0,l=!1){return new Promise((h=>{n||(n=e.getReader()),t=Math.max(t,0),a?i.push([t,l,h]):(r=l,o=t,a=h,async function(){for(;a;){if(s){f();continue}if(c&&(!o||c>=o)){f();continue}const{value:t,done:r}=await n.read();r?s=!0:(c+=(e=t).length||0,u.push(e),c&&(!o||c>=o)&&f())}var e}())}))}}function r(e){const{body:r}=e;return r?n(r):function(e){let n;return function(r=0,o=!1){return n||(n=e.arrayBuffer().then((e=>[e,e,0]))),n=n.then((e=>{if(!e)return null;let[,t,n]=e;if(n>=t.byteLength)return null;if(!r||r+n>=t.byteLength)return[t.slice(n),t,t.byteLength];let o=n+r;return[t.slice(n,o),t,o]})),n.then((e=>{if(!e)return null;const[n]=e;return o?t(n):n}))}}(e)}function o(e){const t=e.indexOf("=");return t<0?[decodeURIComponent(e),""]:[decodeURIComponent(e.substring(0,t)),decodeURIComponent(e.substring(t+1))]}function a(e){const t={};for(const n of e.split("&").filter(Boolean)){const[e,r]=o(n);t[e]=e in t?[t[e],r].flat():[r]}return t}function s(e){const t={};for(const[n,r]of e.entries())t[n.toLowerCase()]=r;return t}function u(e){const t=new URL(e.url);return{method:(e.method||"GET").toUpperCase(),url:`${t.pathname}${t.search}`||"/",headers:s(e.headers),pathname:t.pathname||"/",search:t.search||"",query:a(t.search.substring(1)),read:r(e)}}function c(e){return"string"==typeof e?function(e){let t=[];for(let n of e.split("").map((e=>e.charCodeAt(0))))n<128?t.push(n):n<2048?(t.push(192|31&n>>6),t.push(128|63&n)):(t.push(224|15&n>>12),t.push(128|63&n>>6),t.push(128|63&n));return new Uint8Array(t)}(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}function i(e){const t=new Headers;for(const[n,r]of Object.entries(e.headers))for(const e of[r].flat())t.append(n.toLowerCase(),String(e));return t}function f(e){const t=e[Symbol.asyncIterator]();return new Response(new ReadableStream({async pull(e){const{value:n,done:r}=await t.next();r?e.close():e.enqueue(c(n))}}),{status:e.statusCode,headers:i(e)})}e.createCacheAssetsApi=function(e){const t=caches.open(e);return{async read(e,n){e=`/${e}`;const r=await t,o=await r.match(e);return o?n?o.text():o.arrayBuffer():null},async write(e,n){e=`/${e}`;const r=await t;return await r.put(e,new Response(n)),!0},async delete(e){e=`/${e}`;return(await t).delete(e)},stat:()=>null}},e.createCacheLogApi=function(e){const t=caches.open(e);return{async read(e){e=`/${e}`;const n=await t,r=await n.match(e);return r?r.text():""},async write(e,n){e=`/${e}`;const r=await t,o=await r.match(e),a=o?`${await o.text()}${n}`:n;return await r.put(e,new Response(a)),!0},async clear(e){e=`/${e}`;const n=await t;await n.delete(e)}}},e.createCacheSettingsApi=function(e){const t=caches.open(e);return{async read(e){e=`/${e}`;const n=await t,r=await n.match(e);if(r)return r.json()},async write(e,n){e=`/${e}`;const r=await t;return void 0===n?r.delete(e):(await r.put(e,new Response(JSON.stringify(n))),!0)}}},e.createFetch=function(e,t){return t?async function(n,r){const o=new Request(n,r),a=await e.request(u(o));return a?f(a):t(o)}:async function(t,n){const r=new Request(t,n),o=await e.request(u(r));return o?f(o):new Response(null,{status:404})}},e.createRequest=u,e.createResponse=f,Object.defineProperty(e,"__esModule",{value:!0})}));