lakutata 3.1.3 → 3.1.5
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 +10 -10
- package/README.zh-CN.md +5 -5
- package/dist/cjs/exports/NwjsAdapter.d.ts +1 -0
- package/dist/cjs/exports/NwjsAdapter.js +20 -0
- package/dist/esm/exports/NwjsAdapter.js +1 -0
- package/dist/types/exports/NwjsAdapter.d.ts +1 -0
- package/doc/en/Application.md +1 -1
- package/doc/en/Cache.md +2 -1
- package/doc/en/Command.md +10 -4
- package/doc/en/ContainerdIntegration.md +1 -1
- package/doc/en/DatabaseDrivers.md +3 -2
- package/doc/en/Entrypoint.md +3 -2
- package/doc/en/Exceptions.md +1 -1
- package/doc/en/FFI.md +1 -1
- package/doc/en/GRPC.md +9 -3
- package/doc/en/GettingStarted.md +15 -2
- package/doc/en/HTTP.md +35 -0
- package/doc/en/I18n.md +1 -1
- package/doc/en/Installers.md +34 -6
- package/doc/en/MCP.md +4 -2
- package/doc/en/Math.md +1 -1
- package/doc/en/NativeAddons.md +9 -2
- package/doc/en/Netif.md +261 -0
- package/doc/en/Overview.md +10 -8
- package/doc/en/Packaging.md +4 -1
- package/doc/en/ProjectStructure.md +8 -3
- package/doc/en/ServiceCalls.md +69 -6
- package/doc/en/UpgradingFrom1.md +2 -2
- package/doc/en/UpgradingFrom2.md +4 -4
- package/doc/en/WebRTC.md +4 -4
- package/doc/zh/Application.md +1 -1
- package/doc/zh/Cache.md +1 -1
- package/doc/zh/Command.md +7 -3
- package/doc/zh/ContainerdIntegration.md +1 -1
- package/doc/zh/DatabaseDrivers.md +1 -1
- package/doc/zh/Entrypoint.md +2 -1
- package/doc/zh/Exceptions.md +1 -1
- package/doc/zh/FFI.md +1 -1
- package/doc/zh/GRPC.md +6 -3
- package/doc/zh/GettingStarted.md +11 -2
- package/doc/zh/HTTP.md +30 -0
- package/doc/zh/I18n.md +1 -1
- package/doc/zh/Installers.md +16 -5
- package/doc/zh/MCP.md +3 -2
- package/doc/zh/Math.md +1 -1
- package/doc/zh/NativeAddons.md +3 -2
- package/doc/zh/Netif.md +207 -0
- package/doc/zh/Overview.md +5 -4
- package/doc/zh/Packaging.md +4 -1
- package/doc/zh/ProjectStructure.md +4 -2
- package/doc/zh/ServiceCalls.md +55 -5
- package/doc/zh/UpgradingFrom1.md +2 -2
- package/doc/zh/UpgradingFrom2.md +3 -3
- package/doc/zh/WebRTC.md +1 -1
- package/package.json +29 -15
package/README.md
CHANGED
|
@@ -19,9 +19,9 @@ English | [中文](README.zh-CN.md)
|
|
|
19
19
|
# lakutata
|
|
20
20
|
|
|
21
21
|
An IoC-based application framework for Node.js and TypeScript, with one programming model for web services, CLI tools,
|
|
22
|
-
desktop (Electron) applications and embedded devices. An application is a tree of objects (components, providers,
|
|
22
|
+
desktop (Electron, NW.js) applications and embedded devices. An application is a tree of objects (components, providers,
|
|
23
23
|
controllers) that a container creates. DTOs validate their options and inputs, and transports expose the controllers:
|
|
24
|
-
HTTP (Express, Fastify), CLI (Commander), service RPC (HTTP, Socket.IO, JSON-RPC 2.0, gRPC, NATS, Electron IPC),
|
|
24
|
+
HTTP (Express, Fastify), CLI (Commander), service RPC (HTTP, Socket.IO, JSON-RPC 2.0, gRPC, NATS, Electron IPC, NW.js),
|
|
25
25
|
schedules and message queues. One controller method can serve all of them at once.
|
|
26
26
|
|
|
27
27
|
This package is the framework itself: it re-exports the `@lakutata/*` packages under the subpaths listed below and
|
|
@@ -31,13 +31,13 @@ declaration with examples, and each `@lakutata/*` package has its own README.
|
|
|
31
31
|
## Installation
|
|
32
32
|
|
|
33
33
|
```shell
|
|
34
|
-
npx @lakutata/cli create --name my-app # a new project from a template (web, service, CLI, Electron…)
|
|
34
|
+
npx @lakutata/cli create --name my-app # a new project from a template (web, service, CLI, Electron, NW.js…)
|
|
35
35
|
npm install lakutata # or the framework in an existing project
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
The framework needs Node.js
|
|
39
|
-
use ES modules (`"type": "module"`), as the templates do; the package also ships CommonJS builds. The
|
|
40
|
-
options that the framework needs are published as `lakutata/tsconfig.json`:
|
|
38
|
+
The framework needs Node.js 18.10 or later (`>=18.10.0`); a few features need a newer one (see Getting Started).
|
|
39
|
+
Projects use ES modules (`"type": "module"`), as the templates do; the package also ships CommonJS builds. The
|
|
40
|
+
TypeScript options that the framework needs are published as `lakutata/tsconfig.json`:
|
|
41
41
|
|
|
42
42
|
```json
|
|
43
43
|
{
|
|
@@ -108,7 +108,7 @@ Application
|
|
|
108
108
|
| `lakutata/decorator/ctrl` | `@lakutata/entrypoint` | `@HTTPAction`, `@GET`…`@OPTIONS`, `@CLIAction`, `@ServiceAction`, `@Schedule`, `@Prefix`, `@UseMiddlewares` |
|
|
109
109
|
| `lakutata/adapter/express`, `lakutata/adapter/fastify` | `@lakutata/entrypoint` | The HTTP transports, `staticUI` (Express only) |
|
|
110
110
|
| `lakutata/adapter/commander` | `@lakutata/entrypoint` | The CLI transport |
|
|
111
|
-
| `lakutata/adapter/socket.io`, `lakutata/adapter/jsonrpc`, `lakutata/adapter/electron` | `@lakutata/entrypoint` | The service transports |
|
|
111
|
+
| `lakutata/adapter/socket.io`, `lakutata/adapter/jsonrpc`, `lakutata/adapter/electron`, `lakutata/adapter/nwjs` | `@lakutata/entrypoint` | The service transports |
|
|
112
112
|
| `lakutata/com/logger` | `@lakutata/logger` | The `Logger` component preset as `log` (pino-compatible JSON lines) |
|
|
113
113
|
| `lakutata/orm`, `lakutata/decorator/orm` | `@lakutata/orm` | TypeORM, its decorators |
|
|
114
114
|
| `lakutata/com/database`, `lakutata/provider/database` | `@lakutata/orm` | The `Database` component and provider, the migration commands |
|
|
@@ -144,9 +144,9 @@ on. Each package's README lists its exceptions.
|
|
|
144
144
|
`Entrypoint.md`, `Middlewares.md`, `HTTP.md`, `CLI.md`, `ServiceCalls.md`, `GRPC.md`, `NATS.md`, `Schedules.md`,
|
|
145
145
|
`Queue.md`, `Database.md`, `DatabaseDrivers.md`, `MongoEmbedded.md`, `Entities.md`, `Migrations.md`, `Cache.md`,
|
|
146
146
|
`Mutex.md`, `I18n.md`, `DockerIntegration.md`, `ContainerdIntegration.md`, `Monitor.md`, `Security.md`, `DBus.md`,
|
|
147
|
-
`MCP.md`, `WebRTC.md`, `FFI.md`, `Math.md`, `
|
|
148
|
-
`Installers.md`; and the examples, in `doc/en/examples` and `doc/zh/examples`: whole applications
|
|
149
|
-
templates.
|
|
147
|
+
`MCP.md`, `WebRTC.md`, `FFI.md`, `Math.md`, `Netif.md`, `Command.md`, `Workspaces.md`, `NativeAddons.md`,
|
|
148
|
+
`Packaging.md`, `Installers.md`; and the examples, in `doc/en/examples` and `doc/zh/examples`: whole applications
|
|
149
|
+
built from the templates.
|
|
150
150
|
- `@lakutata/cli`: creating, building and packaging applications.
|
|
151
151
|
- The official Agent Skill for AI coding assistants that work on lakutata projects:
|
|
152
152
|
[lakutata.com/skill](https://lakutata.com/skill/).
|
package/README.zh-CN.md
CHANGED
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
|
|
19
19
|
# lakutata
|
|
20
20
|
|
|
21
|
-
一个基于 IoC 的 Node.js 和 TypeScript 应用框架,让 Web 服务、命令行工具、桌面(Electron)应用和嵌入式设备共用同一套编程模型。应用是一棵由容器创建的对象树(组件、提供者、控制器)。DTO 校验对象的选项和输入,各种传输方式把控制器暴露出去:HTTP(Express、Fastify)、CLI(Commander)、服务调用(HTTP、Socket.IO、JSON-RPC 2.0、gRPC、NATS、Electron IPC)、定时任务和消息队列。同一个控制器方法可以同时通过所有这些方式调用。
|
|
21
|
+
一个基于 IoC 的 Node.js 和 TypeScript 应用框架,让 Web 服务、命令行工具、桌面(Electron、NW.js)应用和嵌入式设备共用同一套编程模型。应用是一棵由容器创建的对象树(组件、提供者、控制器)。DTO 校验对象的选项和输入,各种传输方式把控制器暴露出去:HTTP(Express、Fastify)、CLI(Commander)、服务调用(HTTP、Socket.IO、JSON-RPC 2.0、gRPC、NATS、Electron IPC、NW.js)、定时任务和消息队列。同一个控制器方法可以同时通过所有这些方式调用。
|
|
22
22
|
|
|
23
23
|
这个包就是框架本身:它通过下面列出的子路径重新导出各个 `@lakutata/*` 包,并为每个应用预置两个组件:`log` 和 `entrypoint`。各子路径的类型声明中,每一项都附有说明和示例,每个 `@lakutata/*` 包也都有自己的 README。
|
|
24
24
|
|
|
25
25
|
## 安装
|
|
26
26
|
|
|
27
27
|
```shell
|
|
28
|
-
npx @lakutata/cli create --name my-app # 用模板创建新项目(Web、服务、CLI、Electron……)
|
|
28
|
+
npx @lakutata/cli create --name my-app # 用模板创建新项目(Web、服务、CLI、Electron、NW.js……)
|
|
29
29
|
npm install lakutata # 或者在已有项目中安装框架
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
框架需要 Node.js
|
|
32
|
+
框架需要 Node.js 18.10 或更高版本(`>=18.10.0`),少数功能需要较新的版本(见快速开始)。项目使用 ES 模块(`"type": "module"`),模板也是如此;这个包也提供 CommonJS 版本。框架需要的 TypeScript 选项发布为 `lakutata/tsconfig.json`:
|
|
33
33
|
|
|
34
34
|
```json
|
|
35
35
|
{
|
|
@@ -97,7 +97,7 @@ Application
|
|
|
97
97
|
| `lakutata/decorator/ctrl` | `@lakutata/entrypoint` | `@HTTPAction`、`@GET`…`@OPTIONS`、`@CLIAction`、`@ServiceAction`、`@Schedule`、`@Prefix`、`@UseMiddlewares` |
|
|
98
98
|
| `lakutata/adapter/express`、`lakutata/adapter/fastify` | `@lakutata/entrypoint` | HTTP 传输、`staticUI`(仅 Express) |
|
|
99
99
|
| `lakutata/adapter/commander` | `@lakutata/entrypoint` | CLI 传输 |
|
|
100
|
-
| `lakutata/adapter/socket.io`、`lakutata/adapter/jsonrpc`、`lakutata/adapter/electron` | `@lakutata/entrypoint` | 服务传输 |
|
|
100
|
+
| `lakutata/adapter/socket.io`、`lakutata/adapter/jsonrpc`、`lakutata/adapter/electron`、`lakutata/adapter/nwjs` | `@lakutata/entrypoint` | 服务传输 |
|
|
101
101
|
| `lakutata/com/logger` | `@lakutata/logger` | `Logger` 组件,预置为 `log`(输出与 pino 兼容的 JSON 行) |
|
|
102
102
|
| `lakutata/orm`、`lakutata/decorator/orm` | `@lakutata/orm` | TypeORM 及其装饰器 |
|
|
103
103
|
| `lakutata/com/database`、`lakutata/provider/database` | `@lakutata/orm` | `Database` 组件和提供者、迁移命令 |
|
|
@@ -121,7 +121,7 @@ Application
|
|
|
121
121
|
## 另见
|
|
122
122
|
|
|
123
123
|
- 网站 <https://lakutata.com/zh/>:指南、示例和 API 参考,中英文都有。
|
|
124
|
-
- 指南在这个包的 `doc/zh`(中文)和 `doc/en`(英文)中:`Overview.md`、`GettingStarted.md`、`ProjectStructure.md`、`UpgradingFrom2.md`、`UpgradingFrom1.md`、`Application.md`、`Objects.md`、`Injection.md`、`DTOValidation.md`、`Exceptions.md`、`Logger.md`、`Decorator.md`、`Time.md`、`HelperFunctions.md`、`Controllers.md`、`Entrypoint.md`、`Middlewares.md`、`HTTP.md`、`CLI.md`、`ServiceCalls.md`、`GRPC.md`、`NATS.md`、`Schedules.md`、`Queue.md`、`Database.md`、`DatabaseDrivers.md`、`MongoEmbedded.md`、`Entities.md`、`Migrations.md`、`Cache.md`、`Mutex.md`、`I18n.md`、`DockerIntegration.md`、`ContainerdIntegration.md`、`Monitor.md`、`Security.md`、`DBus.md`、`MCP.md`、`WebRTC.md`、`FFI.md`、`Math.md`、`Command.md`、`Workspaces.md`、`NativeAddons.md`、`Packaging.md`、`Installers.md`;示例在 `doc/zh/examples` 和 `doc/en/examples` 中:从模板构建的完整应用。
|
|
124
|
+
- 指南在这个包的 `doc/zh`(中文)和 `doc/en`(英文)中:`Overview.md`、`GettingStarted.md`、`ProjectStructure.md`、`UpgradingFrom2.md`、`UpgradingFrom1.md`、`Application.md`、`Objects.md`、`Injection.md`、`DTOValidation.md`、`Exceptions.md`、`Logger.md`、`Decorator.md`、`Time.md`、`HelperFunctions.md`、`Controllers.md`、`Entrypoint.md`、`Middlewares.md`、`HTTP.md`、`CLI.md`、`ServiceCalls.md`、`GRPC.md`、`NATS.md`、`Schedules.md`、`Queue.md`、`Database.md`、`DatabaseDrivers.md`、`MongoEmbedded.md`、`Entities.md`、`Migrations.md`、`Cache.md`、`Mutex.md`、`I18n.md`、`DockerIntegration.md`、`ContainerdIntegration.md`、`Monitor.md`、`Security.md`、`DBus.md`、`MCP.md`、`WebRTC.md`、`FFI.md`、`Math.md`、`Netif.md`、`Command.md`、`Workspaces.md`、`NativeAddons.md`、`Packaging.md`、`Installers.md`;示例在 `doc/zh/examples` 和 `doc/en/examples` 中:从模板构建的完整应用。
|
|
125
125
|
- `@lakutata/cli`:创建、构建和打包应用。
|
|
126
126
|
- 官方 Agent Skill(智能体技能),供 AI 编程助手在 lakutata 项目中使用:<https://lakutata.com/zh/skill/>。
|
|
127
127
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@lakutata/entrypoint/adapter/nwjs';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@lakutata/entrypoint/adapter/nwjs"), exports);
|
|
18
|
+
|
|
19
|
+
//The default of the entry: the entry itself (scripts/package-build/cjs-package.mjs)
|
|
20
|
+
if (!Object.prototype.hasOwnProperty.call(exports, 'default')) Object.defineProperty(exports, 'default', {value: exports})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@lakutata/entrypoint/adapter/nwjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@lakutata/entrypoint/adapter/nwjs';
|
package/doc/en/Application.md
CHANGED
|
@@ -12,7 +12,7 @@ options:
|
|
|
12
12
|
|
|
13
13
|
| Option | Meaning |
|
|
14
14
|
|---|---|
|
|
15
|
-
| `id`, `name` | Required. The ID (also the `process.title
|
|
15
|
+
| `id`, `name` | Required. The ID (also the `process.title`, except in NW.js) and the name of the application (`app.appId`, `app.appName`) |
|
|
16
16
|
| `timezone` | An IANA time zone, or `'auto'` (default) for the system's; written to `TZ` |
|
|
17
17
|
| `mode` | `'development'` or `'production'`, when the environment gives none (see section 4) |
|
|
18
18
|
| `shutdownSignals` | The signals that end the application gracefully (default `['SIGTERM', 'SIGINT']`), or `false` |
|
package/doc/en/Cache.md
CHANGED
|
@@ -290,7 +290,8 @@ The values are kept as they are, not copied (section 7). Each process has its ow
|
|
|
290
290
|
- The statements run synchronously: a statement that waits for a locked database blocks the event loop, up to
|
|
291
291
|
`busyTimeout`.
|
|
292
292
|
- `better-sqlite3` is a native addon built for one runtime: an Electron application needs its build for its version of
|
|
293
|
-
Electron.
|
|
293
|
+
Electron; an NW.js application has it built again with the headers of NW.js (0.111.3 or later: the earlier releases
|
|
294
|
+
cannot load it). On Bun, the store uses `bun:sqlite` instead.
|
|
294
295
|
|
|
295
296
|
### PostgreSQL
|
|
296
297
|
|
package/doc/en/Command.md
CHANGED
|
@@ -13,8 +13,7 @@ npm install --global @lakutata/cli # or once for the machine, then: laku
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
The templates add `@lakutata/cli` to the `devDependencies` of the project, so its scripts call `lakutata` directly and
|
|
16
|
-
`npx lakutata` works inside it. The tool needs Node.js
|
|
17
|
-
later (not 23).
|
|
16
|
+
`npx lakutata` works inside it. The tool needs Node.js 18.10 or later (`>=18.10.0`).
|
|
18
17
|
|
|
19
18
|
- `lakutata --help` lists the commands, `lakutata help <command>` (or `lakutata <command> --help`) describes one, and
|
|
20
19
|
`lakutata --version` prints the version of the tool. Without a command, the tool prints its help and exits with code
|
|
@@ -46,7 +45,7 @@ lakutata create --name tool --template cli --package-manager none --no-git
|
|
|
46
45
|
| `--path` | `.` | Where the project directory is created (`<path>/<name>`) |
|
|
47
46
|
| `--init` | | Create the project in `--path` itself, a directory that already exists |
|
|
48
47
|
| `--description`, `--author`, `--license` | license `UNLICENSED` | The information of the package |
|
|
49
|
-
| `--with` | | The optional features of the template, separated by commas (`i18n`, `installer`) |
|
|
48
|
+
| `--with` | | The optional features of the template, separated by commas (`i18n`, `installer`, `win7`) |
|
|
50
49
|
| `--package-manager` | `npm`, or pnpm or yarn when one of them started the tool | `npm`, `pnpm`, `yarn`, or `none` to skip the installation |
|
|
51
50
|
| `--no-git` | | Do not create a git repository |
|
|
52
51
|
| `--yes` | | Do not ask for the features or for a confirmation |
|
|
@@ -99,6 +98,11 @@ adds a language. See [I18n](I18n.md#command-line-tools).
|
|
|
99
98
|
that runs without Node.js: see [Packaging](Packaging.md). `lakutata package installer` makes its installers, which can
|
|
100
99
|
register it as a service: see [Installers](Installers.md).
|
|
101
100
|
|
|
101
|
+
An NW.js application gets its version of NW.js from `lakutata nwjs use <version>` (`latest`, `win7` or a version, which
|
|
102
|
+
`lakutata nwjs versions` lists), which writes it into its `package.json`. `lakutata nwjs run [args...]` runs the compiled
|
|
103
|
+
application in the sdk flavor of that NW.js (with the DevTools), its native addons made to load in it, and gives it the
|
|
104
|
+
arguments. Its installers hold the normal flavor ([Installers](Installers.md), section 9).
|
|
105
|
+
|
|
102
106
|
## 6. Environment variables
|
|
103
107
|
|
|
104
108
|
| Variable | Meaning |
|
|
@@ -106,7 +110,9 @@ register it as a service: see [Installers](Installers.md).
|
|
|
106
110
|
| `LAKUTATA_LANG` | The language of the tool (`en`, `zh-CN`, `zh-TW`) |
|
|
107
111
|
| `LAKUTATA_NPM_REGISTRY` | The registry the templates come from (else `npm_config_registry`, else `https://registry.npmjs.org`) |
|
|
108
112
|
| `LAKUTATA_GITHUB_DOWNLOAD` | Where the `github:` templates are downloaded from (`https://github.com` by default) |
|
|
109
|
-
| `LAKUTATA_CACHE_DIR` | The cache of the tool: the templates,
|
|
113
|
+
| `LAKUTATA_CACHE_DIR` | The cache of the tool: the templates, the tools that make installers and the runtimes of NW.js (`$XDG_CACHE_HOME/lakutata`, else `~/.cache/lakutata`) |
|
|
114
|
+
| `LAKUTATA_NWJS_MIRROR` | Where the runtimes of NW.js are downloaded from (`https://dl.nwjs.io` by default) |
|
|
115
|
+
| `LAKUTATA_NWJS_VERSIONS` | The list of the releases of NW.js (`https://nwjs.io/versions.json` by default) |
|
|
110
116
|
| `NO_COLOR` | Turns the colors off |
|
|
111
117
|
|
|
112
118
|
The scripts and the applications the tool runs get the environment the tool was started with. The variables of the
|
|
@@ -15,7 +15,7 @@ The containers it creates are the same as the containers nerdctl creates: they c
|
|
|
15
15
|
|
|
16
16
|
| Feature | Needs |
|
|
17
17
|
|---|---|
|
|
18
|
-
| Everything | Linux, containerd 1.6 or later with runc, Node.js
|
|
18
|
+
| Everything | Linux, containerd 1.6 or later with runc, Node.js `>=18.10.0`; the application runs as root or as a member of the group owning the socket of containerd |
|
|
19
19
|
| CNI networks (the default `bridge` included), published ports | The CNI plugins (`bridge`, `portmap`, `host-local`… in `/opt/cni/bin`, `/usr/lib/cni` or `/usr/libexec/cni`, the `cniPath` option) and iptables |
|
|
20
20
|
| `exec()` with `stdin`, separate `stdout`/`stderr`, terminals | `mkfifo` on the host (without it, `exec()` puts both outputs in `stdout`) |
|
|
21
21
|
| Builds | A BuildKit daemon (`buildkitd`), local or remote |
|
|
@@ -136,8 +136,9 @@ export const db = buildDatabaseOptions({
|
|
|
136
136
|
- The foreign keys are enforced (`PRAGMA foreign_keys = ON`). There is one connection: `poolSize` is not supported.
|
|
137
137
|
- **`bigint` columns come back as numbers**: values beyond 2^53 lose precision. Keep such values in a text column.
|
|
138
138
|
- `better-sqlite3` is a native module, compiled for one version of Node.js. An Electron application needs the build of
|
|
139
|
-
its Electron (`electron-rebuild`, or the prebuilt binaries of better-sqlite3 for Electron);
|
|
140
|
-
`sqljs`
|
|
139
|
+
its Electron (`electron-rebuild`, or the prebuilt binaries of better-sqlite3 for Electron); an NW.js application has
|
|
140
|
+
it built again with the headers of NW.js (0.111.3 or later: use `sqljs` with the earlier releases); Bun cannot load it
|
|
141
|
+
(use `sqljs` there).
|
|
141
142
|
|
|
142
143
|
## SQLite: sql.js
|
|
143
144
|
|
package/doc/en/Entrypoint.md
CHANGED
|
@@ -60,6 +60,7 @@ The adapters:
|
|
|
60
60
|
| `service` | `socketIOServiceEntrypoint()` | `lakutata/adapter/socket.io` | `socket.io` | [ServiceCalls](ServiceCalls.md) |
|
|
61
61
|
| `service` | `jsonRPCServiceEntrypoint()` | `lakutata/adapter/jsonrpc` | `ws`, for WebSocket | [ServiceCalls](ServiceCalls.md) |
|
|
62
62
|
| `service` | `electronIPCServiceEntrypoint()` | `lakutata/adapter/electron` | (Electron) | [ServiceCalls](ServiceCalls.md) |
|
|
63
|
+
| `service` | `nwjsServiceEntrypoint()` | `lakutata/adapter/nwjs` | (NW.js) | [ServiceCalls](ServiceCalls.md) |
|
|
63
64
|
| `service` | `grpcServiceEntrypoint()` | `@lakutata/grpc/service` | `@lakutata/grpc` | [GRPC](GRPC.md) |
|
|
64
65
|
| `service` | `natsServiceEntrypoint()` | `@lakutata/nats` | `@lakutata/nats` | [NATS](NATS.md) |
|
|
65
66
|
| `schedule` | `scheduleEntrypoint()` | `lakutata/com/entrypoint` | | [Schedules](Schedules.md) |
|
|
@@ -181,8 +182,8 @@ actions of any other transport (`getActions('schedule')`). Each action is descri
|
|
|
181
182
|
|
|
182
183
|
## 6. Pushing events to the clients
|
|
183
184
|
|
|
184
|
-
The service transports that keep their clients connected (Socket.IO, Electron, the event stream of the HTTP
|
|
185
|
-
JSON-RPC over WebSocket or stdio, gRPC) can receive events from the application.
|
|
185
|
+
The service transports that keep their clients connected (Socket.IO, Electron, NW.js, the event stream of the HTTP
|
|
186
|
+
service, JSON-RPC over WebSocket or stdio, gRPC) can receive events from the application.
|
|
186
187
|
`entrypoint.notify(clientId, event, ...args)` sends an event to the client whose id an action found in
|
|
187
188
|
`this.context.clientId`, and returns whether that client received it. `entrypoint.broadcast(event, ...args)` sends it to
|
|
188
189
|
every connected client, and returns their number. See [GRPC](GRPC.md) and [ServiceCalls](ServiceCalls.md).
|
package/doc/en/Exceptions.md
CHANGED
|
@@ -121,7 +121,7 @@ When an action fails, its transport reports the exception:
|
|
|
121
121
|
| Transport | The client receives |
|
|
122
122
|
|---|---|
|
|
123
123
|
| HTTP | The status `statusCode` and `{errno, errMsg}` (see [HTTP](HTTP.md), section 6) |
|
|
124
|
-
| Socket.IO, Electron, the HTTP service, NATS, gRPC | The whole error: all its own properties (see [ServiceCalls](ServiceCalls.md), section 3) |
|
|
124
|
+
| Socket.IO, Electron, NW.js, the HTTP service, NATS, gRPC | The whole error: all its own properties (see [ServiceCalls](ServiceCalls.md), section 3) |
|
|
125
125
|
| JSON-RPC | An error with the code `-32602` for an invalid input, `-32601` when no action matches, `-32001` while the application stops, `-32000` otherwise, and the whole error as its `data` |
|
|
126
126
|
| The command line | `error: <message>` on the standard error, and the exit code 1 (see [CLI](CLI.md)) |
|
|
127
127
|
| Schedules | No client: the exception is given to `onError`, or logged (see [Schedules](Schedules.md)) |
|
package/doc/en/FFI.md
CHANGED
|
@@ -433,7 +433,7 @@ Stopping a worker while asynchronous calls run in the threads of its libraries d
|
|
|
433
433
|
|
|
434
434
|
## 12. Runtimes
|
|
435
435
|
|
|
436
|
-
Node.js
|
|
436
|
+
Node.js `>=18.10.0`, the main process of Electron and Bun; not the renderers of Electron nor the browsers.
|
|
437
437
|
|
|
438
438
|
The tests of the package, including those of the threads of a library, pass on macOS (arm64: Node.js 24, Bun 1.4,
|
|
439
439
|
Electron 44), on Linux (arm64, glibc and musl: Node.js 24, Bun 1.4) and on Windows 11 (arm64, and x64 under emulation:
|
package/doc/en/GRPC.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The package `@lakutata/grpc` serves the service actions of an application over gRPC, and calls them from another
|
|
4
4
|
application. Any language with a gRPC library can call them too. It is written in TypeScript over the HTTP/2 module of
|
|
5
|
-
Node.js (
|
|
5
|
+
Node.js (`>=18.10.0`): no native addon and no generated code. `lakutata` does not include it, so install it
|
|
6
6
|
next to it:
|
|
7
7
|
|
|
8
8
|
```bash
|
|
@@ -56,10 +56,15 @@ The options of `grpcServiceEntrypoint`:
|
|
|
56
56
|
| `tls` | None (plain HTTP/2) | `{cert, key}` for TLS; with `ca` too, the clients must present a certificate signed by it (mutual TLS) |
|
|
57
57
|
| `maxMessageSize` | 4 MiB | The largest request, before and after decompression; a larger one fails with `RESOURCE_EXHAUSTED` |
|
|
58
58
|
| `compression` | `'identity'` | `'gzip'` or `'deflate'` to compress the responses for the clients that accept it. Compressed requests are always accepted |
|
|
59
|
-
| `listening` | | `(address) => void`, called once the server listens; the start waits for it |
|
|
59
|
+
| `listening` | | `(address, listeners) => void`, called once the server listens; the start waits for it |
|
|
60
|
+
| `interface`, `family`, `strict`, `onError` | | Listen on a network interface instead of an address, as the HTTP adapters do (see [HTTP](HTTP.md), section 2); not with `host` or `socketPath` |
|
|
60
61
|
| `middlewares` | | The middlewares of the actions called over gRPC, run after the ones of the entrypoint |
|
|
61
62
|
| `name` | | The name of the adapter, to tell several apart |
|
|
62
63
|
|
|
64
|
+
With `interface`, the package `@lakutata/netif` has to be installed. The `address` given to `listening` is then the
|
|
65
|
+
first one listened on, or `null` while the interface does not exist or has no address yet, and `listeners` are the
|
|
66
|
+
listeners of the interface.
|
|
67
|
+
|
|
63
68
|
The server has no reflection service and no health service.
|
|
64
69
|
|
|
65
70
|
## 2. Calling them from another application
|
|
@@ -248,4 +253,5 @@ seconds by default) to complete. Then the event streams end and the server close
|
|
|
248
253
|
|
|
249
254
|
The package also has the layers the service is built on, usable without lakutata: `GRPCConnection`, a client for any
|
|
250
255
|
gRPC server (unary, server streaming and bidirectional calls, metadata, TLS); `GRPCServer`; and `encode`/`decode`, a
|
|
251
|
-
protobuf codec driven by schemas. The README of `@lakutata/grpc` describes them.
|
|
256
|
+
protobuf codec driven by schemas. The README of `@lakutata/grpc` describes them. `GRPCServer.listenWith()` listens
|
|
257
|
+
through the listeners of network interfaces (`listenOnAll()` of `@lakutata/netif`), as the adapter does.
|
package/doc/en/GettingStarted.md
CHANGED
|
@@ -5,7 +5,18 @@ and write an application by hand.
|
|
|
5
5
|
|
|
6
6
|
## 1. Requirements
|
|
7
7
|
|
|
8
|
-
- Node.js
|
|
8
|
+
- Node.js 18.10 or later (`>=18.10.0`). A few features need a newer Node.js:
|
|
9
|
+
- the Fastify adapter: Fastify 5 needs Node.js 18.19, 19.9, 20 or later (the Express adapter needs nothing more);
|
|
10
|
+
- the Kafka transport of `@lakutata/queue`: Node.js 22.22, 24.6 or later, as `@platformatic/kafka` needs;
|
|
11
|
+
- the executables of Node.js (`lakutata package exe`, the installers): made by a Node.js 20.12, 21.7 or later, or with
|
|
12
|
+
`--node-program` naming one;
|
|
13
|
+
- `await using` with the objects of the framework: Node.js 18.18, 20.4 or later.
|
|
14
|
+
|
|
15
|
+
On Node.js 18 and 19, an application uses commander 13, @inquirer/prompts 7 and better-sqlite3 11: their next major
|
|
16
|
+
versions need Node.js 20 or later.
|
|
17
|
+
|
|
18
|
+
The projects made by `lakutata create` declare Node.js `>=22.13.0`, which the tools of the web and desktop templates
|
|
19
|
+
need.
|
|
9
20
|
- TypeScript, with its decorators (`experimentalDecorators`) and their metadata (`emitDecoratorMetadata`). The framework
|
|
10
21
|
publishes the compiler options it needs as `lakutata/tsconfig.json`; the templates use TypeScript 6.
|
|
11
22
|
- ES modules (`"type": "module"`), as in the templates; the package also ships CommonJS builds.
|
|
@@ -36,13 +47,15 @@ The `default` template is a small HTTP application. Other templates start from a
|
|
|
36
47
|
| `web-react`, `web-vue` | An HTTP API serving a React or Vue single-page application (Vite) |
|
|
37
48
|
| `web-next`, `web-nuxt` | An HTTP API serving a Next.js or Nuxt application from the same process |
|
|
38
49
|
| `electron-react`, `electron-vue` | A desktop application: Electron, its main process serving a React or Vue renderer over IPC |
|
|
50
|
+
| `nwjs-react`, `nwjs-vue` | A desktop application: NW.js, its background script serving a React or Vue user interface isolated in a webview |
|
|
39
51
|
|
|
40
52
|
```bash
|
|
41
53
|
npx @lakutata/cli create --name shop --template service --with i18n,installer
|
|
42
54
|
```
|
|
43
55
|
|
|
44
56
|
`--with` adds optional features: `i18n` (messages in several languages) to every template, `installer` (installers
|
|
45
|
-
and a system service) to `cli`, `service` and the `web-*` templates
|
|
57
|
+
and a system service) to `cli`, `service` and the `web-*` templates, `win7` (NW.js 0.72, which runs on Windows 7) to
|
|
58
|
+
the `nwjs-*` templates. In a terminal, the tool offers them when `--with`
|
|
46
59
|
is not given. [ProjectStructure](ProjectStructure.md) describes the files of the templates, and
|
|
47
60
|
[Command](Command.md) the options of `lakutata create`.
|
|
48
61
|
|
package/doc/en/HTTP.md
CHANGED
|
@@ -105,6 +105,7 @@ Both adapters serve the same actions, with the same results:
|
|
|
105
105
|
|---|---|---|
|
|
106
106
|
| Adapter | `expressHTTPEntrypoint()`, from `lakutata/adapter/express` | `fastifyHTTPEntrypoint()`, from `lakutata/adapter/fastify` |
|
|
107
107
|
| Install | `express` (4 or 5) | `fastify` (5) |
|
|
108
|
+
| Node.js | 18.10 and later | 18.19, 19.9, 20 and later (Fastify 5 needs `diagnostics_channel.tracingChannel`) |
|
|
108
109
|
|
|
109
110
|
The options of `expressHTTPEntrypoint()`:
|
|
110
111
|
|
|
@@ -123,6 +124,8 @@ The options of `expressHTTPEntrypoint()`:
|
|
|
123
124
|
| `fallback` | | Answers the requests outside the paths of the actions, such as the pages of a web UI (section 7) |
|
|
124
125
|
| `stop` | | Called when the adapter stops, once its server is closed |
|
|
125
126
|
| `heartbeat` | `15000` | How often a comment keeps the event streams alive, in milliseconds (section 5) |
|
|
127
|
+
| `listening` | | `(server, listeners) => …`: called once the server listens, or once the listeners of the interface are made (see below) |
|
|
128
|
+
| `interface` | | The network interface to listen on instead of an address, with `family`, `strict` and `onError` (see below) |
|
|
126
129
|
|
|
127
130
|
`fastifyHTTPEntrypoint()` takes the same options, except `server` and `app`, replaced by `fastify`: a Fastify instance,
|
|
128
131
|
or the options of the instance to create (`bodyLimit`, 1 MiB by default; `trustProxy`; `connectionTimeout`,
|
|
@@ -146,6 +149,38 @@ the event streams; Fastify also answers 503 to the requests that still arrive on
|
|
|
146
149
|
progress get the `shutdownTimeout` of the entrypoint (after it, they are answered with 503), then up to one second to
|
|
147
150
|
send their responses, before the remaining connections are closed, the WebSockets included.
|
|
148
151
|
|
|
152
|
+
### On a network interface
|
|
153
|
+
|
|
154
|
+
A device with several network interfaces often serves its pages on one of them only, and the address of that interface
|
|
155
|
+
comes from DHCP and changes. With `interface`, the adapter listens on the interface instead of an address, whatever its
|
|
156
|
+
addresses, and goes on listening when they change and when the interface is unplugged and plugged back. By default it
|
|
157
|
+
uses the package `@lakutata/netif`, installed apart, which compiles a native addon (see [Netif](Netif.md)).
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import {expressHTTPEntrypoint} from 'lakutata/adapter/express'
|
|
161
|
+
|
|
162
|
+
//The pages on eth1 only, whatever its address
|
|
163
|
+
export const http = expressHTTPEntrypoint({
|
|
164
|
+
port: 8080,
|
|
165
|
+
interface: 'eth1',
|
|
166
|
+
listening: (_server, listeners): void => console.log(listeners?.map(listener => listener.addresses))
|
|
167
|
+
})
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
| Option | Default | Meaning |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `interface` | | The name of the interface (`'eth1'`; on Windows the name of the network connection), `{mac: '52:54:00:12:34:56'}` or `{index: 3}`; several in an array, and then `port` cannot be `0`. It cannot be given with `host` |
|
|
173
|
+
| `family` | `'both'` | `'IPv4'`, `'IPv6'` or both |
|
|
174
|
+
| `strict` | `false` | Fails the start where the system cannot refuse the connections that reach the addresses of the interface through another interface, and stops listening while it cannot (see [Netif](Netif.md), section 2) |
|
|
175
|
+
| `onError` | the log of the application | Receives the errors of listening again while the application runs, such as a port taken by another program; the adapter retries by itself |
|
|
176
|
+
| `interfaceListening` | `@lakutata/netif` | Another implementation of the listening on interfaces: an `IInterfaceListening`, the contract of lakutata that `@lakutata/netif` implements |
|
|
177
|
+
|
|
178
|
+
- The interface may not exist yet when the application starts (a USB network adapter not plugged in): the start
|
|
179
|
+
succeeds, and the adapter listens once the interface appears. Until then the `addresses` of the listeners are empty.
|
|
180
|
+
- The server itself does not listen, and its `address()` is `null`: the listeners give the port and the addresses.
|
|
181
|
+
- `family`, `strict`, `onError` and `interfaceListening` without `interface` fail the creation of the adapter, as do
|
|
182
|
+
`interface` and `host` together.
|
|
183
|
+
|
|
149
184
|
## 3. Routes
|
|
150
185
|
|
|
151
186
|
| Decorator | Methods |
|
package/doc/en/I18n.md
CHANGED
|
@@ -174,7 +174,7 @@ The languages a request asks for are read from the sources below, in order, then
|
|
|
174
174
|
| HTTP (Express, Fastify) | The query parameter `?lang=`, the cookie `lang`, then the `Accept-Language` header (by quality) |
|
|
175
175
|
| Socket.IO | The query parameter `lang`, the cookie `lang` and `Accept-Language` of the connection's handshake |
|
|
176
176
|
| HTTP service adapter, JSON-RPC (HTTP, WebSocket) | The query parameter `lang`, the cookie `lang` and `Accept-Language` of the HTTP request (for WebSocket, of the request opening the connection) |
|
|
177
|
-
| Command line, Electron IPC, JSON-RPC over stdio | The variable named by `environmentVariable` (none by default), `LANGUAGE`, `LC_ALL`, `LC_MESSAGES`, `LANG`, then the language of the process |
|
|
177
|
+
| Command line, Electron IPC, NW.js, JSON-RPC over stdio | The variable named by `environmentVariable` (none by default), `LANGUAGE`, `LC_ALL`, `LC_MESSAGES`, `LANG`, then the language of the process |
|
|
178
178
|
| Schedules | None (the default language) |
|
|
179
179
|
|
|
180
180
|
A query or cookie value that is not a language tag is skipped.
|
package/doc/en/Installers.md
CHANGED
|
@@ -21,7 +21,8 @@ npx lakutata package installer --target pkg # only some of them
|
|
|
21
21
|
|
|
22
22
|
An installer holds the executable of the directory layout (`lakutata package exe --layout directory`): the program,
|
|
23
23
|
its native addons (`native/`) and its resources (`resources/`). The program is made with Node.js, or with Bun when
|
|
24
|
-
`lakutata.installer.runtime` is `"bun"`.
|
|
24
|
+
`lakutata.installer.runtime` is `"bun"`. On a Node.js older than 20.12, give a newer one with `--node-program`, as for
|
|
25
|
+
the executables.
|
|
25
26
|
|
|
26
27
|
| Platform | Installers (default) | Their files | Made with |
|
|
27
28
|
|---|---|---|---|
|
|
@@ -68,19 +69,19 @@ The installers are configured by `lakutata.installer` in the `package.json` of t
|
|
|
68
69
|
| `description`, `homepage`, `license` | Those of the `package.json` | The information of the packages |
|
|
69
70
|
| `maintainer` | The `author` of the `package.json` | Its maintainer (`Name <email>`); without one, the tool warns |
|
|
70
71
|
| `vendor` | None | Its vendor; on Windows, the publisher is the vendor, else the maintainer |
|
|
71
|
-
| `runtime` | `node` | `node` or `bun` for the executable; `electron` for an Electron application (section 8) |
|
|
72
|
+
| `runtime` | `node` | `node` or `bun` for the executable; `electron` for an Electron application (section 8), `nwjs` for an NW.js application (section 9) |
|
|
72
73
|
| `addToPath` | `true` | Put the program in the PATH: `/usr/bin/<program>` on Linux, `/usr/local/bin/<program>` on macOS, the PATH of the machine on Windows |
|
|
73
74
|
| `service` | None | `true`, or the options of the service (section 4) |
|
|
74
75
|
| `linux.targets` | `deb`, `rpm`, `tar.gz`; on Alpine `apk`, `tar.gz` | The Linux installers (`deb`, `rpm`, `archlinux`, `tar.gz`; `apk`, `tar.gz` on Alpine) |
|
|
75
76
|
| `linux.depends`, `linux.recommends` | None | The system packages it needs and recommends (the C++ runtime library is always added) |
|
|
76
77
|
| `linux.section`, `linux.priority` | None | Its section and its priority (deb) |
|
|
77
|
-
| `mac.targets` | `pkg`, `tar.gz` | The macOS installers |
|
|
78
|
+
| `mac.targets` | `pkg`, `tar.gz` | The macOS installers (`dmg` too, for an NW.js application) |
|
|
78
79
|
| `win.targets` | `nsis`, `msi`, `zip` | The Windows installers |
|
|
79
80
|
| `linux.scripts`, `mac.scripts`, `win.scripts`… | None | The scripts of the installers (section 5) |
|
|
80
81
|
| `electron` | None | The configuration of electron-builder (section 8) |
|
|
81
82
|
|
|
82
83
|
`lakutata.icon` (beside `lakutata.installer`) is a square PNG image of 256 pixels or more: the icon of the Windows
|
|
83
|
-
executable and installers, and of the Electron applications.
|
|
84
|
+
executable and installers, and of the Electron and NW.js applications.
|
|
84
85
|
|
|
85
86
|
The configuration is checked before anything is built, the options of the installers that are not made included, and an
|
|
86
87
|
error names the field:
|
|
@@ -202,8 +203,9 @@ fi
|
|
|
202
203
|
|
|
203
204
|
## 6. Signing
|
|
204
205
|
|
|
205
|
-
- **macOS**: the `pkg` installers are not signed, and the program
|
|
206
|
-
signature and the notarization, which distribution outside the machines of the
|
|
206
|
+
- **macOS**: the `pkg` installers and the `dmg` images are not signed, and the program or the application they install
|
|
207
|
+
is signed ad hoc only. The Developer ID signature and the notarization, which distribution outside the machines of the
|
|
208
|
+
organization needs, are not made yet.
|
|
207
209
|
- **Windows**: the NSIS and MSI installers are not signed: sign them with signtool before distributing them. The program
|
|
208
210
|
made with Node.js keeps the signature of `node.exe`, which no longer matches, and the tool warns of it.
|
|
209
211
|
- **Linux**: the packages are not signed.
|
|
@@ -278,3 +280,29 @@ and `electron-vue` templates are configured this way.
|
|
|
278
280
|
([NativeAddons](NativeAddons.md), section 4).
|
|
279
281
|
- On Linux arm64, the deb and rpm packages need the fpm of the system (`gem install fpm`, `USE_SYSTEM_FPM=true`), as the
|
|
280
282
|
`Dockerfile.installer` of the Electron templates installs it.
|
|
283
|
+
|
|
284
|
+
## 9. NW.js applications
|
|
285
|
+
|
|
286
|
+
With `"runtime": "nwjs"`, the installers hold an NW.js application made by the builder: the normal flavor of the NW.js
|
|
287
|
+
of the application (its `lakutata.nwjs`, given by `lakutata nwjs use`), downloaded once into the cache of lakutata and
|
|
288
|
+
checked against the checksums of its release, with the application in it: its bundle for the Node.js of that NW.js, its
|
|
289
|
+
native addons, its resources (`lakutata.resources`, read through `resourcesPath()`) and the manifest of NW.js. The
|
|
290
|
+
`nwjs-react` and `nwjs-vue` templates are configured this way.
|
|
291
|
+
|
|
292
|
+
- **The runtime** is named after the application: on Windows, `<name>.exe`, whose icon and version information are
|
|
293
|
+
those of the application; on Linux, `<name>`; on macOS, `<productName>.app`, whose `Info.plist` gives its name, its
|
|
294
|
+
identifier (`appId`), its version and its icon, and which is signed again ad hoc.
|
|
295
|
+
- **The installers** are those of a desktop application: `dmg` on macOS, `nsis` on Windows and `deb` on Linux by
|
|
296
|
+
default (also `pkg` and `tar.gz` on macOS, `msi` and `zip` on Windows, `rpm` and `tar.gz` on Linux). The Windows
|
|
297
|
+
installers add the application to the start menu and to the desktop; the `dmg` disk image holds it beside a link to
|
|
298
|
+
/Applications, where its user drags it, and the `pkg` package installs it there (an Intel application, on the Macs
|
|
299
|
+
of Apple silicon too); the Linux packages add its desktop entry and its icons, and depend on the libraries of
|
|
300
|
+
Chromium.
|
|
301
|
+
- **The architecture** is the one of the machine, or the one of `--arch` (`x64`, `ia32`, `arm64`): `ia32` makes the
|
|
302
|
+
installers of 32-bit Windows, which install the application among the programs of 32 bits. A release of NW.js
|
|
303
|
+
without a build for the Macs of Apple silicon (0.72) is packaged for Intel.
|
|
304
|
+
- **An NW.js application is not a service**, and is not put in the PATH (`addToPath` is `false` by default).
|
|
305
|
+
- **The scripts** run as for the other applications, but a macOS application is removed by deleting it: no removal
|
|
306
|
+
script runs there.
|
|
307
|
+
- **Native addons** are made to load in NW.js: built again for its architecture, or with its headers when they use the
|
|
308
|
+
V8 API, and, on Windows, given the Node.js of NW.js ([NativeAddons](NativeAddons.md), section 4).
|
package/doc/en/MCP.md
CHANGED
|
@@ -248,7 +248,8 @@ Application.run(() => ({
|
|
|
248
248
|
|---|---|---|
|
|
249
249
|
| `port`, `host`, `path` | `3000`, `'127.0.0.1'`, `'/mcp'` | Where it listens |
|
|
250
250
|
| `authenticate` | | `(request) => MCPAuthInfo \| undefined`: the authentication of the client; throwing answers 401, returning `undefined` serves the request without one |
|
|
251
|
-
| `allowedHosts`, `allowedOrigins` | the local names, on a local address | The `Host` and `Origin` headers accepted (403 otherwise); `false` checks none |
|
|
251
|
+
| `allowedHosts`, `allowedOrigins` | the local names, on a local address or the loopback interface | The `Host` and `Origin` headers accepted (403 otherwise); `false` checks none |
|
|
252
|
+
| `interface`, `family`, `strict`, `onError` | | Listen on a network interface instead of `host`, with the package `@lakutata/netif` (see [HTTP](HTTP.md), section 2) |
|
|
252
253
|
| `legacy` | `'stateless'` | The clients of the revisions of 2025: served without sessions, or refused with `'reject'` |
|
|
253
254
|
| `maxRequestBodySize` | 4 MiB | A larger body is answered with 413 |
|
|
254
255
|
| `bus` | in memory | Where the notifications go, to share them between the instances of the application |
|
|
@@ -258,7 +259,8 @@ Application.run(() => ({
|
|
|
258
259
|
- It serves the protocol over Streamable HTTP: the revision 2026-07-28, and the revisions of 2025 without sessions.
|
|
259
260
|
- On a local address, the `Host` and `Origin` headers are checked against the local names, which protects the server
|
|
260
261
|
from DNS rebinding: behind a proxy, list the names the clients use. On another address, nothing is checked unless you
|
|
261
|
-
list names.
|
|
262
|
+
list names. The same goes for `interface`: the loopback interface is checked against the local names, and on another
|
|
263
|
+
interface the clients of the network reach the server, so set `allowedHosts` and `authenticate`.
|
|
262
264
|
- When the application stops, the calls in progress are answered, then the port closes.
|
|
263
265
|
|
|
264
266
|
**Sharing the port of the HTTP adapter.** With `listen: false`, mount the `handler` of the adapter on the Express
|
package/doc/en/Math.md
CHANGED
|
@@ -348,7 +348,7 @@ $ curl -X POST localhost:8080/solve -H 'Content-Type: application/json' -d '{"eq
|
|
|
348
348
|
- The bundles, the executables and the installers made by `lakutata package` carry the compiled addon
|
|
349
349
|
(`build/Release/math.node`). Build them on each target platform, after installing the package there; the rules of
|
|
350
350
|
the native addons apply (see [Packaging](Packaging.md) and [NativeAddons](NativeAddons.md)).
|
|
351
|
-
- The package runs in Node.js
|
|
351
|
+
- The package runs in Node.js `>=18.10.0`, in Bun and in the main process of Electron, which load the
|
|
352
352
|
addon compiled for Node.js; not in the renderers of Electron nor in the browsers. In Bun, terminating a worker thread
|
|
353
353
|
while operations of the addon still run in it ends the whole process with a fatal error of Node-API (a bug of Bun
|
|
354
354
|
1.4).
|
package/doc/en/NativeAddons.md
CHANGED
|
@@ -66,14 +66,13 @@ And `src/index.ts`, the same for all three:
|
|
|
66
66
|
```typescript
|
|
67
67
|
import {createRequire} from 'node:module'
|
|
68
68
|
import path from 'node:path'
|
|
69
|
-
import {fileURLToPath} from 'node:url'
|
|
70
69
|
|
|
71
70
|
type Binding = {
|
|
72
71
|
greet(name: string): string
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
/** The addon built into build/Release, loaded from the directory of the package */
|
|
76
|
-
const binding: Binding = createRequire(
|
|
75
|
+
const binding: Binding = createRequire(__filename)('node-gyp-build')(path.resolve(__dirname, '..'))
|
|
77
76
|
|
|
78
77
|
export function greet(name: string): string {
|
|
79
78
|
return binding.greet(name)
|
|
@@ -96,6 +95,8 @@ export function greet(name: string): string {
|
|
|
96
95
|
for the architecture of the machine (`rustup target add` adds the other ones).
|
|
97
96
|
- **Node-API**: the addons are built for Node-API version 8, which every supported version of Node.js and of Electron
|
|
98
97
|
provides, so they are not rebuilt for each of them.
|
|
98
|
+
- **CommonJS**: the package is CommonJS (`"type": "commonjs"`). The bundles of `lakutata package` are CommonJS and
|
|
99
|
+
load it with `require`, which can load an ES module only on Node.js 20.19, 22.12 or later.
|
|
99
100
|
- The package is `"private": true`, like every package that `lakutata add` creates: an addon is usually shipped with
|
|
100
101
|
its application rather than published.
|
|
101
102
|
|
|
@@ -214,5 +215,11 @@ The application depends on the addon package, and imports it as any package (`im
|
|
|
214
215
|
- **Electron**: the addons are copied as they are installed. The addons that `lakutata add` creates run in Electron
|
|
215
216
|
without being rebuilt, as do all the addons built on Node-API; an addon built on the V8 API of Node.js must be
|
|
216
217
|
installed in its build for Electron before packing (`electron-rebuild`).
|
|
218
|
+
- **NW.js**: the addons are made to load in NW.js when the application runs in it (`lakutata nwjs run`, and once
|
|
219
|
+
packaged). The ones built for another architecture than the one of the runtime are built again from their sources,
|
|
220
|
+
with the headers of the Node.js of NW.js; so are the ones built on the V8 API of Node.js, with the headers of NW.js
|
|
221
|
+
(NW.js 0.111.3 or later: the earlier releases, such as 0.72 for Windows 7, run the addons of Node-API only). On
|
|
222
|
+
Windows, the addons load the Node.js of NW.js (`node.dll`). The addons of the project are left as they are, for its
|
|
223
|
+
tests with Node.js.
|
|
217
224
|
- **Bun**: Bun loads the addons of Node-API; an executable of Bun warns of the addons built on the V8 API of Node.js.
|
|
218
225
|
- **Alpine (musl)**: the executables of Node.js do not load native addons there: make them with Bun.
|