@qilin-agent/host-preview-media 3.1.5 → 3.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 (2) hide show
  1. package/lib/index.js +9 -8
  2. package/package.json +6 -6
package/lib/index.js CHANGED
@@ -22,8 +22,9 @@ function parseRange(raw, size) {
22
22
  if (size <= 0) return { unsatisfiable: true };
23
23
  const match = /^bytes=(.+)$/i.exec(raw.trim());
24
24
  if (match === null) return null;
25
- const [firstSpec = ""] = (match[1] ?? "").split(",");
26
- const spec = firstSpec.trim();
25
+ const specs = match[1];
26
+ const comma = specs.indexOf(",");
27
+ const spec = (comma === -1 ? specs : specs.slice(0, comma)).trim();
27
28
  if (spec === "") return null;
28
29
  if (spec.startsWith("-")) {
29
30
  const suffix = Number(spec.slice(1));
@@ -41,7 +42,7 @@ function parseRange(raw, size) {
41
42
  if (dash === -1) return null;
42
43
  const startText = spec.slice(0, dash);
43
44
  const endText = spec.slice(dash + 1);
44
- const start = startText === "" ? 0 : Number(startText);
45
+ const start = Number(startText);
45
46
  const end = endText === "" ? size - 1 : Number(endText);
46
47
  if (!Number.isInteger(start) || start < 0 || !Number.isInteger(end)) return null;
47
48
  if (start >= size) return { unsatisfiable: true };
@@ -166,7 +167,7 @@ function apply(ctx, config) {
166
167
  const connection = connectionOf(ctx);
167
168
  /** The composition's rejection for one request, or undefined when admitted. */
168
169
  const rejectionOf = (req) => connection.requestRejection(req);
169
- ctx.effect(() => ctx.webServer.register({
170
+ ctx.webServer.register({
170
171
  kind: "prefix",
171
172
  path: PREVIEW_MEDIA_PATH,
172
173
  handler: async (req, res) => {
@@ -190,7 +191,7 @@ function apply(ctx, config) {
190
191
  const type = mediaTypeOf(path);
191
192
  const range = info.size === void 0 ? null : parseRange(req.headers.range, info.size);
192
193
  if (range !== null && "unsatisfiable" in range) {
193
- const size = info.size ?? 0;
194
+ const size = info.size;
194
195
  res.writeHead(416, {
195
196
  ...mediaHeaders(type),
196
197
  "content-range": `bytes */${size}`
@@ -225,7 +226,7 @@ function apply(ctx, config) {
225
226
  writeError(res, error);
226
227
  }
227
228
  }
228
- }), `preview-media: GET/HEAD ${PREVIEW_MEDIA_PATH}`);
229
+ });
229
230
  /** Buffer one request body up to a byte ceiling; the caller names its limit. */
230
231
  const readBody = async (req, limit) => {
231
232
  const chunks = [];
@@ -238,7 +239,7 @@ function apply(ctx, config) {
238
239
  }
239
240
  return Buffer.concat(chunks);
240
241
  };
241
- ctx.effect(() => ctx.webServer.register({
242
+ ctx.webServer.register({
242
243
  kind: "exact",
243
244
  path: `${PREVIEW_MEDIA_PATH}/upload`,
244
245
  handler: async (req, res) => {
@@ -274,7 +275,7 @@ function apply(ctx, config) {
274
275
  writeError(res, error);
275
276
  }
276
277
  }
277
- }), `preview-media: PUT ${PREVIEW_MEDIA_PATH}/upload`);
278
+ });
278
279
  }
279
280
  /** Cordis row Config schema: the media limit is a positive byte count. */
280
281
  const Config = z.object({ mediaLimitBytes: z.number().step(1).min(1).max(2147483647).default(20 * 1024 * 1024) });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qilin-agent/host-preview-media",
3
3
  "description": "Host half of preview media: the /sidebar/media route serving session-workspace files to inline previews, with HTTP Range windows for seeking video",
4
- "version": "3.1.5",
4
+ "version": "3.1.7",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,15 +30,15 @@
30
30
  ],
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@qilin-agent/schemastery": "~3.18.3"
33
+ "@qilin-agent/schemastery": "~3.18.5"
34
34
  },
35
35
  "peerDependencies": {
36
- "@qilin-agent/kylin": "~4.0.3"
36
+ "@qilin-agent/kylin": "~4.0.5"
37
37
  },
38
38
  "devDependencies": {
39
- "@qilin-agent/kylin": "~4.0.3",
40
- "@qilin-agent/kylin-plugin-loader": "~1.0.4",
41
- "@qilin-agent/host-webserver": "3.1.5"
39
+ "@qilin-agent/kylin-plugin-loader": "~1.0.6",
40
+ "@qilin-agent/kylin": "~4.0.5",
41
+ "@qilin-agent/host-webserver": "3.1.7"
42
42
  },
43
43
  "scripts": {
44
44
  "bundle": "tsdown",