tw-framework 2.0.2 → 2.0.3
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/CHANGELOG.md +21 -0
- package/dist/hydration-runtime.js +14 -1
- package/dist/testing.cjs +1 -1
- package/dist/tw-server.mjs +1 -1
- package/dist/tw.mjs +8 -5
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,27 @@ Notable changes to TW Framework. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/), and the project uses
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [2.0.3]
|
|
8
|
+
|
|
9
|
+
A patch release: bug fixes only, no breaking changes, no public API changes.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Runtime -- hydration no longer discards server-rendered values.** A value
|
|
14
|
+
that comes from a page's `server { }` block is never serialised into
|
|
15
|
+
`__tw_state`, so the client runtime saw it as missing: a `for` loop over such a
|
|
16
|
+
value was emptied, an interpolation reading one was blanked, and an `if`
|
|
17
|
+
testing one was hidden -- after the server had already rendered them correctly.
|
|
18
|
+
An expression that evaluates to `undefined` is now treated as "not client
|
|
19
|
+
state" and the server's markup is left alone. Real client state stays reactive.
|
|
20
|
+
- **`tw dev` -- `strategies.hydration.mode: "none"` is honoured.** The dev server
|
|
21
|
+
injected the hydration runtime unconditionally, so there was no way to look at
|
|
22
|
+
a page without hydration while building it.
|
|
23
|
+
- **CLI -- the `tw-framework` bin alias.** The package declared only a `tw` bin,
|
|
24
|
+
so `bunx tw-framework dev` and a `"build": "tw-framework build"` script both
|
|
25
|
+
failed with "not found" even though the README documents that form. Both names
|
|
26
|
+
resolve to the same entry point now.
|
|
27
|
+
|
|
7
28
|
## [2.0.2]
|
|
8
29
|
|
|
9
30
|
A patch release: bug fixes only. No new features, no breaking changes, and no
|
|
@@ -66,6 +66,8 @@
|
|
|
66
66
|
var el = ifs[i];
|
|
67
67
|
if (ownedByLoop(el)) continue;
|
|
68
68
|
var val = evalExpr(el.getAttribute("data-tw-if"));
|
|
69
|
+
// Not client state (a server { } value): keep the branch the server chose.
|
|
70
|
+
if (val === undefined) continue;
|
|
69
71
|
var show = !!val && val !== "false" && val !== "0" && val !== "";
|
|
70
72
|
el.style.display = show ? "" : "none";
|
|
71
73
|
}
|
|
@@ -74,6 +76,7 @@
|
|
|
74
76
|
var el2 = nots[j];
|
|
75
77
|
if (ownedByLoop(el2)) continue;
|
|
76
78
|
var val2 = evalExpr(el2.getAttribute("data-tw-not"));
|
|
79
|
+
if (val2 === undefined) continue;
|
|
77
80
|
var hide = !!val2 && val2 !== "false" && val2 !== "0" && val2 !== "";
|
|
78
81
|
el2.style.display = hide ? "none" : "";
|
|
79
82
|
}
|
|
@@ -88,7 +91,10 @@
|
|
|
88
91
|
var holder = document.createElement("tw-render");
|
|
89
92
|
holder.innerHTML = tpl;
|
|
90
93
|
var spans = holder.querySelectorAll("[data-tw-i]");
|
|
91
|
-
for (var i = 0; i < spans.length; i++)
|
|
94
|
+
for (var i = 0; i < spans.length; i++) {
|
|
95
|
+
if (evalExpr(spans[i].getAttribute("data-tw-i")) === undefined) continue;
|
|
96
|
+
setSpanText(spans[i], spans[i].getAttribute("data-tw-i"));
|
|
97
|
+
}
|
|
92
98
|
|
|
93
99
|
// Nested if/not inside the loop body (evaluated while loopVar is bound)
|
|
94
100
|
var all = holder.querySelectorAll("*");
|
|
@@ -139,6 +145,10 @@
|
|
|
139
145
|
for (var i = 0; i < loops.length; i++) {
|
|
140
146
|
var el = loops[i];
|
|
141
147
|
var arr = evalExpr(el.getAttribute("data-tw-list"));
|
|
148
|
+
// `undefined` means the name is not client state -- a value a server { }
|
|
149
|
+
// block produced, which is never serialised into __tw_state. Treating it
|
|
150
|
+
// as [] wiped the items the server had already rendered.
|
|
151
|
+
if (arr === undefined) continue;
|
|
142
152
|
var v = el.getAttribute("data-tw-var");
|
|
143
153
|
var tpl = el.getAttribute("data-tw-tpl") || "";
|
|
144
154
|
if (!Array.isArray(arr)) arr = [];
|
|
@@ -182,6 +192,9 @@
|
|
|
182
192
|
// here (with the variable out of scope) blanked the text the build had
|
|
183
193
|
// already produced correctly.
|
|
184
194
|
if (spans[i].closest && spans[i].closest("tw-for")) continue;
|
|
195
|
+
// Same rule: an expression that is not client state leaves the
|
|
196
|
+
// server-rendered text alone instead of blanking it.
|
|
197
|
+
if (evalExpr(spans[i].getAttribute("data-tw-i")) === undefined) continue;
|
|
185
198
|
setSpanText(spans[i], spans[i].getAttribute("data-tw-i"));
|
|
186
199
|
}
|
|
187
200
|
var inputs = document.querySelectorAll("[data-tw-model]");
|
package/dist/testing.cjs
CHANGED
|
@@ -236171,7 +236171,7 @@ var init_types4 = __esm({
|
|
|
236171
236171
|
var TW_VERSION, TW_GENERATOR_META;
|
|
236172
236172
|
var init_version = __esm({
|
|
236173
236173
|
"../../packages/compiler/tw/codegen/version.ts"() {
|
|
236174
|
-
TW_VERSION = "2.0.
|
|
236174
|
+
TW_VERSION = "2.0.3";
|
|
236175
236175
|
TW_GENERATOR_META = `<meta name="generator" content="TW Framework ${TW_VERSION}">`;
|
|
236176
236176
|
}
|
|
236177
236177
|
});
|
package/dist/tw-server.mjs
CHANGED
|
@@ -237242,7 +237242,7 @@ var init_types4 = __esm({
|
|
|
237242
237242
|
var TW_VERSION, TW_GENERATOR_META;
|
|
237243
237243
|
var init_version = __esm({
|
|
237244
237244
|
"../../packages/compiler/tw/codegen/version.ts"() {
|
|
237245
|
-
TW_VERSION = "2.0.
|
|
237245
|
+
TW_VERSION = "2.0.3";
|
|
237246
237246
|
TW_GENERATOR_META = `<meta name="generator" content="TW Framework ${TW_VERSION}">`;
|
|
237247
237247
|
}
|
|
237248
237248
|
});
|
package/dist/tw.mjs
CHANGED
|
@@ -236327,7 +236327,7 @@ var init_types4 = __esm({
|
|
|
236327
236327
|
var TW_VERSION, TW_GENERATOR_META;
|
|
236328
236328
|
var init_version = __esm({
|
|
236329
236329
|
"../../packages/compiler/tw/codegen/version.ts"() {
|
|
236330
|
-
TW_VERSION = "2.0.
|
|
236330
|
+
TW_VERSION = "2.0.3";
|
|
236331
236331
|
TW_GENERATOR_META = `<meta name="generator" content="TW Framework ${TW_VERSION}">`;
|
|
236332
236332
|
}
|
|
236333
236333
|
});
|
|
@@ -294675,7 +294675,7 @@ async function createPackageJson(dir, name) {
|
|
|
294675
294675
|
ship: "tw ship"
|
|
294676
294676
|
},
|
|
294677
294677
|
dependencies: {
|
|
294678
|
-
"tw-framework": "^2.0.
|
|
294678
|
+
"tw-framework": "^2.0.3"
|
|
294679
294679
|
},
|
|
294680
294680
|
devDependencies: {
|
|
294681
294681
|
typescript: "^5.4.0",
|
|
@@ -294762,7 +294762,7 @@ dist/
|
|
|
294762
294762
|
async function createReadme(dir, name) {
|
|
294763
294763
|
const content = `# ${name}
|
|
294764
294764
|
|
|
294765
|
-
Built with TW Framework 2.0.
|
|
294765
|
+
Built with TW Framework 2.0.3.
|
|
294766
294766
|
|
|
294767
294767
|
## Getting Started
|
|
294768
294768
|
|
|
@@ -296199,6 +296199,7 @@ async function devCommand() {
|
|
|
296199
296199
|
let devRewrites = [];
|
|
296200
296200
|
let devSigCfg = void 0;
|
|
296201
296201
|
let devApiDir = "api";
|
|
296202
|
+
let devHydrationOff = false;
|
|
296202
296203
|
let devSignalTransport = "sse";
|
|
296203
296204
|
try {
|
|
296204
296205
|
const cfgFile = join31(rootDir, "tw.config.ts");
|
|
@@ -296222,6 +296223,7 @@ async function devCommand() {
|
|
|
296222
296223
|
if (cfg?.headers) {
|
|
296223
296224
|
devCfgHeaders = Array.isArray(cfg.headers) ? cfg.headers : Object.entries(cfg.headers).map(([source, headers]) => ({ source, headers }));
|
|
296224
296225
|
}
|
|
296226
|
+
if (cfg?.strategies?.hydration?.mode === "none") devHydrationOff = true;
|
|
296225
296227
|
const st = cfg?.strategies?.signals?.transport;
|
|
296226
296228
|
if (st === "sse" || st === "ws" || st === "long-poll") devSignalTransport = st;
|
|
296227
296229
|
if (cfg?.signalStream) devSigCfg = cfg.signalStream;
|
|
@@ -296533,7 +296535,8 @@ async function devCommand() {
|
|
|
296533
296535
|
`;
|
|
296534
296536
|
}
|
|
296535
296537
|
if (/<\/body>/.test(html)) {
|
|
296536
|
-
|
|
296538
|
+
const runtimeTag = devHydrationOff ? "" : ' <script src="/__tw_runtime.js"></script>\n';
|
|
296539
|
+
html = html.replace("</body>", devClientTag + (devOpts?.overlay === false ? "" : CLIENT_OVERLAY_SCRIPT) + runtimeTag + "</body>");
|
|
296537
296540
|
}
|
|
296538
296541
|
const devGlobalHead = join31(homeDir, "head.tw");
|
|
296539
296542
|
const devHeadSources = [];
|
|
@@ -297304,7 +297307,7 @@ function ensureTestingShim(rootDir) {
|
|
|
297304
297307
|
if (existsSync32(marker)) return;
|
|
297305
297308
|
const { mkdirSync: mkdirSync12, writeFileSync: writeFileSync14 } = _require("node:fs");
|
|
297306
297309
|
mkdirSync12(join37(shimPkgDir, "tw"), { recursive: true });
|
|
297307
|
-
writeFileSync14(marker, JSON.stringify({ name: "@tw/server", version: "2.0.
|
|
297310
|
+
writeFileSync14(marker, JSON.stringify({ name: "@tw/server", version: "2.0.3", private: true }, null, 2));
|
|
297308
297311
|
let testingBundle = null;
|
|
297309
297312
|
try {
|
|
297310
297313
|
const here = new URL(".", import.meta.url).pathname;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tw-framework",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Full-stack web framework \u2014 own template language (.tw), styling (.tss), compiler and VDOM; runs on Bun and Node",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/tw.mjs",
|
|
7
7
|
"bin": {
|
|
8
|
-
"tw": "./dist/tw.mjs"
|
|
8
|
+
"tw": "./dist/tw.mjs",
|
|
9
|
+
"tw-framework": "./dist/tw.mjs"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
11
12
|
"esbuild": "^0.21.0"
|