reroute-js 0.25.3 → 0.26.1
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 +153 -53
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +446 -150
- package/cli/bin.js.map +13 -9
- package/cli/index.d.ts +1 -1
- package/cli/index.js +4 -4
- package/cli/index.js.map +1 -1
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/build.d.ts +1 -1
- package/cli/src/commands/dev.d.ts +1 -1
- package/cli/src/commands/gen.d.ts +1 -1
- package/cli/src/commands/gen.d.ts.map +1 -1
- package/cli/src/commands/index.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/lib/assets.d.ts +1 -1
- package/cli/src/commands/lib/bundler.d.ts +1 -1
- package/cli/src/commands/lib/command.d.ts +1 -1
- package/cli/src/commands/lib/env.d.ts +1 -1
- package/cli/src/commands/lib/index.d.ts +1 -1
- package/cli/src/commands/lib/log.d.ts +1 -1
- package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
- package/cli/src/commands/lib/markdown/index.d.ts +1 -1
- package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
- package/cli/src/commands/lib/production.d.ts +1 -1
- package/cli/src/commands/lib/server.d.ts +1 -1
- package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
- package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
- package/cli/src/commands/lib/tailwind.d.ts +1 -1
- package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
- package/cli/src/commands/lib/version.d.ts +1 -1
- package/cli/src/commands/og.d.ts +1 -1
- package/cli/src/commands/start.d.ts +1 -1
- package/cli/src/index.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +912 -589
- package/core/index.js.map +22 -14
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +243 -2
- package/core/src/config.d.ts.map +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/llms/extractor.d.ts +1 -1
- package/core/src/llms/formatter.d.ts +1 -1
- package/core/src/llms/full-generator.d.ts +1 -1
- package/core/src/llms/index-generator.d.ts +1 -1
- package/core/src/llms/index.d.ts +1 -1
- package/core/src/og/discovery.d.ts +1 -1
- package/core/src/og/index.d.ts +1 -1
- package/core/src/og/meta.d.ts +1 -1
- package/core/src/og/render.d.ts +1 -1
- package/core/src/og/types.d.ts +1 -1
- package/core/src/robots/discovery.d.ts +1 -1
- package/core/src/robots/generator.d.ts +1 -1
- package/core/src/robots/index.d.ts +1 -1
- package/core/src/robots/policies.d.ts +1 -1
- package/core/src/rss/discovery.d.ts +1 -1
- package/core/src/rss/generator.d.ts +1 -1
- package/core/src/rss/index.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts +1 -1
- package/core/src/sitemap/generator.d.ts +1 -1
- package/core/src/sitemap/index.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/lib/cache.d.ts +1 -1
- package/core/src/ssr/lib/collections.d.ts +1 -1
- package/core/src/ssr/lib/compression.d.ts +1 -1
- package/core/src/ssr/lib/compute/content.d.ts +1 -1
- package/core/src/ssr/lib/compute/index.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts +1 -1
- package/core/src/ssr/lib/data.d.ts +1 -1
- package/core/src/ssr/lib/html.d.ts +1 -1
- package/core/src/ssr/lib/imports.d.ts +1 -1
- package/core/src/ssr/lib/index.d.ts +1 -1
- package/core/src/ssr/lib/layouts.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts +1 -1
- package/core/src/ssr/lib/mime.d.ts +1 -1
- package/core/src/ssr/lib/modules.d.ts +1 -1
- package/core/src/ssr/lib/path.d.ts +1 -1
- package/core/src/ssr/lib/preload.d.ts +1 -1
- package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
- package/core/src/ssr/lib/scripts/data.d.ts +2 -2
- package/core/src/ssr/lib/scripts/data.d.ts.map +1 -1
- package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
- package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
- package/core/src/ssr/lib/scripts/index.d.ts +1 -1
- package/core/src/ssr/lib/seed.d.ts +1 -1
- package/core/src/ssr/lib/setup.d.ts +4 -2
- package/core/src/ssr/lib/setup.d.ts.map +1 -1
- package/core/src/ssr/lib/styles.d.ts +1 -1
- package/core/src/ssr/lib/template.d.ts +1 -1
- package/core/src/ssr/lib/types.d.ts +1 -1
- package/core/src/ssr/render.d.ts +4 -2
- package/core/src/ssr/render.d.ts.map +1 -1
- package/core/src/ssr/stream.d.ts +4 -2
- package/core/src/ssr/stream.d.ts.map +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +715 -468
- package/elysia/index.js.map +15 -11
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/assets.d.ts +1 -1
- package/elysia/src/libs/cache.d.ts +1 -1
- package/elysia/src/libs/caching.d.ts +1 -1
- package/elysia/src/libs/http.d.ts +1 -1
- package/elysia/src/libs/image.d.ts +1 -1
- package/elysia/src/libs/index.d.ts +1 -1
- package/elysia/src/libs/llms.d.ts +1 -1
- package/elysia/src/libs/response.d.ts +1 -1
- package/elysia/src/libs/serving.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/content.d.ts +1 -1
- package/elysia/src/routes/content.d.ts.map +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/index.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts +1 -1
- package/elysia/src/routes/llms.d.ts +1 -1
- package/elysia/src/routes/og.d.ts +1 -1
- package/elysia/src/routes/redirects.d.ts +1 -1
- package/elysia/src/routes/robots.d.ts +1 -1
- package/elysia/src/routes/rss.d.ts +1 -1
- package/elysia/src/routes/search.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts.map +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/routes/static.d.ts.map +1 -1
- package/elysia/src/types.d.ts +1 -1
- package/package.json +4 -15
- package/react/index.d.ts +1 -1
- package/react/index.js +2 -2
- package/react/index.js.map +1 -1
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/LazyRoute.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useData.d.ts +1 -1
- package/react/src/hooks/useFeed.d.ts +1 -1
- package/react/src/hooks/useLayoutData.d.ts +1 -1
- package/react/src/hooks/useLlms.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearch.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/hooks/useToc.d.ts +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/lib/collection.d.ts +1 -1
- package/react/src/lib/content.d.ts +1 -1
- package/react/src/lib/head.d.ts +1 -1
- package/react/src/lib/index.d.ts +1 -1
- package/react/src/lib/lazy-route.d.ts +1 -1
- package/react/src/lib/route-loader.d.ts +1 -1
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +1 -1
- package/react/src/providers/RouterProvider.d.ts +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +1 -1
- package/telemetry/react.d.ts +2 -2
- package/telemetry/react.d.ts.map +1 -1
- package/telemetry/react.js +164 -183
- package/telemetry/react.js.map +7 -6
- package/telemetry/{index.d.ts → server.d.ts} +2 -2
- package/telemetry/server.d.ts.map +1 -0
- package/telemetry/server.js +1134 -0
- package/telemetry/server.js.map +44 -0
- package/telemetry/src/{browser/react.d.ts → react/api.d.ts} +4 -12
- package/telemetry/src/react/api.d.ts.map +1 -0
- package/telemetry/{browser.d.ts → src/react/index.d.ts} +4 -3
- package/telemetry/src/react/index.d.ts.map +1 -0
- package/telemetry/src/{browser/index.d.ts → react/telemetry.d.ts} +13 -13
- package/telemetry/src/react/telemetry.d.ts.map +1 -0
- package/telemetry/src/server/index.d.ts +3 -101
- package/telemetry/src/server/index.d.ts.map +1 -1
- package/telemetry/src/server/instrumentation.d.ts +62 -0
- package/telemetry/src/server/instrumentation.d.ts.map +1 -0
- package/telemetry/src/server/plugin.d.ts +72 -0
- package/telemetry/src/server/plugin.d.ts.map +1 -0
- package/telemetry/browser.d.ts.map +0 -1
- package/telemetry/browser.js +0 -383
- package/telemetry/browser.js.map +0 -10
- package/telemetry/index.d.ts.map +0 -1
- package/telemetry/index.js +0 -525
- package/telemetry/index.js.map +0 -10
- package/telemetry/src/browser/index.d.ts.map +0 -1
- package/telemetry/src/browser/react.d.ts.map +0 -1
package/cli/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
/**
|
|
4
|
-
* reroute-js v0.
|
|
4
|
+
* reroute-js v0.26.1
|
|
5
5
|
*
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2025 stewones <hi@stewan.io>
|
|
@@ -48,7 +48,7 @@ async function getVersionString() {
|
|
|
48
48
|
}
|
|
49
49
|
async function getVersion() {
|
|
50
50
|
if (true) {
|
|
51
|
-
return "0.
|
|
51
|
+
return "0.26.1";
|
|
52
52
|
}
|
|
53
53
|
const possiblePaths = [
|
|
54
54
|
path.join(import.meta.dir, "../../../../package.json"),
|
|
@@ -66,7 +66,7 @@ async function getVersion() {
|
|
|
66
66
|
}
|
|
67
67
|
async function getCommit() {
|
|
68
68
|
if (true) {
|
|
69
|
-
return "
|
|
69
|
+
return "f6fc4f9";
|
|
70
70
|
}
|
|
71
71
|
return "dev";
|
|
72
72
|
}
|
|
@@ -500,6 +500,153 @@ var init_content = __esm(() => {
|
|
|
500
500
|
init_metadata();
|
|
501
501
|
});
|
|
502
502
|
|
|
503
|
+
// packages/telemetry/src/server/instrumentation.ts
|
|
504
|
+
import { context, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
505
|
+
function isOtelAvailable() {
|
|
506
|
+
if (otelAvailable !== undefined)
|
|
507
|
+
return otelAvailable;
|
|
508
|
+
try {
|
|
509
|
+
__require("@opentelemetry/api");
|
|
510
|
+
otelAvailable = true;
|
|
511
|
+
return true;
|
|
512
|
+
} catch {
|
|
513
|
+
otelAvailable = false;
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
class NoopSpan {
|
|
519
|
+
spanContext() {
|
|
520
|
+
return {
|
|
521
|
+
traceId: "",
|
|
522
|
+
spanId: "",
|
|
523
|
+
traceFlags: 0
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
setAttribute() {
|
|
527
|
+
return this;
|
|
528
|
+
}
|
|
529
|
+
setAttributes() {
|
|
530
|
+
return this;
|
|
531
|
+
}
|
|
532
|
+
addEvent() {
|
|
533
|
+
return this;
|
|
534
|
+
}
|
|
535
|
+
addLink() {
|
|
536
|
+
return this;
|
|
537
|
+
}
|
|
538
|
+
addLinks() {
|
|
539
|
+
return this;
|
|
540
|
+
}
|
|
541
|
+
setStatus() {
|
|
542
|
+
return this;
|
|
543
|
+
}
|
|
544
|
+
updateName() {
|
|
545
|
+
return this;
|
|
546
|
+
}
|
|
547
|
+
end() {}
|
|
548
|
+
isRecording() {
|
|
549
|
+
return false;
|
|
550
|
+
}
|
|
551
|
+
recordException() {}
|
|
552
|
+
}
|
|
553
|
+
async function withSpan(name, fn, attributes) {
|
|
554
|
+
if (!isOtelAvailable()) {
|
|
555
|
+
return fn(noopSpan);
|
|
556
|
+
}
|
|
557
|
+
const tracer = trace.getTracer("reroute");
|
|
558
|
+
return tracer.startActiveSpan(name, { attributes }, async (span) => {
|
|
559
|
+
try {
|
|
560
|
+
const result = await fn(span);
|
|
561
|
+
span.end();
|
|
562
|
+
return result;
|
|
563
|
+
} catch (error) {
|
|
564
|
+
span.recordException(error);
|
|
565
|
+
span.setStatus({
|
|
566
|
+
code: SpanStatusCode.ERROR,
|
|
567
|
+
message: error instanceof Error ? error.message : String(error)
|
|
568
|
+
});
|
|
569
|
+
span.end();
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
function withSpanSync(name, fn, attributes) {
|
|
575
|
+
if (!isOtelAvailable()) {
|
|
576
|
+
return fn(noopSpan);
|
|
577
|
+
}
|
|
578
|
+
const tracer = trace.getTracer("reroute");
|
|
579
|
+
return tracer.startActiveSpan(name, { attributes }, (span) => {
|
|
580
|
+
try {
|
|
581
|
+
const result = fn(span);
|
|
582
|
+
span.end();
|
|
583
|
+
return result;
|
|
584
|
+
} catch (error) {
|
|
585
|
+
span.recordException(error);
|
|
586
|
+
span.setStatus({
|
|
587
|
+
code: SpanStatusCode.ERROR,
|
|
588
|
+
message: error instanceof Error ? error.message : String(error)
|
|
589
|
+
});
|
|
590
|
+
span.end();
|
|
591
|
+
throw error;
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
async function withParentSpan(parentSpan, fn) {
|
|
596
|
+
if (!(isOtelAvailable() && parentSpan)) {
|
|
597
|
+
return fn();
|
|
598
|
+
}
|
|
599
|
+
const ctx = trace.setSpan(context.active(), parentSpan);
|
|
600
|
+
return context.with(ctx, fn);
|
|
601
|
+
}
|
|
602
|
+
var otelAvailable, noopSpan;
|
|
603
|
+
var init_instrumentation = __esm(() => {
|
|
604
|
+
noopSpan = new NoopSpan;
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
// packages/telemetry/src/server/plugin.ts
|
|
608
|
+
import {
|
|
609
|
+
metrics,
|
|
610
|
+
SpanStatusCode as SpanStatusCode2,
|
|
611
|
+
trace as trace2
|
|
612
|
+
} from "@opentelemetry/api";
|
|
613
|
+
import { logs, SeverityNumber } from "@opentelemetry/api-logs";
|
|
614
|
+
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-proto";
|
|
615
|
+
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
|
|
616
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
|
|
617
|
+
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
618
|
+
import {
|
|
619
|
+
BatchLogRecordProcessor,
|
|
620
|
+
LoggerProvider
|
|
621
|
+
} from "@opentelemetry/sdk-logs";
|
|
622
|
+
import {
|
|
623
|
+
MeterProvider,
|
|
624
|
+
PeriodicExportingMetricReader
|
|
625
|
+
} from "@opentelemetry/sdk-metrics";
|
|
626
|
+
import {
|
|
627
|
+
BatchSpanProcessor,
|
|
628
|
+
NodeTracerProvider
|
|
629
|
+
} from "@opentelemetry/sdk-trace-node";
|
|
630
|
+
import {
|
|
631
|
+
ATTR_SERVICE_NAME,
|
|
632
|
+
ATTR_SERVICE_VERSION
|
|
633
|
+
} from "@opentelemetry/semantic-conventions";
|
|
634
|
+
import { ATTR_HOST_NAME } from "@opentelemetry/semantic-conventions/incubating";
|
|
635
|
+
var init_plugin = __esm(() => {
|
|
636
|
+
init_core();
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// packages/telemetry/src/server/index.ts
|
|
640
|
+
var init_server = __esm(() => {
|
|
641
|
+
init_instrumentation();
|
|
642
|
+
init_plugin();
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
// packages/telemetry/server.ts
|
|
646
|
+
var init_server2 = __esm(() => {
|
|
647
|
+
init_server();
|
|
648
|
+
});
|
|
649
|
+
|
|
503
650
|
// packages/core/src/ssr/lib/cache.ts
|
|
504
651
|
class SSRDataCache {
|
|
505
652
|
cache = new Map;
|
|
@@ -2316,12 +2463,25 @@ function createSSRExportsScript(pathname) {
|
|
|
2316
2463
|
return "";
|
|
2317
2464
|
}
|
|
2318
2465
|
}
|
|
2319
|
-
function
|
|
2466
|
+
function createTelemetryConfigScript(browserTelemetryConfig) {
|
|
2467
|
+
if (!browserTelemetryConfig || Object.keys(browserTelemetryConfig).length === 0) {
|
|
2468
|
+
return "";
|
|
2469
|
+
}
|
|
2470
|
+
try {
|
|
2471
|
+
const configJson = escapeJsonForScript(JSON.stringify(browserTelemetryConfig));
|
|
2472
|
+
return `<script>(function(){try{var w=(typeof window!=='undefined'?window:globalThis);w.__REROUTE_TELEMETRY_BROWSER__=${configJson};}catch(e){}})();</script>`;
|
|
2473
|
+
} catch (error) {
|
|
2474
|
+
console.error("[reroute] Failed to serialize browser telemetry config:", error);
|
|
2475
|
+
return "";
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
function createDataScript(ssrData, errorMsg, pathname, browserTelemetryConfig) {
|
|
2320
2479
|
let script = "";
|
|
2321
2480
|
script += createContentCaptureScript();
|
|
2322
2481
|
if (pathname) {
|
|
2323
2482
|
script += createSSRExportsScript(pathname);
|
|
2324
2483
|
}
|
|
2484
|
+
script += createTelemetryConfigScript(browserTelemetryConfig);
|
|
2325
2485
|
if (ssrData && Object.keys(ssrData).length > 0) {
|
|
2326
2486
|
try {
|
|
2327
2487
|
const duplicatedData = duplicateQueryParamData(ssrData);
|
|
@@ -2422,7 +2582,7 @@ async function performSSRSetup(options, streaming = false) {
|
|
|
2422
2582
|
});
|
|
2423
2583
|
try {
|
|
2424
2584
|
return await Promise.race([
|
|
2425
|
-
performSSRSetupInternal(options, streaming),
|
|
2585
|
+
withParentSpan(options.parentSpan, () => performSSRSetupInternal(options, streaming)),
|
|
2426
2586
|
timeoutPromise
|
|
2427
2587
|
]);
|
|
2428
2588
|
} catch (error) {
|
|
@@ -2453,34 +2613,70 @@ async function performSSRSetupInternal(options, streaming) {
|
|
|
2453
2613
|
searchParams,
|
|
2454
2614
|
ogConfig
|
|
2455
2615
|
} = options;
|
|
2456
|
-
await
|
|
2457
|
-
|
|
2458
|
-
|
|
2616
|
+
await withSpan("ssr.seed", async (span) => {
|
|
2617
|
+
span.setAttribute("pathname", pathname);
|
|
2618
|
+
span.setAttribute("streaming", streaming);
|
|
2619
|
+
await seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode);
|
|
2620
|
+
if (debug)
|
|
2621
|
+
console.log(`[Setup] ${pathname} - seedModule: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
2622
|
+
});
|
|
2459
2623
|
resetSSRAccessTracking();
|
|
2460
2624
|
const bundlePreload = createBundlePreload(bundleUrl);
|
|
2461
|
-
const preloadResult = await
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2625
|
+
const preloadResult = await withSpan("ssr.preload", async (span) => {
|
|
2626
|
+
span.setAttribute("pathname", pathname);
|
|
2627
|
+
const result = await preloadContentModule(pathname, clientDir, cwd, isWatchMode);
|
|
2628
|
+
span.setAttribute("has_module", !!result.modulePath);
|
|
2629
|
+
if (debug)
|
|
2630
|
+
console.log(`[Setup] ${pathname} - preloadContent: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
2631
|
+
return result;
|
|
2632
|
+
});
|
|
2633
|
+
const computeResult = await withSpan("ssr.compute.data", async (span) => {
|
|
2634
|
+
span.setAttribute("pathname", pathname);
|
|
2635
|
+
span.setAttribute("streaming", streaming);
|
|
2636
|
+
const result = await computeSSRData(pathname, clientDir, cwd, isWatchMode, { streaming, maxAge }, searchParams);
|
|
2637
|
+
span.setAttribute("has_error", !!result.error);
|
|
2638
|
+
span.setAttribute("has_data", Object.keys(result.data).length > 0);
|
|
2639
|
+
if (debug)
|
|
2640
|
+
console.log(`[Setup] ${pathname} - computeSSRData: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
2641
|
+
return result;
|
|
2642
|
+
});
|
|
2467
2643
|
setGlobalSSRData(computeResult.data);
|
|
2468
2644
|
const usingCachedCollections = !!options.cachedCollections;
|
|
2469
|
-
const byCollectionForSSR =
|
|
2470
|
-
|
|
2471
|
-
|
|
2645
|
+
const byCollectionForSSR = await withSpan("ssr.load.collections", async (span) => {
|
|
2646
|
+
span.setAttribute("pathname", pathname);
|
|
2647
|
+
span.setAttribute("cached", usingCachedCollections);
|
|
2648
|
+
const collections = options.cachedCollections ? options.cachedCollections : await loadCollections(cwd, isWatchMode);
|
|
2649
|
+
span.setAttribute("collection_count", Object.keys(collections).length);
|
|
2650
|
+
if (debug)
|
|
2651
|
+
console.log(`[Setup] ${pathname} - loadCollections (cached: ${usingCachedCollections}): ${(performance.now() - t0).toFixed(2)}ms`);
|
|
2652
|
+
return collections;
|
|
2653
|
+
});
|
|
2472
2654
|
setGlobalCollections(byCollectionForSSR);
|
|
2473
2655
|
const usingCachedCSS = !!options.cachedTailwindCSS;
|
|
2474
|
-
const inlineStyleTag =
|
|
2475
|
-
|
|
2476
|
-
|
|
2656
|
+
const inlineStyleTag = await withSpan("ssr.inline.css", async (span) => {
|
|
2657
|
+
const css = options.cachedTailwindCSS ? options.cachedTailwindCSS : await inlineTailwindCSS(clientDir, !streaming, isWatchMode);
|
|
2658
|
+
span.setAttributes({
|
|
2659
|
+
"reroute.cached": usingCachedCSS,
|
|
2660
|
+
"reroute.css.size": css.length
|
|
2661
|
+
});
|
|
2662
|
+
if (debug)
|
|
2663
|
+
console.log(`[Setup] ${pathname} - inlineTailwindCSS (cached: ${usingCachedCSS}): ${(performance.now() - t0).toFixed(2)}ms`);
|
|
2664
|
+
return css;
|
|
2665
|
+
});
|
|
2477
2666
|
let statusOverride = preloadResult.statusOverride;
|
|
2478
2667
|
if (computeResult.statusContainer.value) {
|
|
2479
2668
|
statusOverride = computeResult.statusContainer.value;
|
|
2480
2669
|
}
|
|
2481
|
-
const metadataResult = await
|
|
2482
|
-
|
|
2483
|
-
|
|
2670
|
+
const metadataResult = await withSpan("ssr.extract.metadata", async (span) => {
|
|
2671
|
+
const result = await extractPageMetadata(pathname, clientDir, cwd, isWatchMode, statusOverride, ogConfig);
|
|
2672
|
+
span.setAttributes({
|
|
2673
|
+
"reroute.pathname": pathname,
|
|
2674
|
+
"reroute.metadata.exists": !!result.perPageHead
|
|
2675
|
+
});
|
|
2676
|
+
if (debug)
|
|
2677
|
+
console.log(`[Setup] ${pathname} - extractMetadata: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
2678
|
+
return result;
|
|
2679
|
+
});
|
|
2484
2680
|
return {
|
|
2485
2681
|
ssrData: computeResult.data,
|
|
2486
2682
|
ssrError: computeResult.error,
|
|
@@ -2508,10 +2704,10 @@ function generateCollectionScripts(byCollectionForSSR) {
|
|
|
2508
2704
|
} catch {}
|
|
2509
2705
|
return "";
|
|
2510
2706
|
}
|
|
2511
|
-
function generateHydrationScripts(ssrData, isWatchMode, ssrError, collectionScripts = "", preloadScript = "", bundleUrl = "", pathname = "") {
|
|
2707
|
+
function generateHydrationScripts(ssrData, isWatchMode, ssrError, collectionScripts = "", preloadScript = "", bundleUrl = "", pathname = "", browserTelemetryConfig) {
|
|
2512
2708
|
let scripts = preloadScript;
|
|
2513
2709
|
scripts += collectionScripts;
|
|
2514
|
-
scripts += createDataScript(ssrData, isWatchMode ? ssrError : undefined, pathname);
|
|
2710
|
+
scripts += createDataScript(ssrData, isWatchMode ? ssrError : undefined, pathname, browserTelemetryConfig);
|
|
2515
2711
|
scripts += createFeedsScript();
|
|
2516
2712
|
scripts += createLlmsScript();
|
|
2517
2713
|
if (bundleUrl) {
|
|
@@ -2523,6 +2719,7 @@ function generateHydrationScripts(ssrData, isWatchMode, ssrError, collectionScri
|
|
|
2523
2719
|
return scripts;
|
|
2524
2720
|
}
|
|
2525
2721
|
var init_setup = __esm(() => {
|
|
2722
|
+
init_server2();
|
|
2526
2723
|
init_collections();
|
|
2527
2724
|
init_compute();
|
|
2528
2725
|
init_metadata2();
|
|
@@ -2591,6 +2788,7 @@ async function renderSSRDocument(options) {
|
|
|
2591
2788
|
clientDir,
|
|
2592
2789
|
cwd,
|
|
2593
2790
|
isWatchMode,
|
|
2791
|
+
parentSpan: options.parentSpan,
|
|
2594
2792
|
bundleUrl,
|
|
2595
2793
|
maxAge,
|
|
2596
2794
|
searchParams,
|
|
@@ -2600,14 +2798,29 @@ async function renderSSRDocument(options) {
|
|
|
2600
2798
|
}, false);
|
|
2601
2799
|
const duplicatedData = duplicateQueryParamData(setup2.ssrData);
|
|
2602
2800
|
setGlobalSSRData(duplicatedData);
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2605
|
-
|
|
2801
|
+
const appHtml = await withSpan("ssr.render.react", async (span) => {
|
|
2802
|
+
const componentWithPathname = cloneElement(rootComponent, {
|
|
2803
|
+
pathname,
|
|
2804
|
+
searchParams
|
|
2805
|
+
});
|
|
2806
|
+
span.setAttribute("reroute.pathname", pathname);
|
|
2807
|
+
const html3 = renderToString(componentWithPathname);
|
|
2808
|
+
span.setAttribute("reroute.html.final.size", html3.length);
|
|
2809
|
+
return html3;
|
|
2810
|
+
});
|
|
2811
|
+
const baseTemplate = await withSpan("ssr.load.template", async (span) => {
|
|
2812
|
+
const template2 = await loadIndexHtml(clientDir);
|
|
2813
|
+
span.setAttribute("reroute.template.size", template2.length);
|
|
2814
|
+
return template2;
|
|
2606
2815
|
});
|
|
2607
|
-
const appHtml = renderToString(componentWithPathname);
|
|
2608
|
-
const baseTemplate = await loadIndexHtml(clientDir);
|
|
2609
2816
|
const collectionScripts = generateCollectionScripts(setup2.byCollectionForSSR);
|
|
2610
|
-
const
|
|
2817
|
+
const config = await loadConfig(cwd);
|
|
2818
|
+
const browserTelemetryConfig = config.telemetry?.browser;
|
|
2819
|
+
const hydrationScript = await withSpan("ssr.generate.scripts", async (span) => {
|
|
2820
|
+
const script = generateHydrationScripts(setup2.ssrData, isWatchMode, setup2.ssrError, collectionScripts, setup2.preloadHydrationScript, bundleUrl, pathname, browserTelemetryConfig);
|
|
2821
|
+
span.setAttribute("reroute.scripts.size", script.length);
|
|
2822
|
+
return script;
|
|
2823
|
+
});
|
|
2611
2824
|
let statusOverride = setup2.preloadStatusOverride;
|
|
2612
2825
|
if (setup2.statusContainer.value) {
|
|
2613
2826
|
statusOverride = setup2.statusContainer.value;
|
|
@@ -2622,12 +2835,19 @@ async function renderSSRDocument(options) {
|
|
|
2622
2835
|
dedent(setup2.metadataResult.perPageHead)
|
|
2623
2836
|
].filter(Boolean).join(`
|
|
2624
2837
|
`));
|
|
2625
|
-
const html2 =
|
|
2626
|
-
|
|
2838
|
+
const html2 = withSpanSync("ssr.apply.template", (span) => {
|
|
2839
|
+
const result = applyIndexTemplate(baseTemplate, appHtml, {
|
|
2840
|
+
head: [setup2.inlineStyleTag, combinedHead].filter(Boolean).join(`
|
|
2627
2841
|
`),
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2842
|
+
hydrationScript,
|
|
2843
|
+
lang: setup2.metadataResult.pageLang || lang,
|
|
2844
|
+
appId
|
|
2845
|
+
});
|
|
2846
|
+
span.setAttributes({
|
|
2847
|
+
"reroute.html.final.size": result.length,
|
|
2848
|
+
"reroute.html.original.size": appHtml.length
|
|
2849
|
+
});
|
|
2850
|
+
return result;
|
|
2631
2851
|
});
|
|
2632
2852
|
return {
|
|
2633
2853
|
html: html2,
|
|
@@ -2635,6 +2855,8 @@ async function renderSSRDocument(options) {
|
|
|
2635
2855
|
};
|
|
2636
2856
|
}
|
|
2637
2857
|
var init_render = __esm(() => {
|
|
2858
|
+
init_server2();
|
|
2859
|
+
init_config();
|
|
2638
2860
|
init_lib();
|
|
2639
2861
|
init_html();
|
|
2640
2862
|
});
|
|
@@ -4562,6 +4784,7 @@ async function renderSSRDocumentStream(options) {
|
|
|
4562
4784
|
clientDir,
|
|
4563
4785
|
cwd,
|
|
4564
4786
|
isWatchMode,
|
|
4787
|
+
parentSpan: options.parentSpan,
|
|
4565
4788
|
bundleUrl,
|
|
4566
4789
|
maxAge,
|
|
4567
4790
|
searchParams,
|
|
@@ -4583,14 +4806,19 @@ async function renderSSRDocumentStream(options) {
|
|
|
4583
4806
|
const { readable, writable } = new TransformStream;
|
|
4584
4807
|
const writer = writable.getWriter();
|
|
4585
4808
|
const usingCache = !!options.cachedIndexHtml;
|
|
4586
|
-
const
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4809
|
+
const { htmlHead, rootStart, rootEnd, htmlTail } = await withSpan("ssr.load.template", async (span) => {
|
|
4810
|
+
const template2 = options.cachedIndexHtml ? options.cachedIndexHtml : await loadIndexHtml(clientDir);
|
|
4811
|
+
span.setAttribute("reroute.cached", usingCache);
|
|
4812
|
+
span.setAttribute("reroute.template.size", template2.length);
|
|
4813
|
+
if (debug)
|
|
4814
|
+
console.log(`[renderStream] ${pathname} - loadIndexHtml (cached: ${usingCache}): ${(performance.now() - t0).toFixed(2)}ms`);
|
|
4815
|
+
const parts = splitTemplate(template2, appId);
|
|
4816
|
+
if (debug)
|
|
4817
|
+
console.log(`[renderStream] ${pathname} - splitTemplate: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
4818
|
+
return {
|
|
4819
|
+
...parts
|
|
4820
|
+
};
|
|
4821
|
+
});
|
|
4594
4822
|
const pageLang = setup2.metadataResult.pageLang || lang;
|
|
4595
4823
|
let headWithLang = htmlHead.replace(/<html([^>]*)>/i, `<html$1 lang="${pageLang}">`);
|
|
4596
4824
|
const extraHead = setup2.bundlePreload + setup2.preloadExtraHead + setup2.metadataResult.perPageHead;
|
|
@@ -4600,6 +4828,8 @@ async function renderSSRDocumentStream(options) {
|
|
|
4600
4828
|
if (/<meta\s+name\s*=\s*['"]description['"][^>]*>/i.test(extraHead)) {
|
|
4601
4829
|
headWithLang = headWithLang.replace(/<meta\s+name\s*=\s*['"]description['"][^>]*>/i, "");
|
|
4602
4830
|
}
|
|
4831
|
+
const config = await loadConfig(cwd);
|
|
4832
|
+
const browserTelemetryConfig = config.telemetry?.browser;
|
|
4603
4833
|
streamSSRContent(writer, encoder, {
|
|
4604
4834
|
rootComponent,
|
|
4605
4835
|
pathname,
|
|
@@ -4618,82 +4848,102 @@ async function renderSSRDocumentStream(options) {
|
|
|
4618
4848
|
ssrData: setup2.ssrData,
|
|
4619
4849
|
ssrError: setup2.ssrError,
|
|
4620
4850
|
byCollectionForSSR: setup2.byCollectionForSSR,
|
|
4621
|
-
preloadHydrationScript: setup2.preloadHydrationScript
|
|
4851
|
+
preloadHydrationScript: setup2.preloadHydrationScript,
|
|
4852
|
+
browserTelemetryConfig,
|
|
4853
|
+
parentSpan: options.parentSpan
|
|
4622
4854
|
});
|
|
4623
4855
|
if (debug)
|
|
4624
4856
|
console.log(`[renderStream] ${pathname} - returning stream: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
4625
4857
|
return { stream: readable, status: statusOverride || 200 };
|
|
4626
4858
|
}
|
|
4627
4859
|
async function streamSSRContent(writer, encoder, ctx) {
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4860
|
+
return withParentSpan(ctx.parentSpan, async () => {
|
|
4861
|
+
const t0 = ctx.debug ? performance.now() : 0;
|
|
4862
|
+
const STREAM_TIMEOUT_MS = 60000;
|
|
4863
|
+
let streamTimedOut = false;
|
|
4864
|
+
let timeoutId = null;
|
|
4865
|
+
const cleanup = () => {
|
|
4866
|
+
if (timeoutId) {
|
|
4867
|
+
clearTimeout(timeoutId);
|
|
4868
|
+
timeoutId = null;
|
|
4869
|
+
}
|
|
4870
|
+
};
|
|
4871
|
+
try {
|
|
4872
|
+
const combinedHead = deduplicateMetaTags([ctx.inlineStyleTag, ctx.head, ctx.extraHead].filter(Boolean).join(`
|
|
4640
4873
|
`));
|
|
4641
|
-
|
|
4874
|
+
const headWithLangAndContent = ctx.headWithLang.replace(/<html([^>]*)>/i, `<html$1 lang="${ctx.pageLang}">`).replace(/<\/head>/i, `${combinedHead ? `${combinedHead}
|
|
4642
4875
|
` : ""}</head>`);
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4876
|
+
const headContent = `${headWithLangAndContent}<body>`;
|
|
4877
|
+
await writer.write(encoder.encode(headContent));
|
|
4878
|
+
if (ctx.debug)
|
|
4879
|
+
console.log(`[Stream] ${ctx.pathname} - first byte written: ${(performance.now() - t0).toFixed(2)}ms`);
|
|
4880
|
+
await writer.write(encoder.encode(ctx.rootStart));
|
|
4881
|
+
await withSpan("ssr.document.stream", async (span) => {
|
|
4882
|
+
const componentWithPathname = cloneElement2(ctx.rootComponent, {
|
|
4883
|
+
pathname: ctx.pathname,
|
|
4884
|
+
searchParams: ctx.searchParams
|
|
4885
|
+
});
|
|
4886
|
+
span.setAttribute("reroute.pathname", ctx.pathname);
|
|
4887
|
+
let streamError = null;
|
|
4888
|
+
const streamPromise = renderToReadableStream(componentWithPathname, {
|
|
4889
|
+
onError(error) {
|
|
4890
|
+
console.error("[reroute] SSR stream error:", error);
|
|
4891
|
+
streamError = error instanceof Error ? error : new Error(String(error));
|
|
4892
|
+
}
|
|
4893
|
+
}).catch((err) => {
|
|
4894
|
+
streamError = err;
|
|
4895
|
+
throw err;
|
|
4896
|
+
});
|
|
4897
|
+
const reactStream = await streamPromise;
|
|
4898
|
+
if (streamError)
|
|
4899
|
+
throw streamError;
|
|
4900
|
+
const streamTimeoutPromise = new Promise((resolve) => {
|
|
4901
|
+
timeoutId = setTimeout(() => {
|
|
4902
|
+
console.warn(`[reroute] Stream timeout after ${STREAM_TIMEOUT_MS}ms for ${ctx.pathname}, forcing close`);
|
|
4903
|
+
streamTimedOut = true;
|
|
4904
|
+
resolve({ done: true, value: undefined });
|
|
4905
|
+
}, STREAM_TIMEOUT_MS);
|
|
4906
|
+
});
|
|
4907
|
+
const reader = reactStream.getReader();
|
|
4908
|
+
let chunkCount = 0;
|
|
4909
|
+
while (true) {
|
|
4910
|
+
const result = await Promise.race([
|
|
4911
|
+
reader.read(),
|
|
4912
|
+
streamTimeoutPromise
|
|
4913
|
+
]);
|
|
4914
|
+
if (result.done || streamTimedOut) {
|
|
4915
|
+
try {
|
|
4916
|
+
reader.releaseLock();
|
|
4917
|
+
} catch {}
|
|
4918
|
+
break;
|
|
4919
|
+
}
|
|
4920
|
+
if (result.value) {
|
|
4921
|
+
await writer.write(result.value);
|
|
4922
|
+
chunkCount++;
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
cleanup();
|
|
4926
|
+
span.setAttributes({
|
|
4927
|
+
"reroute.stream.chunks": chunkCount,
|
|
4928
|
+
"reroute.stream.timedOut": streamTimedOut
|
|
4929
|
+
});
|
|
4930
|
+
});
|
|
4931
|
+
await writer.write(encoder.encode(ctx.rootEnd));
|
|
4932
|
+
const allScripts = await withSpan("ssr.generate.scripts", async (span) => {
|
|
4933
|
+
const scripts2 = buildStreamingScripts(ctx);
|
|
4934
|
+
span.setAttribute("reroute.script_size", scripts2.length);
|
|
4935
|
+
return scripts2;
|
|
4936
|
+
});
|
|
4937
|
+
await writer.write(encoder.encode(allScripts + ctx.htmlTail));
|
|
4938
|
+
await writer.close();
|
|
4939
|
+
} catch (error) {
|
|
4940
|
+
cleanup();
|
|
4941
|
+
console.error("[reroute] Stream error:", error);
|
|
4942
|
+
try {
|
|
4943
|
+
await writer.abort(error);
|
|
4944
|
+
} catch {}
|
|
4684
4945
|
}
|
|
4685
|
-
|
|
4686
|
-
await writer.write(encoder.encode(ctx.rootEnd));
|
|
4687
|
-
const allScripts = buildStreamingScripts(ctx);
|
|
4688
|
-
await writer.write(encoder.encode(allScripts + ctx.htmlTail));
|
|
4689
|
-
await writer.close();
|
|
4690
|
-
} catch (error) {
|
|
4691
|
-
cleanup();
|
|
4692
|
-
console.error("[reroute] Stream error:", error);
|
|
4693
|
-
try {
|
|
4694
|
-
await writer.abort(error);
|
|
4695
|
-
} catch {}
|
|
4696
|
-
}
|
|
4946
|
+
});
|
|
4697
4947
|
}
|
|
4698
4948
|
function buildStreamingScripts(ctx) {
|
|
4699
4949
|
const collectionScripts = generateCollectionScripts(ctx.byCollectionForSSR);
|
|
@@ -4704,7 +4954,7 @@ function buildStreamingScripts(ctx) {
|
|
|
4704
4954
|
ssrDataSnapshot[key] = value;
|
|
4705
4955
|
}
|
|
4706
4956
|
}
|
|
4707
|
-
const dataScript = createDataScript(ssrDataSnapshot, ctx.isWatchMode ? ctx.ssrError : undefined, ctx.pathname);
|
|
4957
|
+
const dataScript = createDataScript(ssrDataSnapshot, ctx.isWatchMode ? ctx.ssrError : undefined, ctx.pathname, ctx.browserTelemetryConfig);
|
|
4708
4958
|
const feedsScript = createFeedsScript();
|
|
4709
4959
|
const llmsScript = createLlmsScript();
|
|
4710
4960
|
let allScripts = dataScript + feedsScript + llmsScript + collectionScripts + ctx.preloadHydrationScript;
|
|
@@ -4715,6 +4965,8 @@ function buildStreamingScripts(ctx) {
|
|
|
4715
4965
|
return allScripts;
|
|
4716
4966
|
}
|
|
4717
4967
|
var init_stream = __esm(() => {
|
|
4968
|
+
init_server2();
|
|
4969
|
+
init_config();
|
|
4718
4970
|
init_lib();
|
|
4719
4971
|
init_html();
|
|
4720
4972
|
init_imports();
|
|
@@ -6144,6 +6396,50 @@ async function sha8(text) {
|
|
|
6144
6396
|
hex += b.toString(16).padStart(2, "0");
|
|
6145
6397
|
return hex.slice(0, 8);
|
|
6146
6398
|
}
|
|
6399
|
+
function serializeConfig(config2) {
|
|
6400
|
+
function serializeValue(value, indent = 0) {
|
|
6401
|
+
const spaces = " ".repeat(indent);
|
|
6402
|
+
const nextSpaces = " ".repeat(indent + 1);
|
|
6403
|
+
if (value === null)
|
|
6404
|
+
return "null";
|
|
6405
|
+
if (value === undefined)
|
|
6406
|
+
return "undefined";
|
|
6407
|
+
if (typeof value === "string")
|
|
6408
|
+
return JSON.stringify(value);
|
|
6409
|
+
if (typeof value === "number")
|
|
6410
|
+
return String(value);
|
|
6411
|
+
if (typeof value === "boolean")
|
|
6412
|
+
return String(value);
|
|
6413
|
+
if (value instanceof RegExp)
|
|
6414
|
+
return value.toString();
|
|
6415
|
+
if (typeof value === "function")
|
|
6416
|
+
return value.toString();
|
|
6417
|
+
if (Array.isArray(value)) {
|
|
6418
|
+
if (value.length === 0)
|
|
6419
|
+
return "[]";
|
|
6420
|
+
const items = value.map((item) => `${nextSpaces}${serializeValue(item, indent + 1)}`).join(`,
|
|
6421
|
+
`);
|
|
6422
|
+
return `[
|
|
6423
|
+
${items}
|
|
6424
|
+
${spaces}]`;
|
|
6425
|
+
}
|
|
6426
|
+
if (typeof value === "object") {
|
|
6427
|
+
const entries = Object.entries(value);
|
|
6428
|
+
if (entries.length === 0)
|
|
6429
|
+
return "{}";
|
|
6430
|
+
const props = entries.map(([key, val]) => {
|
|
6431
|
+
const serializedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
6432
|
+
return `${nextSpaces}${serializedKey}: ${serializeValue(val, indent + 1)}`;
|
|
6433
|
+
}).join(`,
|
|
6434
|
+
`);
|
|
6435
|
+
return `{
|
|
6436
|
+
${props}
|
|
6437
|
+
${spaces}}`;
|
|
6438
|
+
}
|
|
6439
|
+
return "undefined";
|
|
6440
|
+
}
|
|
6441
|
+
return serializeValue(config2);
|
|
6442
|
+
}
|
|
6147
6443
|
async function buildSingleContentChunk(cwd, collection, file, contentDir, args) {
|
|
6148
6444
|
const name = file.replace(/\.(tsx|ts|md|mdx)$/, "");
|
|
6149
6445
|
const absSrc = join9(contentDir, file);
|
|
@@ -6719,7 +7015,7 @@ async function generate(cwd, args = [], options = {}) {
|
|
|
6719
7015
|
} catch {}
|
|
6720
7016
|
indexLines.push("");
|
|
6721
7017
|
indexLines.push("// Bundled config for compiled binary support");
|
|
6722
|
-
indexLines.push(`(globalThis as any).__REROUTE_CONFIG__ = ${
|
|
7018
|
+
indexLines.push(`(globalThis as any).__REROUTE_CONFIG__ = ${serializeConfig(config2)};`);
|
|
6723
7019
|
indexLines.push("");
|
|
6724
7020
|
indexLines.push("export type RerouteBundle = typeof bundle;");
|
|
6725
7021
|
await Bun.write(join9(cwd, OUTPUT_ARTIFACTS), indexLines.join(`
|
|
@@ -80480,12 +80776,12 @@ var require_lcd = __commonJS((exports, module) => {
|
|
|
80480
80776
|
}
|
|
80481
80777
|
return flipped;
|
|
80482
80778
|
}
|
|
80483
|
-
function Draw(
|
|
80484
|
-
|
|
80485
|
-
|
|
80779
|
+
function Draw(context2, elements) {
|
|
80780
|
+
context2.clearRect(this.X, this.Y, this.Width, this.Height);
|
|
80781
|
+
context2.save();
|
|
80486
80782
|
var elementWidth = this.CalcElementDimensions().Width;
|
|
80487
|
-
|
|
80488
|
-
|
|
80783
|
+
context2.translate(this.X, this.Y);
|
|
80784
|
+
context2.translate(this.Padding, this.Padding);
|
|
80489
80785
|
for (var i = 0;i < elements.length; i++) {
|
|
80490
80786
|
var element = elements[i];
|
|
80491
80787
|
for (var s = 0;s < this.Points.length; s++) {
|
|
@@ -80493,28 +80789,28 @@ var require_lcd = __commonJS((exports, module) => {
|
|
|
80493
80789
|
var stroke = element & 1 << s ? this.StrokeLight : this.StrokeDark;
|
|
80494
80790
|
if (stroke == this.StrokeDark)
|
|
80495
80791
|
continue;
|
|
80496
|
-
|
|
80497
|
-
|
|
80498
|
-
|
|
80499
|
-
|
|
80500
|
-
|
|
80501
|
-
|
|
80792
|
+
context2.lineWidth = this.StrokeWidth;
|
|
80793
|
+
context2.strokeStyle = stroke;
|
|
80794
|
+
context2.fillStyle = color;
|
|
80795
|
+
context2.moveTo(0, 0);
|
|
80796
|
+
context2.beginPath();
|
|
80797
|
+
context2.moveTo(this.Points[s][0].x, this.Points[s][0].y);
|
|
80502
80798
|
var maxX = 0;
|
|
80503
80799
|
for (var p = 1;p < this.Points[s].length; p++) {
|
|
80504
80800
|
if (this.Points[s][p].x > maxX)
|
|
80505
80801
|
maxX = this.Points[s][p].x;
|
|
80506
|
-
|
|
80802
|
+
context2.lineTo(Math.round(this.Points[s][p].x), Math.round(this.Points[s][p].y));
|
|
80507
80803
|
}
|
|
80508
|
-
|
|
80509
|
-
|
|
80510
|
-
|
|
80804
|
+
context2.closePath();
|
|
80805
|
+
context2.fill();
|
|
80806
|
+
context2.stroke();
|
|
80511
80807
|
if (this.StrokeWidth > 0) {
|
|
80512
|
-
|
|
80808
|
+
context2.stroke();
|
|
80513
80809
|
}
|
|
80514
80810
|
}
|
|
80515
|
-
|
|
80811
|
+
context2.translate(elementWidth + this.Spacing, 0);
|
|
80516
80812
|
}
|
|
80517
|
-
|
|
80813
|
+
context2.restore();
|
|
80518
80814
|
}
|
|
80519
80815
|
function CalcPoints() {
|
|
80520
80816
|
var w = this.ElementWidth, h = this.ElementHeight, sw = this.SegmentWidth * w, si = this.SegmentInterval * w, bw = this.BevelWidth * sw, ib = this.SideBevelEnabled ? 1 : 0, sf = sw * 0.8, slope = h / w, sqrt2 = Math.SQRT2, sqrt3 = Math.sqrt(3);
|
|
@@ -82378,14 +82674,14 @@ var require_event_stream = __commonJS((exports) => {
|
|
|
82378
82674
|
opts.host = opts.host || "localhost";
|
|
82379
82675
|
opts.protocol = opts.protocol || "http";
|
|
82380
82676
|
var protocol = __require(opts.protocol);
|
|
82381
|
-
var
|
|
82677
|
+
var server2 = protocol.createServer(function(instream, outstream) {
|
|
82382
82678
|
var streams2 = setup2(args);
|
|
82383
82679
|
streams2.unshift(es.split());
|
|
82384
82680
|
streams2.unshift(instream);
|
|
82385
82681
|
streams2.push(outstream || instream);
|
|
82386
82682
|
es.pipe.apply(null, streams2);
|
|
82387
82683
|
});
|
|
82388
|
-
|
|
82684
|
+
server2.listen(opts.port, opts.host);
|
|
82389
82685
|
console.error(process.argv[1] + ' is listening for "' + opts.protocol + '" on ' + opts.host + ":" + opts.port);
|
|
82390
82686
|
}
|
|
82391
82687
|
};
|
|
@@ -96553,11 +96849,11 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
96553
96849
|
function unicodeWords(string) {
|
|
96554
96850
|
return string.match(reUnicodeWord) || [];
|
|
96555
96851
|
}
|
|
96556
|
-
var runInContext = function runInContext(
|
|
96557
|
-
|
|
96558
|
-
var { Array: Array2, Date: Date2, Error: Error2, Function: Function2, Math: Math2, Object: Object2, RegExp: RegExp2, String: String2, TypeError: TypeError2 } =
|
|
96852
|
+
var runInContext = function runInContext(context2) {
|
|
96853
|
+
context2 = context2 == null ? root : _.defaults(root.Object(), context2, _.pick(root, contextProps));
|
|
96854
|
+
var { Array: Array2, Date: Date2, Error: Error2, Function: Function2, Math: Math2, Object: Object2, RegExp: RegExp2, String: String2, TypeError: TypeError2 } = context2;
|
|
96559
96855
|
var arrayProto = Array2.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
|
|
96560
|
-
var coreJsData =
|
|
96856
|
+
var coreJsData = context2["__core-js_shared__"];
|
|
96561
96857
|
var funcToString = funcProto.toString;
|
|
96562
96858
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
96563
96859
|
var idCounter = 0;
|
|
@@ -96569,7 +96865,7 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
96569
96865
|
var objectCtorString = funcToString.call(Object2);
|
|
96570
96866
|
var oldDash = root._;
|
|
96571
96867
|
var reIsNative = RegExp2("^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
|
|
96572
|
-
var Buffer2 = moduleExports ?
|
|
96868
|
+
var Buffer2 = moduleExports ? context2.Buffer : undefined2, Symbol2 = context2.Symbol, Uint8Array2 = context2.Uint8Array, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : undefined2, getPrototype = overArg(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined2, symIterator = Symbol2 ? Symbol2.iterator : undefined2, symToStringTag = Symbol2 ? Symbol2.toStringTag : undefined2;
|
|
96573
96869
|
var defineProperty = function() {
|
|
96574
96870
|
try {
|
|
96575
96871
|
var func = getNative(Object2, "defineProperty");
|
|
@@ -96577,9 +96873,9 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
96577
96873
|
return func;
|
|
96578
96874
|
} catch (e) {}
|
|
96579
96875
|
}();
|
|
96580
|
-
var ctxClearTimeout =
|
|
96581
|
-
var { ceil: nativeCeil, floor: nativeFloor } = Math2, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite =
|
|
96582
|
-
var DataView = getNative(
|
|
96876
|
+
var ctxClearTimeout = context2.clearTimeout !== root.clearTimeout && context2.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context2.setTimeout !== root.setTimeout && context2.setTimeout;
|
|
96877
|
+
var { ceil: nativeCeil, floor: nativeFloor } = Math2, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite = context2.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context2.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
|
|
96878
|
+
var DataView = getNative(context2, "DataView"), Map2 = getNative(context2, "Map"), Promise2 = getNative(context2, "Promise"), Set2 = getNative(context2, "Set"), WeakMap2 = getNative(context2, "WeakMap"), nativeCreate = getNative(Object2, "create");
|
|
96583
96879
|
var metaMap = WeakMap2 && new WeakMap2;
|
|
96584
96880
|
var realNames = {};
|
|
96585
96881
|
var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2);
|
|
@@ -104552,12 +104848,12 @@ import { spawn as spawn5 } from "node:child_process";
|
|
|
104552
104848
|
import { readdir as readdir7 } from "node:fs/promises";
|
|
104553
104849
|
import { join as join16 } from "node:path";
|
|
104554
104850
|
async function findAvailablePort() {
|
|
104555
|
-
const
|
|
104851
|
+
const server2 = Bun.serve({
|
|
104556
104852
|
port: 0,
|
|
104557
104853
|
fetch: () => new Response("test")
|
|
104558
104854
|
});
|
|
104559
|
-
const port =
|
|
104560
|
-
|
|
104855
|
+
const port = server2.port;
|
|
104856
|
+
server2.stop();
|
|
104561
104857
|
if (!port) {
|
|
104562
104858
|
throw new Error("Failed to allocate port");
|
|
104563
104859
|
}
|
|
@@ -104686,15 +104982,15 @@ Create an [og].tsx file in your routes directory to generate OG images.`);
|
|
|
104686
104982
|
}
|
|
104687
104983
|
console.log(`Found ${routes.length} route(s):
|
|
104688
104984
|
`);
|
|
104689
|
-
let
|
|
104985
|
+
let server2;
|
|
104690
104986
|
try {
|
|
104691
|
-
|
|
104987
|
+
server2 = await startServer(cwd);
|
|
104692
104988
|
} catch (error) {
|
|
104693
104989
|
console.error("❌ Failed to start server:", error);
|
|
104694
104990
|
console.log("\nMake sure your server is configured and can start with `bun run start`");
|
|
104695
104991
|
process.exit(1);
|
|
104696
104992
|
}
|
|
104697
|
-
const { port, process: serverProcess } =
|
|
104993
|
+
const { port, process: serverProcess } = server2;
|
|
104698
104994
|
const cleanup = () => {
|
|
104699
104995
|
console.log(`
|
|
104700
104996
|
|
|
@@ -104879,7 +105175,7 @@ async function getVersionString2() {
|
|
|
104879
105175
|
}
|
|
104880
105176
|
async function getVersion2() {
|
|
104881
105177
|
if (true) {
|
|
104882
|
-
return "0.
|
|
105178
|
+
return "0.26.1";
|
|
104883
105179
|
}
|
|
104884
105180
|
const possiblePaths = [
|
|
104885
105181
|
path3.join(import.meta.dir, "../../../package.json"),
|
|
@@ -104896,10 +105192,10 @@ async function getVersion2() {
|
|
|
104896
105192
|
}
|
|
104897
105193
|
async function getCommit2() {
|
|
104898
105194
|
if (true) {
|
|
104899
|
-
return "
|
|
105195
|
+
return "f6fc4f9";
|
|
104900
105196
|
}
|
|
104901
105197
|
return "dev";
|
|
104902
105198
|
}
|
|
104903
105199
|
main();
|
|
104904
105200
|
|
|
104905
|
-
//# debugId=
|
|
105201
|
+
//# debugId=DF78AECAB6DCE21964756E2164756E21
|