@vue/server-renderer 3.6.0-alpha.6 → 3.6.0-beta.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.
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @vue/server-renderer v3.6.0-alpha.6
2
+ * @vue/server-renderer v3.6.0-beta.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
6
  import { createVNode as createVNode$1, ssrUtils, ssrContextKey, warn as warn$2, Fragment as Fragment$1, Static, Comment as Comment$1, Text as Text$1, mergeProps as mergeProps$1, createApp, initDirectivesForSSR } from 'vue';
7
- import { makeMap, isOn, isRenderableAttrValue, isSVGTag, propsToAttrMap, isBooleanAttr, includeBooleanAttr, isSSRSafeAttrName, escapeHtml, normalizeClass, isString, normalizeStyle, stringifyStyle, isArray, isObject, normalizeCssVarValue, toDisplayString, isFunction, EMPTY_OBJ, extend, NOOP, looseEqual, looseIndexOf, escapeHtmlComment, isPromise, isVoidTag } from '@vue/shared';
7
+ import { makeMap, isOn, isRenderableAttrValue, isSVGTag, propsToAttrMap, isBooleanAttr, includeBooleanAttr, isSSRSafeAttrName, escapeHtml, normalizeClass, isString, normalizeStyle, stringifyStyle, isArray, isObject, normalizeCssVarValue, toDisplayString, isFunction, EMPTY_OBJ, getGlobalThis, extend, NOOP, looseEqual, looseIndexOf, escapeHtmlComment, isPromise, isVoidTag } from '@vue/shared';
8
8
  export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared';
9
9
 
10
10
  const shouldIgnoreProp = /* @__PURE__ */ makeMap(
@@ -427,6 +427,318 @@ function logError(err, type, instance, throwInDev = true, throwInProd = false) {
427
427
  }
428
428
  }
429
429
 
