lopata 0.3.0 → 0.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lopata",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,6 +28,7 @@
28
28
  "format": "dprint fmt",
29
29
  "format:check": "dprint check",
30
30
  "build:assets": "bun scripts/build-assets.ts",
31
+ "typecheck": "bunx --bun tsc --build",
31
32
  "prepublishOnly": "bun scripts/build-assets.ts"
32
33
  },
33
34
  "devDependencies": {
@@ -27,7 +27,7 @@ export const handlers = {
27
27
 
28
28
  let rawStr: string
29
29
  try {
30
- rawStr = new TextDecoder().decode(row.raw as BufferSource)
30
+ rawStr = new TextDecoder().decode(row.raw as Uint8Array)
31
31
  } catch {
32
32
  rawStr = '<binary content>'
33
33
  }
@@ -42,7 +42,7 @@ export const handlers = {
42
42
  return rows.map(row => {
43
43
  let bodyStr: string
44
44
  try {
45
- bodyStr = new TextDecoder().decode(row.body as BufferSource)
45
+ bodyStr = new TextDecoder().decode(row.body as Uint8Array)
46
46
  } catch {
47
47
  bodyStr = `<binary>`
48
48
  }
package/src/api/r2.ts CHANGED
@@ -53,7 +53,7 @@ export function handleR2Download(url: URL): Response {
53
53
  }
54
54
 
55
55
  const filename = key.split('/').pop() ?? key
56
- const response = new Response(file as unknown as BodyInit, {
56
+ const response = new Response(file as unknown as Bun.BodyInit, {
57
57
  headers: {
58
58
  'Content-Disposition': `attachment; filename="${filename}"`,
59
59
  'Content-Type': file.type || 'application/octet-stream',
@@ -26,12 +26,10 @@ export class BrowserBinding {
26
26
  /** Launch a new browser and return a puppeteer Browser instance. */
27
27
  async launch(opts?: { keep_alive?: number }): Promise<any> {
28
28
  if (this.config.wsEndpoint) {
29
- // @ts-expect-error — puppeteer-core is an optional dependency
30
29
  const puppeteer = await import('puppeteer-core')
31
30
  this._browser = await puppeteer.default.connect({ browserWSEndpoint: this.config.wsEndpoint })
32
31
  return this._browser
33
32
  }
34
- // @ts-expect-error — puppeteer is an optional dependency
35
33
  const puppeteer = await import('puppeteer')
36
34
  this._browser = await puppeteer.default.launch({
37
35
  headless: this.config.headless ?? true,
@@ -43,7 +41,6 @@ export class BrowserBinding {
43
41
  /** Connect to an existing browser session by sessionId. */
44
42
  async connect(sessionId: string): Promise<any> {
45
43
  if (this.config.wsEndpoint) {
46
- // @ts-expect-error — puppeteer-core is an optional dependency
47
44
  const puppeteer = await import('puppeteer-core')
48
45
  return puppeteer.default.connect({ browserWSEndpoint: this.config.wsEndpoint })
49
46
  }
@@ -95,7 +95,7 @@ export class SqliteCache {
95
95
 
96
96
  const headers = new Headers(JSON.parse(row.headers))
97
97
  headers.set('cf-cache-status', 'HIT')
98
- return new Response(row.body as unknown as BodyInit, { status: row.status, headers })
98
+ return new Response(row.body as unknown as Bun.BodyInit, { status: row.status, headers })
99
99
  }
100
100
 
101
101
  async put(request: Request | string, response: Response): Promise<void> {
@@ -24,7 +24,7 @@ export interface ContainerConfig {
24
24
  }
25
25
 
26
26
  interface TcpPort {
27
- fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
27
+ fetch(input: Request | string | URL, init?: RequestInit): Promise<Response>
28
28
  connect(): never
29
29
  }
30
30
 
@@ -215,7 +215,7 @@ export class ContainerRuntime {
215
215
  /**
216
216
  * Forward an HTTP request to the container.
217
217
  */
218
- async fetch(input: RequestInfo | URL, init?: RequestInit, port?: number): Promise<Response> {
218
+ async fetch(input: Request | string | URL, init?: RequestInit, port?: number): Promise<Response> {
219
219
  const targetPort = port ?? this.defaultPort
220
220
  const hostPort = this._hostPorts.get(targetPort)
221
221
  if (!hostPort) {
@@ -429,7 +429,7 @@ export class ContainerContext {
429
429
  getTcpPort(port: number): TcpPort {
430
430
  const runtime = this._runtime
431
431
  return {
432
- fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
432
+ fetch(input: Request | string | URL, init?: RequestInit): Promise<Response> {
433
433
  return runtime.fetch(input, init, port)
434
434
  },
435
435
  connect(): never {
@@ -521,7 +521,7 @@ export class ContainerBase extends DurableObjectBase {
521
521
  requestOrUrl: Request | string | URL,
522
522
  portOrInit?: number | RequestInit,
523
523
  portParam?: number,
524
- ): { input: RequestInfo | URL; init?: RequestInit; port?: number } {
524
+ ): { input: Request | string | URL; init?: RequestInit; port?: number } {
525
525
  if (requestOrUrl instanceof Request) {
526
526
  // containerFetch(request, port?)
527
527
  const port = typeof portOrInit === 'number' ? portOrInit : portParam
@@ -26,7 +26,7 @@ export function cfTimingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuff
26
26
  export class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {
27
27
  readonly digest: Promise<ArrayBuffer>
28
28
 
29
- constructor(algorithm: AlgorithmIdentifier) {
29
+ constructor(algorithm: string | { name: string }) {
30
30
  const algo = typeof algorithm === 'string' ? algorithm : algorithm.name
31
31
 
32
32
  // Map CF algorithm names to Bun.CryptoHasher names
@@ -997,7 +997,7 @@ export class DurableObjectNamespaceImpl {
997
997
 
998
998
  // stub.fetch() — calls the DO's fetch() handler
999
999
  if (prop === 'fetch') {
1000
- return async (input: RequestInfo | URL, init?: RequestInit) => {
1000
+ return async (input: Request | string | URL, init?: RequestInit) => {
1001
1001
  const executor = self._getOrCreateExecutor(idStr, id)!
1002
1002
  self._lastActivity.set(idStr, Date.now())
1003
1003
  const request = input instanceof Request ? input : new Request(input instanceof URL ? input.href : input, init)
@@ -449,7 +449,7 @@ class LazyImageTransformer {
449
449
  raw: { width: w, height: h, channels: 4 },
450
450
  blend: 'dest-in' as any,
451
451
  }])
452
- .toBuffer()
452
+ .toBuffer() as Buffer<ArrayBuffer>
453
453
  }
454
454
 
455
455
  const opts: SharpNs.OverlayOptions = { input: overlayBuf }
package/src/cli.ts CHANGED
File without changes
@@ -77,7 +77,7 @@ export function handleDashboardRequest(request: Request): Response {
77
77
  if (assetMatch && dashboardAssets) {
78
78
  const asset = dashboardAssets.get(assetMatch[1]!)
79
79
  if (asset) {
80
- return new Response(asset.content as unknown as BodyInit, {
80
+ return new Response(asset.content as unknown as Bun.BodyInit, {
81
81
  headers: {
82
82
  'Content-Type': asset.contentType,
83
83
  'Cache-Control': 'public, max-age=31536000, immutable',
package/src/plugin.ts CHANGED
@@ -298,7 +298,7 @@ globalThis.fetch = ((input: any, init?: any): Promise<Response> => {
298
298
  setSpanAttribute('http.response.headers', headersToRecord(response.headers))
299
299
 
300
300
  // Capture response body from a clone (caller keeps the original stream)
301
- const resBody = await readBodyLimited(response.clone())
301
+ const resBody = await readBodyLimited(response.clone() as Response)
302
302
  if (resBody) setSpanAttribute('http.response.body', resBody)
303
303
 
304
304
  return response
@@ -210,7 +210,7 @@ export class TraceStore {
210
210
 
211
211
  params.push(limit)
212
212
 
213
- const rows = this.db.prepare<Record<string, unknown>, unknown[]>(`
213
+ const rows = this.db.prepare<Record<string, unknown>, any>(`
214
214
  SELECT
215
215
  s.trace_id,
216
216
  s.name as root_span_name,
package/src/tsconfig.json CHANGED
@@ -3,6 +3,7 @@
3
3
  "compilerOptions": {
4
4
  "allowJs": true,
5
5
  "composite": true,
6
+ "outDir": "../.tsc-out/src",
6
7
 
7
8
  "noUnusedLocals": false,
8
9
  "noUnusedParameters": false,
@@ -467,7 +467,6 @@ function nodeReqToRequest(req: IncomingMessage): Request {
467
467
  method,
468
468
  headers,
469
469
  body: hasBody ? nodeStreamToReadable(req) : undefined,
470
- // @ts-expect-error duplex is needed for streaming request bodies
471
470
  duplex: hasBody ? 'half' : undefined,
472
471
  })
473
472
  }