@biggive/components 0.0.17 → 0.0.21
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/biggive/biggive.esm.js +1 -1
- package/dist/biggive/p-89e49cb6.js +2 -0
- package/dist/biggive/{p-59970be1.entry.js → p-e330fae6.entry.js} +2 -2
- package/dist/cjs/biggive-campaign-card_3.cjs.entry.js +2 -2
- package/dist/cjs/biggive.cjs.js +2 -2
- package/dist/cjs/{index-8692cc53.js → index-a275852e.js} +243 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/biggive-campaign-card/biggive-campaign-card.css +2 -0
- package/dist/collection/components/biggive-campaign-card/biggive-campaign-card.js +0 -3
- package/dist/collection/components/demo-campaign-cards/demo-campaign-cards.stories.js +5 -0
- package/dist/components/biggive-campaign-card2.js +1 -1
- package/dist/esm/biggive-campaign-card_3.entry.js +2 -2
- package/dist/esm/biggive.js +2 -2
- package/dist/esm/{index-4c3bc0b8.js → index-2280c7b8.js} +243 -2
- package/dist/esm/loader.js +2 -2
- package/dist/types/components/biggive-campaign-card/biggive-campaign-card.d.ts +0 -3
- package/dist/types/components/demo-campaign-cards/demo-campaign-cards.stories.d.ts +5 -0
- package/hydrate/index.d.ts +217 -0
- package/hydrate/index.js +6898 -0
- package/hydrate/package.json +6 -0
- package/package.json +16 -3
- package/readme.md +45 -2
- package/dist/biggive/p-ce3d5ebc.js +0 -2
|
@@ -15,6 +15,7 @@ const plt = {
|
|
|
15
15
|
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
16
16
|
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
17
17
|
};
|
|
18
|
+
const supportsShadow = true;
|
|
18
19
|
const promiseResolve = (v) => Promise.resolve(v);
|
|
19
20
|
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
20
21
|
try {
|
|
@@ -25,6 +26,13 @@ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
|
25
26
|
return false;
|
|
26
27
|
})()
|
|
27
28
|
;
|
|
29
|
+
const CONTENT_REF_ID = 'r';
|
|
30
|
+
const ORG_LOCATION_ID = 'o';
|
|
31
|
+
const SLOT_NODE_ID = 's';
|
|
32
|
+
const TEXT_NODE_ID = 't';
|
|
33
|
+
const HYDRATE_ID = 's-id';
|
|
34
|
+
const HYDRATED_STYLE_ID = 'sty-id';
|
|
35
|
+
const HYDRATE_CHILD_ID = 'c-id';
|
|
28
36
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
29
37
|
const createTime = (fnName, tagName = '') => {
|
|
30
38
|
{
|
|
@@ -72,7 +80,12 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
72
80
|
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
73
81
|
}
|
|
74
82
|
if (!appliedStyles.has(scopeId)) {
|
|
75
|
-
|
|
83
|
+
if (styleContainerNode.host &&
|
|
84
|
+
(styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
|
|
85
|
+
// This is only happening on native shadow-dom, do not needs CSS var shim
|
|
86
|
+
styleElm.innerHTML = style;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
76
89
|
{
|
|
77
90
|
styleElm = doc.createElement('style');
|
|
78
91
|
styleElm.innerHTML = style;
|
|
@@ -110,6 +123,7 @@ const attachStyles = (hostRef) => {
|
|
|
110
123
|
endAttachStyles();
|
|
111
124
|
};
|
|
112
125
|
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
126
|
+
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
|
|
113
127
|
/**
|
|
114
128
|
* Default style mode id
|
|
115
129
|
*/
|
|
@@ -675,6 +689,207 @@ const then = (promise, thenFn) => {
|
|
|
675
689
|
};
|
|
676
690
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
677
691
|
;
|
|
692
|
+
const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
693
|
+
const endHydrate = createTime('hydrateClient', tagName);
|
|
694
|
+
const shadowRoot = hostElm.shadowRoot;
|
|
695
|
+
const childRenderNodes = [];
|
|
696
|
+
const slotNodes = [];
|
|
697
|
+
const shadowRootNodes = shadowRoot ? [] : null;
|
|
698
|
+
const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
|
699
|
+
if (!plt.$orgLocNodes$) {
|
|
700
|
+
initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
|
701
|
+
}
|
|
702
|
+
hostElm[HYDRATE_ID] = hostId;
|
|
703
|
+
hostElm.removeAttribute(HYDRATE_ID);
|
|
704
|
+
clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
|
705
|
+
childRenderNodes.map((c) => {
|
|
706
|
+
const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
|
707
|
+
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
708
|
+
const node = c.$elm$;
|
|
709
|
+
if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
|
710
|
+
orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
|
711
|
+
}
|
|
712
|
+
if (!shadowRoot) {
|
|
713
|
+
node['s-hn'] = tagName;
|
|
714
|
+
if (orgLocationNode) {
|
|
715
|
+
node['s-ol'] = orgLocationNode;
|
|
716
|
+
node['s-ol']['s-nr'] = node;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
plt.$orgLocNodes$.delete(orgLocationId);
|
|
720
|
+
});
|
|
721
|
+
if (shadowRoot) {
|
|
722
|
+
shadowRootNodes.map((shadowRootNode) => {
|
|
723
|
+
if (shadowRootNode) {
|
|
724
|
+
shadowRoot.appendChild(shadowRootNode);
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
endHydrate();
|
|
729
|
+
};
|
|
730
|
+
const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
|
|
731
|
+
let childNodeType;
|
|
732
|
+
let childIdSplt;
|
|
733
|
+
let childVNode;
|
|
734
|
+
let i;
|
|
735
|
+
if (node.nodeType === 1 /* ElementNode */) {
|
|
736
|
+
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
737
|
+
if (childNodeType) {
|
|
738
|
+
// got the node data from the element's attribute
|
|
739
|
+
// `${hostId}.${nodeId}.${depth}.${index}`
|
|
740
|
+
childIdSplt = childNodeType.split('.');
|
|
741
|
+
if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
|
742
|
+
childVNode = {
|
|
743
|
+
$flags$: 0,
|
|
744
|
+
$hostId$: childIdSplt[0],
|
|
745
|
+
$nodeId$: childIdSplt[1],
|
|
746
|
+
$depth$: childIdSplt[2],
|
|
747
|
+
$index$: childIdSplt[3],
|
|
748
|
+
$tag$: node.tagName.toLowerCase(),
|
|
749
|
+
$elm$: node,
|
|
750
|
+
$attrs$: null,
|
|
751
|
+
$children$: null,
|
|
752
|
+
$key$: null,
|
|
753
|
+
$name$: null,
|
|
754
|
+
$text$: null,
|
|
755
|
+
};
|
|
756
|
+
childRenderNodes.push(childVNode);
|
|
757
|
+
node.removeAttribute(HYDRATE_CHILD_ID);
|
|
758
|
+
// this is a new child vnode
|
|
759
|
+
// so ensure its parent vnode has the vchildren array
|
|
760
|
+
if (!parentVNode.$children$) {
|
|
761
|
+
parentVNode.$children$ = [];
|
|
762
|
+
}
|
|
763
|
+
// add our child vnode to a specific index of the vnode's children
|
|
764
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
765
|
+
// this is now the new parent vnode for all the next child checks
|
|
766
|
+
parentVNode = childVNode;
|
|
767
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
768
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
// recursively drill down, end to start so we can remove nodes
|
|
773
|
+
for (i = node.childNodes.length - 1; i >= 0; i--) {
|
|
774
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
|
775
|
+
}
|
|
776
|
+
if (node.shadowRoot) {
|
|
777
|
+
// keep drilling down through the shadow root nodes
|
|
778
|
+
for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
|
779
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
else if (node.nodeType === 8 /* CommentNode */) {
|
|
784
|
+
// `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
|
|
785
|
+
childIdSplt = node.nodeValue.split('.');
|
|
786
|
+
if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
|
|
787
|
+
// comment node for either the host id or a 0 host id
|
|
788
|
+
childNodeType = childIdSplt[0];
|
|
789
|
+
childVNode = {
|
|
790
|
+
$flags$: 0,
|
|
791
|
+
$hostId$: childIdSplt[1],
|
|
792
|
+
$nodeId$: childIdSplt[2],
|
|
793
|
+
$depth$: childIdSplt[3],
|
|
794
|
+
$index$: childIdSplt[4],
|
|
795
|
+
$elm$: node,
|
|
796
|
+
$attrs$: null,
|
|
797
|
+
$children$: null,
|
|
798
|
+
$key$: null,
|
|
799
|
+
$name$: null,
|
|
800
|
+
$tag$: null,
|
|
801
|
+
$text$: null,
|
|
802
|
+
};
|
|
803
|
+
if (childNodeType === TEXT_NODE_ID) {
|
|
804
|
+
childVNode.$elm$ = node.nextSibling;
|
|
805
|
+
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
|
|
806
|
+
childVNode.$text$ = childVNode.$elm$.textContent;
|
|
807
|
+
childRenderNodes.push(childVNode);
|
|
808
|
+
// remove the text comment since it's no longer needed
|
|
809
|
+
node.remove();
|
|
810
|
+
if (!parentVNode.$children$) {
|
|
811
|
+
parentVNode.$children$ = [];
|
|
812
|
+
}
|
|
813
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
814
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
815
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
else if (childVNode.$hostId$ === hostId) {
|
|
820
|
+
// this comment node is specifcally for this host id
|
|
821
|
+
if (childNodeType === SLOT_NODE_ID) {
|
|
822
|
+
// `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
|
|
823
|
+
childVNode.$tag$ = 'slot';
|
|
824
|
+
if (childIdSplt[5]) {
|
|
825
|
+
node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
node['s-sn'] = '';
|
|
829
|
+
}
|
|
830
|
+
node['s-sr'] = true;
|
|
831
|
+
if (shadowRootNodes) {
|
|
832
|
+
// browser support shadowRoot and this is a shadow dom component
|
|
833
|
+
// create an actual slot element
|
|
834
|
+
childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
|
835
|
+
if (childVNode.$name$) {
|
|
836
|
+
// add the slot name attribute
|
|
837
|
+
childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
|
838
|
+
}
|
|
839
|
+
// insert the new slot element before the slot comment
|
|
840
|
+
node.parentNode.insertBefore(childVNode.$elm$, node);
|
|
841
|
+
// remove the slot comment since it's not needed for shadow
|
|
842
|
+
node.remove();
|
|
843
|
+
if (childVNode.$depth$ === '0') {
|
|
844
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
slotNodes.push(childVNode);
|
|
848
|
+
if (!parentVNode.$children$) {
|
|
849
|
+
parentVNode.$children$ = [];
|
|
850
|
+
}
|
|
851
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
852
|
+
}
|
|
853
|
+
else if (childNodeType === CONTENT_REF_ID) {
|
|
854
|
+
// `${CONTENT_REF_ID}.${hostId}`;
|
|
855
|
+
if (shadowRootNodes) {
|
|
856
|
+
// remove the content ref comment since it's not needed for shadow
|
|
857
|
+
node.remove();
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
else if (parentVNode && parentVNode.$tag$ === 'style') {
|
|
864
|
+
const vnode = newVNode(null, node.textContent);
|
|
865
|
+
vnode.$elm$ = node;
|
|
866
|
+
vnode.$index$ = '0';
|
|
867
|
+
parentVNode.$children$ = [vnode];
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
871
|
+
if (node.nodeType === 1 /* ElementNode */) {
|
|
872
|
+
let i = 0;
|
|
873
|
+
for (; i < node.childNodes.length; i++) {
|
|
874
|
+
initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
|
|
875
|
+
}
|
|
876
|
+
if (node.shadowRoot) {
|
|
877
|
+
for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
|
|
878
|
+
initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
else if (node.nodeType === 8 /* CommentNode */) {
|
|
883
|
+
const childIdSplt = node.nodeValue.split('.');
|
|
884
|
+
if (childIdSplt[0] === ORG_LOCATION_ID) {
|
|
885
|
+
orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
|
|
886
|
+
node.nodeValue = '';
|
|
887
|
+
// useful to know if the original location is
|
|
888
|
+
// the root light-dom of a shadow dom component
|
|
889
|
+
node['s-en'] = childIdSplt[3];
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
};
|
|
678
893
|
/**
|
|
679
894
|
* Parse a new property value for a given property type.
|
|
680
895
|
*
|
|
@@ -909,6 +1124,17 @@ const connectedCallback = (elm) => {
|
|
|
909
1124
|
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
910
1125
|
// first time this component has connected
|
|
911
1126
|
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1127
|
+
let hostId;
|
|
1128
|
+
{
|
|
1129
|
+
hostId = elm.getAttribute(HYDRATE_ID);
|
|
1130
|
+
if (hostId) {
|
|
1131
|
+
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1132
|
+
const scopeId = addStyle(elm.shadowRoot, cmpMeta);
|
|
1133
|
+
elm.classList.remove(scopeId + '-h', scopeId + '-s');
|
|
1134
|
+
}
|
|
1135
|
+
initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
912
1138
|
{
|
|
913
1139
|
// find the first ancestor component (if there is one) and register
|
|
914
1140
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -916,7 +1142,10 @@ const connectedCallback = (elm) => {
|
|
|
916
1142
|
while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
|
917
1143
|
// climb up the ancestors looking for the first
|
|
918
1144
|
// component that hasn't finished its lifecycle update yet
|
|
919
|
-
if (ancestorComponent
|
|
1145
|
+
if ((ancestorComponent.nodeType === 1 /* ElementNode */ &&
|
|
1146
|
+
ancestorComponent.hasAttribute('s-id') &&
|
|
1147
|
+
ancestorComponent['s-p']) ||
|
|
1148
|
+
ancestorComponent['s-p']) {
|
|
920
1149
|
// we found this components first ancestor component
|
|
921
1150
|
// keep a reference to this component's ancestor component
|
|
922
1151
|
attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
|
@@ -956,10 +1185,22 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
956
1185
|
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
|
957
1186
|
const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
|
|
958
1187
|
const deferredConnectedCallbacks = [];
|
|
1188
|
+
const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
959
1189
|
let appLoadFallback;
|
|
960
1190
|
let isBootstrapping = true;
|
|
1191
|
+
let i = 0;
|
|
961
1192
|
Object.assign(plt, options);
|
|
962
1193
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1194
|
+
{
|
|
1195
|
+
// If the app is already hydrated there is not point to disable the
|
|
1196
|
+
// async queue. This will improve the first input delay
|
|
1197
|
+
plt.$flags$ |= 2 /* appLoaded */;
|
|
1198
|
+
}
|
|
1199
|
+
{
|
|
1200
|
+
for (; i < styles.length; i++) {
|
|
1201
|
+
registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
963
1204
|
lazyBundles.map((lazyBundle) => {
|
|
964
1205
|
lazyBundle[1].map((compactMeta) => {
|
|
965
1206
|
const cmpMeta = {
|
package/dist/esm/loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { p as promiseResolve, b as bootstrapLazy } from './index-
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-2280c7b8.js';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
|
-
Stencil Client Patch Esm v2.17.
|
|
4
|
+
Stencil Client Patch Esm v2.17.3 | MIT Licensed | https://stenciljs.com
|
|
5
5
|
*/
|
|
6
6
|
const patchEsm = () => {
|
|
7
7
|
return promiseResolve();
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v5.3.0
|
|
2
|
+
|
|
3
|
+
export declare function createWindowFromHtml(templateHtml: string, uniqueId: string): any;
|
|
4
|
+
export interface HydrateDocumentOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Build ID that will be added to `<html data-stencil-build="BUILD_ID">`. By default
|
|
7
|
+
* a random ID will be generated
|
|
8
|
+
*/
|
|
9
|
+
buildId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the `href` attribute on the `<link rel="canonical">`
|
|
12
|
+
* tag within the `<head>`. If the value is not defined it will
|
|
13
|
+
* ensure a canonical link tag is no included in the `<head>`.
|
|
14
|
+
*/
|
|
15
|
+
canonicalUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Include the HTML comments and attributes used by the clientside
|
|
18
|
+
* JavaScript to read the structure of the HTML and rebuild each
|
|
19
|
+
* component. Defaults to `true`.
|
|
20
|
+
*/
|
|
21
|
+
clientHydrateAnnotations?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Constrain `setTimeout()` to 1ms, but still async. Also
|
|
24
|
+
* only allows `setInterval()` to fire once, also constrained to 1ms.
|
|
25
|
+
* Defaults to `true`.
|
|
26
|
+
*/
|
|
27
|
+
constrainTimeouts?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Sets `document.cookie`
|
|
30
|
+
*/
|
|
31
|
+
cookie?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the `dir` attribute on the top level `<html>`.
|
|
34
|
+
*/
|
|
35
|
+
direction?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Component tag names listed here will not be prerendered, nor will
|
|
38
|
+
* hydrated on the clientside. Components listed here will be ignored
|
|
39
|
+
* as custom elements and treated no differently than a `<div>`.
|
|
40
|
+
*/
|
|
41
|
+
excludeComponents?: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Sets the `lang` attribute on the top level `<html>`.
|
|
44
|
+
*/
|
|
45
|
+
language?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum number of components to hydrate on one page. Defaults to `300`.
|
|
48
|
+
*/
|
|
49
|
+
maxHydrateCount?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Sets `document.referrer`
|
|
52
|
+
*/
|
|
53
|
+
referrer?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Removes every `<script>` element found in the `document`. Defaults to `false`.
|
|
56
|
+
*/
|
|
57
|
+
removeScripts?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Removes CSS not used by elements within the `document`. Defaults to `true`.
|
|
60
|
+
*/
|
|
61
|
+
removeUnusedStyles?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The url the runtime uses for the resources, such as the assets directory.
|
|
64
|
+
*/
|
|
65
|
+
resourcesUrl?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Prints out runtime console logs to the NodeJS process. Defaults to `false`.
|
|
68
|
+
*/
|
|
69
|
+
runtimeLogging?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Component tags listed here will only be prerendered or serverside-rendered
|
|
72
|
+
* and will not be clientside hydrated. This is useful for components that
|
|
73
|
+
* are not dynamic and do not need to be defined as a custom element within the
|
|
74
|
+
* browser. For example, a header or footer component would be a good example that
|
|
75
|
+
* may not require any clientside JavaScript.
|
|
76
|
+
*/
|
|
77
|
+
staticComponents?: string[];
|
|
78
|
+
/**
|
|
79
|
+
* The amount of milliseconds to wait for a page to finish rendering until
|
|
80
|
+
* a timeout error is thrown. Defaults to `15000`.
|
|
81
|
+
*/
|
|
82
|
+
timeout?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Sets `document.title`.
|
|
85
|
+
*/
|
|
86
|
+
title?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Sets `location.href`
|
|
89
|
+
*/
|
|
90
|
+
url?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Sets `navigator.userAgent`
|
|
93
|
+
*/
|
|
94
|
+
userAgent?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface SerializeDocumentOptions extends HydrateDocumentOptions {
|
|
97
|
+
/**
|
|
98
|
+
* Runs after the `document` has been hydrated.
|
|
99
|
+
*/
|
|
100
|
+
afterHydrate?(document: any): any | Promise<any>;
|
|
101
|
+
/**
|
|
102
|
+
* Sets an approximate line width the HTML should attempt to stay within.
|
|
103
|
+
* Note that this is "approximate", in that HTML may often not be able
|
|
104
|
+
* to be split at an exact line width. Additionally, new lines created
|
|
105
|
+
* is where HTML naturally already has whitespace, such as before an
|
|
106
|
+
* attribute or spaces between words. Defaults to `100`.
|
|
107
|
+
*/
|
|
108
|
+
approximateLineWidth?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Runs before the `document` has been hydrated.
|
|
111
|
+
*/
|
|
112
|
+
beforeHydrate?(document: any): any | Promise<any>;
|
|
113
|
+
/**
|
|
114
|
+
* Format the HTML in a nicely indented format.
|
|
115
|
+
* Defaults to `false`.
|
|
116
|
+
*/
|
|
117
|
+
prettyHtml?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Remove quotes from attribute values when possible.
|
|
120
|
+
* Defaults to `true`.
|
|
121
|
+
*/
|
|
122
|
+
removeAttributeQuotes?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Remove the `=""` from standardized `boolean` attributes,
|
|
125
|
+
* such as `hidden` or `checked`. Defaults to `true`.
|
|
126
|
+
*/
|
|
127
|
+
removeBooleanAttributeQuotes?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Remove these standardized attributes when their value is empty:
|
|
130
|
+
* `class`, `dir`, `id`, `lang`, and `name`, `title`. Defaults to `true`.
|
|
131
|
+
*/
|
|
132
|
+
removeEmptyAttributes?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Remove HTML comments. Defaults to `true`.
|
|
135
|
+
*/
|
|
136
|
+
removeHtmlComments?: boolean;
|
|
137
|
+
}
|
|
138
|
+
export interface HydrateFactoryOptions extends SerializeDocumentOptions {
|
|
139
|
+
serializeToHtml: boolean;
|
|
140
|
+
destroyWindow: boolean;
|
|
141
|
+
destroyDocument: boolean;
|
|
142
|
+
}
|
|
143
|
+
export interface Diagnostic {
|
|
144
|
+
level: "error" | "warn" | "info" | "log" | "debug";
|
|
145
|
+
type: string;
|
|
146
|
+
header?: string;
|
|
147
|
+
language?: string;
|
|
148
|
+
messageText: string;
|
|
149
|
+
debugText?: string;
|
|
150
|
+
code?: string;
|
|
151
|
+
absFilePath?: string;
|
|
152
|
+
relFilePath?: string;
|
|
153
|
+
lineNumber?: number;
|
|
154
|
+
columnNumber?: number;
|
|
155
|
+
lines?: {
|
|
156
|
+
lineIndex: number;
|
|
157
|
+
lineNumber: number;
|
|
158
|
+
text?: string;
|
|
159
|
+
errorCharStart: number;
|
|
160
|
+
errorLength?: number;
|
|
161
|
+
}[];
|
|
162
|
+
}
|
|
163
|
+
export interface HydrateResults {
|
|
164
|
+
buildId: string;
|
|
165
|
+
diagnostics: Diagnostic[];
|
|
166
|
+
url: string;
|
|
167
|
+
host: string;
|
|
168
|
+
hostname: string;
|
|
169
|
+
href: string;
|
|
170
|
+
port: string;
|
|
171
|
+
pathname: string;
|
|
172
|
+
search: string;
|
|
173
|
+
hash: string;
|
|
174
|
+
html: string;
|
|
175
|
+
components: HydrateComponent[];
|
|
176
|
+
anchors: HydrateAnchorElement[];
|
|
177
|
+
imgs: HydrateImgElement[];
|
|
178
|
+
scripts: HydrateScriptElement[];
|
|
179
|
+
styles: HydrateStyleElement[];
|
|
180
|
+
staticData: HydrateStaticData[];
|
|
181
|
+
title: string;
|
|
182
|
+
hydratedCount: number;
|
|
183
|
+
httpStatus: number;
|
|
184
|
+
}
|
|
185
|
+
export interface HydrateComponent {
|
|
186
|
+
tag: string;
|
|
187
|
+
mode: string;
|
|
188
|
+
count: number;
|
|
189
|
+
depth: number;
|
|
190
|
+
}
|
|
191
|
+
export interface HydrateElement {
|
|
192
|
+
[attrName: string]: string | undefined;
|
|
193
|
+
}
|
|
194
|
+
export interface HydrateAnchorElement extends HydrateElement {
|
|
195
|
+
href?: string;
|
|
196
|
+
target?: string;
|
|
197
|
+
}
|
|
198
|
+
export interface HydrateImgElement extends HydrateElement {
|
|
199
|
+
src?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface HydrateScriptElement extends HydrateElement {
|
|
202
|
+
src?: string;
|
|
203
|
+
type?: string;
|
|
204
|
+
}
|
|
205
|
+
export interface HydrateStyleElement extends HydrateElement {
|
|
206
|
+
href?: string;
|
|
207
|
+
}
|
|
208
|
+
export interface HydrateStaticData {
|
|
209
|
+
id: string;
|
|
210
|
+
type: string;
|
|
211
|
+
content: string;
|
|
212
|
+
}
|
|
213
|
+
export declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<HydrateResults>;
|
|
214
|
+
export declare function hydrateDocument(doc: any | string, options?: HydrateDocumentOptions): Promise<HydrateResults>;
|
|
215
|
+
export declare function serializeDocumentToString(doc: any, opts: HydrateFactoryOptions): string;
|
|
216
|
+
|
|
217
|
+
export {};
|