@arcgis/lumina 4.31.0-next.84 → 4.31.0-next.86
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/LitElement.d.ts +9 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +51 -82
- package/dist/runtime.d.ts +24 -24
- package/dist/stencil-ssr-compatibility/index.d.ts +78 -0
- package/dist/stencil-ssr-compatibility/index.js +88 -0
- package/dist/typings/importMeta.d.ts +0 -1
- package/dist/utils.d.ts +6 -0
- package/package.json +8 -5
package/dist/LitElement.d.ts
CHANGED
|
@@ -45,7 +45,13 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
|
|
|
45
45
|
* only to satisfy the type checker.
|
|
46
46
|
*/
|
|
47
47
|
options?: LitElementPropertyDeclaration | number | [number, LitElementPropertyDeclaration]): void;
|
|
48
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Since we can't pass arguments to web component constructor, before lazy
|
|
50
|
+
* loading logic calls document.createElement(), it temporary sets this static
|
|
51
|
+
* property.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
* */
|
|
49
55
|
static lazy: ProxyComponent | undefined;
|
|
50
56
|
static readonly lumina = true;
|
|
51
57
|
/**
|
|
@@ -67,10 +73,6 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
|
|
|
67
73
|
* // build, but if you have to, you can detect if you are in a lazy build like so:
|
|
68
74
|
* const isLazy = this.el !== this;
|
|
69
75
|
* ```
|
|
70
|
-
*
|
|
71
|
-
* @remarks
|
|
72
|
-
* Since we can't pass arguments to web component constructor, we are using
|
|
73
|
-
* a temporary static property instead
|
|
74
76
|
*/
|
|
75
77
|
el: HTMLElement;
|
|
76
78
|
/**
|
|
@@ -116,8 +118,6 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
|
|
|
116
118
|
private _postLoaded;
|
|
117
119
|
constructor();
|
|
118
120
|
connectedCallback(): void;
|
|
119
|
-
/** Do asynchronous component load */
|
|
120
|
-
private _load;
|
|
121
121
|
/**
|
|
122
122
|
* Overwrite Lit's default behavior of attaching shadow root to the lit
|
|
123
123
|
* element, and instead use this.el to support lazy builds.
|
|
@@ -125,6 +125,8 @@ export declare class LitElement extends OriginalLitElement implements ComponentL
|
|
|
125
125
|
* Also, support the case when component asked to not use shadow root
|
|
126
126
|
*/
|
|
127
127
|
protected createRenderRoot(): DocumentFragment | HTMLElement;
|
|
128
|
+
/** Do asynchronous component load */
|
|
129
|
+
private _load;
|
|
128
130
|
/**
|
|
129
131
|
* Overwriting default shouldUpdate simply to get access to
|
|
130
132
|
* "changedProperties" so that we can later provide it to ControllerManager
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { handleComponentMetaUpdate, handleHmrUpdate } from "./hmrSupport";
|
|
|
6
6
|
export type { DefineCustomElements, LazyLoadOptions } from "./lazyLoad";
|
|
7
7
|
export { makeDefineCustomElements } from "./lazyLoad";
|
|
8
8
|
export { LitElement } from "./LitElement";
|
|
9
|
-
export { PublicLitElement } from "./PublicLitElement";
|
|
9
|
+
export type { PublicLitElement } from "./PublicLitElement";
|
|
10
10
|
export type { Runtime, RuntimeOptions, DevOnlyGlobalRuntime, DevOnlyGlobalComponentRefCallback } from "./runtime";
|
|
11
11
|
export { makeRuntime } from "./runtime";
|
|
12
12
|
export * from "./jsx/jsx";
|
package/dist/index.js
CHANGED
|
@@ -76,7 +76,10 @@ function devOnlyDetectIncorrectLazyUsages(LitClass) {
|
|
|
76
76
|
...Object.getOwnPropertyDescriptors(Node.prototype),
|
|
77
77
|
...Object.getOwnPropertyDescriptors(EventTarget.prototype)
|
|
78
78
|
}).filter(([key, { value }]) => typeof value === "function" && !allowList.has(key)).forEach(([key]) => {
|
|
79
|
-
genericPrototype[key] = () => {
|
|
79
|
+
genericPrototype[key] = (...args) => {
|
|
80
|
+
if (key === "hasAttribute" && args[0] === "defer-hydration") {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
80
83
|
throw new Error(
|
|
81
84
|
`You should not be calling this.${key}() directly as it won't work correctly in lazy-builds. Instead, ${customErrorMessages[key] ?? `use this.el.${key}()`}`
|
|
82
85
|
);
|
|
@@ -112,11 +115,6 @@ var makeDefineCustomElements = (runtime, structure) => function defineCustomElem
|
|
|
112
115
|
if (resourcesUrl) {
|
|
113
116
|
runtime.setAssetPath(resourcesUrl);
|
|
114
117
|
}
|
|
115
|
-
const hideUntilHydrated = new CSSStyleSheet();
|
|
116
|
-
hideUntilHydrated.replaceSync(
|
|
117
|
-
`:is(${Object.keys(structure).join(",")}):not([${runtime.hydratedAttribute}]){visibility:hidden}[${runtime.hydratedAttribute}]{visibility:inherit}`
|
|
118
|
-
);
|
|
119
|
-
document.adoptedStyleSheets = [...document.adoptedStyleSheets, hideUntilHydrated];
|
|
120
118
|
Object.entries(structure).forEach(createLazyElement);
|
|
121
119
|
};
|
|
122
120
|
function createLazyElement([tagName, [load, compactMeta = ""]]) {
|
|
@@ -487,7 +485,7 @@ if (!alreadyHadObservers) {
|
|
|
487
485
|
|
|
488
486
|
// src/LitElement.ts
|
|
489
487
|
import { Deferred as Deferred2, camelToKebab as camelToKebab3 } from "@arcgis/components-utils";
|
|
490
|
-
import { LitElement as OriginalLitElement } from "lit";
|
|
488
|
+
import { LitElement as OriginalLitElement, isServer } from "lit";
|
|
491
489
|
import { useControllerManager } from "@arcgis/components-controllers";
|
|
492
490
|
var emptyFunction = () => void 0;
|
|
493
491
|
var _LitElement = class _LitElement extends OriginalLitElement {
|
|
@@ -512,10 +510,6 @@ var _LitElement = class _LitElement extends OriginalLitElement {
|
|
|
512
510
|
* // build, but if you have to, you can detect if you are in a lazy build like so:
|
|
513
511
|
* const isLazy = this.el !== this;
|
|
514
512
|
* ```
|
|
515
|
-
*
|
|
516
|
-
* @remarks
|
|
517
|
-
* Since we can't pass arguments to web component constructor, we are using
|
|
518
|
-
* a temporary static property instead
|
|
519
513
|
*/
|
|
520
514
|
this.el = this.constructor.lazy ?? this;
|
|
521
515
|
/**
|
|
@@ -551,16 +545,18 @@ var _LitElement = class _LitElement extends OriginalLitElement {
|
|
|
551
545
|
if (process.env.NODE_ENV !== "production") {
|
|
552
546
|
globalThis.devOnly$luminaComponentRefCallback?.(this);
|
|
553
547
|
}
|
|
548
|
+
if (isServer) {
|
|
549
|
+
this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
|
|
550
|
+
}
|
|
554
551
|
}
|
|
555
552
|
static finalizeStyles(styles) {
|
|
556
553
|
if (process.env.NODE_ENV === "test" && Array.isArray(styles)) {
|
|
557
554
|
styles = styles.filter(Boolean);
|
|
558
555
|
}
|
|
559
556
|
const finalizedStyles = super.finalizeStyles(styles);
|
|
560
|
-
const
|
|
561
|
-
const options = Class.shadowRootOptions;
|
|
557
|
+
const options = this.constructor.shadowRootOptions;
|
|
562
558
|
const useLightDom = options === noShadowRoot;
|
|
563
|
-
return this.runtime === void 0 || useLightDom ? finalizedStyles : [
|
|
559
|
+
return this.runtime?.commonStyles === void 0 || useLightDom ? finalizedStyles : [this.runtime.commonStyles, ...finalizedStyles];
|
|
564
560
|
}
|
|
565
561
|
static createProperty(name, options) {
|
|
566
562
|
const flags = typeof options === "number" ? options : Array.isArray(options) ? options[0] : 0;
|
|
@@ -598,32 +594,15 @@ var _LitElement = class _LitElement extends OriginalLitElement {
|
|
|
598
594
|
});
|
|
599
595
|
}
|
|
600
596
|
connectedCallback() {
|
|
597
|
+
if (this.el.hasAttribute("defer-hydration")) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
601
600
|
const isFirstCall = !this.manager.connectedCalled;
|
|
602
601
|
super.connectedCallback();
|
|
603
602
|
if (isFirstCall) {
|
|
604
603
|
queueMicrotask(() => void this._load().catch(this._postLoaded.reject));
|
|
605
604
|
}
|
|
606
605
|
}
|
|
607
|
-
/** Do asynchronous component load */
|
|
608
|
-
async _load() {
|
|
609
|
-
const parentLoadPromise = this._ancestorLoad ?? attachToAncestor(this, this);
|
|
610
|
-
if (parentLoadPromise) {
|
|
611
|
-
await parentLoadPromise;
|
|
612
|
-
}
|
|
613
|
-
await this.manager._load();
|
|
614
|
-
this._enableUpdating(true);
|
|
615
|
-
this.performUpdate();
|
|
616
|
-
this._postLoad.resolve();
|
|
617
|
-
const pendingChildren = this._offspring.filter((loaded) => !loaded.manager?.loadedCalled);
|
|
618
|
-
if (pendingChildren.length) {
|
|
619
|
-
await Promise.allSettled(pendingChildren.map(async (child) => await child.componentOnReady()));
|
|
620
|
-
}
|
|
621
|
-
this._offspring.length = 0;
|
|
622
|
-
const Class = this.constructor;
|
|
623
|
-
this.el.setAttribute(Class.runtime.hydratedAttribute, "");
|
|
624
|
-
this.manager._loaded();
|
|
625
|
-
this._postLoaded.resolve();
|
|
626
|
-
}
|
|
627
606
|
/**
|
|
628
607
|
* Overwrite Lit's default behavior of attaching shadow root to the lit
|
|
629
608
|
* element, and instead use this.el to support lazy builds.
|
|
@@ -631,17 +610,21 @@ var _LitElement = class _LitElement extends OriginalLitElement {
|
|
|
631
610
|
* Also, support the case when component asked to not use shadow root
|
|
632
611
|
*/
|
|
633
612
|
createRenderRoot() {
|
|
634
|
-
|
|
635
|
-
return this.el.shadowRoot;
|
|
636
|
-
}
|
|
613
|
+
const existingShadowRoot = this.el.shadowRoot;
|
|
637
614
|
const Class = this.constructor;
|
|
638
615
|
const options = Class.shadowRootOptions;
|
|
639
616
|
const useLightDom = options === noShadowRoot;
|
|
640
|
-
const renderRoot = useLightDom ? this.el : this.el.attachShadow(options);
|
|
617
|
+
const renderRoot = existingShadowRoot ?? (useLightDom ? this.el : this.el.attachShadow(options));
|
|
641
618
|
Object.defineProperty(this, "shadowRoot", {
|
|
642
619
|
// Create shadow root on the proxy instance, to make Lit render content there
|
|
643
620
|
value: renderRoot
|
|
644
621
|
});
|
|
622
|
+
if (existingShadowRoot) {
|
|
623
|
+
if (process.env.NODE_ENV === "production") {
|
|
624
|
+
OriginalLitElement.prototype.createRenderRoot.call(this);
|
|
625
|
+
}
|
|
626
|
+
return existingShadowRoot;
|
|
627
|
+
}
|
|
645
628
|
const domRoot = renderRoot.getRootNode();
|
|
646
629
|
domRoot.adoptedStyleSheets = [
|
|
647
630
|
...domRoot.adoptedStyleSheets,
|
|
@@ -649,6 +632,25 @@ var _LitElement = class _LitElement extends OriginalLitElement {
|
|
|
649
632
|
];
|
|
650
633
|
return renderRoot;
|
|
651
634
|
}
|
|
635
|
+
/** Do asynchronous component load */
|
|
636
|
+
async _load() {
|
|
637
|
+
const parentLoadPromise = this._ancestorLoad ?? attachToAncestor(this, this);
|
|
638
|
+
if (parentLoadPromise) {
|
|
639
|
+
await parentLoadPromise;
|
|
640
|
+
}
|
|
641
|
+
await this.manager._load();
|
|
642
|
+
this._enableUpdating(true);
|
|
643
|
+
this.performUpdate();
|
|
644
|
+
this._postLoad.resolve();
|
|
645
|
+
const pendingChildren = this._offspring.filter((loaded) => !loaded.manager?.loadedCalled);
|
|
646
|
+
if (pendingChildren.length) {
|
|
647
|
+
await Promise.allSettled(pendingChildren.map(async (child) => await child.componentOnReady()));
|
|
648
|
+
}
|
|
649
|
+
this._offspring.length = 0;
|
|
650
|
+
this.el.setAttribute(this.constructor.runtime.hydratedAttribute, "");
|
|
651
|
+
this.manager._loaded();
|
|
652
|
+
this._postLoaded.resolve();
|
|
653
|
+
}
|
|
652
654
|
/**
|
|
653
655
|
* Overwriting default shouldUpdate simply to get access to
|
|
654
656
|
* "changedProperties" so that we can later provide it to ControllerManager
|
|
@@ -697,53 +699,20 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
697
699
|
);
|
|
698
700
|
}
|
|
699
701
|
|
|
700
|
-
// src/PublicLitElement.ts
|
|
701
|
-
var PublicLitElement = class extends HTMLElement {
|
|
702
|
-
/**
|
|
703
|
-
* Create a promise that resolves once component is fully loaded.
|
|
704
|
-
*
|
|
705
|
-
* @example
|
|
706
|
-
* const map = document.createElement("arcgis-map");
|
|
707
|
-
* document.body.append(map);
|
|
708
|
-
* map.componentOnReady().then(() => {
|
|
709
|
-
* console.log("Map is ready to go!");
|
|
710
|
-
* });
|
|
711
|
-
*/
|
|
712
|
-
async componentOnReady() {
|
|
713
|
-
await Promise.resolve();
|
|
714
|
-
return this;
|
|
715
|
-
}
|
|
716
|
-
};
|
|
717
|
-
|
|
718
702
|
// src/runtime.ts
|
|
719
|
-
|
|
720
|
-
function makeRuntime({
|
|
721
|
-
defaultAssetsUrl,
|
|
722
|
-
hydratedAttribute = "hydrated",
|
|
723
|
-
commonStyles,
|
|
724
|
-
globalStyles
|
|
725
|
-
}) {
|
|
726
|
-
const href = globalThis.location?.href;
|
|
703
|
+
function makeRuntime(options) {
|
|
727
704
|
let assetPath;
|
|
728
|
-
setAssetPath(
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
function getAssetPath(suffix) {
|
|
733
|
-
const assetUrl = new URL(suffix, assetPath);
|
|
734
|
-
return assetUrl.origin !== globalThis.location?.origin ? assetUrl.href : assetUrl.pathname;
|
|
735
|
-
}
|
|
736
|
-
const hideUntilHydrated = unsafeCSS(`:host(:not([${hydratedAttribute}])){visibility:hidden}`);
|
|
737
|
-
if (globalStyles) {
|
|
738
|
-
document.adoptedStyleSheets = [...document.adoptedStyleSheets, globalStyles.styleSheet];
|
|
739
|
-
}
|
|
705
|
+
const setAssetPath = (path) => {
|
|
706
|
+
assetPath = new URL(path, globalThis.location?.href).href;
|
|
707
|
+
};
|
|
740
708
|
const runtime = {
|
|
741
|
-
|
|
742
|
-
|
|
709
|
+
...options,
|
|
710
|
+
// FEATURE: research https://vitejs.dev/guide/build.html#advanced-base-options
|
|
711
|
+
getAssetPath(suffix) {
|
|
712
|
+
const assetUrl = new URL(suffix, assetPath);
|
|
713
|
+
return assetUrl.origin !== globalThis.location?.origin ? assetUrl.href : assetUrl.pathname;
|
|
714
|
+
},
|
|
743
715
|
setAssetPath,
|
|
744
|
-
hydratedAttribute,
|
|
745
|
-
commonStyles: [...commonStyles ? [commonStyles] : [], hideUntilHydrated],
|
|
746
|
-
globalStyles,
|
|
747
716
|
customElement(tagName, component) {
|
|
748
717
|
component.runtime = runtime;
|
|
749
718
|
component.tagName = tagName;
|
|
@@ -752,6 +721,7 @@ function makeRuntime({
|
|
|
752
721
|
}
|
|
753
722
|
}
|
|
754
723
|
};
|
|
724
|
+
setAssetPath(options.defaultAssetPath);
|
|
755
725
|
if (process.env.NODE_ENV !== "production") {
|
|
756
726
|
globalThis.devOnly$luminaRuntime = runtime;
|
|
757
727
|
}
|
|
@@ -796,7 +766,6 @@ function createPrototypeProxy(tagName) {
|
|
|
796
766
|
}
|
|
797
767
|
export {
|
|
798
768
|
LitElement,
|
|
799
|
-
PublicLitElement,
|
|
800
769
|
bindAttribute,
|
|
801
770
|
bindBooleanAttribute,
|
|
802
771
|
bindEvent,
|
package/dist/runtime.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { LitElement } from "./LitElement";
|
|
|
5
5
|
* different configuration options. For that reason, the configuration options
|
|
6
6
|
* can not be a global object, but has to be an object that you pass around.
|
|
7
7
|
*/
|
|
8
|
-
export type Runtime = {
|
|
8
|
+
export type Runtime = RuntimeOptions & {
|
|
9
9
|
/**
|
|
10
10
|
* Get the base path to where the package assets can be found.
|
|
11
11
|
* By default, the package asset path is set to "https://js.arcgis.com/<simplified-package-name>/<released-verion>/".
|
|
@@ -53,42 +53,42 @@ export type Runtime = {
|
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
readonly customElement: (tagName: string, component: typeof LitElement) => void;
|
|
56
|
-
readonly defaultAssetsUrl: RuntimeOptions["defaultAssetsUrl"];
|
|
57
|
-
readonly hydratedAttribute: NonNullable<RuntimeOptions["hydratedAttribute"]>;
|
|
58
|
-
readonly commonStyles: readonly NonNullable<RuntimeOptions["commonStyles"]>[];
|
|
59
|
-
readonly globalStyles: RuntimeOptions["globalStyles"];
|
|
60
56
|
};
|
|
61
57
|
export type RuntimeOptions = {
|
|
62
58
|
/**
|
|
63
|
-
* The default
|
|
64
|
-
*
|
|
65
|
-
* based on the value
|
|
59
|
+
* The default asset path to use in NPM and CDN builds.
|
|
60
|
+
*
|
|
61
|
+
* This option will be set by Lumina compiler based on the value of the
|
|
62
|
+
* `assets.defaultPath` option in the `useLumina()` plugin.
|
|
66
63
|
*/
|
|
67
|
-
readonly
|
|
64
|
+
readonly defaultAssetPath: string;
|
|
68
65
|
/**
|
|
69
|
-
* The attribute that indicates a component has
|
|
70
|
-
*
|
|
66
|
+
* The attribute that indicates a component has rendered it's content.
|
|
67
|
+
* Usually this attribute is added after your component's `loaded()` lifecycle
|
|
68
|
+
* happened. However, during SSR, "hydrated" is added right away on the
|
|
69
|
+
* server.
|
|
70
|
+
*
|
|
71
|
+
* Until element has this attribute, it will have `visibility:hidden` style
|
|
72
|
+
* applied.
|
|
73
|
+
*
|
|
74
|
+
* This option will be set by the Lumina compiler based on the value of
|
|
75
|
+
* the `css.hydratedAttribute` option in the `useLumina()` plugin.
|
|
71
76
|
*/
|
|
72
|
-
readonly hydratedAttribute
|
|
77
|
+
readonly hydratedAttribute: string;
|
|
73
78
|
/**
|
|
74
79
|
* Styles that you wish to make available in each component's shadow root, but
|
|
75
80
|
* to not apply outside the shadow root
|
|
76
81
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* export const runtime = makeRuntime({
|
|
80
|
-
* defaultAssetsUrl: import.meta.env.BASE_URL,
|
|
81
|
-
* commonStyles: styles,
|
|
82
|
-
* });
|
|
82
|
+
* This option will be set by Lumina compiler based on the value of the
|
|
83
|
+
* `css.commonStylesPath` option in the `useLumina()` plugin.
|
|
83
84
|
*/
|
|
84
85
|
readonly commonStyles?: CSSResult;
|
|
85
|
-
/**
|
|
86
|
-
* Styles that you wish to applied to the entire page, even outside the shadow
|
|
87
|
-
* dom. Useful for declaring CSS variables.
|
|
88
|
-
*/
|
|
89
|
-
readonly globalStyles?: CSSResult;
|
|
90
86
|
};
|
|
91
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The options object will be provided by Lumina compiler at build-time.
|
|
89
|
+
* It should not be specified in the source code.
|
|
90
|
+
*/
|
|
91
|
+
export declare function makeRuntime(options?: RuntimeOptions): Runtime;
|
|
92
92
|
/**
|
|
93
93
|
* Exposing the reference to the runtime globally when in tests or development.
|
|
94
94
|
* This is primarily for usage by dynamically created components in tests
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lots of silencing of ESLint in this file to be compatible with Stencil's
|
|
3
|
+
* unsafe typings.
|
|
4
|
+
*/
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
import { type RenderInfo } from "@lit-labs/ssr/lib/render.js";
|
|
7
|
+
import type { Readable } from "node:stream";
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated
|
|
10
|
+
* Use `render` from `@lit-labs/ssr` instead.
|
|
11
|
+
*
|
|
12
|
+
* @see https://lit.dev/docs/ssr/server-usage/
|
|
13
|
+
*/
|
|
14
|
+
export interface HydrateResults {
|
|
15
|
+
buildId: string;
|
|
16
|
+
diagnostics: any[];
|
|
17
|
+
url: string;
|
|
18
|
+
host: string;
|
|
19
|
+
hostname: string;
|
|
20
|
+
href: string;
|
|
21
|
+
port: string;
|
|
22
|
+
pathname: string;
|
|
23
|
+
search: string;
|
|
24
|
+
hash: string;
|
|
25
|
+
html: string;
|
|
26
|
+
components: HydrateComponent[];
|
|
27
|
+
anchors: any[];
|
|
28
|
+
imgs: any[];
|
|
29
|
+
scripts: any[];
|
|
30
|
+
styles: any[];
|
|
31
|
+
staticData: any[];
|
|
32
|
+
title: string;
|
|
33
|
+
hydratedCount: number;
|
|
34
|
+
httpStatus: number;
|
|
35
|
+
}
|
|
36
|
+
export interface HydrateComponent {
|
|
37
|
+
tag: string;
|
|
38
|
+
mode: string;
|
|
39
|
+
count: number;
|
|
40
|
+
depth: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated
|
|
44
|
+
* Use `getWindow` from `@lit-labs/ssr/lib/dom-shim` instead.
|
|
45
|
+
*
|
|
46
|
+
* @see https://lit.dev/docs/ssr/server-usage/
|
|
47
|
+
*/
|
|
48
|
+
export declare function createWindowFromHtml(templateHtml: string, uniqueId?: string): any;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated
|
|
51
|
+
* Use `RenderResultReadable` from `@lit-labs/ssr` instead.
|
|
52
|
+
*
|
|
53
|
+
* @see https://lit.dev/docs/ssr/server-usage/
|
|
54
|
+
*/
|
|
55
|
+
export declare function streamToString(html: any, options?: Partial<RenderInfo>): Readable;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated
|
|
58
|
+
* Use `render` from `@lit-labs/ssr` instead.
|
|
59
|
+
*
|
|
60
|
+
* @see https://lit.dev/docs/ssr/server-usage/
|
|
61
|
+
*/
|
|
62
|
+
export declare function renderToString(html: any, options?: Partial<RenderInfo>): Promise<HydrateResults>;
|
|
63
|
+
export declare function renderToString(html: any, options: Partial<RenderInfo> | undefined, asStream: true): Readable;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated
|
|
66
|
+
* Use `render` from `@lit-labs/ssr` instead.
|
|
67
|
+
*
|
|
68
|
+
* @see https://lit.dev/docs/ssr/server-usage/
|
|
69
|
+
*/
|
|
70
|
+
export declare function hydrateDocument(doc: any, options?: Partial<RenderInfo>): Promise<HydrateResults>;
|
|
71
|
+
export declare function hydrateDocument(doc: any, options: Partial<RenderInfo> | undefined, asStream: true): Readable;
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated
|
|
74
|
+
* Use `render` from `@lit-labs/ssr` instead.
|
|
75
|
+
*
|
|
76
|
+
* @see https://lit.dev/docs/ssr/server-usage/
|
|
77
|
+
*/
|
|
78
|
+
export declare function serializeDocumentToString(doc: any, _unused?: unknown): string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/stencil-ssr-compatibility/index.ts
|
|
2
|
+
import { getWindow } from "@lit-labs/ssr/lib/dom-shim.js";
|
|
3
|
+
import { render } from "@lit-labs/ssr/lib/render.js";
|
|
4
|
+
import { html } from "@lit-labs/ssr/lib/server-template.js";
|
|
5
|
+
import { unsafeStatic, withStatic } from "lit/static-html.js";
|
|
6
|
+
import { collectResult } from "@lit-labs/ssr/lib/render-result.js";
|
|
7
|
+
import { RenderResultReadable } from "@lit-labs/ssr/lib/render-result-readable.js";
|
|
8
|
+
var staticHtml = withStatic(html);
|
|
9
|
+
function createWindowFromHtml(templateHtml, uniqueId = Math.random().toString()) {
|
|
10
|
+
const window = getWindow({ includeJSBuiltIns: true });
|
|
11
|
+
window.document.defaultView = window;
|
|
12
|
+
window.document.templateHtml = templateHtml;
|
|
13
|
+
window.document.buildId = uniqueId;
|
|
14
|
+
return window;
|
|
15
|
+
}
|
|
16
|
+
function streamToString(html2, options) {
|
|
17
|
+
const { result } = getRenderResult(html2, options);
|
|
18
|
+
return new RenderResultReadable(result);
|
|
19
|
+
}
|
|
20
|
+
function getRenderResult(rawSource, options) {
|
|
21
|
+
const maybeDocument = typeof rawSource === "object" && rawSource !== null ? "document" in rawSource ? rawSource.document : rawSource : void 0;
|
|
22
|
+
const source = maybeDocument && "templateHtml" in maybeDocument ? maybeDocument.templateHtml : maybeDocument && "documentElement" in maybeDocument ? maybeDocument.documentElement?.outerHTML ?? maybeDocument : rawSource;
|
|
23
|
+
const renderTemplate = typeof source === "string" ? staticHtml`${unsafeStatic(source)}` : source;
|
|
24
|
+
const tagNames = [];
|
|
25
|
+
const result = render(renderTemplate, {
|
|
26
|
+
customElementRendered(tagName) {
|
|
27
|
+
tagNames.push(tagName);
|
|
28
|
+
},
|
|
29
|
+
...options
|
|
30
|
+
});
|
|
31
|
+
return { result, maybeDocument, tagNames };
|
|
32
|
+
}
|
|
33
|
+
function renderToString(html2, options, asStream = false) {
|
|
34
|
+
if (asStream) {
|
|
35
|
+
return streamToString(html2, options);
|
|
36
|
+
} else {
|
|
37
|
+
return resultsToString(html2, options);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function resultsToString(html2, options) {
|
|
41
|
+
const { result, tagNames, maybeDocument } = getRenderResult(html2, options);
|
|
42
|
+
const collected = await collectResult(result);
|
|
43
|
+
const renderResult = {
|
|
44
|
+
buildId: maybeDocument?.buildId ?? Math.random().toString(),
|
|
45
|
+
diagnostics: [],
|
|
46
|
+
url: globalThis?.location?.href ?? "https://hydrate.stenciljs.com/",
|
|
47
|
+
host: globalThis?.location?.host ?? "hydrate.stenciljs.com",
|
|
48
|
+
hostname: globalThis?.location?.hostname ?? "hydrate.stenciljs.com",
|
|
49
|
+
href: globalThis?.location?.href ?? "https://hydrate.stenciljs.com/",
|
|
50
|
+
port: globalThis?.location?.port ?? "",
|
|
51
|
+
pathname: globalThis?.location?.pathname ?? "/",
|
|
52
|
+
search: globalThis?.location?.search ?? "",
|
|
53
|
+
hash: globalThis?.location?.hash ?? "",
|
|
54
|
+
html: collected,
|
|
55
|
+
httpStatus: 200,
|
|
56
|
+
hydratedCount: tagNames.length,
|
|
57
|
+
anchors: [],
|
|
58
|
+
components: tagNames.map((tag) => ({
|
|
59
|
+
tag,
|
|
60
|
+
mode: "$",
|
|
61
|
+
count: 1,
|
|
62
|
+
depth: 1
|
|
63
|
+
})),
|
|
64
|
+
imgs: [],
|
|
65
|
+
scripts: [],
|
|
66
|
+
staticData: [],
|
|
67
|
+
styles: [],
|
|
68
|
+
title: globalThis?.document?.title ?? "Vite + TS"
|
|
69
|
+
};
|
|
70
|
+
if (maybeDocument && "templateHtml" in maybeDocument) {
|
|
71
|
+
maybeDocument.outerHtml = collected;
|
|
72
|
+
}
|
|
73
|
+
return renderResult;
|
|
74
|
+
}
|
|
75
|
+
function hydrateDocument(doc, options, asStream) {
|
|
76
|
+
return renderToString(doc, options, asStream);
|
|
77
|
+
}
|
|
78
|
+
function serializeDocumentToString(doc, _unused) {
|
|
79
|
+
const maybeDocument = doc;
|
|
80
|
+
return maybeDocument.outerHtml ?? maybeDocument.templateHtml ?? String(maybeDocument);
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
createWindowFromHtml,
|
|
84
|
+
hydrateDocument,
|
|
85
|
+
renderToString,
|
|
86
|
+
serializeDocumentToString,
|
|
87
|
+
streamToString
|
|
88
|
+
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -12,3 +12,9 @@
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare const noShadowRoot: ShadowRootInit;
|
|
15
|
+
/**
|
|
16
|
+
* The above property is an empty object at runtime for bundle size reasons.
|
|
17
|
+
* While empty object is not a valid shadowRootOption, it is never passed to
|
|
18
|
+
* attachShadow() since we use this exact empty object as a magic value to opt
|
|
19
|
+
* out of shadow root.
|
|
20
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/lumina",
|
|
3
|
-
"version": "4.31.0-next.
|
|
3
|
+
"version": "4.31.0-next.86",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./dist/index.js",
|
|
10
10
|
"./config": "./dist/config.js",
|
|
11
|
+
"./stencil-ssr-compatibility": "./dist/stencil-ssr-compatibility/index.js",
|
|
11
12
|
"./typings": {
|
|
12
13
|
"types": "./dist/typings/index.d.ts"
|
|
13
14
|
},
|
|
@@ -28,18 +29,20 @@
|
|
|
28
29
|
"clean": "rimraf ./dist ./build ./turbo ./node_modules"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@arcgis/components-controllers": "4.31.0-next.
|
|
32
|
-
"@arcgis/components-utils": "4.31.0-next.
|
|
32
|
+
"@arcgis/components-controllers": "4.31.0-next.86",
|
|
33
|
+
"@arcgis/components-utils": "4.31.0-next.86",
|
|
34
|
+
"@lit-labs/ssr": "^3.2.2",
|
|
35
|
+
"@lit-labs/ssr-client": "^1.1.7",
|
|
33
36
|
"csstype": "^3.1.3",
|
|
34
37
|
"lit": "^3.1.2"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
|
-
"@arcgis/typescript-config": "4.31.0-next.
|
|
40
|
+
"@arcgis/typescript-config": "4.31.0-next.86",
|
|
38
41
|
"@types/node": "^20.2.5",
|
|
39
42
|
"eslint": "^8.55.0",
|
|
40
43
|
"rimraf": "^5.0.0",
|
|
41
44
|
"tsup": "^8.1.0",
|
|
42
45
|
"typescript": "~5.4.0"
|
|
43
46
|
},
|
|
44
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "f334d75f7c86dd52bebccb91e9e5d2a33f9afd30"
|
|
45
48
|
}
|