octane 0.2.6 → 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/README.md +5 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/runtime.cjs +773 -385
- package/dist/cjs/runtime.server.cjs +319 -76
- package/dist/cjs/version.cjs +1 -1
- package/dist/compiler/bundler.js +6 -6
- package/dist/compiler/compile-universal.js +1 -1
- package/dist/compiler/compile.js +407 -126
- package/dist/compiler/context-use.js +154 -0
- package/dist/compiler/hook-deps.js +17 -1
- package/dist/compiler/index.d.ts +1 -3
- package/dist/compiler/native-read-diagnostics.js +21 -34
- package/dist/compiler/slot-hooks.d.ts +0 -1
- package/dist/compiler/slot-hooks.js +9 -3
- package/dist/compiler/strong-mode.js +716 -39
- package/dist/compiler/text-type-facts.js +38 -24
- package/dist/compiler/typescript.d.ts +8 -1
- package/dist/compiler/typescript.js +48 -20
- package/dist/compiler/vite.d.ts +6 -2
- package/dist/compiler/vite.js +85 -5
- package/dist/compiler/volar.LICENSES.txt +1 -1
- package/dist/compiler/volar.d.ts +1 -1
- package/dist/compiler/volar.js +3498 -3484
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/runtime.d.ts +19 -5
- package/dist/runtime.js +770 -385
- package/dist/runtime.server.d.ts +7 -6
- package/dist/runtime.server.js +319 -76
- package/dist/signals/index.d.ts +1 -1
- package/dist/signals/types.d.ts +1 -1
- package/dist/universal-core.d.ts +15 -0
- package/dist/universal-core.js +575 -83
- 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
|
}
|
|
@@ -2392,7 +2585,8 @@ function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
|
|
|
2392
2585
|
occ: null,
|
|
2393
2586
|
path: null,
|
|
2394
2587
|
deferred: false,
|
|
2395
|
-
asyncScope: ASYNC_SCOPE
|
|
2588
|
+
asyncScope: ASYNC_SCOPE,
|
|
2589
|
+
namespace: explicitNamespace ?? void 0
|
|
2396
2590
|
} : {
|
|
2397
2591
|
parent: pf,
|
|
2398
2592
|
seg: nextChildSegment(pf),
|
|
@@ -2401,9 +2595,9 @@ function ssrComponent(parent, comp, props, inherit, key, identityScoped) {
|
|
|
2401
2595
|
occ: null,
|
|
2402
2596
|
path: null,
|
|
2403
2597
|
deferred: false,
|
|
2404
|
-
asyncScope: ASYNC_SCOPE
|
|
2598
|
+
asyncScope: ASYNC_SCOPE,
|
|
2599
|
+
namespace: explicitNamespace ?? pf.namespace
|
|
2405
2600
|
};
|
|
2406
|
-
frame.namespace = explicitNamespace ?? pf?.namespace;
|
|
2407
2601
|
return renderComponentFramed(comp, props, parent, frame, inherit);
|
|
2408
2602
|
} finally {
|
|
2409
2603
|
if (identityScoped !== true) ASYNC_SCOPE = previousIdentityScope;
|
|
@@ -2645,6 +2839,7 @@ function vtSsrAnnotate(html, attrs) {
|
|
|
2645
2839
|
return html.slice(0, insertion) + inject + html.slice(insertion);
|
|
2646
2840
|
}
|
|
2647
2841
|
function vtSsrClaimArm(html, kind) {
|
|
2842
|
+
if (!VT_SSR_HAS_CANDIDATES) return html;
|
|
2648
2843
|
const start = vtSsrFirstVisibleOpenTag(html);
|
|
2649
2844
|
if (start === -1) return html;
|
|
2650
2845
|
const end = vtSsrOpenTagEnd(html, start + 1);
|
|
@@ -3591,26 +3786,33 @@ function useFormStatus() {
|
|
|
3591
3786
|
function useOptimistic(state) {
|
|
3592
3787
|
return [state, NOOP];
|
|
3593
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
|
+
};
|
|
3594
3805
|
function memo(component) {
|
|
3595
3806
|
const memoWrapper = (props, scope, extra) => component(props, scope, extra);
|
|
3807
|
+
Object.defineProperty(memoWrapper, MEMO_OWNER, { value: memoWrapper });
|
|
3596
3808
|
Object.defineProperty(memoWrapper, "type", { value: component });
|
|
3597
3809
|
Object.defineProperty(memoWrapper, "displayName", {
|
|
3598
3810
|
configurable: true,
|
|
3599
3811
|
writable: true,
|
|
3600
3812
|
value: component.displayName || component.name || "Memo"
|
|
3601
3813
|
});
|
|
3602
|
-
Object.defineProperty(memoWrapper, "__memo",
|
|
3603
|
-
|
|
3604
|
-
return this === memoWrapper;
|
|
3605
|
-
}
|
|
3606
|
-
});
|
|
3607
|
-
Object.defineProperty(memoWrapper, "defaultProps", {
|
|
3608
|
-
configurable: true,
|
|
3609
|
-
get: () => component.defaultProps,
|
|
3610
|
-
set: (value) => {
|
|
3611
|
-
component.defaultProps = value;
|
|
3612
|
-
}
|
|
3613
|
-
});
|
|
3814
|
+
Object.defineProperty(memoWrapper, "__memo", MEMO_MARKER_DESCRIPTOR);
|
|
3815
|
+
Object.defineProperty(memoWrapper, "defaultProps", MEMO_DEFAULT_PROPS_DESCRIPTOR);
|
|
3614
3816
|
return memoWrapper;
|
|
3615
3817
|
}
|
|
3616
3818
|
function markWarm(component, plan) {
|
|
@@ -3782,15 +3984,15 @@ function namespaceHeadElement(headKey, tag, attrs, text, authoredKey) {
|
|
|
3782
3984
|
if (key !== void 0) config.key = key;
|
|
3783
3985
|
return createElement(namespaceHead, config);
|
|
3784
3986
|
}
|
|
3785
|
-
function spliceHead(body, head) {
|
|
3786
|
-
if (head === ""
|
|
3787
|
-
|
|
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));
|
|
3788
3991
|
if (headClose !== -1) return body.slice(0, headClose) + head + body.slice(headClose);
|
|
3789
|
-
if (
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
}
|
|
3992
|
+
if (!documentRoot) return head + body;
|
|
3993
|
+
const openingEnd = documentTagEnd(body, body.indexOf("<html") + 5);
|
|
3994
|
+
if (openingEnd !== -1)
|
|
3995
|
+
return body.slice(0, openingEnd) + "<head>" + head + "</head>" + body.slice(openingEnd);
|
|
3794
3996
|
if (head === "") return body;
|
|
3795
3997
|
return head + body;
|
|
3796
3998
|
}
|
|
@@ -4050,7 +4252,8 @@ function runFullFramedPass(component, props, resolved, nonceAttr = "", identifie
|
|
|
4050
4252
|
occ: null,
|
|
4051
4253
|
path: "",
|
|
4052
4254
|
deferred: false,
|
|
4053
|
-
asyncScope: ""
|
|
4255
|
+
asyncScope: "",
|
|
4256
|
+
namespace: void 0
|
|
4054
4257
|
};
|
|
4055
4258
|
CURRENT_COMP = component;
|
|
4056
4259
|
CURRENT_PROPS = props;
|
|
@@ -4156,7 +4359,8 @@ function runDiscoveryRound(jobs, resolved, identifierPrefix) {
|
|
|
4156
4359
|
occ: null,
|
|
4157
4360
|
path: null,
|
|
4158
4361
|
deferred: false,
|
|
4159
|
-
asyncScope: job.frame.asyncScope
|
|
4362
|
+
asyncScope: job.frame.asyncScope,
|
|
4363
|
+
namespace: void 0
|
|
4160
4364
|
};
|
|
4161
4365
|
try {
|
|
4162
4366
|
renderComponentFramed(job.comp, job.props, job.parentScope, frame);
|
|
@@ -5010,6 +5214,13 @@ function isDocumentRoot(body) {
|
|
|
5010
5214
|
const next = body.charCodeAt(i + 5);
|
|
5011
5215
|
return next === 62 || next === 32 || next === 9 || next === 10 || next === 13;
|
|
5012
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
|
+
}
|
|
5013
5224
|
function documentHeadInsertionPoint(body) {
|
|
5014
5225
|
let searchFrom = 0;
|
|
5015
5226
|
for (; ; ) {
|
|
@@ -5034,6 +5245,37 @@ function documentTagEnd(body, from) {
|
|
|
5034
5245
|
}
|
|
5035
5246
|
return -1;
|
|
5036
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
|
+
}
|
|
5037
5279
|
function segmentChunk(b, nonceAttr) {
|
|
5038
5280
|
let seedScript = "";
|
|
5039
5281
|
if (b.seeds.length > 0) {
|
|
@@ -5310,7 +5552,8 @@ async function runStream(component, props, options, sink, resolved) {
|
|
|
5310
5552
|
shell += spliceHead(pass.body, leadingStyles + shellHead);
|
|
5311
5553
|
}
|
|
5312
5554
|
} else {
|
|
5313
|
-
|
|
5555
|
+
const shellPrefix = leadingStyles + shellHead;
|
|
5556
|
+
shell += documentRoot ? spliceHead(pass.body, shellPrefix, true) : shellPrefix === "" ? pass.body : spliceHead(pass.body, shellPrefix, false);
|
|
5314
5557
|
}
|
|
5315
5558
|
if (pass.serial.length > 0) shell += serializeSuspenseSeeds(pass.serial, nonceAttr);
|
|
5316
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
|
package/dist/compiler/bundler.js
CHANGED
|
@@ -516,7 +516,6 @@ class OctaneBundlerCompiler {
|
|
|
516
516
|
profile: options.profile === true,
|
|
517
517
|
inlineHookMemo: options.inlineHookMemo !== false,
|
|
518
518
|
strong: options.strong === true,
|
|
519
|
-
nativeReads: options.nativeReads === true,
|
|
520
519
|
universalRuntime: normalizeUniversalRuntime(options.universalRuntime),
|
|
521
520
|
};
|
|
522
521
|
this.renderers = normalizeRendererConfig(options.renderers);
|
|
@@ -1086,7 +1085,6 @@ class OctaneBundlerCompiler {
|
|
|
1086
1085
|
// byte identical even when a shared client/server bundler configuration opts in.
|
|
1087
1086
|
const profile = environment === 'client' && (options.profile ?? this.defaults.profile) === true;
|
|
1088
1087
|
const inlineHookMemo = (options.inlineHookMemo ?? this.defaults.inlineHookMemo) !== false;
|
|
1089
|
-
const nativeReads = (options.nativeReads ?? this.defaults.nativeReads) === true;
|
|
1090
1088
|
// An application's global policy never leaks into installed or linked
|
|
1091
1089
|
// compatibility packages, including workspace packages nested inside the
|
|
1092
1090
|
// project root. Modules may still opt themselves in with their own
|
|
@@ -1186,11 +1184,13 @@ class OctaneBundlerCompiler {
|
|
|
1186
1184
|
hmr,
|
|
1187
1185
|
mode: environment,
|
|
1188
1186
|
dev,
|
|
1187
|
+
...(renderer.target === 'dom' && options.textTypeFacts !== undefined
|
|
1188
|
+
? { textTypeFacts: options.textTypeFacts }
|
|
1189
|
+
: null),
|
|
1189
1190
|
profile,
|
|
1190
1191
|
profileFilename,
|
|
1191
1192
|
...(inlineHookMemo ? null : { inlineHookMemo: false }),
|
|
1192
1193
|
...(strong ? { strong: true } : null),
|
|
1193
|
-
...(nativeReads ? { nativeReads: true } : null),
|
|
1194
1194
|
...(universalRuntime === undefined ? null : { universalRuntime }),
|
|
1195
1195
|
// Keep the established DOM compiler call byte-for-byte equivalent. A
|
|
1196
1196
|
// renderer descriptor is an orthogonal compiler input only for the
|
|
@@ -1280,9 +1280,9 @@ class OctaneBundlerCompiler {
|
|
|
1280
1280
|
const nativeHookImport = /from\s*['"]octane\/signals\/(?:client|server)['"]/.test(code);
|
|
1281
1281
|
const hasHookRuntimeImport =
|
|
1282
1282
|
/from\s*['"]octane['"]/.test(code) ||
|
|
1283
|
-
|
|
1283
|
+
/from\s*['"]octane\/server['"]/.test(code) ||
|
|
1284
1284
|
nativeHookImport ||
|
|
1285
|
-
|
|
1285
|
+
/from\s*['"]octane\/signals['"]/.test(code);
|
|
1286
1286
|
// Manual factories can import only other binding helpers, so their
|
|
1287
1287
|
// escaping hooks still need a provider boundary. Unrelated helpers keep
|
|
1288
1288
|
// their cheap pass-through without collecting unused manifest watches.
|
|
@@ -1332,7 +1332,7 @@ class OctaneBundlerCompiler {
|
|
|
1332
1332
|
inlineHookMemo: inlinePlainMemo,
|
|
1333
1333
|
...(manualSlots ? { manualSlots: true } : null),
|
|
1334
1334
|
...(strong ? { strong: true } : null),
|
|
1335
|
-
|
|
1335
|
+
renderer,
|
|
1336
1336
|
...(specializeVoidRoot
|
|
1337
1337
|
? {
|
|
1338
1338
|
isVoidComponentImport: options.isVoidComponentImport,
|
|
@@ -550,7 +550,7 @@ const RUNTIME_TYPESCRIPT_NODES = new Set([
|
|
|
550
550
|
'TSTypeAssertion',
|
|
551
551
|
]);
|
|
552
552
|
|
|
553
|
-
function forEachRuntimeAstChild(node, visit) {
|
|
553
|
+
export function forEachRuntimeAstChild(node, visit) {
|
|
554
554
|
if (
|
|
555
555
|
typeof node?.type === 'string' &&
|
|
556
556
|
node.type.startsWith('TS') &&
|