@mikrojs/native 0.14.0 → 0.15.0-pr-243.20260613121220

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 (53) hide show
  1. package/dist/index.d.ts +3 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/types.d.ts +1 -1
  6. package/dist/types.d.ts.map +1 -1
  7. package/include/mikrojs/mikrojs.h +22 -1
  8. package/include/mikrojs/private.h +1 -1
  9. package/include/mikrojs/udp.h +1 -1
  10. package/package.json +2 -2
  11. package/prebuilds/darwin-arm64/mikrojs.napi.node +0 -0
  12. package/prebuilds/linux-arm64/mikrojs.napi.node +0 -0
  13. package/prebuilds/linux-x64/mikrojs.napi.node +0 -0
  14. package/runtime/ble/ble.ts +2 -2
  15. package/runtime/ble/validators.ts +1 -1
  16. package/runtime/cbor/cbor.ts +1 -1
  17. package/runtime/fs/fs.ts +2 -2
  18. package/runtime/http/helpers.ts +1 -1
  19. package/runtime/http/native.ts +2 -2
  20. package/runtime/http/request.ts +3 -3
  21. package/runtime/http/server-impl.ts +1 -1
  22. package/runtime/http/server.ts +1 -1
  23. package/runtime/i2c/i2c.ts +1 -1
  24. package/runtime/internal.d.ts +21 -21
  25. package/runtime/kv/nvs.ts +2 -2
  26. package/runtime/kv/rtc.ts +2 -2
  27. package/runtime/module/module.ts +1 -1
  28. package/runtime/neopixel/neopixel.ts +1 -1
  29. package/runtime/observable/lazy.ts +1 -1
  30. package/runtime/observable/native-observable.node-shim.ts +1 -1
  31. package/runtime/observable/observable.ts +1 -1
  32. package/runtime/observable/operators.ts +2 -2
  33. package/runtime/pin/pin.ts +3 -3
  34. package/runtime/pwm/pwm.ts +1 -1
  35. package/runtime/result/native-result.node-shim.ts +1 -1
  36. package/runtime/result/result.ts +1 -1
  37. package/runtime/sleep/sleep.ts +2 -2
  38. package/runtime/sntp/sntp.ts +2 -2
  39. package/runtime/spi/spi.ts +1 -1
  40. package/runtime/stdio/stdio.ts +1 -1
  41. package/runtime/sys/sys.ts +2 -2
  42. package/runtime/test/test.ts +2 -2
  43. package/runtime/uart/uart.ts +1 -1
  44. package/runtime/udp/udp.ts +2 -2
  45. package/runtime/wifi/wifi.ts +1 -1
  46. package/src/fs.cpp +1 -1
  47. package/src/mik_cbor.cpp +1 -1
  48. package/src/mik_observable.cpp +1 -1
  49. package/src/mik_repl.cpp +21 -45
  50. package/src/mik_result.cpp +1 -1
  51. package/src/mik_udp.cpp +1 -1
  52. package/src/mikrojs.cpp +10 -2
  53. package/src/modules.cpp +4 -1
