@tnldotdev/tnl 0.1.0-rc.13 → 0.1.0-rc.17
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/NOTICE +6 -0
- package/README.md +109 -16
- package/THIRD_PARTY_LICENSES.txt +6597 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +4 -0
- package/dist/internal/dev.d.ts +46 -0
- package/dist/internal/dev.js +428 -0
- package/dist/internal/runtime.d.ts +19 -0
- package/dist/internal/runtime.js +113 -0
- package/dist/next.d.ts +10 -0
- package/dist/next.js +85 -0
- package/dist/vite.d.ts +3 -0
- package/dist/vite.js +98 -0
- package/lib/config.d.ts +69 -0
- package/lib/config.mjs +3 -0
- package/package.json +57 -9
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,34 +1,127 @@
|
|
|
1
1
|
# `@tnldotdev/tnl`
|
|
2
2
|
|
|
3
|
-
This package installs the `tnl` client for macOS or Linux on arm64 or x64
|
|
4
|
-
|
|
3
|
+
This package installs the `tnl` client for macOS or Linux on arm64 or x64 and
|
|
4
|
+
provides its browser-safe project runtime plus official Next.js and Vite
|
|
5
|
+
integrations. It does not include the `tnld` server process.
|
|
5
6
|
|
|
6
7
|
## Install
|
|
7
8
|
|
|
8
|
-
Install the client:
|
|
9
|
-
|
|
10
9
|
```console
|
|
11
10
|
pnpm add --save-dev @tnldotdev/tnl@next
|
|
12
11
|
```
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
The package selects an exact-version native optional dependency for the current
|
|
14
|
+
platform. It has no install script and does not download executable code from a
|
|
15
|
+
third-party host. Node.js 22.18 or newer is required by the launcher,
|
|
16
|
+
integrations, and TypeScript configuration loader.
|
|
17
|
+
|
|
18
|
+
## Project Runtime
|
|
19
|
+
|
|
20
|
+
The framework integrations expose generated project metadata through the root
|
|
21
|
+
module during development:
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
```ts
|
|
24
|
+
import { tnl } from "@tnldotdev/tnl";
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
if (tnl) {
|
|
27
|
+
tnl.memberNamespace;
|
|
28
|
+
tnl.services.api.hostname;
|
|
29
|
+
tnl.services.api.url;
|
|
30
|
+
tnl.runningUnderTnlDev;
|
|
23
31
|
}
|
|
24
32
|
```
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
The `tnl` value is undefined during builds, previews, and production. During
|
|
35
|
+
`tnl dev`, `runningUnderTnlDev` is true and the integration receives complete
|
|
36
|
+
project metadata from the private protocol. During an ordinary framework
|
|
37
|
+
development server, the integration reads the generated `.tnl/project.json`
|
|
38
|
+
file without changing network configuration and sets `runningUnderTnlDev` to
|
|
39
|
+
false. If generated metadata is absent, `tnl` is undefined.
|
|
28
40
|
|
|
29
|
-
The
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
The tnl client also generates `.tnl/project.d.ts`. Include that directory in the
|
|
42
|
+
application's TypeScript inputs to get exact service keys and literal hostname,
|
|
43
|
+
URL, and common member-namespace values. Without the generated declaration,
|
|
44
|
+
the root module uses safe broad string and service-record types.
|
|
45
|
+
|
|
46
|
+
`tnl publish` cannot inject metadata into an application process that is already
|
|
47
|
+
running. Metadata generated earlier can still be available to ordinary local
|
|
48
|
+
development, with `runningUnderTnlDev` remaining false.
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
The package exports `defineConfig` and project configuration types:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
// tnl.config.ts
|
|
56
|
+
import { defineConfig } from "@tnldotdev/tnl/config";
|
|
57
|
+
|
|
58
|
+
export default defineConfig(({ worktree }) => ({
|
|
59
|
+
tunnel: { subdomain: worktree.label },
|
|
60
|
+
dev: { command: ["pnpm", "dev"] },
|
|
61
|
+
}));
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`worktree.label` combines a readable worktree name with an eight-character hash.
|
|
65
|
+
It is stable for one client state directory and differs across worktrees and
|
|
66
|
+
installations. Its private random input is not exposed to the configuration
|
|
67
|
+
factory.
|
|
68
|
+
|
|
69
|
+
`tnl.config.ts` is implicitly configuration version 1. Static `tnl.yml`,
|
|
70
|
+
`tnl.yaml`, and `tnl.json` files require `version: 1`; the JSON Schema is
|
|
71
|
+
available at `https://tnl.dev/schema/v1.json`.
|
|
72
|
+
|
|
73
|
+
`tnl init` adds this package, creates project and framework configuration when
|
|
74
|
+
it is absent, and ignores generated `.tnl` state. It preserves existing Next.js,
|
|
75
|
+
Vite, and TypeScript configuration and reports the exact integration actions
|
|
76
|
+
still needed.
|
|
77
|
+
|
|
78
|
+
## Next.js
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
// next.config.ts
|
|
82
|
+
import { withTnl } from "@tnldotdev/tnl/next";
|
|
83
|
+
|
|
84
|
+
export default withTnl({
|
|
85
|
+
reactStrictMode: true,
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`withTnl` preserves object, promised, synchronous-function, and
|
|
90
|
+
asynchronous-function configuration. During `tnl dev`, it adds the assigned
|
|
91
|
+
hostname to `allowedDevOrigins`, injects the project runtime, and registers the
|
|
92
|
+
actual listener target reported by Next.js after it binds. Existing host and
|
|
93
|
+
port choices, including Next.js defaults and custom values, are preserved. An
|
|
94
|
+
unforced port may use Next.js's normal occupied-port retry behavior without
|
|
95
|
+
tunneling a different process on the preferred port. A port forced by
|
|
96
|
+
`tnl dev --port` remains exact. Host settings remain independent, so a project
|
|
97
|
+
can intentionally expose its development server on the LAN as well as through
|
|
98
|
+
tnl.
|
|
99
|
+
|
|
100
|
+
Next.js 16.3.4 or newer is supported.
|
|
101
|
+
|
|
102
|
+
## Vite
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
// vite.config.ts
|
|
106
|
+
import { defineConfig } from "vite";
|
|
107
|
+
import tnl from "@tnldotdev/tnl/vite";
|
|
108
|
+
|
|
109
|
+
export default defineConfig({
|
|
110
|
+
plugins: [tnl()],
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
During `tnl dev`, the plugin allows the assigned hostname, injects the project
|
|
115
|
+
runtime, and registers Vite's actual post-bind target. It preserves Vite's
|
|
116
|
+
default or configured host and port behavior, including occupied-port retries;
|
|
117
|
+
a port forced by `tnl dev --port` remains exact. User host settings can
|
|
118
|
+
independently expose Vite on the LAN. During ordinary development the plugin
|
|
119
|
+
only injects generated metadata. Builds and previews remain inert. Vite 6.0.9
|
|
120
|
+
or newer is supported.
|
|
121
|
+
|
|
122
|
+
Next.js and Vite are optional peers, so only the framework already used by the
|
|
123
|
+
project is required. Keep hostname, policy, server, service, and command
|
|
124
|
+
settings in project configuration rather than passing integration options.
|
|
32
125
|
|
|
33
126
|
Deploy `tnld` with the release container or install it from Homebrew or a
|
|
34
127
|
release archive.
|