@mikrojs/native 0.10.0-pr-134.gc6ec955 → 0.10.0

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/CMakeLists.txt CHANGED
@@ -82,8 +82,8 @@ include(cmake/mikrojs_bytecode.cmake)
82
82
  mikrojs_generate_bytecode(
83
83
  RUNTIME_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime"
84
84
  MODULES cbor env result schema fs http/helpers http/request i2c kv/nvs kv/rtc kv/shared module neopixel observable observable/lazy observable/operators pin pwm reader sleep spi sntp stdio stream sys test uart udp wifi
85
- MODULE_PREFIX "mikrojs"
86
- SYMBOL_PREFIX "mikrojs"
85
+ MODULE_PREFIX "mikro"
86
+ SYMBOL_PREFIX "mikro"
87
87
  TARGET gen_bytecode
88
88
  )
89
89
  add_dependencies(mikrojs gen_bytecode)
@@ -7,7 +7,7 @@
7
7
  # mikrojs_generate_bytecode(
8
8
  # RUNTIME_DIR <path> # Directory containing <mod>/<mod>.ts files
9
9
  # MODULES <mod1> <mod2> # Module names to compile
10
- # MODULE_PREFIX <prefix> # Module name prefix (e.g. "mikrojs" -> "mikrojs/pin")
10
+ # MODULE_PREFIX <prefix> # Module name prefix (e.g. "mikro" -> "mikro/pin")
11
11
  # SYMBOL_PREFIX <prefix> # C symbol prefix (e.g. "mikrojs" -> "mikrojs_pin_bytecode")
12
12
  # TARGET <name> # Custom target name (default: gen_bytecode)
13
13
  # WORKING_DIRECTORY <dir> # Working dir for esbuild (default: CMAKE_CURRENT_SOURCE_DIR)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikrojs/native",
3
- "version": "0.10.0-pr-134.gc6ec955",
3
+ "version": "0.10.0",
4
4
  "description": "Mikro.js C++ runtime library and Node.js native addon",
5
5
  "keywords": [
6
6
  "esp32",
@@ -9,15 +9,15 @@
9
9
  "quickjs",
10
10
  "runtime"
11
11
  ],
12
- "homepage": "https://github.com/mikrojs/mikrojs#readme",
12
+ "homepage": "https://github.com/mikrojs/mikro#readme",
13
13
  "bugs": {
14
- "url": "https://github.com/mikrojs/mikrojs/issues"
14
+ "url": "https://github.com/mikrojs/mikro/issues"
15
15
  },
16
16
  "license": "MIT",
17
17
  "author": "Bjørge Næss <bjoerge@gmail.com>",
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "git+https://github.com/mikrojs/mikrojs.git"
20
+ "url": "git+https://github.com/mikrojs/mikro.git"
21
21
  },
22
22
  "files": [
23
23
  "dist",
@@ -79,7 +79,7 @@
79
79
  "cmake-js": "^8.0.0",
80
80
  "node-addon-api": "^8.7.0",
81
81
  "node-gyp-build": "^4.8.4",
82
- "@mikrojs/quickjs": "0.10.0-pr-134.gc6ec955"
82
+ "@mikrojs/quickjs": "0.10.0"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@swc/core": "^1.15.30",
@@ -1,5 +1,5 @@
1
- import {lazyEvent} from 'mikrojs/observable/lazy'
2
- import {err, ok} from 'mikrojs/result'
1
+ import {lazyEvent} from 'mikro/observable/lazy'
2
+ import {err, ok} from 'mikro/result'
3
3
  import {Ble as NativeBle} from 'native:ble'
4
4
 
5
5
  import type {Result} from '../result/types.js'
package/runtime/fs/fs.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {err, ok} from 'mikrojs/result'
1
+ import {err, ok} from 'mikro/result'
2
2
  import * as native from 'native:fs'
3
3
 
4
4
  import type {Result} from '../result/types.js'
@@ -3,7 +3,7 @@
3
3
  // LTE modem over UART) implement the `Request` type directly and reuse
4
4
  // `prepareBody` + `makeResponse` for the boring parts.
5
5
 
6
- import {err, ok} from 'mikrojs/result'
6
+ import {err, ok} from 'mikro/result'
7
7
 
8
8
  import type {Result} from '../result/types.js'
9
9
 
@@ -8,8 +8,8 @@ import {
8
8
  type Request,
9
9
  RequestError,
10
10
  type RequestOptions,
11
- } from 'mikrojs/http/helpers'
12
- import {err, ok} from 'mikrojs/result'
11
+ } from 'mikro/http/helpers'
12
+ import {err, ok} from 'mikro/result'
13
13
 
