@timber-js/app 0.2.0-alpha.194 → 0.2.0-alpha.195
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/LICENSE +8 -0
- package/dist/_chunks/{cli-schema-sync-ZwM9u_ob.js → cli-schema-sync-3Wutm8pH.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-ZwM9u_ob.js.map → cli-schema-sync-3Wutm8pH.js.map} +1 -1
- package/dist/_chunks/{error-boundary-D-ODYX41.js → error-boundary-D-lkwyaD.js} +3 -3
- package/dist/_chunks/{error-boundary-D-ODYX41.js.map → error-boundary-D-lkwyaD.js.map} +1 -1
- package/dist/_chunks/{router-ref-DuYuV_0Q.js → router-ref-BzqbPwYC.js} +2 -2
- package/dist/_chunks/{router-ref-DuYuV_0Q.js.map → router-ref-BzqbPwYC.js.map} +1 -1
- package/dist/_chunks/{ssr-data-14MXm7Pj.js → ssr-data-Ya2HJPFp.js} +1 -7
- package/dist/_chunks/{ssr-data-14MXm7Pj.js.map → ssr-data-Ya2HJPFp.js.map} +1 -1
- package/dist/_chunks/{use-segment-params-C4r4BD9T.js → use-segment-params-DzTBpkvj.js} +3 -3
- package/dist/_chunks/{use-segment-params-C4r4BD9T.js.map → use-segment-params-DzTBpkvj.js.map} +1 -1
- package/dist/_chunks/{walkers-uCu3WW6_.js → walkers-BU6z9xRV.js} +2 -2
- package/dist/_chunks/{walkers-uCu3WW6_.js.map → walkers-BU6z9xRV.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +3 -3
- package/dist/client/internal.js +4 -4
- package/dist/config-types.d.ts +12 -9
- package/dist/config-types.d.ts.map +1 -1
- package/dist/cookies/index.js +1 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -35
- package/dist/index.js.map +1 -1
- package/dist/routing/index.js +1 -1
- package/dist/server/index.js +1 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server/internal.js +1 -1
- package/docs/api/34-api-config.mdx +7 -4
- package/docs/learn/13-configuration.mdx +1 -1
- package/package.json +12 -12
- package/src/cli.ts +0 -0
- package/src/config-types.ts +12 -9
- package/src/index.ts +44 -58
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { t as MDX_EXTENSIONS } from "./_chunks/mdx-file-CXyHGUpS.js";
|
|
|
7
7
|
import { h as swallow } from "./_chunks/logger-pumCm3Il.js";
|
|
8
8
|
import { c as writeRouteCodegen, i as getPrerenderExport, l as buildDirToRouteMap, n as formatConventionWarnings, r as lintConventions, s as flushCodegenWrites, t as checkAppDirExists } from "./_chunks/convention-lint-DO10_pVl.js";
|
|
9
9
|
import { c as resolveClientJavascript, i as mergeFileConfig, l as createNoopTimer, o as resolveAppDir, r as loadTimberConfigFile, s as resolveBuildDir, t as createPluginContext } from "./_chunks/plugin-context-8idfR3UZ.js";
|
|
10
|
-
import { r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-
|
|
10
|
+
import { r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-BU6z9xRV.js";
|
|
11
11
|
import { i as poisonPillSource, r as markerFor, t as EXPLICIT_MARKERS } from "./_chunks/poison-rules-DoEhbqaY.js";
|
|
12
12
|
import { i as withBasePath, n as normalizeBasePath, t as isRelativeBase } from "./_chunks/base-path-DaQrzbez.js";
|
|
13
13
|
import { t as rscPayloadPath } from "./_chunks/rsc-payload-path-B_LBodc2.js";
|
|
@@ -18,7 +18,7 @@ import { t as formatSize } from "./_chunks/format-BKclgVbk.js";
|
|
|
18
18
|
import { createLogger, normalizePath, parseAst } from "vite";
|
|
19
19
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve, win32 } from "node:path";
|
|
20
20
|
import { builtinModules, createRequire } from "node:module";
|
|
21
|
-
import react
|
|
21
|
+
import react from "@vitejs/plugin-react";
|
|
22
22
|
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
23
23
|
import nodeHTTP from "node:http";
|
|
24
24
|
import { Readable, pipeline } from "node:stream";
|
|
@@ -117,7 +117,7 @@ function timberContent(ctx) {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
|
-
//#region ../../node_modules/.pnpm/srvx@0.12.
|
|
120
|
+
//#region ../../node_modules/.pnpm/srvx@0.12.7/node_modules/srvx/dist/adapters/node.mjs
|
|
121
121
|
function sendNodeResponse(nodeRes, webRes) {
|
|
122
122
|
try {
|
|
123
123
|
return _sendNodeResponse(nodeRes, webRes, false) || Promise.resolve();
|
|
@@ -148,8 +148,14 @@ function _sendNodeResponse(nodeRes, webRes, detached) {
|
|
|
148
148
|
return webRes.body ? streamBody(webRes.body, nodeRes) : endNodeResponse(nodeRes, detached);
|
|
149
149
|
}
|
|
150
150
|
function writeHead(nodeRes, status, statusText, rawHeaders) {
|
|
151
|
-
if (!nodeRes.headersSent)
|
|
152
|
-
|
|
151
|
+
if (!nodeRes.headersSent) {
|
|
152
|
+
if (nodeRes.req?.httpVersion === "2.0") nodeRes.writeHead(status, rawHeaders);
|
|
153
|
+
else nodeRes.writeHead(status, safeStatusText(statusText), rawHeaders);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
var INVALID_REASON_PHRASE_RE = /[^\t\u0020-\u007E\u0080-\u00FF]/g;
|
|
157
|
+
function safeStatusText(statusText) {
|
|
158
|
+
return typeof statusText === "string" && statusText ? statusText.replace(INVALID_REASON_PHRASE_RE, "") : statusText;
|
|
153
159
|
}
|
|
154
160
|
function endNodeResponse(nodeRes, detached) {
|
|
155
161
|
if (detached) {
|
|
@@ -163,6 +169,12 @@ function pipeBody(stream, nodeRes, status, statusText, headers) {
|
|
|
163
169
|
stream.destroy?.();
|
|
164
170
|
return;
|
|
165
171
|
}
|
|
172
|
+
if (nodeRes.req?.method === "HEAD") {
|
|
173
|
+
if (typeof stream.destroy === "function") stream.destroy();
|
|
174
|
+
else stream.abort?.();
|
|
175
|
+
writeHead(nodeRes, status, statusText, headers);
|
|
176
|
+
return endNodeResponse(nodeRes);
|
|
177
|
+
}
|
|
166
178
|
if (typeof stream.on !== "function" || typeof stream.destroy !== "function") {
|
|
167
179
|
writeHead(nodeRes, status, statusText, headers);
|
|
168
180
|
stream.pipe(nodeRes);
|
|
@@ -173,14 +185,19 @@ function pipeBody(stream, nodeRes, status, statusText, headers) {
|
|
|
173
185
|
return endNodeResponse(nodeRes);
|
|
174
186
|
}
|
|
175
187
|
return new Promise((resolve) => {
|
|
176
|
-
function
|
|
188
|
+
function cleanup() {
|
|
189
|
+
stream.off("error", onEarlyError);
|
|
177
190
|
stream.off("readable", onReadable);
|
|
191
|
+
nodeRes.off("close", onResClose);
|
|
192
|
+
}
|
|
193
|
+
function onEarlyError() {
|
|
194
|
+
cleanup();
|
|
178
195
|
stream.destroy();
|
|
179
196
|
writeHead(nodeRes, 500, "Internal Server Error", []);
|
|
180
197
|
endNodeResponse(nodeRes).then(resolve);
|
|
181
198
|
}
|
|
182
199
|
function onReadable() {
|
|
183
|
-
|
|
200
|
+
cleanup();
|
|
184
201
|
if (nodeRes.destroyed) {
|
|
185
202
|
stream.destroy();
|
|
186
203
|
return resolve();
|
|
@@ -188,8 +205,14 @@ function pipeBody(stream, nodeRes, status, statusText, headers) {
|
|
|
188
205
|
writeHead(nodeRes, status, statusText, headers);
|
|
189
206
|
pipeline$1(stream, nodeRes).catch(() => {}).then(() => resolve());
|
|
190
207
|
}
|
|
208
|
+
function onResClose() {
|
|
209
|
+
cleanup();
|
|
210
|
+
stream.destroy();
|
|
211
|
+
resolve();
|
|
212
|
+
}
|
|
191
213
|
stream.once("error", onEarlyError);
|
|
192
214
|
stream.once("readable", onReadable);
|
|
215
|
+
nodeRes.once("close", onResClose);
|
|
193
216
|
});
|
|
194
217
|
}
|
|
195
218
|
function streamBody(stream, nodeRes) {
|
|
@@ -4852,7 +4875,7 @@ function encode(decoded) {
|
|
|
4852
4875
|
return writer.flush();
|
|
4853
4876
|
}
|
|
4854
4877
|
//#endregion
|
|
4855
|
-
//#region ../../node_modules/.pnpm/magic-string@1.2.
|
|
4878
|
+
//#region ../../node_modules/.pnpm/magic-string@1.2.2/node_modules/magic-string/dist/index.mjs
|
|
4856
4879
|
var BitSet = class BitSet {
|
|
4857
4880
|
constructor(arg) {
|
|
4858
4881
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
@@ -5257,6 +5280,10 @@ var MagicString = class MagicString {
|
|
|
5257
5280
|
offset: {
|
|
5258
5281
|
writable: true,
|
|
5259
5282
|
value: options.offset || 0
|
|
5283
|
+
},
|
|
5284
|
+
hasMovedChunks: {
|
|
5285
|
+
writable: true,
|
|
5286
|
+
value: false
|
|
5260
5287
|
}
|
|
5261
5288
|
});
|
|
5262
5289
|
}
|
|
@@ -5308,6 +5335,7 @@ var MagicString = class MagicString {
|
|
|
5308
5335
|
clone() {
|
|
5309
5336
|
const cloned = new MagicString(this.original, {
|
|
5310
5337
|
filename: this.filename,
|
|
5338
|
+
ignoreList: this.ignoreList,
|
|
5311
5339
|
offset: this.offset
|
|
5312
5340
|
});
|
|
5313
5341
|
let originalChunk = this.firstChunk;
|
|
@@ -5327,8 +5355,10 @@ var MagicString = class MagicString {
|
|
|
5327
5355
|
cloned.lastChunk = clonedChunk;
|
|
5328
5356
|
if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
5329
5357
|
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
5358
|
+
cloned.storedNames = { ...this.storedNames };
|
|
5330
5359
|
cloned.intro = this.intro;
|
|
5331
5360
|
cloned.outro = this.outro;
|
|
5361
|
+
cloned.hasMovedChunks = this.hasMovedChunks;
|
|
5332
5362
|
return cloned;
|
|
5333
5363
|
}
|
|
5334
5364
|
/**
|
|
@@ -5489,6 +5519,13 @@ var MagicString = class MagicString {
|
|
|
5489
5519
|
this._split(index);
|
|
5490
5520
|
const first = this.byStart.get(start);
|
|
5491
5521
|
const last = this.byEnd.get(end);
|
|
5522
|
+
if (this.hasMovedChunks) {
|
|
5523
|
+
let cursor = first;
|
|
5524
|
+
while (cursor !== last) {
|
|
5525
|
+
cursor = cursor.next;
|
|
5526
|
+
if (!cursor || cursor.start < start || cursor.end > end) throw new MagicStringError(`cannot move ${start} to ${end} because an earlier move split that range`);
|
|
5527
|
+
}
|
|
5528
|
+
}
|
|
5492
5529
|
const oldLeft = first.previous;
|
|
5493
5530
|
const oldRight = last.next;
|
|
5494
5531
|
const newRight = this.byStart.get(index);
|
|
@@ -5507,6 +5544,7 @@ var MagicString = class MagicString {
|
|
|
5507
5544
|
last.next = newRight || null;
|
|
5508
5545
|
if (!newLeft) this.firstChunk = first;
|
|
5509
5546
|
if (!newRight) this.lastChunk = last;
|
|
5547
|
+
this.hasMovedChunks = true;
|
|
5510
5548
|
return this;
|
|
5511
5549
|
}
|
|
5512
5550
|
/**
|
|
@@ -5870,7 +5908,19 @@ var MagicString = class MagicString {
|
|
|
5870
5908
|
* Indicates if the string has been changed.
|
|
5871
5909
|
*/
|
|
5872
5910
|
hasChanged() {
|
|
5873
|
-
|
|
5911
|
+
if (this.intro || this.outro) return true;
|
|
5912
|
+
let outputIndex = 0;
|
|
5913
|
+
let chunk = this.firstChunk;
|
|
5914
|
+
while (chunk) {
|
|
5915
|
+
if (chunk.intro || chunk.outro) return true;
|
|
5916
|
+
if (!chunk.edited && chunk.start === outputIndex) outputIndex = chunk.end;
|
|
5917
|
+
else {
|
|
5918
|
+
if (!this.original.startsWith(chunk.content, outputIndex)) return true;
|
|
5919
|
+
outputIndex += chunk.content.length;
|
|
5920
|
+
}
|
|
5921
|
+
chunk = chunk.next;
|
|
5922
|
+
}
|
|
5923
|
+
return outputIndex !== this.original.length;
|
|
5874
5924
|
}
|
|
5875
5925
|
/** @internal */
|
|
5876
5926
|
_replaceRegexp(searchValue, replacement) {
|
|
@@ -11032,27 +11082,6 @@ function defineConfig(config) {
|
|
|
11032
11082
|
return config;
|
|
11033
11083
|
}
|
|
11034
11084
|
/**
|
|
11035
|
-
* Resolve the React Compiler plugin via @rolldown/plugin-babel.
|
|
11036
|
-
*
|
|
11037
|
-
* Uses the `reactCompilerPreset` from @vitejs/plugin-react, which:
|
|
11038
|
-
* - Uses Babel ONLY for the compiler pass (OXC handles JSX)
|
|
11039
|
-
* - Automatically scopes to client environment via applyToEnvironmentHook
|
|
11040
|
-
* - Uses react/compiler-runtime built into React 19
|
|
11041
|
-
*
|
|
11042
|
-
* @rolldown/plugin-babel and babel-plugin-react-compiler are optional peer deps.
|
|
11043
|
-
* If either is missing, require() fails with a clear error message.
|
|
11044
|
-
*/
|
|
11045
|
-
function resolveReactCompilerPlugin(config, req) {
|
|
11046
|
-
let babel;
|
|
11047
|
-
try {
|
|
11048
|
-
babel = req("@rolldown/plugin-babel");
|
|
11049
|
-
} catch {
|
|
11050
|
-
throw new Error("[timber] reactCompiler requires @rolldown/plugin-babel. Install it: pnpm add -D @rolldown/plugin-babel babel-plugin-react-compiler");
|
|
11051
|
-
}
|
|
11052
|
-
const options = typeof config === "object" ? config : {};
|
|
11053
|
-
return (babel.default ?? babel)({ presets: [reactCompilerPreset(options)] });
|
|
11054
|
-
}
|
|
11055
|
-
/**
|
|
11056
11085
|
* Build the options object for @vitejs/plugin-rsc.
|
|
11057
11086
|
*
|
|
11058
11087
|
* Uses a getter for `enableActionEncryption` so the RSC plugin reads
|
|
@@ -11095,6 +11124,24 @@ function createRscOptions(ctx, encryptionKeyExpr) {
|
|
|
11095
11124
|
* causing file-based config for reactCompiler, actionEncryption, and
|
|
11096
11125
|
* output mode to be silently ignored. See TIM-451.
|
|
11097
11126
|
*/
|
|
11127
|
+
/**
|
|
11128
|
+
* Wrap plugin-react's `vite:react-compiler` configResolved so it always
|
|
11129
|
+
* sees `isProduction: true` during builds. The compiler plugin uses
|
|
11130
|
+
* `!config.isProduction` to decide whether to emit jsxDEV calls, but
|
|
11131
|
+
* Vite derives isProduction from process.env.NODE_ENV — which may be
|
|
11132
|
+
* "development" in the shell. Rather than mutating the env, we pass a
|
|
11133
|
+
* prototype-based view with the single property overridden.
|
|
11134
|
+
*/
|
|
11135
|
+
function patchReactCompilerForProdJsx(plugins) {
|
|
11136
|
+
for (const p of plugins) if (p && typeof p === "object" && "name" in p && p.name === "vite:react-compiler") {
|
|
11137
|
+
const orig = p.configResolved;
|
|
11138
|
+
if (typeof orig === "function") p.configResolved = function(config) {
|
|
11139
|
+
const view = config.command === "build" && !config.isProduction ? Object.create(config, { isProduction: { value: true } }) : config;
|
|
11140
|
+
return orig.call(this, view);
|
|
11141
|
+
};
|
|
11142
|
+
}
|
|
11143
|
+
return plugins;
|
|
11144
|
+
}
|
|
11098
11145
|
function timber(config) {
|
|
11099
11146
|
const ctx = createPluginContext(config);
|
|
11100
11147
|
const consumerRequire = createRequire(join(process.cwd(), "package.json"));
|
|
@@ -11216,15 +11263,12 @@ function timber(config) {
|
|
|
11216
11263
|
if (peerWarning) process.stderr.write(`${peerWarning}\n\n`);
|
|
11217
11264
|
}
|
|
11218
11265
|
};
|
|
11219
|
-
const
|
|
11220
|
-
const effectiveReactCompiler = config?.reactCompiler ?? earlyFileConfig?.reactCompiler;
|
|
11221
|
-
if (effectiveReactCompiler) reactCompilerPlugins.push(resolveReactCompilerPlugin(effectiveReactCompiler, consumerRequire));
|
|
11266
|
+
const effectiveReactCompiler = config?.reactCompiler ?? earlyFileConfig?.reactCompiler ?? true;
|
|
11222
11267
|
// @vitejs/plugin-rsc handles:
|
|
11223
11268
|
return [
|
|
11224
11269
|
rootSync,
|
|
11225
11270
|
timberReactProd(),
|
|
11226
|
-
react(),
|
|
11227
|
-
...reactCompilerPlugins,
|
|
11271
|
+
...patchReactCompilerForProdJsx(react({ compiler: effectiveReactCompiler || false })),
|
|
11228
11272
|
vitePluginRsc(createRscOptions(ctx, encryptionKeyExpr)),
|
|
11229
11273
|
timberShims(ctx),
|
|
11230
11274
|
timberRouting(ctx),
|