@taujs/react 0.1.4 → 0.1.5

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/dist/index.d.ts CHANGED
@@ -44,7 +44,7 @@ type HydrateAppOptions<T> = {
44
44
  declare function hydrateApp<T>({ appComponent, rootElementId, enableDebug, logger, dataKey, onHydrationError, onStart, onSuccess, }: HydrateAppOptions<T>): void;
45
45
 
46
46
  type RenderCallbacks<T> = {
47
- onHead?: (head: string) => boolean | void;
47
+ onHead?: (head: string) => void;
48
48
  onShellReady?: () => void;
49
49
  onAllReady?: (data: T) => void;
50
50
  onFinish?: (data: T) => void;
@@ -53,8 +53,6 @@ type RenderCallbacks<T> = {
53
53
  type StreamOptions = {
54
54
  /** Timeout in ms for shell to be ready (default: 10000) */
55
55
  shellTimeoutMs?: number;
56
- /** Whether to use cork/uncork for batched writes (default: true) */
57
- useCork?: boolean;
58
56
  };
59
57
  type HeadContext<T extends Record<string, unknown> = Record<string, unknown>, R = unknown> = {
60
58
  data: T;
package/dist/index.js CHANGED
@@ -364,7 +364,7 @@ function createRenderer({
364
364
  logger,
365
365
  enableDebug = false
366
366
  }) {
367
- const { shellTimeoutMs = 1e4, useCork = true } = streamOptions;
367
+ const { shellTimeoutMs = 1e4 } = streamOptions;
368
368
  const renderSSR = async (initialData, location, meta = {}, signal, opts) => {
369
369
  const { log, warn } = createUILogger(opts?.logger ?? logger, {
370
370
  debugCategory: "ssr",
@@ -412,7 +412,6 @@ function createRenderer({
412
412
  });
413
413
  const routeContext = opts?.routeContext;
414
414
  const effectiveShellTimeout = opts?.shellTimeoutMs ?? shellTimeoutMs;
415
- const effectiveUseCork = opts?.useCork ?? useCork;
416
415
  const controller = createStreamController(writable, { log, warn, error });
417
416
  if (signal) {
418
417
  const handleAbortSignal = () => controller.benignAbort(`AbortSignal triggered; aborting stream for location: ${location}`);
@@ -447,6 +446,7 @@ function createRenderer({
447
446
  });
448
447
  controller.setStopShellTimer(stopShellTimer);
449
448
  log("Starting stream:", location);
449
+ let piped = false;
450
450
  try {
451
451
  const store = createSSRStore(initialData);
452
452
  const appElement = /* @__PURE__ */ jsx3(SSRStoreProvider, { store, children: appComponent({ location, routeContext }) });
@@ -471,38 +471,15 @@ function createRenderer({
471
471
  }
472
472
  }
473
473
  const head = headContent({ data: headData ?? {}, meta, routeContext });
474
- const canCork = effectiveUseCork && typeof writable.cork === "function" && typeof writable.uncork === "function";
475
- if (canCork)
476
- try {
477
- writable.cork();
478
- } catch {
479
- }
480
- let wroteOk = true;
481
- try {
482
- const res = typeof writable.write === "function" ? writable.write(head) : true;
483
- wroteOk = res !== false;
484
- } finally {
485
- if (canCork) {
486
- try {
487
- writable.uncork();
488
- } catch {
489
- }
490
- }
491
- }
492
- let forceWait = false;
493
474
  try {
494
- forceWait = cb.onHead(head) === false;
475
+ cb.onHead(head);
495
476
  } catch (cbErr) {
496
477
  warn("onHead callback threw:", cbErr);
497
478
  }
498
- const startPipe = () => stream.pipe(writable);
499
- if (forceWait || !wroteOk) {
500
- if (typeof writable.once === "function") {
501
- writable.once("drain", startPipe);
502
- } else {
503
- startPipe();
504
- }
505
- } else startPipe();
479
+ if (!piped) {
480
+ piped = true;
481
+ stream.pipe(writable);
482
+ }
506
483
  try {
507
484
  cb.onShellReady();
508
485
  } catch (cbErr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taujs/react",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "taujs | τjs",
5
5
  "author": "Aoede <taujs@aoede.uk.net> (https://www.aoede.uk.net)",
6
6
  "license": "MIT",