@mikrojs/native 0.0.8 → 0.2.0-pr-14.20260426233358

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mikrojs/native
2
2
 
3
- Standalone, platform-independent C++ runtime library for mikrojs, powered by QuickJS-NG. Zero ESP-IDF dependencies runs on any POSIX host for development and testing, and on ESP32 via a thin platform adapter.
3
+ Standalone, platform-independent C++ runtime library for Mikro.js, powered by QuickJS-NG. Zero ESP-IDF dependencies. Runs on any POSIX host for development and testing, and on ESP32 via a thin platform adapter.
4
4
 
5
5
  ## Directory structure
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikrojs/native",
3
- "version": "0.0.8",
3
+ "version": "0.2.0-pr-14.20260426233358+07b444f",
4
4
  "description": "Mikro.js C++ runtime library and Node.js native addon",
5
5
  "keywords": [
6
6
  "esp32",
@@ -75,7 +75,7 @@
75
75
  "cmake-js": "^8.0.0",
76
76
  "node-addon-api": "^8.7.0",
77
77
  "node-gyp-build": "^4.8.4",
78
- "@mikrojs/quickjs": "0.0.8"
78
+ "@mikrojs/quickjs": "0.2.0-pr-14.20260426233358+07b444f"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@swc/core": "^1.15.30",
@@ -23,7 +23,7 @@ declare class TextEncoder {
23
23
 
24
24
  declare class TextDecoder {
25
25
  constructor(label?: 'utf-8' | 'utf8')
26
- decode(input?: ArrayBufferView | ArrayBuffer, options?: {stream?: boolean}): string
26
+ decode(input?: Uint8Array, options?: {stream?: boolean}): string
27
27
  }
28
28
 
29
29
  declare class AbortError extends Error {
@@ -53,6 +53,10 @@ declare class AbortController {
53
53
  abort(reason?: unknown): void
54
54
  }
55
55
 
56
+ declare interface JSON {
57
+ parse(text: string, reviver?: (this: any, key: string, value: any) => any): unknown
58
+ }
59
+
56
60
  declare interface ImportMeta {
57
61
  readonly url: string
58
62
  readonly main: boolean
@@ -9,9 +9,7 @@ export interface RequestOptions {
9
9
  method?: string
10
10
  /** Headers as pairs or a record. Keys used as-is (no implicit case change). */
11
11
  headers?: [string, string][] | Record<string, string>
12
- /** Shortcut: stringify as JSON and set `content-type: application/json`. */
13
- json?: unknown
14
- /** Raw body. Mutually exclusive with `json`. */
12
+ /** Raw body. */
15
13
  body?: Uint8Array | string
16
14
  /** Total wallclock deadline; transport enforces. */
17
15
  timeoutMs?: number
@@ -87,21 +85,14 @@ const textEncoder = new TextEncoder()
87
85
 
88
86
  /**
89
87
  * Normalize `RequestOptions` into the byte-oriented shape a transport actually
90
- * sends: final body bytes (or null) and header pairs. Applies the `json`
91
- * shortcut (encodes + sets content-type unless already present) and
92
- * UTF-8-encodes string bodies.
88
+ * sends: final body bytes (or null) and header pairs. UTF-8-encodes string
89
+ * bodies.
93
90
  */
94
91
  export function prepareBody(opts: RequestOptions): {
95
92
  body: Uint8Array | null
96
93
  headers: [string, string][]
97
94
  } {
98
95
  const headers = normalizeHeaders(opts.headers)
99
- if (opts.json !== undefined) {
100
- if (!hasHeader(headers, 'content-type')) {
101
- headers.push(['content-type', 'application/json'])
102
- }
103
- return {body: textEncoder.encode(JSON.stringify(opts.json)), headers}
104
- }
105
96
  if (opts.body === undefined) return {body: null, headers}
106
97
  if (typeof opts.body === 'string') return {body: textEncoder.encode(opts.body), headers}
107
98
  return {body: opts.body, headers}
@@ -186,14 +177,6 @@ function normalizeHeaders(
186
177
  return out
187
178
  }
188
179
 
189
- function hasHeader(headers: [string, string][], name: string): boolean {
190
- const lower = name.toLowerCase()
191
- for (const [k] of headers) {
192
- if (k.toLowerCase() === lower) return true
193
- }
194
- return false
195
- }
196
-
197
180
  async function drain(source: AsyncIterable<Uint8Array>): Promise<Uint8Array> {
198
181
  const parts: Uint8Array[] = []
199
182
  let total = 0