1 | /**
|
2 | * @license
|
3 | * Copyright 2019 Google LLC
|
4 | * SPDX-License-Identifier: BSD-3-Clause
|
5 | */
|
6 | import { _$LH as p, noChange, } from './lit-html.js';
|
7 | // Contains either the minified or unminified `_$resolve` Directive method name.
|
8 | let resolveMethodName = null;
|
9 | /**
|
10 | * END USERS SHOULD NOT RELY ON THIS OBJECT.
|
11 | *
|
12 | * We currently do not make a mangled rollup build of the lit-ssr code. In order
|
13 | * to keep a number of (otherwise private) top-level exports mangled in the
|
14 | * client side code, we export a _$LH object containing those members (or
|
15 | * helper methods for accessing private fields of those members), and then
|
16 | * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the
|
17 | * client-side code is being used in `dev` mode or `prod` mode.
|
18 | * @private
|
19 | */
|
20 | export const _$LH = {
|
21 | boundAttributeSuffix: p._boundAttributeSuffix,
|
22 | marker: p._marker,
|
23 | markerMatch: p._markerMatch,
|
24 | HTML_RESULT: p._HTML_RESULT,
|
25 | getTemplateHtml: p._getTemplateHtml,
|
26 | overrideDirectiveResolve: (directiveClass, resolveOverrideFn) => class extends directiveClass {
|
27 | _$resolve(_part, values) {
|
28 | return resolveOverrideFn(this, values);
|
29 | }
|
30 | },
|
31 | patchDirectiveResolve: (directiveClass, resolveOverrideFn) => {
|
32 | if (directiveClass.prototype._$resolve !== resolveOverrideFn) {
|
33 | resolveMethodName ??= directiveClass.prototype._$resolve
|
34 | .name;
|
35 | for (let proto = directiveClass.prototype; proto !== Object.prototype; proto = Object.getPrototypeOf(proto)) {
|
36 | if (proto.hasOwnProperty(resolveMethodName)) {
|
37 | proto[resolveMethodName] = resolveOverrideFn;
|
38 | return;
|
39 | }
|
40 | }
|
41 | // Nothing was patched which indicates an error. The most likely error is
|
42 | // that somehow both minified and unminified lit code passed through this
|
43 | // codepath. This is possible as lit-labs/ssr contains its own lit-html
|
44 | // module as a dependency for server rendering client Lit code. If a
|
45 | // client contains multiple duplicate Lit modules with minified and
|
46 | // unminified exports, we currently cannot handle both.
|
47 | throw new Error(`Internal error: It is possible that both dev mode and production mode` +
|
48 | ` Lit was mixed together during SSR. Please comment on the issue: ` +
|
49 | `https://github.com/lit/lit/issues/4527`);
|
50 | }
|
51 | },
|
52 | setDirectiveClass(value, directiveClass) {
|
53 | // This property needs to remain unminified.
|
54 | value['_$litDirective$'] = directiveClass;
|
55 | },
|
56 | getAttributePartCommittedValue: (part, value, index) => {
|
57 | // Use the part setter to resolve directives/concatenate multiple parts
|
58 | // into a final value (captured by passing in a commitValue override)
|
59 | let committedValue = noChange;
|
60 | // Note that _commitValue need not be in `stableProperties` because this
|
61 | // method is only run on `AttributePart`s created by lit-ssr using the same
|
62 | // version of the library as this file
|
63 | part._commitValue = (value) => (committedValue = value);
|
64 | part._$setValue(value, part, index);
|
65 | return committedValue;
|
66 | },
|
67 | connectedDisconnectable: (props) => ({
|
68 | ...props,
|
69 | _$isConnected: true,
|
70 | }),
|
71 | resolveDirective: p._resolveDirective,
|
72 | AttributePart: p._AttributePart,
|
73 | PropertyPart: p._PropertyPart,
|
74 | BooleanAttributePart: p._BooleanAttributePart,
|
75 | EventPart: p._EventPart,
|
76 | ElementPart: p._ElementPart,
|
77 | TemplateInstance: p._TemplateInstance,
|
78 | isIterable: p._isIterable,
|
79 | ChildPart: p._ChildPart,
|
80 | };
|
81 | //# sourceMappingURL=private-ssr-support.js.map |
\ | No newline at end of file |