430
+ const jobs = [];
431
+ let postJobs = [];
432
+ let activePostJobs = null;
433
+ let currentFlushPromise = null;
434
+ let jobsLength = 0;
435
+ let flushIndex = 0;
436
+ let postFlushIndex = 0;
437
+ const resolvedPromise = /* @__PURE__ */ Promise.resolve();
438
+ const RECURSION_LIMIT = 100;
439
+ function nextTick(fn) {
440
+ const p = currentFlushPromise || resolvedPromise;
441
+ return fn ? p.then(this ? fn.bind(this) : fn) : p;
442
+ }
443
+ function findInsertionIndex(order, queue, start, end) {
444
+ while (start < end) {
445
+ const middle = start + end >>> 1;
446
+ if (queue[middle].order <= order) {
447
+ start = middle + 1;
448
+ } else {
449
+ end = middle;
450
+ }
451
+ }
452
+ return start;
453
+ }
454
+ function queueJob(job, id, isPre = false) {
455
+ if (queueJobWorker(
456
+ job,
457
+ isPre ? -2 : Infinity ,
458
+ jobs,
459
+ jobsLength,
460
+ flushIndex
461
+ )) {
462
+ jobsLength++;
463
+ queueFlush();
464
+ }
465
+ }
466
+ function queueJobWorker(job, order, queue, length, flushIndex2) {
467
+ const flags = job.flags;
468
+ if (!(flags & 1)) {
469
+ job.flags = flags | 1;
470
+ job.order = order;
471
+ if (flushIndex2 === length || // fast path when the job id is larger than the tail
472
+ order >= queue[length - 1].order) {
473
+ queue[length] = job;
474
+ } else {
475
+ queue.splice(findInsertionIndex(order, queue, flushIndex2, length), 0, job);
476
+ }
477
+ return true;
478
+ }
479
+ return false;
480
+ }
481
+ const doFlushJobs = () => {
482
+ try {
483
+ flushJobs();
484
+ } catch (e) {
485
+ currentFlushPromise = null;
486
+ throw e;
487
+ }
488
+ };
489
+ function queueFlush() {
490
+ if (!currentFlushPromise) {
491
+ currentFlushPromise = resolvedPromise.then(doFlushJobs);
492
+ }
493
+ }
494
+ function queuePostFlushCb(jobs2, id = Infinity) {
495
+ if (!isArray(jobs2)) {
496
+ if (activePostJobs && id === -1) {
497
+ activePostJobs.splice(postFlushIndex, 0, jobs2);
498
+ } else {
499
+ queueJobWorker(jobs2, id, postJobs, postJobs.length, 0);
500
+ }
501
+ } else {
502
+ for (const job of jobs2) {
503
+ queueJobWorker(job, id, postJobs, postJobs.length, 0);
504
+ }
505
+ }
506
+ queueFlush();
507
+ }
508
+ function flushPostFlushCbs(seen) {
509
+ if (postJobs.length) {
510
+ if (activePostJobs) {
511
+ activePostJobs.push(...postJobs);
512
+ postJobs.length = 0;
513
+ return;
514
+ }
515
+ activePostJobs = postJobs;
516
+ postJobs = [];
517
+ if (!!(process.env.NODE_ENV !== "production")) {
518
+ seen = seen || /* @__PURE__ */ new Map();
519
+ }
520
+ while (postFlushIndex < activePostJobs.length) {
521
+ const cb = activePostJobs[postFlushIndex++];
522
+ if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) {
523
+ continue;
524
+ }
525
+ if (cb.flags & 2) {
526
+ cb.flags &= -2;
527
+ }
528
+ if (!(cb.flags & 4)) {
529
+ try {
530
+ cb();
531
+ } finally {
532
+ cb.flags &= -2;
533
+ }
534
+ }
535
+ }
536
+ activePostJobs = null;
537
+ postFlushIndex = 0;
538
+ }
539
+ }
540
+ function flushJobs(seen) {
541
+ if (!!(process.env.NODE_ENV !== "production")) {
542
+ seen || (seen = /* @__PURE__ */ new Map());
543
+ }
544
+ try {
545
+ while (flushIndex < jobsLength) {
546
+ const job = jobs[flushIndex];
547
+ jobs[flushIndex++] = void 0;
548
+ if (!(job.flags & 4)) {
549
+ if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, job)) {
550
+ continue;
551
+ }
552
+ if (job.flags & 2) {
553
+ job.flags &= ~1;
554
+ }
555
+ try {
556
+ job();
557
+ } catch (err) {
558
+ handleError(
559
+ err,
560
+ job.i,
561
+ job.i ? 15 : 14
562
+ );
563
+ } finally {
564
+ if (!(job.flags & 2)) {
565
+ job.flags &= ~1;
566
+ }
567
+ }
568
+ }
569
+ }
570
+ } finally {
571
+ while (flushIndex < jobsLength) {
572
+ jobs[flushIndex].flags &= -2;
573
+ jobs[flushIndex++] = void 0;
574
+ }
575
+ flushIndex = 0;
576
+ jobsLength = 0;
577
+ flushPostFlushCbs(seen);
578
+ currentFlushPromise = null;
579
+ if (jobsLength || postJobs.length) {
580
+ flushJobs(seen);
581
+ }
582
+ }
583
+ }
584
+ function checkRecursiveUpdates(seen, fn) {
585
+ const count = seen.get(fn) || 0;
586
+ if (count > RECURSION_LIMIT) {
587
+ const instance = fn.i;
588
+ const componentName = instance && getComponentName(instance.type);
589
+ handleError(
590
+ `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
591
+ null,
592
+ 10
593
+ );
594
+ return true;
595
+ }
596
+ seen.set(fn, count + 1);
597
+ return false;
598
+ }
599
+
600
+ let isHmrUpdating = false;
601
+ const hmrDirtyComponents = /* @__PURE__ */ new Map();
602
+ const hmrDirtyComponentsMode = /* @__PURE__ */ new Map();
603
+ if (!!(process.env.NODE_ENV !== "production")) {
604
+ getGlobalThis().__VUE_HMR_RUNTIME__ = {
605
+ createRecord: tryWrap(createRecord),
606
+ rerender: tryWrap(rerender),
607
+ reload: tryWrap(reload)
608
+ };
609
+ }
610
+ const map = /* @__PURE__ */ new Map();
611
+ function createRecord(id, initialDef) {
612
+ if (map.has(id)) {
613
+ return false;
614
+ }
615
+ map.set(id, {
616
+ initialDef: normalizeClassComponent(initialDef),
617
+ instances: /* @__PURE__ */ new Set()
618
+ });
619
+ return true;
620
+ }
621
+ function normalizeClassComponent(component) {
622
+ return isClassComponent(component) ? component.__vccOpts : component;
623
+ }
624
+ function rerender(id, newRender) {
625
+ const record = map.get(id);
626
+ if (!record) {
627
+ return;
628
+ }
629
+ record.initialDef.render = newRender;
630
+ [...record.instances].forEach((instance) => {
631
+ if (newRender) {
632
+ instance.render = newRender;
633
+ normalizeClassComponent(instance.type).render = newRender;
634
+ }
635
+ isHmrUpdating = true;
636
+ if (instance.vapor) {
637
+ if (!instance.isUnmounted) instance.hmrRerender();
638
+ } else {
639
+ const i = instance;
640
+ if (!(i.effect.flags & 1024)) {
641
+ i.renderCache = [];
642
+ i.effect.run();
643
+ }
644
+ }
645
+ nextTick(() => {
646
+ isHmrUpdating = false;
647
+ });
648
+ });
649
+ }
650
+ function reload(id, newComp) {
651
+ const record = map.get(id);
652
+ if (!record) return;
653
+ newComp = normalizeClassComponent(newComp);
654
+ const isVapor = record.initialDef.__vapor;
655
+ updateComponentDef(record.initialDef, newComp);
656
+ const instances = [...record.instances];
657
+ if (isVapor && newComp.__vapor && !instances.some((i) => i.ceReload)) {
658
+ for (const instance of instances) {
659
+ if (instance.root && instance.root.ce && instance !== instance.root) {
660
+ instance.root.ce._removeChildStyle(instance.type);
661
+ }
662
+ }
663
+ for (const instance of instances) {
664
+ instance.hmrReload(newComp);
665
+ }
666
+ } else {
667
+ for (const instance of instances) {
668
+ const oldComp = normalizeClassComponent(instance.type);
669
+ let dirtyInstances = hmrDirtyComponents.get(oldComp);
670
+ if (!dirtyInstances) {
671
+ if (oldComp !== record.initialDef) {
672
+ updateComponentDef(oldComp, newComp);
673
+ }
674
+ hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
675
+ }
676
+ dirtyInstances.add(instance);
677
+ hmrDirtyComponentsMode.set(oldComp, !!isVapor);
678
+ instance.appContext.propsCache.delete(instance.type);
679
+ instance.appContext.emitsCache.delete(instance.type);
680
+ instance.appContext.optionsCache.delete(instance.type);
681
+ if (instance.ceReload) {
682
+ dirtyInstances.add(instance);
683
+ instance.ceReload(newComp.styles);
684
+ dirtyInstances.delete(instance);
685
+ } else if (instance.parent) {
686
+ queueJob(() => {
687
+ isHmrUpdating = true;
688
+ const parent = instance.parent;
689
+ if (parent.vapor) {
690
+ parent.hmrRerender();
691
+ } else {
692
+ if (!(parent.effect.flags & 1024)) {
693
+ parent.renderCache = [];
694
+ parent.effect.run();
695
+ }
696
+ }
697
+ nextTick(() => {
698
+ isHmrUpdating = false;
699
+ });
700
+ dirtyInstances.delete(instance);
701
+ });
702
+ } else if (instance.appContext.reload) {
703
+ instance.appContext.reload();
704
+ } else if (typeof window !== "undefined") {
705
+ window.location.reload();
706
+ } else {
707
+ console.warn(
708
+ "[HMR] Root or manually mounted instance modified. Full reload required."
709
+ );
710
+ }
711
+ if (instance.root.ce && instance !== instance.root) {
712
+ instance.root.ce._removeChildStyle(oldComp);
713
+ }
714
+ }
715
+ }
716
+ queuePostFlushCb(() => {
717
+ hmrDirtyComponents.clear();
718
+ hmrDirtyComponentsMode.clear();
719
+ });
720
+ }
721
+ function updateComponentDef(oldComp, newComp) {
722
+ extend(oldComp, newComp);
723
+ for (const key in oldComp) {
724
+ if (key !== "__file" && !(key in newComp)) {
725
+ delete oldComp[key];
726
+ }
727
+ }
728
+ }
729
+ function tryWrap(fn) {
730
+ return (id, arg) => {
731
+ try {
732
+ return fn(id, arg);
733
+ } catch (e) {
734
+ console.error(e);
735
+ console.warn(
736
+ `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
737
+ );
738
+ }
739
+ };
740
+ }
741
+
430
742
  let devtools;
