solid-js 1.5.2 → 1.5.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/dist/server.cjs CHANGED
@@ -489,7 +489,6 @@ function lazy(fn) {
489
489
  return p;
490
490
  };
491
491
  const contexts = new Set();
492
- setTimeout(load);
493
492
  const wrap = props => {
494
493
  load();
495
494
  const id = sharedConfig.context.id.slice(0, -1);
@@ -503,21 +502,22 @@ function lazy(fn) {
503
502
  ctx.resources.set(id, track);
504
503
  contexts.add(ctx);
505
504
  }
506
- if (sharedConfig.context.async) p.then(() => {
507
- track.loading = false;
508
- notifySuspense(contexts);
509
- });
505
+ if (sharedConfig.context.async) {
506
+ sharedConfig.context.block(p.then(() => {
507
+ track.loading = false;
508
+ notifySuspense(contexts);
509
+ }));
510
+ }
510
511
  return "";
511
512
  };
512
513
  wrap.preload = load;
513
514
  return wrap;
514
515
  }
515
516
  function suspenseComplete(c) {
516
- if (c.complete) return true;
517
517
  for (const r of c.resources.values()) {
518
518
  if (r.loading) return false;
519
519
  }
520
- return c.complete = true;
520
+ return true;
521
521
  }
522
522
  function notifySuspense(contexts) {
523
523
  for (const c of contexts) {
@@ -556,8 +556,7 @@ function Suspense(props) {
556
556
  if (suspenseComplete(value)) {
557
557
  done(resolveSSRNode(res));
558
558
  }
559
- },
560
- complete: false
559
+ }
561
560
  });
