@foldkit/vite-plugin 0.16.0 → 0.16.1-canary.6a5cbafae641
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 +21 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @foldkit/vite-plugin
|
|
2
2
|
|
|
3
|
-
Vite plugin for Foldkit: view identity branding for the differ, plus hot module reloading with
|
|
3
|
+
Vite plugin for Foldkit: view identity branding for the differ, plus hot module reloading with Model preservation.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -38,20 +38,20 @@ Foldkit core modules are never instrumented, and functions that never return vno
|
|
|
38
38
|
|
|
39
39
|
When you save a file during development, the plugin:
|
|
40
40
|
|
|
41
|
-
1. Preserves your application's current
|
|
41
|
+
1. Preserves your application's current Model
|
|
42
42
|
2. Triggers a full page reload
|
|
43
|
-
3. Restores the preserved
|
|
43
|
+
3. Restores the preserved Model after reload
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Code changes do not reset the application. Forms stay filled, counters keep their values, and games keep their positions.
|
|
46
46
|
|
|
47
47
|
## How it works
|
|
48
48
|
|
|
49
49
|
The plugin uses Vite's WebSocket connection to communicate between the dev server and browser:
|
|
50
50
|
|
|
51
|
-
- **On file change**: The browser sends the current
|
|
52
|
-
- **On reload**: The browser requests the preserved
|
|
51
|
+
- **On file change**: The browser sends the current Model to the Vite server for preservation.
|
|
52
|
+
- **On reload**: The browser requests the preserved Model from the server and initializes the Foldkit Runtime with it.
|
|
53
53
|
|
|
54
|
-
Model
|
|
54
|
+
The Model survives hot reloads but clears on a manual browser refresh, so a refresh still resets the application.
|
|
55
55
|
|
|
56
56
|
## Server rendering dev host
|
|
57
57
|
|
|
@@ -67,7 +67,11 @@ Vite retains ownership of configured proxy routes before Foldkit handles applica
|
|
|
67
67
|
|
|
68
68
|
## Build id
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
The build id does not make hydration correct. It makes hydration refuse when it would otherwise be incorrect.
|
|
71
|
+
|
|
72
|
+
Server-rendered HTML carries the deployment id, and the client bundle carries its own copy. `Runtime.hydrate` compares them before reading the Flags payload or adopting DOM. When they differ, startup stops and the document body is marked `inert`, `aria-hidden`, and `data-foldkit-refused`. A nondismissable modal shield covers its controls and existing top-layer content, then takes focus without closing author-owned dialogs.
|
|
73
|
+
|
|
74
|
+
Nothing moves, so no custom element reconnects and no frame reloads. The containment blocks native page interaction; it is not a script or global-event sandbox. A client already running in an open tab is not rechecked when a deployment lands because the comparison happens only when a client boots against a page.
|
|
71
75
|
|
|
72
76
|
The plugin compiles the id into application code as `import.meta.env.FOLDKIT_BUILD_ID`, from its `buildId` option or from the `FOLDKIT_BUILD_ID` environment variable:
|
|
73
77
|
|
|
@@ -88,7 +92,13 @@ Server.renderToString(config, {
|
|
|
88
92
|
Runtime.hydrate(application, { buildId: import.meta.env.FOLDKIT_BUILD_ID })
|
|
89
93
|
```
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
Use a public value the deployment already has, such as a commit, release tag, or container digest. Three things have to be true:
|
|
96
|
+
|
|
97
|
+
- The id appears in the HTML every visitor receives, so it must never contain a secret.
|
|
98
|
+
- Two deployments must never share an id.
|
|
99
|
+
- The same value must reach the client and server builds, which run as separate commands.
|
|
100
|
+
|
|
101
|
+
A hydratable render given no id fails with `MissingBuildId`. Only a build takes the id from the deployment. The dev server compiles a fixed one because one live source session supplies both transforms and has no deployment identity to derive.
|
|
92
102
|
|
|
93
103
|
The standalone `foldkitSsr({ serverEntry, buildId })` export compiles the same define for its server entry. When it runs in development without an explicit value, it uses the fixed development id too. The aggregate `foldkit({ buildId, ssr })` plugin passes its top-level value through automatically.
|
|
94
104
|
|
|
@@ -96,7 +106,7 @@ The standalone `foldkitSsr({ serverEntry, buildId })` export compiles the same d
|
|
|
96
106
|
|
|
97
107
|
When `@foldkit/devtools` is installed as a development dependency, the plugin mounts its overlay automatically during development and leaves it out of production builds. No application import or `devTools.overlay` field is needed.
|
|
98
108
|
|
|
99
|
-
To include the overlay in production, list `@foldkit/devtools` in regular `dependencies` and set `devTools.show` to `'Always'`. Dependency placement controls whether Vite includes the overlay, and `show` controls whether the Foldkit
|
|
109
|
+
To include the overlay in production, list `@foldkit/devtools` in regular `dependencies` and set `devTools.show` to `'Always'`. Dependency placement controls whether Vite includes the overlay, and `show` controls whether the Foldkit Runtime mounts it.
|
|
100
110
|
|
|
101
111
|
## DevTools MCP relay
|
|
102
112
|
|
|
@@ -106,7 +116,7 @@ Pass `devToolsMcpPort` to enable the relay that exposes your running Foldkit app
|
|
|
106
116
|
plugins: [foldkit({ devToolsMcpPort: 9988 })]
|
|
107
117
|
```
|
|
108
118
|
|
|
109
|
-
When set, the plugin opens a separate WebSocket server on the given port. The MCP server connects to it and forwards typed `Request` and `Response` frames between AI agents and your
|
|
119
|
+
When set, the plugin opens a separate WebSocket server on the given port. The MCP server connects to it and forwards typed `Request` and `Response` frames between AI agents and your Runtime. Without `devToolsMcpPort` (the default), the relay is not started and the plugin behaves exactly as before.
|
|
110
120
|
|
|
111
121
|
See the [DevTools MCP documentation](https://foldkit.dev/ai/mcp) for setup, the available tools, and how dispatch validation works.
|
|
112
122
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EACV,MAAM,EAIP,MAAM,MAAM,CAAA;AAKb,OAAO,EAAE,KAAK,iBAAiB,EAAc,MAAM,UAAU,CAAA;AAG7D,OAAO,EAAE,KAAK,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EACL,KAAK,2BAA2B,EAChC,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAE1B,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAA;IACxC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EACV,MAAM,EAIP,MAAM,MAAM,CAAA;AAKb,OAAO,EAAE,KAAK,iBAAiB,EAAc,MAAM,UAAU,CAAA;AAG7D,OAAO,EAAE,KAAK,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EACL,KAAK,2BAA2B,EAChC,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAE1B,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAA;IACxC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAC,CAAA;AAklBF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,UAAS,oBAAyB,KAAG,KAAK,CAAC,MAAM,CA+ExE,CAAA"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foldkit/vite-plugin",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1-canary.6a5cbafae641",
|
|
4
4
|
"description": "Vite plugin for Foldkit hot module reloading with state preservation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"effect": "4.0.0-rc.109",
|
|
20
|
-
"foldkit": "
|
|
20
|
+
"foldkit": "0.148.2-canary.6a5cbafae641",
|
|
21
21
|
"vite": "^7.0.0 || ^8.0.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"vite": "^8.0.16",
|
|
35
35
|
"vite7": "npm:vite@^7.0.0",
|
|
36
36
|
"vitest": "^4.1.9",
|
|
37
|
-
"foldkit": "0.148.
|
|
37
|
+
"foldkit": "0.148.2-canary.6a5cbafae641"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
40
|
"vite",
|