octane 0.2.7 → 0.2.8
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/cjs/index.cjs +2 -0
- package/dist/cjs/runtime.cjs +338 -111
- package/dist/cjs/runtime.server.cjs +307 -66
- package/dist/cjs/version.cjs +1 -1
- package/dist/compiler/compile.js +171 -13
- package/dist/compiler/context-use.js +154 -0
- package/dist/compiler/hook-deps.js +17 -1
- package/dist/compiler/native-read-diagnostics.js +11 -32
- package/dist/compiler/slot-hooks.js +6 -0
- package/dist/compiler/strong-mode.js +716 -39
- package/dist/compiler/volar.LICENSES.txt +1 -1
- package/dist/compiler/volar.js +3485 -3476
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/runtime.d.ts +8 -3
- package/dist/runtime.js +337 -111
- package/dist/runtime.server.d.ts +6 -5
- package/dist/runtime.server.js +307 -66
- package/dist/universal-core.d.ts +15 -0
- package/dist/universal-core.js +516 -32
- package/dist/version.js +1 -1
- package/package.json +3 -3
|
@@ -417,6 +417,120 @@ const PORTAL_TAG = /* @__PURE__ */ Symbol.for("octane.portal");
|
|
|
417
417
|
const Fragment = /* @__PURE__ */ Symbol.for("octane.Fragment");
|
|
418
418
|
const Activity = /* @__PURE__ */ Symbol.for("octane.Activity");
|
|
419
419
|
const SCOPED_ELEMENT_PROPS = /* @__PURE__ */ new WeakSet();
|
|
420
|
+
const SCOPED_CHILDREN_RESOLVER = /* @__PURE__ */ Symbol("octane.scopedChildrenResolver");
|
|
421
|
+
const SCOPED_VALUE_RESOLVER = /* @__PURE__ */ Symbol("octane.scopedValueResolver");
|
|
422
|
+
function getScopedChildren() {
|
|
423
|
+
return this[SCOPED_CHILDREN_RESOLVER]();
|
|
424
|
+
}
|
|
425
|
+
const SCOPED_CHILDREN_PROPERTY = { configurable: true, enumerable: true, get: getScopedChildren };
|
|
426
|
+
function setScopedChildrenResolver(target, resolve) {
|
|
427
|
+
Object.defineProperty(target, SCOPED_CHILDREN_RESOLVER, { value: resolve });
|
|
428
|
+
}
|
|
429
|
+
const SCOPED_VALUE_PROPERTIES = {
|
|
430
|
+
type: {
|
|
431
|
+
configurable: true,
|
|
432
|
+
enumerable: true,
|
|
433
|
+
get() {
|
|
434
|
+
return this[SCOPED_VALUE_RESOLVER]().type;
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
props: {
|
|
438
|
+
configurable: true,
|
|
439
|
+
enumerable: true,
|
|
440
|
+
get() {
|
|
441
|
+
return this[SCOPED_VALUE_RESOLVER]().props;
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
key: {
|
|
445
|
+
configurable: true,
|
|
446
|
+
enumerable: true,
|
|
447
|
+
get() {
|
|
448
|
+
return this[SCOPED_VALUE_RESOLVER]().key;
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
ref: {
|
|
452
|
+
configurable: true,
|
|
453
|
+
enumerable: true,
|
|
454
|
+
get() {
|
|
455
|
+
return this[SCOPED_VALUE_RESOLVER]().ref;
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
children: {
|
|
459
|
+
configurable: true,
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get() {
|
|
462
|
+
return this[SCOPED_VALUE_RESOLVER]().children;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
function restoreWritableScopedChildren(props, name, value) {
|
|
467
|
+
const inherited = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(props), name);
|
|
468
|
+
if (inherited?.get === void 0 && inherited?.set === void 0) return false;
|
|
469
|
+
Object.defineProperty(props, "children", {
|
|
470
|
+
configurable: true,
|
|
471
|
+
enumerable: true,
|
|
472
|
+
writable: true,
|
|
473
|
+
value
|
|
474
|
+
});
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
function copyScopedElementConfig(type, config) {
|
|
478
|
+
if (config != null && import_has_own.hasOwnProp.call(config, "__proto__") || import_has_own.hasOwnProp.call(Object.prototype, "children")) {
|
|
479
|
+
const props2 = copyElementConfig(config);
|
|
480
|
+
(0, import_shared_value_helpers.applyElementDefaultProps)(type, props2);
|
|
481
|
+
Object.defineProperty(props2, "children", SCOPED_CHILDREN_PROPERTY);
|
|
482
|
+
return props2;
|
|
483
|
+
}
|
|
484
|
+
const props = {};
|
|
485
|
+
let copiedChildren;
|
|
486
|
+
let hasChildren = false;
|
|
487
|
+
let childrenAreWritable = false;
|
|
488
|
+
if (config != null) {
|
|
489
|
+
for (const name in config) {
|
|
490
|
+
if (name === "key" || !import_has_own.hasOwnProp.call(config, name)) continue;
|
|
491
|
+
if (name === "children") {
|
|
492
|
+
copiedChildren = config[name];
|
|
493
|
+
Object.defineProperty(props, "children", SCOPED_CHILDREN_PROPERTY);
|
|
494
|
+
hasChildren = true;
|
|
495
|
+
} else {
|
|
496
|
+
const value = config[name];
|
|
497
|
+
if (hasChildren && !childrenAreWritable && !import_has_own.hasOwnProp.call(props, name) && restoreWritableScopedChildren(props, name, copiedChildren)) {
|
|
498
|
+
childrenAreWritable = true;
|
|
499
|
+
}
|
|
500
|
+
props[name] = value;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const defaults = type?.defaultProps;
|
|
505
|
+
if (defaults != null) {
|
|
506
|
+
for (const name in defaults) {
|
|
507
|
+
if (name === "children") {
|
|
508
|
+
if ((childrenAreWritable ? props.children : hasChildren ? copiedChildren : props.children) === void 0) {
|
|
509
|
+
const defaultChildren = defaults[name];
|
|
510
|
+
copiedChildren = defaultChildren;
|
|
511
|
+
if (childrenAreWritable) {
|
|
512
|
+
props.children = defaultChildren;
|
|
513
|
+
} else if (!hasChildren) {
|
|
514
|
+
if (Object.getPrototypeOf(props) !== Object.prototype || Object.getOwnPropertyDescriptor(Object.prototype, "children") !== void 0) {
|
|
515
|
+
props.children = defaultChildren;
|
|
516
|
+
} else {
|
|
517
|
+
Object.defineProperty(props, "children", SCOPED_CHILDREN_PROPERTY);
|
|
518
|
+
hasChildren = true;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
if (hasChildren && !childrenAreWritable && !import_has_own.hasOwnProp.call(props, name) && restoreWritableScopedChildren(props, name, copiedChildren)) {
|
|
524
|
+
childrenAreWritable = true;
|
|
525
|
+
}
|
|
526
|
+
if (props[name] === void 0) props[name] = defaults[name];
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (childrenAreWritable || !hasChildren)
|
|
531
|
+
Object.defineProperty(props, "children", SCOPED_CHILDREN_PROPERTY);
|
|
532
|
+
return props;
|
|
533
|
+
}
|
|
420
534
|
function hasElementConfigKey(config) {
|
|
421
535
|
if (config == null || typeof config !== "object" && typeof config !== "function") return false;
|
|
422
536
|
if (import_has_own.hasOwnProp.call(config, "key")) {
|
|
@@ -495,32 +609,20 @@ function nativeCreateScopedValue(readElement) {
|
|
|
495
609
|
return scopedValueDescriptor(createNativeServerScopedResolver(readElement));
|
|
496
610
|
}
|
|
497
611
|
function scopedValueDescriptor(resolve) {
|
|
498
|
-
const descriptor = {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
},
|
|
506
|
-
get key() {
|
|
507
|
-
return resolve().key;
|
|
508
|
-
},
|
|
509
|
-
get ref() {
|
|
510
|
-
return resolve().ref;
|
|
511
|
-
},
|
|
512
|
-
get children() {
|
|
513
|
-
return resolve().children;
|
|
514
|
-
}
|
|
515
|
-
};
|
|
612
|
+
const descriptor = { $$kind: ELEMENT_TAG };
|
|
613
|
+
Object.defineProperty(descriptor, SCOPED_VALUE_RESOLVER, { value: resolve });
|
|
614
|
+
Object.defineProperty(descriptor, "type", SCOPED_VALUE_PROPERTIES.type);
|
|
615
|
+
Object.defineProperty(descriptor, "props", SCOPED_VALUE_PROPERTIES.props);
|
|
616
|
+
Object.defineProperty(descriptor, "key", SCOPED_VALUE_PROPERTIES.key);
|
|
617
|
+
Object.defineProperty(descriptor, "ref", SCOPED_VALUE_PROPERTIES.ref);
|
|
618
|
+
Object.defineProperty(descriptor, "children", SCOPED_VALUE_PROPERTIES.children);
|
|
516
619
|
if (process.env.NODE_ENV !== "production") Object.freeze(descriptor);
|
|
517
620
|
return descriptor;
|
|
518
621
|
}
|
|
519
622
|
function createScopedElement(type, props, readChildren) {
|
|
520
623
|
const src = props ?? null;
|
|
521
624
|
const key = hasElementConfigKey(src) ? "" + src.key : null;
|
|
522
|
-
const copiedProps =
|
|
523
|
-
(0, import_shared_value_helpers.applyElementDefaultProps)(type, copiedProps);
|
|
625
|
+
const copiedProps = copyScopedElementConfig(type, src);
|
|
524
626
|
let resolved = false;
|
|
525
627
|
let resolvedScope = null;
|
|
526
628
|
let resolvedChildren;
|
|
@@ -539,8 +641,7 @@ function createScopedElement(type, props, readChildren) {
|
|
|
539
641
|
function nativeCreateScopedElement(type, props, readChildren) {
|
|
540
642
|
const src = props ?? null;
|
|
541
643
|
const key = hasElementConfigKey(src) ? "" + src.key : null;
|
|
542
|
-
const copiedProps =
|
|
543
|
-
(0, import_shared_value_helpers.applyElementDefaultProps)(type, copiedProps);
|
|
644
|
+
const copiedProps = copyScopedElementConfig(type, src);
|
|
544
645
|
return scopedElementDescriptor(
|
|
545
646
|
type,
|
|
546
647
|
copiedProps,
|
|
@@ -549,18 +650,17 @@ function nativeCreateScopedElement(type, props, readChildren) {
|
|
|
549
650
|
);
|
|
550
651
|
}
|
|
551
652
|
function scopedElementDescriptor(type, copiedProps, key, children) {
|
|
552
|
-
|
|
553
|
-
Object.defineProperty(copiedProps, "children", childProperty);
|
|
653
|
+
setScopedChildrenResolver(copiedProps, children);
|
|
554
654
|
SCOPED_ELEMENT_PROPS.add(copiedProps);
|
|
555
655
|
const descriptor = {
|
|
556
656
|
$$kind: ELEMENT_TAG,
|
|
557
657
|
type,
|
|
558
658
|
props: copiedProps,
|
|
559
659
|
key,
|
|
560
|
-
ref: copiedProps.ref !== void 0 ? copiedProps.ref : null
|
|
561
|
-
children: null
|
|
660
|
+
ref: copiedProps.ref !== void 0 ? copiedProps.ref : null
|
|
562
661
|
};
|
|
563
|
-
Object.defineProperty(descriptor, "children",
|
|
662
|
+
Object.defineProperty(descriptor, "children", SCOPED_CHILDREN_PROPERTY);
|
|
663
|
+
setScopedChildrenResolver(descriptor, children);
|
|
564
664
|
return finalizeElementDescriptor(descriptor);
|
|
565
665
|
}
|
|
566
666
|
function createElement(type, props, ...children) {
|
|
@@ -624,16 +724,50 @@ function ssrDeoptKey(item, index) {
|
|
|
624
724
|
}
|
|
625
725
|
function scopedSsrDeoptKey(path, item, index, key) {
|
|
626
726
|
const explicit = isElementDescriptor(item) && item.key != null;
|
|
727
|
+
if (path.length === 0 && !explicit) return index;
|
|
627
728
|
return JSON.stringify([path, explicit ? "key" : "index", explicit ? String(key) : index]);
|
|
628
729
|
}
|
|
730
|
+
const SSR_DEOPT_KEY_STRINGIFY = JSON.stringify;
|
|
731
|
+
function nestedImplicitSsrKeyPrefix(path) {
|
|
732
|
+
if (JSON.stringify !== SSR_DEOPT_KEY_STRINGIFY || "toJSON" in path) return null;
|
|
733
|
+
for (let i = 0; i < path.length; i++) {
|
|
734
|
+
const type = typeof path[i];
|
|
735
|
+
if (type !== "string" && type !== "number") return null;
|
|
736
|
+
}
|
|
737
|
+
return "[" + JSON.stringify(path) + ',"index",';
|
|
738
|
+
}
|
|
739
|
+
function appendNestedSsrDeoptKey(outKeys, path, item, index, key, implicitPrefix) {
|
|
740
|
+
const explicit = isElementDescriptor(item) && item.key != null;
|
|
741
|
+
if (!explicit) {
|
|
742
|
+
if (implicitPrefix === void 0) implicitPrefix = nestedImplicitSsrKeyPrefix(path);
|
|
743
|
+
if (implicitPrefix !== null && JSON.stringify === SSR_DEOPT_KEY_STRINGIFY && !("toJSON" in path)) {
|
|
744
|
+
outKeys.push(implicitPrefix + index + "]");
|
|
745
|
+
return implicitPrefix;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
outKeys.push(JSON.stringify([path, explicit ? "key" : "index", explicit ? String(key) : index]));
|
|
749
|
+
return implicitPrefix;
|
|
750
|
+
}
|
|
629
751
|
function flattenSsrChildContainer(outItems, outKeys, children, kind, path) {
|
|
630
752
|
const count = children.length;
|
|
753
|
+
let implicitPrefix;
|
|
631
754
|
for (let i = 0; i < count; i++) {
|
|
632
755
|
const item = children[i];
|
|
633
756
|
if (isFragmentDescriptor(item)) {
|
|
634
757
|
if (item.ref != null || import_has_own.hasOwnProp.call(item.props, "ref")) {
|
|
635
758
|
outItems.push(fragmentRefDescriptor(item));
|
|
636
|
-
|
|
759
|
+
if (path.length === 0 || count === 1) {
|
|
760
|
+
outKeys.push(scopedSsrDeoptKey(path, item, i, ssrDeoptKey(item, i)));
|
|
761
|
+
} else {
|
|
762
|
+
implicitPrefix = appendNestedSsrDeoptKey(
|
|
763
|
+
outKeys,
|
|
764
|
+
path,
|
|
765
|
+
item,
|
|
766
|
+
i,
|
|
767
|
+
ssrDeoptKey(item, i),
|
|
768
|
+
implicitPrefix
|
|
769
|
+
);
|
|
770
|
+
}
|
|
637
771
|
continue;
|
|
638
772
|
}
|
|
639
773
|
const nested = fragmentDescriptorChildren(item);
|
|
@@ -656,7 +790,18 @@ function flattenSsrChildContainer(outItems, outKeys, children, kind, path) {
|
|
|
656
790
|
continue;
|
|
657
791
|
}
|
|
658
792
|
outItems.push(item);
|
|
659
|
-
|
|
793
|
+
if (path.length === 0 || count === 1) {
|
|
794
|
+
outKeys.push(scopedSsrDeoptKey(path, item, i, ssrDeoptKey(item, i)));
|
|
795
|
+
} else {
|
|
796
|
+
implicitPrefix = appendNestedSsrDeoptKey(
|
|
797
|
+
outKeys,
|
|
798
|
+
path,
|
|
799
|
+
item,
|
|
800
|
+
i,
|
|
801
|
+
ssrDeoptKey(item, i),
|
|
802
|
+
implicitPrefix
|
|
803
|
+
);
|
|
804
|
+
}
|
|
660
805
|
}
|
|
661
806
|
}
|
|
662
807
|
function prepareSsrDeoptList(value, includeKeyedSingle) {
|
|
@@ -692,9 +837,16 @@ function cloneElement(element, config, ...children) {
|
|
|
692
837
|
throw new Error((0, import_error_codes_server_generated.formatServerError)(4));
|
|
693
838
|
}
|
|
694
839
|
let scopedChildren;
|
|
840
|
+
let scopedResolver;
|
|
695
841
|
let props;
|
|
696
842
|
if (SCOPED_ELEMENT_PROPS.has(element.props)) {
|
|
697
843
|
scopedChildren = Object.getOwnPropertyDescriptor(element, "children").get;
|
|
844
|
+
if (scopedChildren === getScopedChildren) {
|
|
845
|
+
scopedResolver = element[SCOPED_CHILDREN_RESOLVER];
|
|
846
|
+
} else if (scopedChildren === SCOPED_VALUE_PROPERTIES.children.get) {
|
|
847
|
+
const get = scopedChildren;
|
|
848
|
+
scopedChildren = () => get.call(element);
|
|
849
|
+
}
|
|
698
850
|
props = {};
|
|
699
851
|
for (const name in element.props) {
|
|
700
852
|
if (name !== "key" && name !== "children" && import_has_own.hasOwnProp.call(element.props, name)) {
|
|
@@ -719,44 +871,85 @@ function cloneElement(element, config, ...children) {
|
|
|
719
871
|
}
|
|
720
872
|
const n = children.length;
|
|
721
873
|
let kids;
|
|
722
|
-
let
|
|
874
|
+
let preserveScopedChildren = false;
|
|
723
875
|
if (n === 1) {
|
|
724
876
|
kids = children[0];
|
|
725
877
|
} else if (n > 1) {
|
|
726
878
|
kids = children;
|
|
727
879
|
} else if (scopedChildren !== void 0 && !replacedChildren) {
|
|
728
|
-
|
|
729
|
-
|
|
880
|
+
Object.defineProperty(
|
|
881
|
+
props,
|
|
882
|
+
"children",
|
|
883
|
+
scopedResolver === void 0 ? { configurable: true, enumerable: true, get: scopedChildren } : SCOPED_CHILDREN_PROPERTY
|
|
884
|
+
);
|
|
885
|
+
if (scopedResolver !== void 0) setScopedChildrenResolver(props, scopedResolver);
|
|
730
886
|
SCOPED_ELEMENT_PROPS.add(props);
|
|
887
|
+
preserveScopedChildren = true;
|
|
731
888
|
kids = null;
|
|
732
889
|
} else {
|
|
733
890
|
kids = "children" in props ? props.children : element.children;
|
|
734
891
|
}
|
|
735
892
|
if (n > 0) props.children = kids;
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
893
|
+
let descriptor;
|
|
894
|
+
if (preserveScopedChildren) {
|
|
895
|
+
descriptor = {
|
|
896
|
+
$$kind: ELEMENT_TAG,
|
|
897
|
+
type: element.type,
|
|
898
|
+
props,
|
|
899
|
+
key,
|
|
900
|
+
ref: props.ref !== void 0 ? props.ref : null
|
|
901
|
+
};
|
|
902
|
+
Object.defineProperty(
|
|
903
|
+
descriptor,
|
|
904
|
+
"children",
|
|
905
|
+
scopedResolver === void 0 ? { configurable: true, enumerable: true, get: scopedChildren } : SCOPED_CHILDREN_PROPERTY
|
|
906
|
+
);
|
|
907
|
+
if (scopedResolver !== void 0) setScopedChildrenResolver(descriptor, scopedResolver);
|
|
908
|
+
} else {
|
|
909
|
+
descriptor = {
|
|
910
|
+
$$kind: ELEMENT_TAG,
|
|
911
|
+
type: element.type,
|
|
912
|
+
props,
|
|
913
|
+
key,
|
|
914
|
+
ref: props.ref !== void 0 ? props.ref : null,
|
|
915
|
+
children: kids ?? null
|
|
916
|
+
};
|
|
917
|
+
}
|
|
745
918
|
return finalizeElementDescriptor(descriptor);
|
|
746
919
|
}
|
|
747
920
|
function cloneAndReplaceElementKey(element, key) {
|
|
748
921
|
const scopedChildren = SCOPED_ELEMENT_PROPS.has(element.props);
|
|
749
|
-
|
|
750
|
-
$$kind: ELEMENT_TAG,
|
|
751
|
-
type: element.type,
|
|
752
|
-
props: element.props,
|
|
753
|
-
key,
|
|
754
|
-
ref: element.ref,
|
|
755
|
-
children: scopedChildren ? null : element.children
|
|
756
|
-
};
|
|
922
|
+
let descriptor;
|
|
757
923
|
if (scopedChildren) {
|
|
758
924
|
const get = Object.getOwnPropertyDescriptor(element, "children").get;
|
|
759
|
-
|
|
925
|
+
const copiedGetter = get === SCOPED_VALUE_PROPERTIES.children.get ? () => get.call(element) : get;
|
|
926
|
+
descriptor = {
|
|
927
|
+
$$kind: ELEMENT_TAG,
|
|
928
|
+
type: element.type,
|
|
929
|
+
props: element.props,
|
|
930
|
+
key,
|
|
931
|
+
ref: element.ref
|
|
932
|
+
};
|
|
933
|
+
Object.defineProperty(
|
|
934
|
+
descriptor,
|
|
935
|
+
"children",
|
|
936
|
+
get === getScopedChildren ? SCOPED_CHILDREN_PROPERTY : { configurable: true, enumerable: true, get: copiedGetter }
|
|
937
|
+
);
|
|
938
|
+
if (get === getScopedChildren) {
|
|
939
|
+
setScopedChildrenResolver(
|
|
940
|
+
descriptor,
|
|
941
|
+
element[SCOPED_CHILDREN_RESOLVER]
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
} else {
|
|
945
|
+
descriptor = {
|
|
946
|
+
$$kind: ELEMENT_TAG,
|
|
947
|
+
type: element.type,
|
|
948
|
+
props: element.props,
|
|
949
|
+
key,
|
|
950
|
+
ref: element.ref,
|
|
951
|
+
children: element.children
|
|
952
|
+
};
|
|
760
953
|
}
|
|
761
954
|
return finalizeElementDescriptor(descriptor);
|
|
762
955
|
}
|
|
@@ -3593,26 +3786,33 @@ function useFormStatus() {
|
|
|
3593
3786
|
function useOptimistic(state) {
|
|
3594
3787
|
return [state, NOOP];
|
|
3595
3788
|
}
|
|
3789
|
+
const MEMO_OWNER = /* @__PURE__ */ Symbol("memoOwner");
|
|
3790
|
+
const MEMO_MARKER_DESCRIPTOR = {
|
|
3791
|
+
get() {
|
|
3792
|
+
return this === this[MEMO_OWNER];
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
const MEMO_DEFAULT_PROPS_DESCRIPTOR = {
|
|
3796
|
+
configurable: true,
|
|
3797
|
+
// Static hoisters must copy `type` along with this accessor.
|
|
3798
|
+
get() {
|
|
3799
|
+
return this.type.defaultProps;
|
|
3800
|
+
},
|
|
3801
|
+
set(value) {
|
|
3802
|
+
this.type.defaultProps = value;
|
|
3803
|
+
}
|
|
3804
|
+
};
|
|
3596
3805
|
function memo(component) {
|
|
3597
3806
|
const memoWrapper = (props, scope, extra) => component(props, scope, extra);
|
|
3807
|
+
Object.defineProperty(memoWrapper, MEMO_OWNER, { value: memoWrapper });
|
|
3598
3808
|
Object.defineProperty(memoWrapper, "type", { value: component });
|
|
3599
3809
|
Object.defineProperty(memoWrapper, "displayName", {
|
|
3600
3810
|
configurable: true,
|
|
3601
3811
|
writable: true,
|
|
3602
3812
|
value: component.displayName || component.name || "Memo"
|
|
3603
3813
|
});
|
|
3604
|
-
Object.defineProperty(memoWrapper, "__memo",
|
|
3605
|
-
|
|
3606
|
-
return this === memoWrapper;
|
|
3607
|
-
}
|
|
3608
|
-
});
|
|
3609
|
-
Object.defineProperty(memoWrapper, "defaultProps", {
|
|
3610
|
-
configurable: true,
|
|
3611
|
-
get: () => component.defaultProps,
|
|
3612
|
-
set: (value) => {
|
|
3613
|
-
component.defaultProps = value;
|
|
3614
|
-
}
|
|
3615
|
-
});
|
|
3814
|
+
Object.defineProperty(memoWrapper, "__memo", MEMO_MARKER_DESCRIPTOR);
|
|
3815
|
+
Object.defineProperty(memoWrapper, "defaultProps", MEMO_DEFAULT_PROPS_DESCRIPTOR);
|
|
3616
3816
|
return memoWrapper;
|
|
3617
3817
|
}
|
|
3618
3818
|
function markWarm(component, plan) {
|
|
@@ -3784,10 +3984,12 @@ function namespaceHeadElement(headKey, tag, attrs, text, authoredKey) {
|
|
|
3784
3984
|
if (key !== void 0) config.key = key;
|
|
3785
3985
|
return createElement(namespaceHead, config);
|
|
3786
3986
|
}
|
|
3787
|
-
function spliceHead(body, head) {
|
|
3788
|
-
if (!
|
|
3789
|
-
|
|
3987
|
+
function spliceHead(body, head, documentRoot = isDocumentRoot(body)) {
|
|
3988
|
+
if (!documentRoot && (head === "" || !isLeadingHeadRoot(body)))
|
|
3989
|
+
return head === "" ? body : head + body;
|
|
3990
|
+
const headClose = documentRoot ? body.indexOf("</head>") : findFragmentHeadClose(body, documentHeadInsertionPoint(body));
|
|
3790
3991
|
if (headClose !== -1) return body.slice(0, headClose) + head + body.slice(headClose);
|
|
3992
|
+
if (!documentRoot) return head + body;
|
|
3791
3993
|
const openingEnd = documentTagEnd(body, body.indexOf("<html") + 5);
|
|
3792
3994
|
if (openingEnd !== -1)
|
|
3793
3995
|
return body.slice(0, openingEnd) + "<head>" + head + "</head>" + body.slice(openingEnd);
|
|
@@ -5012,6 +5214,13 @@ function isDocumentRoot(body) {
|
|
|
5012
5214
|
const next = body.charCodeAt(i + 5);
|
|
5013
5215
|
return next === 62 || next === 32 || next === 9 || next === 10 || next === 13;
|
|
5014
5216
|
}
|
|
5217
|
+
function isLeadingHeadRoot(body) {
|
|
5218
|
+
let i = 0;
|
|
5219
|
+
while (body.startsWith("<!--[-->", i)) i += 8;
|
|
5220
|
+
if (!body.startsWith("<head", i)) return false;
|
|
5221
|
+
const next = body.charCodeAt(i + 5);
|
|
5222
|
+
return next === 62 || next === 32 || next === 9 || next === 10 || next === 13;
|
|
5223
|
+
}
|
|
5015
5224
|
function documentHeadInsertionPoint(body) {
|
|
5016
5225
|
let searchFrom = 0;
|
|
5017
5226
|
for (; ; ) {
|
|
@@ -5036,6 +5245,37 @@ function documentTagEnd(body, from) {
|
|
|
5036
5245
|
}
|
|
5037
5246
|
return -1;
|
|
5038
5247
|
}
|
|
5248
|
+
function findFragmentHeadClose(body, from) {
|
|
5249
|
+
while (from !== -1) {
|
|
5250
|
+
const start = body.indexOf("<", from);
|
|
5251
|
+
if (start === -1) return -1;
|
|
5252
|
+
if (body.startsWith("<!--", start)) {
|
|
5253
|
+
const end2 = body.indexOf("-->", start + 4);
|
|
5254
|
+
if (end2 === -1) return -1;
|
|
5255
|
+
from = end2 + 3;
|
|
5256
|
+
continue;
|
|
5257
|
+
}
|
|
5258
|
+
if (body.startsWith("</head>", start)) return start;
|
|
5259
|
+
const end = documentTagEnd(body, start + 1);
|
|
5260
|
+
if (end === -1) return -1;
|
|
5261
|
+
let rawClose = null;
|
|
5262
|
+
if (body.startsWith("<script", start)) {
|
|
5263
|
+
const next = body.charCodeAt(start + 7);
|
|
5264
|
+
if (next === 62 || next === 32 || next === 9 || next === 10 || next === 13)
|
|
5265
|
+
rawClose = "</script>";
|
|
5266
|
+
} else if (body.startsWith("<style", start)) {
|
|
5267
|
+
const next = body.charCodeAt(start + 6);
|
|
5268
|
+
if (next === 62 || next === 32 || next === 9 || next === 10 || next === 13)
|
|
5269
|
+
rawClose = "</style>";
|
|
5270
|
+
}
|
|
5271
|
+
if (rawClose !== null) {
|
|
5272
|
+
const rawEnd = body.indexOf(rawClose, end);
|
|
5273
|
+
if (rawEnd === -1) return -1;
|
|
5274
|
+
from = rawEnd + rawClose.length;
|
|
5275
|
+
} else from = end;
|
|
5276
|
+
}
|
|
5277
|
+
return -1;
|
|
5278
|
+
}
|
|
5039
5279
|
function segmentChunk(b, nonceAttr) {
|
|
5040
5280
|
let seedScript = "";
|
|
5041
5281
|
if (b.seeds.length > 0) {
|
|
@@ -5312,7 +5552,8 @@ async function runStream(component, props, options, sink, resolved) {
|
|
|
5312
5552
|
shell += spliceHead(pass.body, leadingStyles + shellHead);
|
|
5313
5553
|
}
|
|
5314
5554
|
} else {
|
|
5315
|
-
|
|
5555
|
+
const shellPrefix = leadingStyles + shellHead;
|
|
5556
|
+
shell += documentRoot ? spliceHead(pass.body, shellPrefix, true) : shellPrefix === "" ? pass.body : spliceHead(pass.body, shellPrefix, false);
|
|
5316
5557
|
}
|
|
5317
5558
|
if (pass.serial.length > 0) shell += serializeSuspenseSeeds(pass.serial, nonceAttr);
|
|
5318
5559
|
if (pass.signals !== void 0) shell += serializeNativeSignalSeeds(pass.signals, nonceAttr);
|
package/dist/cjs/version.cjs
CHANGED
|
@@ -21,7 +21,7 @@ __export(version_exports, {
|
|
|
21
21
|
version: () => version
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const version = "0.2.
|
|
24
|
+
const version = "0.2.8";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
version
|