package/dist/index.d.ts CHANGED
@@ -21,17 +21,17 @@ export declare class MikroRuntime {
21
21
  * Virtual modules are checked by the loader before builtin bytecode,
22
22
  * allowing JS-based mocks to override any native:* C module. */
23
23
  registerModuleSource(name: string, source: string): void;
24
- /** Drain all outbound messages sent from QuickJS via native:host.send().
24
+ /** Drain all outbound messages sent from QuickJS via native:mikro/host.send().
25
25
  * Returns and clears the queue. Call after each loopOnce(). */
26
26
  drainMessages(): HostMessage[];
27
27
  /** Post a message from Node.js into the QuickJS runtime.
28
- * Delivered to the native:host.onMessage() callback on the next loop tick. */
28
+ * Delivered to the native:mikro/host.onMessage() callback on the next loop tick. */
29
29
  postMessage(type: string, data: string): void;
30
30
  /** Set a preprocessor function called on module source before compilation.
31
31
  * Return a string to replace the source, or undefined to use the original.
32
32
  * Useful for stripping TypeScript types from .ts files. */
33
33
  setPreprocessor(fn: (filename: string, source: string) => string | undefined): void;
34
- /** Set a synchronous RPC handler called from QuickJS via native:host.call().
34
+ /** Set a synchronous RPC handler called from QuickJS via native:mikro/host.call().
35
35
  * The handler receives a method name (e.g. 'pin.pinMode') and JSON-encoded args,
36
36
  * and must return a JSON-encoded result string (or a Promise of one for async). */
37
37
  setRpcHandler(handler: (method: string, argsJson: string) => string | Promise<string>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../add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G;AAED,wGAAwG;AACxG,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,EAAE,GACnB,MAAM,CA4BR;AAED,YAAY,EAAC,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAC,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -62,13 +62,13 @@ export class MikroRuntime {
62
62
  registerModuleSource(name, source) {
63
63
  this.native.registerModuleSource(name, source);
64
64
  }
65
- /** Drain all outbound messages sent from QuickJS via native:host.send().
65
+ /** Drain all outbound messages sent from QuickJS via native:mikro/host.send().
66
66
  * Returns and clears the queue. Call after each loopOnce(). */
67
67
  drainMessages() {
68
68
  return this.native.drainMessages();
69
69
  }
70
70
  /** Post a message from Node.js into the QuickJS runtime.
71
- * Delivered to the native:host.onMessage() callback on the next loop tick. */
71
+ * Delivered to the native:mikro/host.onMessage() callback on the next loop tick. */
72
72
  postMessage(type, data) {
73
73
  this.native.postMessage(type, data);
74
74
  }
@@ -78,7 +78,7 @@ export class MikroRuntime {
78
78
  setPreprocessor(fn) {
79
79
  this.native.setPreprocessor(fn);
80
80
  }
81
- /** Set a synchronous RPC handler called from QuickJS via native:host.call().
81
+ /** Set a synchronous RPC handler called from QuickJS via native:mikro/host.call().
82
82
  * The handler receives a method name (e.g. 'pin.pinMode') and JSON-encoded args,
83
83
  * and must return a JSON-encoded result string (or a Promise of one for async). */
84
84
  setRpcHandler(handler) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../addon/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAU9B,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAA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EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;IAEnE,kEAAkE;IAClE,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI,GAAG,GAAG,CAAC,CAAA;IACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,GAAG,IAAI,MAAM,GAAG,CAAC,CAAC,CAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAA;QACrD,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;YAChB,GAAG,IAAI,IAAI,CAAA;YACX,GAAG,GAAG,CAAC,CAAA;QACT,CAAC;IACH,CAAC;IACD,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;QACd,GAAG,IAAI,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CACL,kEAAkE;QAClE,IAAI;QACJ,yBAAyB;QACzB,IAAI;QACJ,kBAAkB,UAAU,WAAW,GAAG,CAAC,MAAM,KAAK;QACtD,IAAI;QACJ,iBAAiB,UAAU,IAAI,GAAG,CAAC,MAAM,SAAS;QAClD,GAAG;QACH,MAAM,CACP,CAAA;AACH,CAAC"}
package/dist/types.d.ts CHANGED
@@ -6,7 +6,7 @@ export interface MikroRuntimeOptions {
6
6
  fsLimit?: number;
7
7
  fsReadMax?: number;
8
8
  env?: Record<string, string>;
9
- /** Virtual module sources to register, keyed by module name (e.g. 'native:pin'). */
9
+ /** Virtual module sources to register, keyed by module name (e.g. 'native:mikro/pin'). */
10
10
  modules?: Record<string, string>;
11
11
  }
12
12
  export interface HostMessage {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../addon/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IACl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CAAA;KAAC,CAAA;IACpD,EAAE,IAAI,IAAI,CAAA;IACV,iBAAiB,IAAI,IAAI,CAAA;IACzB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAC9D;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,KAAK,OAAO,CAAC,EAAE,mBAAmB,KAAK,kBAAkB,CAAA;IACvE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACjC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;CAClF"}
@@ -245,7 +245,7 @@ int MIK_AllocModuleSlot(MIKRuntime* mik_rt);
245
245
  typedef JSModuleDef* (*MIKModuleInitFn)(JSContext* ctx);
246
246
 
247
247
  typedef struct mik_module_desc_t {
248
- const char* name; /* module name, e.g. "native:pin" */
248
+ const char* name; /* module name, e.g. "native:mikro/pin" */
249
249
  MIKModuleInitFn init; /* called on first import; returns the JSModuleDef */
250
250
  MIKLoopConsumeFn consume; /* event loop consumer (nullable) */
251
251
  MIKLoopDestroyFn destroy; /* cleanup on shutdown (nullable) */
@@ -255,9 +255,29 @@ typedef struct mik_module_desc_t {
255
255
  extern mik_module_desc_t* mik__module_registry_head;
256
256
 
257
257
  /* NOLINTBEGIN(bugprone-macro-parentheses,cppcoreguidelines-avoid-non-const-global-variables) */
258
+ /* Namespace governance. The build defines MIK_PACKAGE_NAME for every component:
259
+ * "mikro" for the core runtime, and the owning npm package name for a discovered
260
+ * driver/board package (assigned authoritatively from the dependency graph, not
261
+ * self-declared). A native module must then be named "native:<MIK_PACKAGE_NAME>/…"
262
+ * and a registered builtin "<MIK_PACKAGE_NAME>/…". This reserves the native:
263
+ * namespace to mikro and stops a package from claiming or shadowing another's
264
+ * name. Enforced at compile time; the static_assert needs string-literal args
265
+ * (always the case here). */
266
+ #ifdef MIK_PACKAGE_NAME
267
+ #define MIK__REQUIRE_PREFIX(name_, prefix_) \
268
+ static_assert(__builtin_strncmp((name_), (prefix_), sizeof(prefix_) - 1) == 0, \
269
+ "mikrojs: name must start with \"" prefix_ "\"")
270
+ #define MIK__REQUIRE_NATIVE_NS(name_) MIK__REQUIRE_PREFIX(name_, "native:" MIK_PACKAGE_NAME "/")
271
+ #define MIK__REQUIRE_BUILTIN_NS(name_) MIK__REQUIRE_PREFIX(name_, MIK_PACKAGE_NAME "/")
272
+ #else
273
+ #define MIK__REQUIRE_NATIVE_NS(name_) static_assert(true, "")
274
+ #define MIK__REQUIRE_BUILTIN_NS(name_) static_assert(true, "")
275
+ #endif
276
+
258
277
  /* The descriptor has external linkage so the linker can be told to keep it
259
278
  * via -u flags (static symbols in static libraries get stripped). */
260
279
  #define MIK_REGISTER_MODULE(id, name_, init_, consume_, destroy_) \
280
+ MIK__REQUIRE_NATIVE_NS(name_); \
261
281
  mik_module_desc_t mik__mod_desc_##id = { \
262
282
  name_, init_, consume_, destroy_, NULL}; \
263
283
  static void __attribute__((constructor)) mik__register_mod_##id(void) { \
@@ -278,6 +298,7 @@ extern mik_ext_builtin_t* mik__ext_builtin_head;
278
298
 
279
299
  /* The descriptor has external linkage so the linker can keep it via -u flags. */
280
300
  #define MIK_REGISTER_BUILTIN(id, name_, data_, size_) \
301
+ MIK__REQUIRE_BUILTIN_NS(name_); \
281
302
  mik_ext_builtin_t mik__builtin_##id = { \
282
303
  name_, data_, size_, NULL}; \
283
304
  static void __attribute__((constructor)) mik__register_builtin_##id(void) { \
@@ -103,7 +103,7 @@ struct MIKRuntime {
103
103
  * vector and freed when removed or flushed. */
104
104
  std::vector<MIKRejectedPromise> pending_rejections;
105
105
  /* Shared prototype for Result objects ({ok, value} / {ok, error}) created
106
- * by mik__result_ok/mik__result_err and the native:result ok()/err()
106
+ * by mik__result_ok/mik__result_err and the native:mikro/result ok()/err()
107
107
  * functions. Holds .map/.mapErr/.andThen/.match/.orDefault/.orPanic +
108
108
  * Symbol.for('mikrojs.inspect'). Initialized eagerly by mik__result_init
109
109
  * and freed in MIK_FreeRuntime. */
@@ -2,6 +2,6 @@
2
2
 
3
3
  #include "quickjs.h"
4
4
 
5
- /* Register the `native:udp` module on the given context.
5
+ /* Register the `native:mikro/udp` module on the given context.
6
6
  * Called explicitly from MIK_NewRuntime (see mikrojs.cpp). */
7
7
  JSModuleDef* mik__udp_init(JSContext* ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikrojs/native",
3
- "version": "0.14.0",
3
+ "version": "0.15.0-pr-243.20260613121220",
4
4
  "description": "Mikro.js C++ runtime library and Node.js native addon",
5
5
  "keywords": [
6
6
  "esp32",
@@ -83,7 +83,7 @@
83
83
  "cmake-js": "^8.0.0",
84
84
  "node-addon-api": "^8.7.0",
85
85
  "node-gyp-build": "^4.8.4",
86
- "@mikrojs/quickjs": "0.14.0"
86
+ "@mikrojs/quickjs": "0.15.0-pr-243.20260613121220+eb4e93b"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@swc/core": "^1.15.30",
@@ -1,6 +1,6 @@
1
1
  import {lazyEvent} from 'mikro/observable/lazy'
2
2
  import {err, ok} from 'mikro/result'
3
- import {Ble as NativeBle} from 'native:ble'
3
+ import {Ble as NativeBle} from 'native:mikro/ble'
4
4
 
5
5
  import type {Result} from '../result/types.js'
6
6
  import type {
@@ -18,7 +18,7 @@ import type {
18
18
  import {parseUuid} from './uuid.js'
19
19
  import {ADV_PAYLOAD_MAX, computeAdvertisingPayloadSize, validateInterval} from './validators.js'
20
20
 
21
- // Inline constructors for the JS-side validated variants (native:ble doesn't
21
+ // Inline constructors for the JS-side validated variants (native:mikro/ble doesn't
22
22
  // emit these — they come from validateInterval, validateServices, and the
23
23
  // advertise payload-size check). Kept as `const` factories so validators.ts
24
24
  // can stay decoupled from the BleError shape for unit testing.
@@ -1,5 +1,5 @@
1
1
  // Pure validation helpers for the BLE module. Extracted so they can be
2
- // unit-tested on the host without pulling in the native `native:ble` module.
2
+ // unit-tested on the host without pulling in the native `native:mikro/ble` module.
3
3
 
4
4
  import type {AdvertiseInterval, AdvertiseOptions, BleError} from './types.js'
5
5
 
@@ -1 +1 @@
1
- export {decode, encode} from 'native:cbor'
1
+ export {decode, encode} from 'native:mikro/cbor'
package/runtime/fs/fs.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {err, ok} from 'mikro/result'
2
- import * as native from 'native:fs'
2
+ import * as native from 'native:mikro/fs'
3
3
 
4
4
  import type {Result} from '../result/types.js'
5
5
  import type {
@@ -11,7 +11,7 @@ import type {
11
11
  WriteFileOptions,
12
12
  } from './types.js'
13
13
 
14
- // native:fs emits typed FSError variants directly (see mik__fs_err_result in
14
+ // native:mikro/fs emits typed FSError variants directly (see mik__fs_err_result in
15
15
  // src/fs.cpp), including the `path` field for path-level operations. These
16
16
  // wrappers are thin pass-throughs that only exist to expose a typed public
17
17
  // API surface for mikrojs/fs.
@@ -1,5 +1,5 @@
1
1
  // Transport-agnostic HTTP request/response primitives. No dependency on
2
- // `native:http`. Apps driving HTTP through a non-lwIP transport (e.g. an
2
+ // `native:mikro/http`. Apps driving HTTP through a non-lwIP transport (e.g. an
3
3
  // LTE modem over UART) implement the `Request` type directly and reuse
4
4
  // `prepareBody` + `makeResponse` for the boring parts.
5
5
 
@@ -1,4 +1,4 @@
1
- // Internal: native:http-backed request implementation. Bundled into
1
+ // Internal: native:mikro/http-backed request implementation. Bundled into
2
2
  // http/request.js; not exposed as its own subpath. Exists as a seam so host
3
3
  // tests can inject a fake native module.
4
4
 
@@ -38,7 +38,7 @@ export interface NativeHttpModule {
38
38
  }
39
39
 
40
40
  /**
41
- * Build a `Request` function driven by a `native:http`-shaped module. Owns
41
+ * Build a `Request` function driven by a `native:mikro/http`-shaped module. Owns
42
42
  * AbortSignal listener lifecycle and total-wallclock timeout enforcement.
43
43
  *
44
44
  * Callers are responsible for releasing the native pending slot by either
@@ -1,16 +1,16 @@
1
- import * as native from 'native:http'
1
+ import * as native from 'native:mikro/http'
2
2
 
3
3
  import {createRequestFromNative} from './native.js'
4
4
 
5
5
  /**
6
- * Default HTTP request for the mikrojs runtime. Uses the ESP32 `native:http`
6
+ * Default HTTP request for the mikrojs runtime. Uses the ESP32 `native:mikro/http`
7
7
  * transport, which streams response bodies chunk-by-chunk with reader-driven
8
8
  * backpressure, integrates with `AbortSignal`, and enforces total-wallclock
9
9
  * timeouts.
10
10
  *
11
11
  * For `RequestError`, `BodyConsumedError`, `prepareBody`, `makeResponse`, or
12
12
  * any of the shared types, import from `mikrojs/http/helpers`. That subpath
13
- * has no dependency on `native:http`, so importing it from custom transports
13
+ * has no dependency on `native:mikro/http`, so importing it from custom transports
14
14
  * (e.g. an LTE modem) doesn't retain the WiFi-backed HTTP stack.
15
15
  */
16
16
  export const request = createRequestFromNative(native)
@@ -1,4 +1,4 @@
1
- // Internal: native:http_server-backed server implementation. Bundled into
1
+ // Internal: native:mikro/http_server-backed server implementation. Bundled into
2
2
  // http/server.js; not exposed as its own subpath. Exists as a seam so host
3
3
  // tests can inject a fake native module (mirrors http/native.ts for the client).
4
4
 
@@ -1,4 +1,4 @@
1
- import * as native from 'native:http_server'
1
+ import * as native from 'native:mikro/http_server'
2
2
 
3
3
  import {createServerFromNative} from './server-impl.js'
4
4
 
@@ -1,4 +1,4 @@
1
- import * as native from 'native:i2c'
1
+ import * as native from 'native:mikro/i2c'
2
2
 
3
3
  import type {Result} from '../result/types.js'
4
4
  import type {I2c as PlatformI2c, I2cError, I2cOptions} from './types.js'
@@ -15,25 +15,25 @@ declare module 'mikro/observable/lazy' {
15
15
  export {lazyEvent} from './observable/lazy.js'
16
16
  }
17
17
 
18
- declare module 'native:cbor' {
18
+ declare module 'native:mikro/cbor' {
19
19
  import type {CborError} from '@mikrojs/native/runtime/cbor/types'
20
20
  import type {Result} from 'mikro/result'
21
21
  export function encode(value: unknown): Result<Uint8Array, CborError>
22
22
  export function decode(data: Uint8Array): Result<unknown, CborError>
23
23
  }
24
24
 
25
- declare module 'native:result' {
25
+ declare module 'native:mikro/result' {
26
26
  import type {ErrResult, OkResult} from './result/types.js'
27
27
  export function ok(): OkResult<void>
28
28
  export function ok<T>(value: T): OkResult<T>
29
29
  export function err<E>(error: E): ErrResult<E>
30
30
  }
31
31
 
32
- declare module 'native:observable' {
32
+ declare module 'native:mikro/observable' {
33
33
  export {Observable} from '@mikrojs/native/runtime/observable/types'
34
34
  }
35
35
 
36
- declare module 'native:sys' {
36
+ declare module 'native:mikro/sys' {
37
37
  import type {JsMemoryUsage, ResetReason} from './sys/types.js'
38
38
  export function evalScript(code: string): Promise<{value: unknown}>
39
39
  export function memoryUsage(): {
@@ -70,7 +70,7 @@ declare module 'native:sys' {
70
70
  export const resetReason: ResetReason
71
71
  }
72
72
 
73
- declare module 'native:fs' {
73
+ declare module 'native:mikro/fs' {
74
74
  import type {DirEntry, FSError, MkdirOptions, StatResult, WriteFileOptions} from './fs/types.js'
75
75
  import type {Result} from './result/types.js'
76
76
 
@@ -108,7 +108,7 @@ declare module 'native:fs' {
108
108
  export function exists(path: string): boolean
109
109
  }
110
110
 
111
- declare module 'native:stdio' {
111
+ declare module 'native:mikro/stdio' {
112
112
  export const stdout: {
113
113
  write(output: Uint8Array | string): boolean
114
114
  flush(): void
@@ -121,7 +121,7 @@ declare module 'native:stdio' {
121
121
  }
122
122
  }
123
123
 
124
- declare module 'native:pin' {
124
+ declare module 'native:mikro/pin' {
125
125
  import type {PinError} from '@mikrojs/native/runtime/pin/types'
126
126
  import type {Result} from 'mikro/result'
127
127
  export type PinMode = 0x01 | 0x03 | 0x05
@@ -133,7 +133,7 @@ declare module 'native:pin' {
133
133
  export function analogReadMillivolts(pin: number, attenuation: number): Result<number, PinError>
134
134
  }
135
135
 
136
- declare module 'native:sleep' {
136
+ declare module 'native:mikro/sleep' {
137
137
  import type {DeepWakeupSources, LightWakeupSources} from '@mikrojs/native/runtime/sleep/types'
138
138
 
139
139
  export function deepSleep(sources: DeepWakeupSources): never
@@ -143,7 +143,7 @@ declare module 'native:sleep' {
143
143
  export function canWakeFromExt1(): boolean
144
144
  }
145
145
 
146
- declare module 'native:http' {
146
+ declare module 'native:mikro/http' {
147
147
  import type {RequestError} from 'mikro/http/helpers'
148
148
  import type {Result} from 'mikro/result'
149
149
 
@@ -165,7 +165,7 @@ declare module 'native:http' {
165
165
  export function pendingCount(): number
166
166
  }
167
167
 
168
- declare module 'native:http_server' {
168
+ declare module 'native:mikro/http_server' {
169
169
  import type {Result} from 'mikro/result'
170
170
 
171
171
  import type {ServerError} from './http/server-impl.js'
@@ -196,7 +196,7 @@ declare module 'native:http_server' {
196
196
  export function respondEnd(id: number): void
197
197
  export function getHeader(id: number, name: string): string | undefined
198
198
  }
199
- declare module 'native:i2c' {
199
+ declare module 'native:mikro/i2c' {
200
200
  import type {I2cError} from '@mikrojs/native/runtime/i2c/types'
201
201
  import type {Result} from 'mikro/result'
202
202
 
@@ -228,7 +228,7 @@ declare module 'native:i2c' {
228
228
  scan(): Result<Uint8Array, I2cError>
229
229
  }
230
230
  }
231
- declare module 'native:spi' {
231
+ declare module 'native:mikro/spi' {
232
232
  import type {SpiError} from '@mikrojs/native/runtime/spi/types'
233
233
  import type {Result} from 'mikro/result'
234
234
 
@@ -257,7 +257,7 @@ declare module 'native:spi' {
257
257
  }
258
258
  }
259
259
 
260
- declare module 'native:sntp' {
260
+ declare module 'native:mikro/sntp' {
261
261
  import type {SntpError} from '@mikrojs/native/runtime/sntp/types'
262
262
  import type {Result} from 'mikro/result'
263
263
  /**
@@ -275,7 +275,7 @@ declare module 'native:sntp' {
275
275
  export function setTimezone(tz: string): void
276
276
  }
277
277
 
278
- declare module 'native:rtc' {
278
+ declare module 'native:mikro/rtc' {
279
279
  type NRV = {ok: true} | {ok: false; error: {code: number; message: string}}
280
280
  export function set(key: string, value: unknown): NRV
281
281
  export function get(key: string): unknown
@@ -284,7 +284,7 @@ declare module 'native:rtc' {
284
284
  export function info(): {used: number; total: number; entries: number}
285
285
  }
286
286
 
287
- declare module 'native:nvs_kv' {
287
+ declare module 'native:mikro/nvs_kv' {
288
288
  type NRV = {ok: true} | {ok: false; error: {code: number; message: string}}
289
289
  export function set(key: string, value: unknown): NRV
290
290
  export function get(key: string): unknown
@@ -293,7 +293,7 @@ declare module 'native:nvs_kv' {
293
293
  export function info(): {entries: number; used: number; total: number; free: number}
294
294
  }
295
295
 
296
- declare module 'native:pwm' {
296
+ declare module 'native:mikro/pwm' {
297
297
  import type {PwmError} from '@mikrojs/native/runtime/pwm/types'
298
298
  import type {Result} from 'mikro/result'
299
299
 
@@ -310,7 +310,7 @@ declare module 'native:pwm' {
310
310
  }
311
311
  }
312
312
 
313
- declare module 'native:neopixel' {
313
+ declare module 'native:mikro/neopixel' {
314
314
  import type {NeoPixelError} from '@mikrojs/native/runtime/neopixel/types'
315
315
  import type {Result} from 'mikro/result'
316
316
 
@@ -328,7 +328,7 @@ declare module 'native:neopixel' {
328
328
  }
329
329
  }
330
330
 
331
- declare module 'native:uart' {
331
+ declare module 'native:mikro/uart' {
332
332
  import type {UartError} from '@mikrojs/native/runtime/uart/types'
333
333
  import type {Result} from 'mikro/result'
334
334
 
@@ -360,7 +360,7 @@ declare module 'native:uart' {
360
360
  }
361
361
  }
362
362
 
363
- declare module 'native:ble' {
363
+ declare module 'native:mikro/ble' {
364
364
  import type {BleError} from '@mikrojs/native/runtime/ble/types'
365
365
  import type {Result} from 'mikro/result'
366
366
 
@@ -414,7 +414,7 @@ declare module 'native:ble' {
414
414
  }
415
415
  }
416
416
 
417
- declare module 'native:wifi' {
417
+ declare module 'native:mikro/wifi' {
418
418
  import type {WifiError} from '@mikrojs/native/runtime/wifi/types'
419
419
  import type {Result} from 'mikro/result'
420
420
 
@@ -495,7 +495,7 @@ declare module 'native:wifi' {
495
495
  }
496
496
  }
497
497
 
498
- declare module 'native:udp' {
498
+ declare module 'native:mikro/udp' {
499
499
  import type {
500
500
  BindOptions,
501
501
  PeerAddress,
package/runtime/kv/nvs.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import {KVError, makeCreateValue} from 'mikro/kv/shared'
2
- import {clear, get, info, remove, set} from 'native:nvs_kv'
2
+ import {clear, get, info, remove, set} from 'native:mikro/nvs_kv'
3
3
 
4
4
  import type {NvsStorage} from './types.js'
5
5
 
6
- // Loaded in isolation: this file avoids `native:rtc`, so apps importing
6
+ // Loaded in isolation: this file avoids `native:mikro/rtc`, so apps importing
7
7
  // `mikrojs/kv/nvs` directly don't pay for the RTC backend. `KVError` and
8
8
  // `makeCreateValue` come from the shared bytecode module at runtime so
9
9
  // they aren't duplicated across nvs.js and rtc.js.
package/runtime/kv/rtc.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import {KVError, makeCreateValue} from 'mikro/kv/shared'
2
- import {clear, get, info, remove, set} from 'native:rtc'
2
+ import {clear, get, info, remove, set} from 'native:mikro/rtc'
3
3
 
4
4
  import type {RtcStorage} from './types.js'
5
5
 
6
- // Loaded in isolation: this file avoids `native:nvs_kv`, so apps importing
6
+ // Loaded in isolation: this file avoids `native:mikro/nvs_kv`, so apps importing
7
7
  // `mikrojs/kv/rtc` directly don't pay for the NVS backend. `KVError` and
8
8
  // `makeCreateValue` come from the shared bytecode module at runtime so
9
9
  // they aren't duplicated across nvs.js and rtc.js.
@@ -1,4 +1,4 @@
1
- import {isUnloadableNamespace, unloadNamespace} from 'native:sys'
1
+ import {isUnloadableNamespace, unloadNamespace} from 'native:mikro/sys'
2
2
 
3
3
  /**
4
4
  * Load a dynamically imported module, run `use` with it, then unload it and
@@ -1,4 +1,4 @@
1
- import {NeoPixel as NativeNeoPixel} from 'native:neopixel'
1
+ import {NeoPixel as NativeNeoPixel} from 'native:mikro/neopixel'
2
2
 
3
3
  import type {Result} from '../result/types.js'
4
4
  import type {NeoPixelError, NeoPixelOptions} from './types.js'
@@ -1,4 +1,4 @@
1
- import {Observable} from 'native:observable'
1
+ import {Observable} from 'native:mikro/observable'
2
2
 
3
3
  import type {Subscriber} from './types.js'
4
4
 
@@ -1,4 +1,4 @@
1
- // Host-side shim for `native:observable`, used only in vitest (Node) where
1
+ // Host-side shim for `native:mikro/observable`, used only in vitest (Node) where
2
2
  // the mikrojs C runtime isn't available. Keep in sync with mik_observable.cpp.
3
3
  //
4
4
  // Mirrors the locked design in .claude/plans/observable.md:
@@ -1 +1 @@
1
- export {Observable} from 'native:observable'
1
+ export {Observable} from 'native:mikro/observable'
@@ -17,11 +17,11 @@
17
17
  * See `.claude/plans/observable.md` for the full design.
18
18
  */
19
19
 
20
- import {Observable as NativeObservable} from 'native:observable'
20
+ import {Observable as NativeObservable} from 'native:mikro/observable'
21
21
 
22
22
  import type {Observable as ObservableT} from './types.js'
23
23
 
24
- /* `native:observable` resolves only inside the runtime build; outside
24
+ /* `native:mikro/observable` resolves only inside the runtime build; outside
25
25
  * (twoslash, host typecheck without internal.d.ts) it falls back to `any`,
26
26
  * which collapses pipe/operator inference at use sites. Pin the type to the
27
27
  * declared class in `./types.ts` so consumers always see the typed shape. */
@@ -1,11 +1,11 @@
1
- import * as native from 'native:pin'
1
+ import * as native from 'native:mikro/pin'
2
2
 
3
3
  import type {Result} from '../result/types.js'
4
4
  import type {AnalogReadOptions, Attenuation, PinError, PinMode} from './types.js'
5
5
 
6
6
  // Public mode lookup. Kept as a runtime value (rather than inlined) because
7
7
  // user code occasionally reads it to build a mode-picker UI on host-side
8
- // tooling; the native:pin layer uses the numeric constants directly.
8
+ // tooling; the native:mikro/pin layer uses the numeric constants directly.
9
9
  const PIN_MODE_INPUT = 0x01
10
10
  const PIN_MODE_OUTPUT = 0x03
11
11
  const PIN_MODE_INPUT_PULLUP = 0x05
@@ -24,7 +24,7 @@ const NativeAttenuation: Record<Attenuation, number> = {
24
24
  } as const
25
25
 
26
26
  // Wrappers translate the string/enum JS-idiom args to the numeric codes the
27
- // native layer expects. Errors flow through unchanged: native:pin returns
27
+ // native layer expects. Errors flow through unchanged: native:mikro/pin returns
28
28
  // {ok, error:{name,message}} directly (see mik_pin.cpp), so no remapping.
29
29
 
30
30
  export function pinMode(pin: number, mode: PinMode): Result<void, PinError> {
@@ -1,5 +1,5 @@
1
1
  import {ok} from 'mikro/result'
2
- import {Pwm as NativePwm} from 'native:pwm'
2
+ import {Pwm as NativePwm} from 'native:mikro/pwm'
3
3
 
4
4
  import type {Result} from '../result/types.js'
5
5
  import type {PwmError, PwmOptions} from './types.js'
@@ -1,4 +1,4 @@
1
- // Host-side shim for `native:result` used only in vitest (Node) where the
1
+ // Host-side shim for `native:mikro/result` used only in vitest (Node) where the
2
2
  // mikrojs C runtime isn't available. Keep in sync with mik_result.cpp.
3
3
 
4
4
  const proto = {
@@ -1,4 +1,4 @@
1
- export {err, ok} from 'native:result'
1
+ export {err, ok} from 'native:mikro/result'
2
2
 
3
3
  export class PanicError extends Error {
4
4
  constructor(message: string, options?: {cause?: unknown}) {
@@ -1,9 +1,9 @@
1
- import {deepSleep as nativeDeepSleep, lightSleep as nativeLightSleep} from 'native:sleep'
1
+ import {deepSleep as nativeDeepSleep, lightSleep as nativeLightSleep} from 'native:mikro/sleep'
2
2
 
3
3
  import type {DeepWakeupSources, LightWakeupSources} from './types.js'
4
4
 
5
5
  export type {DeepWakeupSources, LightWakeupSources, RtcGpio, WakeupLevel} from './types.js'
6
- export {canWakeFromExt0, canWakeFromExt1} from 'native:sleep'
6
+ export {canWakeFromExt0, canWakeFromExt1} from 'native:mikro/sleep'
7
7
 
8
8
  export function deepSleep(sources: DeepWakeupSources | number): never {
9
9
  return nativeDeepSleep(typeof sources === 'number' ? {timer: sources} : sources)
@@ -1,10 +1,10 @@
1
1
  import {err, ok} from 'mikro/result'
2
- import {setTimezone, stop as nativeStop, sync as nativeSync} from 'native:sntp'
2
+ import {setTimezone, stop as nativeStop, sync as nativeSync} from 'native:mikro/sntp'
3
3
 
4
4
  import type {Result} from '../result/types.js'
5
5
  import type {Sntp, SntpError, SntpOptions, SntpSyncResult, SntpSyncResultWithStop} from './types.js'
6
6
 
7
- // native:sntp emits `InitFailed` / `Cancelled` directly; `Timeout` is a
7
+ // native:mikro/sntp emits `InitFailed` / `Cancelled` directly; `Timeout` is a
8
8
  // JS-side variant (the Promise racer below owns the clock).
9
9
 
10
10
  const DEFAULT_SERVERS = ['pool.ntp.org']
@@ -1,4 +1,4 @@
1
- import * as native from 'native:spi'
1
+ import * as native from 'native:mikro/spi'
2
2
 
3
3
  import type {Result} from '../result/types.js'
4
4
  import type {Spi as PlatformSpi, SpiError, SpiOptions} from './types.js'
@@ -1,4 +1,4 @@
1
- import * as native from 'native:stdio'
1
+ import * as native from 'native:mikro/stdio'
2
2
 
3
3
  import type {StdIn, StdOut} from './types.js'
4
4
 
@@ -1,6 +1,6 @@
1
1
  import {err, ok, PanicError, type Result} from 'mikro/result'
2
- import {getWakeupCause as nativeGetWakeupCause} from 'native:sleep'
3
- import * as native from 'native:sys'
2
+ import {getWakeupCause as nativeGetWakeupCause} from 'native:mikro/sleep'
3
+ import * as native from 'native:mikro/sys'
4
4
 
5
5
  export function uptime(): {boot: number; rtc: number} {
6
6
  return native.uptime()
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-console */
2
2
  import {gc, memoryUsage, MonotonicTimestamp} from 'mikro/sys'
3
- import {pendingCount as pendingHttpCount} from 'native:http'
4
- import {activeTimers} from 'native:sys'
3
+ import {pendingCount as pendingHttpCount} from 'native:mikro/http'
4
+ import {activeTimers} from 'native:mikro/sys'
5
5
 
6
6
  import type {ErrResult, OkResult, Result} from '../result/types.js'
7
7
  import type {Assert, TestFn, TestOptions} from './types.js'
@@ -1,5 +1,5 @@
1
1
  import {ok} from 'mikro/result'
2
- import * as native from 'native:uart'
2
+ import * as native from 'native:mikro/uart'
3
3
 
4
4
  import type {Result} from '../result/types.js'
5
5
  import type {
@@ -1,6 +1,6 @@
1
1
  import {ok} from 'mikro/result'
2
- import {Observable} from 'native:observable'
3
- import {bind as nativeBind, type NativeUdpSocket} from 'native:udp'
2
+ import {Observable} from 'native:mikro/observable'
3
+ import {bind as nativeBind, type NativeUdpSocket} from 'native:mikro/udp'
4
4
 
5
5
  import type {Subscriber} from '../observable/types.js'
6
6
  import type {Result} from '../result/types.js'
@@ -1,6 +1,6 @@
1
1
  import {lazyEvent} from 'mikro/observable/lazy'
2
2
  import {err, ok} from 'mikro/result'
3
- import {Wifi as NativeWifi} from 'native:wifi'
3
+ import {Wifi as NativeWifi} from 'native:mikro/wifi'
4
4
 
5
5
  import type {Result} from '../result/types.js'
6
6
  import type {
package/src/fs.cpp CHANGED
@@ -869,7 +869,7 @@ void mik__pub_fs_register(JSContext* ctx) {
869
869
  JS_SetPropertyFunctionList(ctx, proto, mik_file_proto_funcs, countof(mik_file_proto_funcs));
870
870
  JS_SetClassProto(ctx, mik_file_class_id, proto);
871
871
 
872
- JSModuleDef* m = JS_NewCModule(ctx, "native:fs", mik__pub_fs_module_init);
872
+ JSModuleDef* m = JS_NewCModule(ctx, "native:mikro/fs", mik__pub_fs_module_init);
873
873
  if (m) {
874
874
  for (size_t i = 0; i < countof(pub_fs_exports); i++) {
875
875
  JS_AddModuleExport(ctx, m, pub_fs_exports[i]);
package/src/mik_cbor.cpp CHANGED
@@ -322,7 +322,7 @@ static int mik__cbor_module_init(JSContext* ctx, JSModuleDef* m) {
322
322
  }
323
323
 
324
324
  JSModuleDef* mik__cbor_init(JSContext* ctx) {
325
- JSModuleDef* m = JS_NewCModule(ctx, "native:cbor", mik__cbor_module_init);
325
+ JSModuleDef* m = JS_NewCModule(ctx, "native:mikro/cbor", mik__cbor_module_init);
326
326
  if (!m) return nullptr;
327
327
  JS_AddModuleExport(ctx, m, "encode");
328
328
  JS_AddModuleExport(ctx, m, "decode");
@@ -943,7 +943,7 @@ JSModuleDef* mik__observable_init(JSContext* ctx) {
943
943
  JS_NewClassID(rt, &multicast_class_id);
944
944
  JS_NewClass(rt, multicast_class_id, &multicast_class_def);
945
945
 
946
- JSModuleDef* m = JS_NewCModule(ctx, "native:observable", observable_module_init);
946
+ JSModuleDef* m = JS_NewCModule(ctx, "native:mikro/observable", observable_module_init);
947
947
  if (!m) return nullptr;
948
948
  JS_AddModuleExport(ctx, m, "Observable");
949
949
  return m;
package/src/mik_repl.cpp CHANGED
@@ -25,7 +25,6 @@ static JSContext* repl_ctx = nullptr;
25
25
  static MIKRuntime* repl_mik_rt = nullptr;
26
26
  static int show_depth = 2;
27
27
  static bool show_hidden = false;
28
- static bool show_time = false;
29
28
 
30
29
  /* ── Protocol mode state ─────────────────────────────────────────── */
31
30
 
@@ -285,6 +284,15 @@ static JSValue repl_eval_and_pump(JSContext* ctx, const char* code, size_t len)
285
284
  }
286
285
  }
287
286
 
287
+ /* Emit eval duration (since t0) as a PROMPT message; the CLI renders it on the
288
+ * result line when timing display is enabled. */
289
+ static void repl_send_timing(MIKReplTransport* transport, int64_t t0) {
290
+ int64_t elapsed = MIK_GetPlatform()->get_boot_us() - t0;
291
+ char timing[32];
292
+ int tlen = snprintf(timing, sizeof(timing), "%.1fms", (double)elapsed / 1000.0);
293
+ mik__proto_send(transport, MIK_MSG_PROMPT, timing, tlen);
294
+ }
295
+
288
296
  /* ── Tab completion ──────────────────────────────────────────────── */
289
297
 
290
298
  static constexpr int MAX_COMPLETIONS = 32;
@@ -315,10 +323,10 @@ static void completion_callback(CompletionBuf& cb, int argc, const char* const*
315
323
 
316
324
  /* Check for directive completion */
317
325
  if (argc == 1 && last_token[0] == '/') {
318
- static const char* directives[] = {"/help", "/mem", "/gc", "/exit",
319
- "/ls", "/cat", "/rm", "/time",
320
- "/depth", "/hidden", "/df", "/du",
321
- "/pause", "/resume", "/info"};
326
+ static const char* directives[] = {"/help", "/mem", "/gc", "/exit",
327
+ "/ls", "/cat", "/rm", "/depth",
328
+ "/hidden", "/df", "/du", "/pause",
329
+ "/resume", "/info"};
322
330
  size_t tok_len = strlen(last_token);
323
331
  for (size_t i = 0; i < countof(directives); i++) {
324
332
  if (strncmp(directives[i], last_token, tok_len) == 0) {
@@ -431,7 +439,6 @@ static bool handle_directive_impl(JSContext* ctx, const char* line, std::string&
431
439
  "/help Show this help\n"
432
440
  "/mem Show heap memory usage\n"
433
441
  "/gc Run garbage collector\n"
434
- "/time Toggle timing display\n"
435
442
  "/depth N Set object inspection depth (default 2)\n"
436
443
  "/hidden Toggle hidden property display\n"
437
444
  "/pause Pause app (suspend timers/callbacks)\n"
@@ -562,12 +569,6 @@ static bool handle_directive_impl(JSContext* ctx, const char* line, std::string&
562
569
  return true;
563
570
  }
564
571
 
565
- if (strcmp(line, "/time") == 0) {
566
- show_time = !show_time;
567
- dir_printf(out, "Timing %s\n", show_time ? "on" : "off");
568
- return true;
569
- }
570
-
571
572
  if (strncmp(line, "/depth", 6) == 0) {
572
573
  const char* arg = line + 6;
573
574
  while (*arg == ' ') arg++;
@@ -884,7 +885,6 @@ void MIK_ProtocolOpen(MIKReplTransport* transport) {
884
885
  repl_active = true;
885
886
  show_depth = 2;
886
887
  show_hidden = false;
887
- show_time = false;
888
888
 
889
889
  /* Build MSG_READY with CBOR device info: {"chip": tstr, "id": tstr, "v": tstr}.
890
890
  * Cached here and only emitted in response to a client CMD_HELLO so a
@@ -985,10 +985,7 @@ void MIK_ProtocolServeLoop(void) {
985
985
  std::string code = repl_rewrite_const_let(payload.c_str());
986
986
  code = repl_maybe_wrap_object(code);
987
987
 
988
- int64_t t0 = 0;
989
- if (show_time) {
990
- t0 = platform->get_boot_us();
991
- }
988
+ int64_t t0 = platform->get_boot_us();
992
989
 
993
990
  repl_evaluating = true;
994
991
  repl_async_skipped = false;
@@ -1045,15 +1042,8 @@ void MIK_ProtocolServeLoop(void) {
1045
1042
 
1046
1043
  JS_FreeValue(ctx, exc);
1047
1044
 
1048
- /* Send timing before error so CLI can attach it to the input echo */
1049
- if (show_time) {
1050
- int64_t elapsed = platform->get_boot_us() - t0;
1051
- char timing[64];
1052
- int tlen =
1053
- snprintf(timing, sizeof(timing), "%.1fms", (double)elapsed / 1000.0);
1054
- mik__proto_send(transport, MIK_MSG_PROMPT, timing, tlen);
1055
- }
1056
-
1045
+ /* Timing precedes the error so the CLI can render it on that line. */
1046
+ repl_send_timing(transport, t0);
1057
1047
  mik__proto_send(transport, MIK_MSG_EVAL_ERROR, msg.c_str(), msg.size());
1058
1048
  } else if (!JS_IsUndefined(result)) {
1059
1049
  std::string inspected = mik_inspect(ctx, result, show_depth, false, show_hidden);
@@ -1063,28 +1053,14 @@ void MIK_ProtocolServeLoop(void) {
1063
1053
  JS_SetPropertyStr(ctx, global, "_", JS_DupValue(ctx, result));
1064
1054
  JS_FreeValue(ctx, global);
1065
1055
 
1066
- /* Send timing before result so CLI can attach it to the input echo */
1067
- if (show_time) {
1068
- int64_t elapsed = platform->get_boot_us() - t0;
1069
- char timing[64];
1070
- int tlen =
1071
- snprintf(timing, sizeof(timing), "%.1fms", (double)elapsed / 1000.0);
1072
- mik__proto_send(transport, MIK_MSG_PROMPT, timing, tlen);
1073
- }
1074
-
1056
+ /* Timing precedes the result so the CLI can render it on that line. */
1057
+ repl_send_timing(transport, t0);
1075
1058
  mik__proto_send(transport, MIK_MSG_RESULT, inspected.c_str(),
1076
1059
  inspected.size());
1077
1060
  } else {
1078
- /* Send timing before empty result */
1079
- if (show_time) {
1080
- int64_t elapsed = platform->get_boot_us() - t0;
1081
- char timing[64];
1082
- int tlen =
1083
- snprintf(timing, sizeof(timing), "%.1fms", (double)elapsed / 1000.0);
1084
- mik__proto_send(transport, MIK_MSG_PROMPT, timing, tlen);
1085
- }
1086
-
1087
- /* undefined result — send empty result so CLI knows eval finished */
1061
+ /* undefined result — send timing then an empty result so the CLI
1062
+ * knows the eval finished. */
1063
+ repl_send_timing(transport, t0);
1088
1064
  mik__proto_send(transport, MIK_MSG_RESULT, nullptr, 0);
1089
1065
  }
1090
1066
 
@@ -336,7 +336,7 @@ JSModuleDef* mik__result_init(JSContext* ctx) {
336
336
  rt->result_ok_void_singleton = singleton;
337
337
  }
338
338
 
339
- JSModuleDef* m = JS_NewCModule(ctx, "native:result", mik__result_module_init);
339
+ JSModuleDef* m = JS_NewCModule(ctx, "native:mikro/result", mik__result_module_init);
340
340
  if (!m) return nullptr;
341
341
  JS_AddModuleExport(ctx, m, "ok");
342
342
  JS_AddModuleExport(ctx, m, "err");
package/src/mik_udp.cpp CHANGED
@@ -777,7 +777,7 @@ JSModuleDef* mik__udp_init(JSContext* ctx) {
777
777
  JS_NewClassID(rt, &udp_socket_class_id);
778
778
  JS_NewClass(rt, udp_socket_class_id, &mik__udp_socket_class);
779
779
 
780
- JSModuleDef* m = JS_NewCModule(ctx, "native:udp", mik__udp_module_init);
780
+ JSModuleDef* m = JS_NewCModule(ctx, "native:mikro/udp", mik__udp_module_init);
781
781
  if (!m) return nullptr;
782
782
  JS_AddModuleExport(ctx, m, "bind");
783
783
  return m;
package/src/mikrojs.cpp CHANGED
@@ -357,7 +357,7 @@ MIKRuntime* MIK_NewRuntimeInternal(MIKRunOptions* options) {
357
357
  JS_SetHostPromiseRejectionTracker(rt, mik__promise_rejection_tracker, NULL);
358
358
 
359
359
  /* Register internal C modules */
360
- JSModuleDef* sys_mod = JS_NewCModule(ctx, "native:sys", mik__sys_module_init);
360
+ JSModuleDef* sys_mod = JS_NewCModule(ctx, "native:mikro/sys", mik__sys_module_init);
361
361
  CHECK_NOT_NULL(sys_mod);
362
362
  mik__add_exports(ctx, sys_mod, sys_exports, countof(sys_exports));
363
363
 
@@ -381,7 +381,7 @@ MIKRuntime* MIK_NewRuntimeInternal(MIKRunOptions* options) {
381
381
  mod.init_fn(ctx);
382
382
  }
383
383
 
384
- JSModuleDef* stdio_mod = JS_NewCModule(ctx, "native:stdio", mik__stdio_module_init);
384
+ JSModuleDef* stdio_mod = JS_NewCModule(ctx, "native:mikro/stdio", mik__stdio_module_init);
385
385
  CHECK_NOT_NULL(stdio_mod);
386
386
  mik__add_exports(ctx, stdio_mod, stdio_exports, countof(stdio_exports));
387
387
 
@@ -544,6 +544,14 @@ int MIK_AllocModuleSlot(MIKRuntime* mik_rt) {
544
544
 
545
545
  static void mik__check_module_collisions(void) {
546
546
  for (mik_module_desc_t* a = mik__module_registry_head; a != nullptr; a = a->next) {
547
+ /* Every native: name must be package-qualified ("native:<package>/…").
548
+ * The compile-time macro enforces this when MIK_PACKAGE_NAME is set;
549
+ * this catches a registration that bypassed it (e.g. a hand-rolled
550
+ * driver), so an unqualified name can't squat the bare namespace. */
551
+ if (strncmp(a->name, "native:", 7) == 0 && strchr(a->name + 7, '/') == nullptr) {
552
+ fprintf(stderr, "FATAL: native module name not package-qualified: \"%s\"\n", a->name);
553
+ abort();
554
+ }
547
555
  for (mik_module_desc_t* b = a->next; b != nullptr; b = b->next) {
548
556
  if (strcmp(a->name, b->name) == 0) {
549
557
  fprintf(stderr, "FATAL: native module name collision: \"%s\"\n", a->name);
package/src/modules.cpp CHANGED
@@ -693,7 +693,10 @@ static char* mik__module_normalizer_impl(JSContext* ctx, const char* base_name,
693
693
  static const char internal_prefix[] = "native:";
694
694
  if (strncmp(name, internal_prefix, strlen(internal_prefix)) == 0) {
695
695
  // Only firmware-embedded modules (native:, mikro/, @mikrojs/, registered
696
- // external builtins) may import native: internals
696
+ // external builtins) may import native: internals. A builtin may import
697
+ // any native: module, including another package's — native-level
698
+ // composition (e.g. an audio driver reusing a codec package's bindings)
699
+ // is intentionally allowed.
697
700
  if (strncmp(base_name, "native:", 7) != 0 && strncmp(base_name, "mikro/", 6) != 0 &&
698
701
  strncmp(base_name, "@mikrojs/", 9) != 0 && !mik__is_ext_builtin_name(base_name)) {
699
702
  JS_ThrowTypeError(