14
14
  import type {ErrResult, Result} from '../result/types.js'
15
15
 
@@ -4,20 +4,20 @@ type NR<T> = {ok: true; value: T} | {ok: false; error: {code: number; message: s
4
4
 
5
5
  // Internal shared runtime modules. Registered as builtins so sibling bundles
6
6
  // can reference them at runtime to dedupe shared code, but not exposed via
7
- // the public `mikrojs/*` subpath exports so user apps can't accidentally
7
+ // the public `mikro/*` subpath exports so user apps can't accidentally
8
8
  // import them. Keep these in sync with the MODULES list in the firmware +
9
9
  // @mikrojs/native CMakeLists.
10
- declare module 'mikrojs/kv/shared' {
10
+ declare module 'mikro/kv/shared' {
11
11
  export {KVError, makeCreateValue, type NativeKvFns} from './kv/shared.js'
12
12
  }
13
13
 
14
- declare module 'mikrojs/observable/lazy' {
14
+ declare module 'mikro/observable/lazy' {
15
15
  export {lazyEvent} from './observable/lazy.js'
16
16
  }
17
17
 
18
18
  declare module 'native:cbor' {
19
19
  import type {CborError} from '@mikrojs/native/runtime/cbor/types'
20
- import type {Result} from 'mikrojs/result'
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
  }
@@ -122,7 +122,7 @@ declare module 'native:stdio' {
122
122
 
123
123
  declare module 'native:pin' {
124
124
  import type {PinError} from '@mikrojs/native/runtime/pin/types'
125
- import type {Result} from 'mikrojs/result'
125
+ import type {Result} from 'mikro/result'
126
126
  export type PinMode = 0x01 | 0x03 | 0x05
127
127
  export function pinMode(pin: number, value: PinMode): Result<void, PinError>
128
128
  export function digitalWrite(pin: number, value: 0 | 1): Result<void, PinError>
@@ -143,8 +143,8 @@ declare module 'native:sleep' {
143
143
  }
144
144
 
145
145
  declare module 'native:http' {
146
- import type {RequestError} from 'mikrojs/http/helpers'
147
- import type {Result} from 'mikrojs/result'
146
+ import type {RequestError} from 'mikro/http/helpers'
147
+ import type {Result} from 'mikro/result'
148
148
 
149
149
  import type {ErrResult} from './result/types.js'
150
150
  type HeadersMsg = {status: number; headers: [string, string][]}
@@ -165,7 +165,7 @@ declare module 'native:http' {
165
165
  }
166
166
  declare module 'native:i2c' {
167
167
  import type {I2cError} from '@mikrojs/native/runtime/i2c/types'
168
- import type {Result} from 'mikrojs/result'
168
+ import type {Result} from 'mikro/result'
169
169
 
170
170
  export interface I2cBaseOptions {
171
171
  freq?: number
@@ -197,7 +197,7 @@ declare module 'native:i2c' {
197
197
  }
198
198
  declare module 'native:spi' {
199
199
  import type {SpiError} from '@mikrojs/native/runtime/spi/types'
200
- import type {Result} from 'mikrojs/result'
200
+ import type {Result} from 'mikro/result'
201
201
 
202
202
  export interface SpiOptions {
203
203
  clk: number
@@ -226,7 +226,7 @@ declare module 'native:spi' {
226
226
 
227
227
  declare module 'native:sntp' {
228
228
  import type {SntpError} from '@mikrojs/native/runtime/sntp/types'
229
- import type {Result} from 'mikrojs/result'
229
+ import type {Result} from 'mikro/result'
230
230
  /**
231
231
  * Native errors: the outer Result covers init/config failures (InitFailed);
232
232
  * the inner Result on resolve covers post-start errors (Cancelled).
@@ -262,7 +262,7 @@ declare module 'native:nvs_kv' {
262
262
 
263
263
  declare module 'native:pwm' {
264
264
  import type {PwmError} from '@mikrojs/native/runtime/pwm/types'
265
- import type {Result} from 'mikrojs/result'
265
+ import type {Result} from 'mikro/result'
266
266
 
267
267
  export declare const Pwm: {
268
268
  prototype: Pwm
@@ -279,7 +279,7 @@ declare module 'native:pwm' {
279
279
 
280
280
  declare module 'native:neopixel' {
281
281
  import type {NeoPixelError} from '@mikrojs/native/runtime/neopixel/types'
282
- import type {Result} from 'mikrojs/result'
282
+ import type {Result} from 'mikro/result'
283
283
 
284
284
  export declare const NeoPixel: {
285
285
  prototype: NeoPixel
@@ -297,7 +297,7 @@ declare module 'native:neopixel' {
297
297
 
298
298
  declare module 'native:uart' {
299
299
  import type {UartError} from '@mikrojs/native/runtime/uart/types'
300
- import type {Result} from 'mikrojs/result'
300
+ import type {Result} from 'mikro/result'
301
301
 
302
302
  export interface UartOptions {
303
303
  tx?: number
@@ -329,7 +329,7 @@ declare module 'native:uart' {
329
329
 
330
330
  declare module 'native:ble' {
331
331
  import type {BleError} from '@mikrojs/native/runtime/ble/types'
332
- import type {Result} from 'mikrojs/result'
332
+ import type {Result} from 'mikro/result'
333
333
 
334
334
  type R<T> = Result<T, BleError>
335
335
 
@@ -383,7 +383,7 @@ declare module 'native:ble' {
383
383
 
384
384
  declare module 'native:wifi' {
385
385
  import type {WifiError} from '@mikrojs/native/runtime/wifi/types'
386
- import type {Result} from 'mikrojs/result'
386
+ import type {Result} from 'mikro/result'
387
387
 
388
388
  type R<T> = Result<T, WifiError>
389
389
 
@@ -469,7 +469,7 @@ declare module 'native:udp' {
469
469
  UdpError,
470
470
  UdpFamily,
471
471
  } from '@mikrojs/native/runtime/udp/types'
472
- import type {Result} from 'mikrojs/result'
472
+ import type {Result} from 'mikro/result'
473
473
 
474
474
  export interface NativeUdpSocket {
475
475
  readonly port: number
package/runtime/kv/nvs.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {KVError, makeCreateValue} from 'mikrojs/kv/shared'
1
+ import {KVError, makeCreateValue} from 'mikro/kv/shared'
2
2
  import {clear, get, info, remove, set} from 'native:nvs_kv'
3
3
 
4
4
  import type {NvsStorage} from './types.js'
package/runtime/kv/rtc.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {KVError, makeCreateValue} from 'mikrojs/kv/shared'
1
+ import {KVError, makeCreateValue} from 'mikro/kv/shared'
2
2
  import {clear, get, info, remove, set} from 'native:rtc'
3
3
 
4
4
  import type {RtcStorage} from './types.js'
@@ -1,7 +1,7 @@
1
- import {err, ok} from 'mikrojs/result'
1
+ import {err, ok} from 'mikro/result'
2
2
  // Typed loosely to avoid deep type instantiation from Infer<S> in parse's generics.
3
3
  // Type safety is provided by the storage interface overloads in types.ts.
4
- import {parse as _parse} from 'mikrojs/schema'
4
+ import {parse as _parse} from 'mikro/schema'
5
5
 
6
6
  import type {NativeError} from '../result/types.js'
7
7
 
@@ -1,4 +1,4 @@
1
- import {ok} from 'mikrojs/result'
1
+ import {ok} from 'mikro/result'
2
2
  import {Pwm as NativePwm} from 'native:pwm'
3
3
 
4
4
  import type {Result} from '../result/types.js'
@@ -9,7 +9,7 @@
9
9
  * lazy-load efficiency.
10
10
  */
11
11
 
12
- import {err, ok} from 'mikrojs/result'
12
+ import {err, ok} from 'mikro/result'
13
13
 
14
14
  import type {Result} from '../result/types.js'
15
15
 
@@ -7,7 +7,7 @@
7
7
  * `packages/mikrojs` and by user apps via their tsconfig.
8
8
  */
9
9
 
10
- import type {Result} from 'mikrojs/result'
10
+ import type {Result} from 'mikro/result'
11
11
 
12
12
  export type ReaderError = {name: 'Timeout'; ms: number} | {name: 'StreamClosed'}
13
13
 
@@ -1,4 +1,4 @@
1
- import {err, ok} from 'mikrojs/result'
1
+ import {err, ok} from 'mikro/result'
2
2
 
3
3
  import type {Result} from '../result/types.js'
4
4
 
@@ -1,4 +1,4 @@
1
- import {err, ok} from 'mikrojs/result'
1
+ import {err, ok} from 'mikro/result'
2
2
  import {setTimezone, stop as nativeStop, sync as nativeSync} from 'native:sntp'
3
3
 
4
4
  import type {Result} from '../result/types.js'
@@ -14,7 +14,7 @@
14
14
  * Expand only when a second call site asks for it.
15
15
  */
16
16
 
17
- import {err, ok} from 'mikrojs/result'
17
+ import {err, ok} from 'mikro/result'
18
18
 
19
19
  import type {Result} from '../result/types.js'
20
20
 
@@ -11,7 +11,7 @@
11
11
  * errors widen the error type with a `StreamError` variant.
12
12
  */
13
13
 
14
- import type {Result} from 'mikrojs/result'
14
+ import type {Result} from 'mikro/result'
15
15
 
16
16
  export type StreamError = {name: 'Timeout'; ms: number} | {name: 'StreamClosed'}
17
17
 
@@ -1,4 +1,4 @@
1
- import {err, ok, PanicError, type Result} from 'mikrojs/result'
1
+ import {err, ok, PanicError, type Result} from 'mikro/result'
2
2
  import {getWakeupCause as nativeGetWakeupCause} from 'native:sleep'
3
3
  import * as native from 'native:sys'
4
4
 
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-console */
2
- import {gc, memoryUsage, MonotonicTimestamp} from 'mikrojs/sys'
2
+ import {gc, memoryUsage, MonotonicTimestamp} from 'mikro/sys'
3
3
  import {pendingCount as pendingHttpCount} from 'native:http'
4
4
  import {activeTimers} from 'native:sys'
5
5
 
@@ -1,4 +1,4 @@
1
- import {ok} from 'mikrojs/result'
1
+ import {ok} from 'mikro/result'
2
2
  import * as native from 'native:uart'
3
3
 
4
4
  import type {Result} from '../result/types.js'
@@ -1,4 +1,4 @@
1
- import {ok} from 'mikrojs/result'
1
+ import {ok} from 'mikro/result'
2
2
  import {Observable} from 'native:observable'
3
3
  import {bind as nativeBind, type NativeUdpSocket} from 'native:udp'
4
4
 
@@ -1,5 +1,5 @@
1
- import {lazyEvent} from 'mikrojs/observable/lazy'
2
- import {err, ok} from 'mikrojs/result'
1
+ import {lazyEvent} from 'mikro/observable/lazy'
2
+ import {err, ok} from 'mikro/result'
3
3
  import {Wifi as NativeWifi} from 'native:wifi'
4
4
 
5
5
  import type {Result} from '../result/types.js'
@@ -104,7 +104,7 @@ for (const name of moduleNames) {
104
104
  target: 'es2024',
105
105
  platform: 'neutral',
106
106
  format: 'esm',
107
- external: ['mikrojs', 'mikrojs/*', '@mikrojs/*', 'native:*'],
107
+ external: ['mikro', 'mikro/*', '@mikrojs/*', 'native:*'],
108
108
  })
109
109
 
110
110
  const output = result.outputFiles?.[0]
@@ -128,7 +128,7 @@ for (const name of moduleNames) {
128
128
  // Extract external imports so CMake can pass them as -M flags to qjsc
129
129
  const externals = []
130
130
  for (const match of source.matchAll(
131
- /(?:from|import)\s*["']((?:native:|mikrojs\/|@mikrojs\/)[^"']+)["']/g,
131
+ /(?:from|import)\s*["']((?:native:|mikro\/|@mikrojs\/)[^"']+)["']/g,
132
132
  )) {
133
133
  externals.push(match[1])
134
134
  }
package/src/builtins.cpp CHANGED
@@ -14,8 +14,8 @@ typedef struct {
14
14
 
15
15
  /* Generated by mikrojs_generate_bytecode() in CMake — includes + lookup table.
16
16
  * Adding a new module only requires updating the MODULES list in CMakeLists.txt. */
17
- #include "gen/mikrojs_builtins_table.h"
18
- #define builtins mikrojs_builtins
17
+ #include "gen/mikro_builtins_table.h"
18
+ #define builtins mikro_builtins
19
19
 
20
20
  /* External builtins registered by board/driver packages via MIK_REGISTER_BUILTIN() */
21
21
  // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
package/src/modules.cpp CHANGED
@@ -200,7 +200,7 @@ static JSModuleDef* mik_module_load_from_fs(JSContext* ctx, const char* module_n
200
200
 
201
201
  static JSModuleDef* mik_module_loader_inner(JSContext* ctx, const char* module_name,
202
202
  void* opaque) {
203
- static const char mikrojs_prefix[] = "mikrojs/";
203
+ static const char mikro_prefix[] = "mikro/";
204
204
 
205
205
  /* Virtual modules take priority over builtins — allows host-side JS to
206
206
  * override any native:* C module (e.g. mocking device modules for dev). */
@@ -239,7 +239,7 @@ static JSModuleDef* mik_module_loader_inner(JSContext* ctx, const char* module_n
239
239
  return nullptr;
240
240
  }
241
241
 
242
- if (strncmp(mikrojs_prefix, module_name, strlen(mikrojs_prefix)) == 0) {
242
+ if (strncmp(mikro_prefix, module_name, strlen(mikro_prefix)) == 0) {
243
243
  JSModuleDef* builtin_m = mik__load_builtin(ctx, module_name);
244
244
  if (builtin_m) return builtin_m;
245
245
  /* mik__load_builtin returns NULL either because the module isn't in
@@ -655,11 +655,11 @@ static char* mik__resolve_node_modules(JSContext* ctx, const char* base_dir,
655
655
  return NULL;
656
656
  }
657
657
 
658
- /* Anchored names (native:, mikrojs/, @mikrojs/) are never unloaded
658
+ /* Anchored names (native:, mikro/, @mikrojs/) are never unloaded
659
659
  * and don't contribute meaningfully to the import graph for orphan
660
660
  * detection. We skip recording edges where the target is anchored. */
661
661
  static bool mik__is_anchored_name(const char* name) {
662
- return strncmp(name, "native:", 7) == 0 || strncmp(name, "mikrojs/", 8) == 0 ||
662
+ return strncmp(name, "native:", 7) == 0 || strncmp(name, "mikro/", 6) == 0 ||
663
663
  strncmp(name, "@mikrojs/", 9) == 0;
664
664
  }
665
665
 
@@ -683,8 +683,8 @@ static char* mik__module_normalizer_impl(JSContext* ctx, const char* base_name,
683
683
 
684
684
  static const char internal_prefix[] = "native:";
685
685
  if (strncmp(name, internal_prefix, strlen(internal_prefix)) == 0) {
686
- // Only built-in modules (native:, mikrojs/, @mikrojs/) may import native: internals
687
- if (strncmp(base_name, "native:", 7) != 0 && strncmp(base_name, "mikrojs/", 8) != 0 &&
686
+ // Only built-in modules (native:, mikro/, @mikrojs/) may import native: internals
687
+ if (strncmp(base_name, "native:", 7) != 0 && strncmp(base_name, "mikro/", 6) != 0 &&
688
688
  strncmp(base_name, "@mikrojs/", 9) != 0) {
689
689
  JS_ThrowTypeError(ctx, "Failed to resolve module specifier '%s'", name);
690
690
  return NULL;
@@ -693,7 +693,7 @@ static char* mik__module_normalizer_impl(JSContext* ctx, const char* base_name,
693
693
 
694
694
  if (name[0] != '.' && name[0] != '/') {
695
695
  /* Built-in modules pass through unchanged */
696
- if (strncmp(name, "mikrojs/", 8) == 0 || strncmp(name, "native:", 7) == 0) {
696
+ if (strncmp(name, "mikro/", 6) == 0 || strncmp(name, "native:", 7) == 0) {
697
697
  return js_strdup(ctx, name);
698
698
  }
699
699
  /* Check if this bare specifier matches an external builtin (board/driver