562
561
  function runSuspense() {
563
562
  setHydrateContext({ ...ctx,
@@ -584,7 +583,11 @@ function Suspense(props) {
584
583
  });
585
584
  done = ctx.async ? ctx.registerFragment(id) : undefined;
586
585
  if (ctx.async) {
587
- setHydrateContext(undefined);
586
+ setHydrateContext({ ...ctx,
587
+ count: 0,
588
+ id: ctx.id + "0.f",
589
+ noHydrate: true
590
+ });
588
591
  const res = {
589
592
  t: `<span id="pl-${id}">${resolveSSRNode(props.fallback)}</span>`
590
593
  };
package/dist/server.js CHANGED
@@ -485,7 +485,6 @@ function lazy(fn) {
485
485
  return p;
486
486
  };
487
487
  const contexts = new Set();
488
- setTimeout(load);
489
488
  const wrap = props => {
490
489
  load();
491
490
  const id = sharedConfig.context.id.slice(0, -1);
@@ -499,21 +498,22 @@ function lazy(fn) {
499
498
  ctx.resources.set(id, track);
500
499
  contexts.add(ctx);
501
500
  }
502
- if (sharedConfig.context.async) p.then(() => {
503
- track.loading = false;
504
- notifySuspense(contexts);
505
- });
501
+ if (sharedConfig.context.async) {
502
+ sharedConfig.context.block(p.then(() => {
503
+ track.loading = false;
504
+ notifySuspense(contexts);
505
+ }));
506
+ }
506
507
  return "";
507
508
  };
508
509
  wrap.preload = load;
509
510
  return wrap;
510
511
  }
511
512
  function suspenseComplete(c) {
512
- if (c.complete) return true;
513
513
  for (const r of c.resources.values()) {
514
514
  if (r.loading) return false;
515
515
  }
516
- return c.complete = true;
516
+ return true;
517
517
  }
518
518
  function notifySuspense(contexts) {
519
519
  for (const c of contexts) {
@@ -552,8 +552,7 @@ function Suspense(props) {
552
552
  if (suspenseComplete(value)) {
553
553
  done(resolveSSRNode(res));
554
554
  }
555
- },
556
- complete: false
555
+ }
557
556
  });
558
557
  function runSuspense() {
559
558
  setHydrateContext({ ...ctx,
@@ -580,7 +579,11 @@ function Suspense(props) {
580
579
  });
581
580
  done = ctx.async ? ctx.registerFragment(id) : undefined;
582
581
  if (ctx.async) {
583
- setHydrateContext(undefined);
582
+ setHydrateContext({ ...ctx,
583
+ count: 0,
584
+ id: ctx.id + "0.f",
585
+ noHydrate: true
586
+ });
584
587
  const res = {
585
588
  t: `<span id="pl-${id}">${resolveSSRNode(props.fallback)}</span>`
586
589
  };
@@ -286,7 +286,7 @@ export namespace JSX {
286
286
 
287
287
  interface CSSProperties extends csstype.PropertiesHyphen {
288
288
  // Override
289
- [key: `—${string}`]: string | number | undefined
289
+ [key: `-${string}`]: string | number | undefined
290
290
  }
291
291
 
292
292
  type HTMLAutocapitalize = "off" | "none" | "on" | "sentences" | "words" | "characters";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.5.2",
4
+ "version": "1.5.3",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
package/types/jsx.d.ts CHANGED
@@ -285,7 +285,7 @@ export namespace JSX {
285
285
 
286
286
  interface CSSProperties extends csstype.PropertiesHyphen {
287
287
  // Override
288
- [key: `—${string}`]: string | number | undefined
288
+ [key: `-${string}`]: string | number | undefined
289
289
  }
290
290
 
291
291
  type HTMLAutocapitalize = "off" | "none" | "on" | "sentences" | "words" | "characters";
@@ -82,7 +82,6 @@ declare type SuspenseContextType = {
82
82
  loading: boolean;
83
83
  error: any;
84
84
  }>;
85
- complete: boolean;
86
85
  completed: () => void;
87
86
  };
88
87
  export declare type ResourceActions<T> = {
@@ -131,6 +130,7 @@ declare type HydrationContext = {
131
130
  count: number;
132
131
  writeResource: (id: string, v: Promise<any> | any, error?: boolean, deferStream?: boolean) => void;
133
132
  replace: (id: string, replacement: () => any) => void;
133
+ block: (p: Promise<any>) => void;
134
134
  resources: Record<string, any>;
135
135
  suspense: Record<string, SuspenseContextType>;
136
136
  registerFragment: (v: string) => (v?: string, err?: any) => boolean;
@@ -266,8 +266,7 @@ function toRefParam(index) {
266
266
  const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t)}`;
267
267
  function renderToString(code, options = {}) {
268
268
  let scripts = "";
269
- let context;
270
- solidJs.sharedConfig.context = context = {
269
+ solidJs.sharedConfig.context = {
271
270
  id: options.renderId || "",
272
271
  count: 0,
273
272
  suspense: {},
@@ -279,8 +278,8 @@ function renderToString(code, options = {}) {
279
278
  }
280
279
  };
281
280
  let html = resolveSSRNode(escape(code()));
282
- solidJs.sharedConfig.context = undefined;
283
- html = injectAssets(context.assets, html);
281
+ solidJs.sharedConfig.context.noHydrate = true;
282
+ html = injectAssets(solidJs.sharedConfig.context.assets, html);
284
283
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
285
284
  return html;
286
285
  }
@@ -354,6 +353,9 @@ function renderToStream(code, options = {}) {
354
353
  suspense: {},
355
354
  assets: [],
356
355
  nonce,
356
+ block(p) {
357
+ if (!firstFlushed) blockingResources.push(p);
358
+ },
357
359
  replace(id, payloadFn) {
358
360
  if (firstFlushed) return;
359
361
  const placeholder = `<!${id}>`;
@@ -393,14 +395,15 @@ function renderToStream(code, options = {}) {
393
395
  }
394
396
  }
395
397
  }
396
- Promise.resolve().then(checkEnd);
398
+ if (!registry.size) Promise.resolve().then(checkEnd);
397
399
  return firstFlushed;
398
400
  };
399
401
  }
400
402
  };
401
403
  let html = resolveSSRNode(escape(code()));
402
404
  function doShell() {
403
- solidJs.sharedConfig.context = undefined;
405
+ solidJs.sharedConfig.context = context;
406
+ context.noHydrate = true;
404
407
  html = injectAssets(context.assets, html);
405
408
  for (const key in context.resources) {
406
409
  if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
@@ -429,7 +432,7 @@ function renderToStream(code, options = {}) {
429
432
  complete();
430
433
  };
431
434
  } else onCompleteAll = complete;
432
- checkEnd();
435
+ if (!registry.size) Promise.resolve().then(checkEnd);
433
436
  },
434
437
  pipe(w) {
435
438
  Promise.allSettled(blockingResources).then(() => {
@@ -263,8 +263,7 @@ function toRefParam(index) {
263
263
  const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t)}`;
264
264
  function renderToString(code, options = {}) {
265
265
  let scripts = "";
266
- let context;
267
- sharedConfig.context = context = {
266
+ sharedConfig.context = {
268
267
  id: options.renderId || "",
269
268
  count: 0,
270
269
  suspense: {},
@@ -276,8 +275,8 @@ function renderToString(code, options = {}) {
276
275
  }
277
276
  };
278
277
  let html = resolveSSRNode(escape(code()));
279
- sharedConfig.context = undefined;
280
- html = injectAssets(context.assets, html);
278
+ sharedConfig.context.noHydrate = true;
279
+ html = injectAssets(sharedConfig.context.assets, html);
281
280
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
282
281
  return html;
283
282
  }
@@ -351,6 +350,9 @@ function renderToStream(code, options = {}) {
351
350
  suspense: {},
352
351
  assets: [],
353
352
  nonce,
353
+ block(p) {
354
+ if (!firstFlushed) blockingResources.push(p);
355
+ },
354
356
  replace(id, payloadFn) {
355
357
  if (firstFlushed) return;
356
358
  const placeholder = `<!${id}>`;
@@ -390,14 +392,15 @@ function renderToStream(code, options = {}) {
390
392
  }
391
393
  }
392
394
  }
393
- Promise.resolve().then(checkEnd);
395
+ if (!registry.size) Promise.resolve().then(checkEnd);
394
396
  return firstFlushed;
395
397
  };
396
398
  }
397
399
  };
398
400
  let html = resolveSSRNode(escape(code()));
399
401
  function doShell() {
400
- sharedConfig.context = undefined;
402
+ sharedConfig.context = context;
403
+ context.noHydrate = true;
401
404
  html = injectAssets(context.assets, html);
402
405
  for (const key in context.resources) {
403
406
  if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
@@ -426,7 +429,7 @@ function renderToStream(code, options = {}) {
426
429
  complete();
427
430
  };
428
431
  } else onCompleteAll = complete;
429
- checkEnd();
432
+ if (!registry.size) Promise.resolve().then(checkEnd);
430
433
  },
431
434
  pipe(w) {
432
435
  Promise.allSettled(blockingResources).then(() => {