solid-js 1.2.5 → 1.3.0-beta.10

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/web/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createMemo, createRoot, createRenderEffect, sharedConfig, createSignal, onCleanup, splitProps, untrack } from 'solid-js';
1
+ import { createMemo, createRoot, createRenderEffect, sharedConfig, enableHydration, createSignal, onCleanup, splitProps, untrack } from 'solid-js';
2
2
  export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, mergeProps } from 'solid-js';
3
3
 
4
4
  const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
@@ -95,7 +95,7 @@ function render(code, element, init) {
95
95
  let disposer;
96
96
  createRoot(dispose => {
97
97
  disposer = dispose;
98
- insert(element, code(), element.firstChild ? null : undefined, init);
98
+ element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
99
99
  });
100
100
  return () => {
101
101
  disposer();
@@ -215,28 +215,21 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
215
215
  prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG);
216
216
  }
217
217
  }
218
- function hydrate(code, element) {
219
- sharedConfig.resources = globalThis._$HYDRATION.resources;
220
- sharedConfig.completed = globalThis._$HYDRATION.completed;
221
- sharedConfig.events = globalThis._$HYDRATION.events;
218
+ function hydrate$1(code, element, options = {}) {
219
+ sharedConfig.completed = globalThis._$HY.completed;
220
+ sharedConfig.events = globalThis._$HY.events;
221
+ sharedConfig.load = globalThis._$HY.load;
222
+ sharedConfig.gather = root => gatherHydratable(element, root);
223
+ sharedConfig.registry = new Map();
222
224
  sharedConfig.context = {
223
- id: "",
224
- count: 0,
225
- loadResource: globalThis._$HYDRATION.loadResource
225
+ id: options.renderId || "",
226
+ count: 0
226
227
  };
227
- sharedConfig.registry = new Map();
228
- gatherHydratable(element);
228
+ gatherHydratable(element, options.renderId);
229
229
  const dispose = render(code, element, [...element.childNodes]);
230
230
  sharedConfig.context = null;
231
231
  return dispose;
232
232
  }
233
- function gatherHydratable(element) {
234
- const templates = element.querySelectorAll(`*[data-hk]`);
235
- for (let i = 0; i < templates.length; i++) {
236
- const node = templates[i];
237
- sharedConfig.registry.set(node.getAttribute("data-hk"), node);
238
- }
239
- }
240
233
  function getNextElement(template) {
241
234
  let node, key;
242
235
  if (!sharedConfig.context || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
@@ -330,7 +323,7 @@ function eventHandler(e) {
330
323
  Object.defineProperty(e, "currentTarget", {
331
324
  configurable: true,
332
325
  get() {
333
- return node;
326
+ return node || document;
334
327
  }
335
328
  });
336
329
  while (node !== null) {
@@ -385,7 +378,12 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
385
378
  createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
386
379
  return () => current;
387
380
  }
388
- if (sharedConfig.context && current && current.length) return current;
381
+ if (sharedConfig.context && current && current.length) {
382
+ for (let i = 0; i < array.length; i++) {
383
+ if (array[i].parentNode) return current = array;
384
+ }
385
+ return current;
386
+ }
389
387
  if (array.length === 0) {
390
388
  current = cleanChildren(parent, current, marker);
391
389
  if (multi) return current;
@@ -402,6 +400,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
402
400
  }
403
401
  current = array;
404
402
  } else if (value instanceof Node) {
403
+ if (sharedConfig.context) return current = value.parentNode ? value : current;
405
404
  if (Array.isArray(current)) {
406
405
  if (multi) return current = cleanChildren(parent, current, marker, value);
407
406
  cleanChildren(parent, current, null, value);
@@ -453,6 +452,14 @@ function cleanChildren(parent, current, marker, replacement) {
453
452
  } else parent.insertBefore(node, marker);
454
453
  return [node];
455
454
  }
455
+ function gatherHydratable(element, root) {
456
+ const templates = element.querySelectorAll(`*[data-hk]`);
457
+ for (let i = 0; i < templates.length; i++) {
458
+ const node = templates[i];
459
+ const key = node.getAttribute("data-hk");
460
+ if (!root || key.startsWith(root)) sharedConfig.registry.set(key, node);
461
+ }
462
+ }
456
463
  function getHydrationKey() {
457
464
  const hydrate = sharedConfig.context;
458
465
  return `${hydrate.id}${hydrate.count++}`;
@@ -466,8 +473,7 @@ function NoHydration(props) {
466
473
 
467
474
  function renderToString(fn, options) {}
468
475
  function renderToStringAsync(fn, options) {}
469
- function pipeToNodeWritable(fn, writable, options) {}
470
- function pipeToWritable(fn, writable, options) {}
476
+ function renderToStream(fn, options) {}
471
477
  function ssr(template, ...nodes) {}
472
478
  function resolveSSRNode(node) {}
473
479
  function ssrClassList(value) {}
@@ -483,6 +489,10 @@ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
483
489
  function createElement(tagName, isSVG = false) {
484
490
  return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
485
491
  }
492
+ const hydrate = (...args) => {
493
+ enableHydration();
494
+ return hydrate$1(...args);
495
+ };
486
496
  function Portal(props) {
487
497
  const {
488
498
  useShadow
@@ -536,4 +546,4 @@ function Dynamic(props) {
536
546
  });
537
547
  }
538
548
 
539
- export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, gatherHydratable, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, insert, isServer, memo, pipeToNodeWritable, pipeToWritable, render, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
549
+ export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
@@ -232,147 +232,191 @@ function stringifyString(str) {
232
232
  return result;
233
233
  }
234
234
 
235
+ const REPLACE_SCRIPT = `function $df(e,y,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e,y)}`;
236
+ const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
235
237
  function renderToString(code, options = {}) {
236
- solidJs.sharedConfig.context = Object.assign({
237
- id: "",
238
+ let scripts = "";
239
+ solidJs.sharedConfig.context = {
240
+ id: options.renderId || "",
238
241
  count: 0,
239
- assets: []
240
- }, options);
241
- let html = resolveSSRNode(escape(code()));
242
- return injectAssets(solidJs.sharedConfig.context.assets, html);
242
+ suspense: {},
243
+ assets: [],
244
+ nonce: options.nonce,
245
+ writeResource(id, p, error) {
246
+ if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
247
+ scripts += `_$HY.set("${id}", ${devalue(p)});`;
248
+ }
249
+ };
250
+ let html = injectAssets(solidJs.sharedConfig.context.assets, resolveSSRNode(escape(code())));
251
+ if (scripts.length) html = injectScripts(html, scripts, options.nonce);
252
+ return html;
243
253
  }
244
254
  function renderToStringAsync(code, options = {}) {
245
- options = {
246
- timeoutMs: 30000,
247
- ...options
248
- };
249
- const context = solidJs.sharedConfig.context = Object.assign({
250
- id: "",
255
+ let scripts = "";
256
+ const {
257
+ nonce,
258
+ renderId,
259
+ timeoutMs = 30000
260
+ } = options;
261
+ const context = solidJs.sharedConfig.context = {
262
+ id: renderId || "",
251
263
  count: 0,
252
264
  resources: {},
253
265
  suspense: {},
254
266
  assets: [],
255
- async: true
256
- }, options);
257
- const timeout = new Promise((_, reject) => setTimeout(() => reject("renderToString timed out"), options.timeoutMs));
258
- return Promise.race([solidJs.awaitSuspense(() => escape(code())), timeout]).then(res => {
259
- let html = resolveSSRNode(res);
260
- return injectAssets(context.assets, html);
267
+ async: true,
268
+ nonce,
269
+ writeResource(id, p, error) {
270
+ if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
271
+ if (typeof p !== "object" || !("then" in p)) return scripts += `_$HY.set("${id}", ${devalue(p)});`;
272
+ p.then(d => scripts += `_$HY.set("${id}", ${devalue(d)});`).catch(() => scripts += `_$HY.set("${id}", null);`);
273
+ }
274
+ };
275
+ const timeout = new Promise((_, reject) => setTimeout(() => reject("renderToString timed out"), timeoutMs));
276
+ function asyncWrap(fn) {
277
+ return new Promise(resolve => {
278
+ const registry = new Set();
279
+ const cache = Object.create(null);
280
+ solidJs.sharedConfig.context.registerFragment = register;
281
+ const rendered = fn();
282
+ if (!registry.size) resolve(rendered);
283
+ function register(key) {
284
+ registry.add(key);
285
+ return (value = "", error) => {
286
+ cache[key] = value;
287
+ registry.delete(key);
288
+ if (error) return scripts += `_$HY.set("${key}", Promise.resolve(${serializeError(error)}));`;
289
+ scripts += `_$HY.set("${key}", true);`;
290
+ if (!registry.size) Promise.resolve().then(() => {
291
+ let source = resolveSSRNode(rendered);
292
+ let final = "";
293
+ let match;
294
+ while (match = source.match(FRAGMENT_REPLACE)) {
295
+ final += source.substring(0, match.index);
296
+ source = cache[match[1]] + source.substring(match.index + match[0].length);
297
+ }
298
+ resolve(final + source);
299
+ });
300
+ return true;
301
+ };
302
+ }
303
+ });
304
+ }
305
+ return Promise.race([asyncWrap(() => escape(code())), timeout]).then(res => {
306
+ let html = injectAssets(context.assets, resolveSSRNode(res));
307
+ if (scripts.length) html = injectScripts(html, scripts, nonce);
308
+ return html;
261
309
  });
262
310
  }
263
- function pipeToNodeWritable(code, writable, options = {}) {
311
+ function renderToStream(code, options = {}) {
264
312
  const {
265
313
  nonce,
266
- onReady = ({
267
- startWriting
268
- }) => startWriting(),
269
- onComplete
314
+ onCompleteShell,
315
+ onCompleteAll,
316
+ renderId
270
317
  } = options;
271
318
  const tmp = [];
272
- let count = 0,
273
- completed = 0,
274
- buffer = {
275
- write(payload) {
276
- tmp.push(payload);
319
+ const tasks = [];
320
+ const registry = new Map();
321
+ const checkEnd = () => {
322
+ if (!registry.size && !completed) {
323
+ onCompleteAll && onCompleteAll(result);
324
+ writable && writable.end();
325
+ completed = true;
277
326
  }
278
327
  };
279
- const result = {
280
- startWriting() {
281
- buffer = writable;
282
- tmp.forEach(chunk => buffer.write(chunk));
283
- setTimeout(checkEnd);
284
- },
285
- write(c) {
286
- writable.write(c);
287
- },
288
- abort() {
289
- completed = count;
290
- checkEnd();
328
+ const writeInitialScript = () => {
329
+ if (tasks.length && !completed) {
330
+ buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.join(";")}</script>`);
331
+ tasks.length = 0;
291
332
  }
333
+ scheduled = false;
292
334
  };
293
- const checkEnd = () => {
294
- if (completed === count) {
295
- onComplete && onComplete(result);
296
- writable.end();
335
+ let writable;
336
+ let completed = false;
337
+ let scriptFlushed = false;
338
+ let scheduled = true;
339
+ let buffer = {
340
+ write(payload) {
341
+ tmp.push(payload);
297
342
  }
298
343
  };
299
- solidJs.sharedConfig.context = Object.assign({
300
- id: "",
344
+ solidJs.sharedConfig.context = {
345
+ id: renderId || "",
301
346
  count: 0,
347
+ async: true,
302
348
  streaming: true,
349
+ resources: {},
303
350
  suspense: {},
304
- assets: []
305
- }, options);
306
- solidJs.sharedConfig.context.writeResource = (id, p) => {
307
- count++;
308
- Promise.resolve().then(() => buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HYDRATION.startResource("${id}")</script>`));
309
- p.then(d => {
310
- buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HYDRATION.resolveResource("${id}", ${devalue(d)})</script>`);
311
- ++completed && checkEnd();
312
- });
313
- };
314
- let html = resolveSSRNode(escape(code()));
315
- html = injectAssets(solidJs.sharedConfig.context.assets, html);
316
- buffer.write(html);
317
- onReady(result);
318
- }
319
- function pipeToWritable(code, writable, options = {}) {
320
- const {
351
+ assets: [],
321
352
  nonce,
322
- onReady = ({
323
- startWriting
324
- }) => startWriting(),
325
- onComplete
326
- } = options;
327
- const tmp = [];
328
- const writer = writable.getWriter();
329
- const encoder = new TextEncoder();
330
- solidJs.sharedConfig.context = Object.assign({
331
- id: "",
332
- count: 0,
333
- streaming: true,
334
- suspense: {},
335
- assets: []
336
- }, options);
337
- let count = 0,
338
- completed = 0,
339
- buffer = {
340
- write(payload) {
341
- tmp.push(payload);
342
- }
343
- };
344
- const result = {
345
- startWriting() {
346
- buffer = writer;
347
- tmp.forEach(chunk => writer.write(chunk));
348
- setTimeout(checkEnd);
349
- },
350
- write(c) {
351
- writer.write(encoder.encode(c));
353
+ writeResource(id, p, error) {
354
+ if (!scheduled) {
355
+ Promise.resolve().then(writeInitialScript);
356
+ scheduled = true;
357
+ }
358
+ if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
359
+ if (typeof p !== "object" || !("then" in p)) return tasks.push(`_$HY.set("${id}", ${devalue(p)})`);
360
+ tasks.push(`_$HY.init("${id}")`);
361
+ p.then(d => {
362
+ !completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`);
363
+ }).catch(err => {
364
+ !completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", null, ${serializeError(err)})</script>`);
365
+ });
352
366
  },
353
- abort() {
354
- completed = count;
355
- checkEnd();
356
- }
357
- };
358
- const checkEnd = () => {
359
- if (completed === count) {
360
- onComplete && onComplete(result);
361
- writable.close();
367
+ registerFragment(key) {
368
+ registry.set(key, []);
369
+ if (!scheduled) {
370
+ Promise.resolve().then(writeInitialScript);
371
+ scheduled = true;
372
+ }
373
+ tasks.push(`_$HY.init("${key}")`);
374
+ return (value, error) => {
375
+ const keys = registry.get(key);
376
+ registry.delete(key);
377
+ if (waitForFragments(registry, key)) return;
378
+ if ((value !== undefined || error) && !completed) {
379
+ buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div><script${nonce ? ` nonce="${nonce}"` : ""}>${!scriptFlushed ? REPLACE_SCRIPT : ""}${keys.length ? keys.map(k => `_$HY.unset("${k}");`) : ""}$df("${key}"${error ? "," + serializeError(error) : ""})</script>`);
380
+ scriptFlushed = true;
381
+ }
382
+ checkEnd();
383
+ return true;
384
+ };
362
385
  }
363
386
  };
364
- solidJs.sharedConfig.context.writeResource = (id, p) => {
365
- count++;
366
- Promise.resolve().then(() => buffer.write(encoder.encode(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HYDRATION.startResource("${id}")</script>`)));
367
- p.then(d => {
368
- buffer.write(encoder.encode(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HYDRATION.resolveResource("${id}", ${devalue(d)})</script>`));
369
- ++completed && checkEnd();
370
- });
371
- };
372
387
  let html = resolveSSRNode(escape(code()));
373
388
  html = injectAssets(solidJs.sharedConfig.context.assets, html);
374
- buffer.write(encoder.encode(html));
375
- onReady(result);
389
+ Promise.resolve().then(() => {
390
+ if (tasks.length) html = injectScripts(html, tasks.join(";"), nonce);
391
+ buffer.write(html);
392
+ tasks.length = 0;
393
+ scheduled = false;
394
+ onCompleteShell && onCompleteShell();
395
+ });
396
+ return {
397
+ pipe(w) {
398
+ buffer = writable = w;
399
+ tmp.forEach(chunk => buffer.write(chunk));
400
+ if (completed) writable.end();else setTimeout(checkEnd);
401
+ },
402
+ pipeTo(w) {
403
+ const encoder = new TextEncoder();
404
+ const writer = w.getWriter();
405
+ writable = {
406
+ end() {
407
+ writer.releaseLock();
408
+ w.close();
409
+ }
410
+ };
411
+ buffer = {
412
+ write(payload) {
413
+ writer.write(encoder.encode(payload));
414
+ }
415
+ };
416
+ tmp.forEach(chunk => buffer.write(chunk));
417
+ if (completed) writable.end();else setTimeout(checkEnd);
418
+ }
419
+ };
376
420
  }
377
421
  function Assets(props) {
378
422
  solidJs.sharedConfig.context.assets.push(() => NoHydration({
@@ -382,15 +426,21 @@ function Assets(props) {
382
426
  }));
383
427
  return ssr(`%%$${solidJs.sharedConfig.context.assets.length - 1}%%`);
384
428
  }
385
- function HydrationScript() {
386
- solidJs.sharedConfig.context.assets.push(generateHydrationScript);
429
+ function HydrationScript(props) {
430
+ const {
431
+ nonce
432
+ } = solidJs.sharedConfig.context;
433
+ solidJs.sharedConfig.context.assets.push(() => generateHydrationScript({
434
+ nonce,
435
+ ...props
436
+ }));
387
437
  return ssr(`%%$${solidJs.sharedConfig.context.assets.length - 1}%%`);
388
438
  }
389
439
  function NoHydration(props) {
390
440
  const c = solidJs.sharedConfig.context;
391
- delete solidJs.sharedConfig.context;
441
+ c.noHydrate = true;
392
442
  const children = props.children;
393
- solidJs.sharedConfig.context = c;
443
+ c.noHydrate = false;
394
444
  return children;
395
445
  }
396
446
  function ssr(t, ...nodes) {
@@ -518,26 +568,13 @@ function resolveSSRNode(node) {
518
568
  }
519
569
  function getHydrationKey() {
520
570
  const hydrate = solidJs.sharedConfig.context;
521
- return hydrate && `${hydrate.id}${hydrate.count++}`;
571
+ return hydrate && !hydrate.noHydrate && `${hydrate.id}${hydrate.count++}`;
522
572
  }
523
- function generateHydrationScript() {
524
- const {
525
- nonce,
526
- streaming,
527
- resources,
528
- eventNames = ["click", "input"]
529
- } = solidJs.sharedConfig.context;
530
- let s = `<script${nonce ? ` nonce="${nonce}"` : ""}>(()=>{_$HYDRATION={events:[],completed:new WeakSet};const t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),e=e=>{let o=e.composedPath&&e.composedPath()[0]||e.target,s=t(o);s&&!_$HYDRATION.completed.has(s)&&_$HYDRATION.events.push([s,e])};["${eventNames.join('","')}"].forEach(t=>document.addEventListener(t,e))})();`;
531
- if (streaming) {
532
- s += `(()=>{const e=_$HYDRATION,o={};e.startResource=e=>{let r;o[e]=[new Promise(e=>r=e),r]},e.resolveResource=(e,r)=>{const n=o[e];if(!n)return o[e]=[r];n[1](r)},e.loadResource=e=>{const r=o[e];if(r)return r[0]}})();`;
533
- }
534
- if (resources) {
535
- s += `_$HYDRATION.resources = ${devalue(Object.keys(resources).reduce((r, k) => {
536
- r[k] = resources[k].data;
537
- return r;
538
- }, {}))};`;
539
- }
540
- return s + `</script>`;
573
+ function generateHydrationScript({
574
+ eventNames = ["click", "input"],
575
+ nonce
576
+ }) {
577
+ return `<script${nonce ? ` nonce="${nonce}"` : ""}>((e,t,o={})=>{t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let s=o.composedPath&&o.composedPath()[0]||o.target,n=t(s);n&&!e.completed.has(n)&&e.events.push([n,o])})))),e.init=(e,t,s)=>{o[e]=[new Promise(((e,o)=>(t=e,s=o))),t,s]},e.set=(e,t,s,n)=>{(n=o[e])&&(s?n[2](s):n[1](t)),o[e]=[t]},e.unset=e=>{delete o[e]},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}))</script><!xs>`;
541
578
  }
542
579
  function injectAssets(assets, html) {
543
580
  for (let i = 0; i < assets.length; i++) {
@@ -545,6 +582,52 @@ function injectAssets(assets, html) {
545
582
  }
546
583
  return html;
547
584
  }
585
+ function injectScripts(html, scripts, nonce) {
586
+ const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
587
+ const index = html.indexOf("<!xs>");
588
+ if (index > -1) {
589
+ return html.slice(0, index) + tag + html.slice(index);
590
+ }
591
+ return html + tag;
592
+ }
593
+ function serializeError(error) {
594
+ return error.message ? `new Error(${devalue(error.message)})` : devalue(error);
595
+ }
596
+ function waitForFragments(registry, key) {
597
+ for (const k of [...registry.keys()].reverse()) {
598
+ if (key.startsWith(k)) {
599
+ registry.get(k).push(key);
600
+ return true;
601
+ }
602
+ }
603
+ return false;
604
+ }
605
+ function pipeToNodeWritable(code, writable, options = {}) {
606
+ if (options.onReady) {
607
+ options.onCompleteShell = () => {
608
+ options.onReady({
609
+ startWriting() {
610
+ stream.pipe(writable);
611
+ }
612
+ });
613
+ };
614
+ }
615
+ const stream = renderToStream(code, options);
616
+ if (!options.onReady) stream.pipe(writable);
617
+ }
618
+ function pipeToWritable(code, writable, options = {}) {
619
+ if (options.onReady) {
620
+ options.onCompleteShell = () => {
621
+ options.onReady({
622
+ startWriting() {
623
+ stream.pipeTo(writable);
624
+ }
625
+ });
626
+ };
627
+ }
628
+ const stream = renderToStream(code, options);
629
+ if (!options.onReady) stream.pipeTo(writable);
630
+ }
548
631
 
549
632
  const isServer = true;
550
633
  function spread() {}
@@ -634,6 +717,7 @@ exports.getHydrationKey = getHydrationKey;
634
717
  exports.isServer = isServer;
635
718
  exports.pipeToNodeWritable = pipeToNodeWritable;
636
719
  exports.pipeToWritable = pipeToWritable;
720
+ exports.renderToStream = renderToStream;
637
721
  exports.renderToString = renderToString;
638
722
  exports.renderToStringAsync = renderToStringAsync;
639
723
  exports.resolveSSRNode = resolveSSRNode;