431
743
  let buffer = [];
432
744
  function setDevtoolsHook(hook, target) {
@@ -467,7 +779,7 @@ const isTeleport = (type) => type.__isTeleport;
467
779
 
468
780
  function setTransitionHooks(vnode, hooks) {
469
781
  if (vnode.shapeFlag & 6 && vnode.component) {
470
- if (vnode.type.__vapor) {
782
+ if (isVaporComponent(vnode.type)) {
471
783
  getVaporInterface(vnode.component, vnode).setTransitionHooks(
472
784
  vnode.component,
473
785
  hooks
@@ -484,7 +796,7 @@ function setTransitionHooks(vnode, hooks) {
484
796
  }
485
797
  }
486
798
 
487
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
799
+ const NULL_DYNAMIC_COMPONENT = /* @__PURE__ */ Symbol.for("v-ndc");
488
800
 
489
801
  const internalObjectProto = {};
490
802
  const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
@@ -503,12 +815,18 @@ app.use(vaporInteropPlugin)
503
815
  }
504
816
  return res;
505
817
  }
818
+ function isVaporComponent(type) {
819
+ if (!!(process.env.NODE_ENV !== "production") && isHmrUpdating && hmrDirtyComponentsMode.has(type)) {
820
+ return hmrDirtyComponentsMode.get(type);
821
+ }
822
+ return type.__vapor;
823
+ }
506
824
 
507
825
  const isSuspense = (type) => type.__isSuspense;
508
826
 
509
- const Fragment = Symbol.for("v-fgt");
510
- const Text = Symbol.for("v-txt");
511
- const Comment = Symbol.for("v-cmt");
827
+ const Fragment = /* @__PURE__ */ Symbol.for("v-fgt");
828
+ const Text = /* @__PURE__ */ Symbol.for("v-txt");
829
+ const Comment = /* @__PURE__ */ Symbol.for("v-cmt");
512
830
  function isVNode$2(value) {
513
831
  return value ? value.__v_isVNode === true : false;
514
832
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/server-renderer",
3
- "version": "3.6.0-alpha.6",
3
+ "version": "3.6.0-beta.1",
4
4
  "description": "@vue/server-renderer",
5
5
  "main": "index.js",
6
6
  "module": "dist/server-renderer.esm-bundler.js",
@@ -46,10 +46,10 @@
46
46
  },
47
47
  "homepage": "https://github.com/vuejs/core/tree/main/packages/server-renderer#readme",
48
48
  "peerDependencies": {
49
- "vue": "3.6.0-alpha.6"
49
+ "vue": "3.6.0-beta.1"
50
50
  },
51
51
  "dependencies": {
52
- "@vue/compiler-ssr": "3.6.0-alpha.6",
53
- "@vue/shared": "3.6.0-alpha.6"
52
+ "@vue/compiler-ssr": "3.6.0-beta.1",
53
+ "@vue/shared": "3.6.0-beta.1"
54
54
  }
55
55
  }