@rxdi/lit-html 0.7.156 → 0.7.158

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.
Files changed (95) hide show
  1. package/dist/async.d.ts +3 -3
  2. package/dist/async.js +4 -4
  3. package/dist/decorators/component.decorator.d.ts +1 -2
  4. package/dist/decorators/component.decorator.js +3 -3
  5. package/dist/index.d.ts +28 -17
  6. package/dist/index.js +28 -17
  7. package/package.json +4 -2
  8. package/dist/lit-element/decorators.d.ts +0 -14
  9. package/dist/lit-element/decorators.js +0 -32
  10. package/dist/lit-element/experimental-hydrate-support.d.ts +0 -6
  11. package/dist/lit-element/experimental-hydrate-support.js +0 -65
  12. package/dist/lit-element/index.d.ts +0 -7
  13. package/dist/lit-element/index.js +0 -25
  14. package/dist/lit-element/lit-element.d.ts +0 -157
  15. package/dist/lit-element/lit-element.js +0 -258
  16. package/dist/lit-element/polyfill-support.d.ts +0 -24
  17. package/dist/lit-element/polyfill-support.js +0 -58
  18. package/dist/lit-element/private-ssr-support.d.ts +0 -21
  19. package/dist/lit-element/private-ssr-support.js +0 -25
  20. package/dist/lit-html/async-directive.d.ts +0 -170
  21. package/dist/lit-html/async-directive.js +0 -250
  22. package/dist/lit-html/directive-helpers.d.ts +0 -105
  23. package/dist/lit-html/directive-helpers.js +0 -192
  24. package/dist/lit-html/directive.d.ts +0 -65
  25. package/dist/lit-html/directive.js +0 -52
  26. package/dist/lit-html/directives/async-append.d.ts +0 -38
  27. package/dist/lit-html/directives/async-append.js +0 -55
  28. package/dist/lit-html/directives/async-replace.d.ts +0 -39
  29. package/dist/lit-html/directives/async-replace.js +0 -112
  30. package/dist/lit-html/directives/cache.d.ts +0 -34
  31. package/dist/lit-html/directives/cache.js +0 -80
  32. package/dist/lit-html/directives/class-map.d.ts +0 -44
  33. package/dist/lit-html/directives/class-map.js +0 -92
  34. package/dist/lit-html/directives/guard.d.ts +0 -59
  35. package/dist/lit-html/directives/guard.js +0 -82
  36. package/dist/lit-html/directives/if-defined.d.ts +0 -13
  37. package/dist/lit-html/directives/if-defined.js +0 -17
  38. package/dist/lit-html/directives/live.d.ts +0 -42
  39. package/dist/lit-html/directives/live.js +0 -79
  40. package/dist/lit-html/directives/private-async-helpers.d.ts +0 -57
  41. package/dist/lit-html/directives/private-async-helpers.js +0 -117
  42. package/dist/lit-html/directives/ref.d.ts +0 -65
  43. package/dist/lit-html/directives/ref.js +0 -113
  44. package/dist/lit-html/directives/repeat.d.ts +0 -63
  45. package/dist/lit-html/directives/repeat.js +0 -416
  46. package/dist/lit-html/directives/style-map.d.ts +0 -46
  47. package/dist/lit-html/directives/style-map.js +0 -102
  48. package/dist/lit-html/directives/template-content.d.ts +0 -25
  49. package/dist/lit-html/directives/template-content.js +0 -33
  50. package/dist/lit-html/directives/unsafe-html.d.ts +0 -26
  51. package/dist/lit-html/directives/unsafe-html.js +0 -64
  52. package/dist/lit-html/directives/unsafe-svg.d.ts +0 -26
  53. package/dist/lit-html/directives/unsafe-svg.js +0 -26
  54. package/dist/lit-html/directives/until.d.ts +0 -43
  55. package/dist/lit-html/directives/until.js +0 -137
  56. package/dist/lit-html/experimental-hydrate.d.ts +0 -50
  57. package/dist/lit-html/experimental-hydrate.js +0 -322
  58. package/dist/lit-html/lit-html.d.ts +0 -335
  59. package/dist/lit-html/lit-html.js +0 -1259
  60. package/dist/lit-html/polyfill-support.d.ts +0 -67
  61. package/dist/lit-html/polyfill-support.js +0 -185
  62. package/dist/lit-html/private-ssr-support.d.ts +0 -52
  63. package/dist/lit-html/private-ssr-support.js +0 -54
  64. package/dist/lit-html/static.d.ts +0 -58
  65. package/dist/lit-html/static.js +0 -114
  66. package/dist/reactive-element/css-tag.d.ts +0 -64
  67. package/dist/reactive-element/css-tag.js +0 -125
  68. package/dist/reactive-element/decorators/base.d.ts +0 -47
  69. package/dist/reactive-element/decorators/base.js +0 -70
  70. package/dist/reactive-element/decorators/custom-element.d.ts +0 -26
  71. package/dist/reactive-element/decorators/custom-element.js +0 -47
  72. package/dist/reactive-element/decorators/event-options.d.ts +0 -37
  73. package/dist/reactive-element/decorators/event-options.js +0 -47
  74. package/dist/reactive-element/decorators/index.d.ts +0 -14
  75. package/dist/reactive-element/decorators/index.js +0 -32
  76. package/dist/reactive-element/decorators/property.d.ts +0 -40
  77. package/dist/reactive-element/decorators/property.js +0 -92
  78. package/dist/reactive-element/decorators/query-all.d.ts +0 -31
  79. package/dist/reactive-element/decorators/query-all.js +0 -46
  80. package/dist/reactive-element/decorators/query-assigned-nodes.d.ts +0 -33
  81. package/dist/reactive-element/decorators/query-assigned-nodes.js +0 -55
  82. package/dist/reactive-element/decorators/query-async.d.ts +0 -39
  83. package/dist/reactive-element/decorators/query-async.js +0 -71
  84. package/dist/reactive-element/decorators/query.d.ts +0 -32
  85. package/dist/reactive-element/decorators/query.js +0 -60
  86. package/dist/reactive-element/decorators/state.d.ts +0 -24
  87. package/dist/reactive-element/decorators/state.js +0 -29
  88. package/dist/reactive-element/index.d.ts +0 -5
  89. package/dist/reactive-element/index.js +0 -17
  90. package/dist/reactive-element/polyfill-support.d.ts +0 -40
  91. package/dist/reactive-element/polyfill-support.js +0 -89
  92. package/dist/reactive-element/reactive-controller.d.ts +0 -76
  93. package/dist/reactive-element/reactive-controller.js +0 -7
  94. package/dist/reactive-element/reactive-element.d.ts +0 -653
  95. package/dist/reactive-element/reactive-element.js +0 -979
@@ -1,67 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- /**
7
- * lit-html patch to support browsers without native web components.
8
- *
9
- * This module should be used in addition to loading the web components
10
- * polyfills via @webcomponents/webcomponentjs. When using those polyfills
11
- * support for polyfilled Shadow DOM is automatic via the ShadyDOM polyfill.
12
- * Scoping classes are added to DOM nodes to facilitate CSS scoping that
13
- * simulates the style scoping Shadow DOM provides. ShadyDOM does this scoping
14
- * to all elements added to the DOM. This module provides an important
15
- * optimization for this process by pre-scoping lit-html template
16
- * DOM. This means ShadyDOM does not have to scope each instance of the
17
- * template DOM. Instead, each template is scoped only once.
18
- *
19
- * Creating scoped CSS is not covered by this module. It is, however, integrated
20
- * into the lit-element and @lit/reactive-element packages. See the ShadyCSS docs
21
- * for how to apply scoping to CSS:
22
- * https://github.com/webcomponents/polyfills/tree/master/packages/shadycss#usage.
23
- *
24
- * @packageDocumentation
25
- */
26
- interface RenderOptions {
27
- readonly renderBefore?: ChildNode | null;
28
- scope?: string;
29
- }
30
- interface ShadyTemplateResult {
31
- strings: TemplateStringsArray;
32
- ['_$litType$']?: string;
33
- }
34
- interface Directive {
35
- __directive?: Directive;
36
- }
37
- interface DirectiveParent {
38
- _$parent?: DirectiveParent;
39
- __directive?: Directive;
40
- __directives?: Array<Directive | undefined>;
41
- }
42
- interface PatchableChildPartConstructor {
43
- new (...args: any[]): PatchableChildPart;
44
- }
45
- interface PatchableChildPart {
46
- __directive?: Directive;
47
- _$committedValue: unknown;
48
- _$startNode: ChildNode;
49
- _$endNode: ChildNode | null;
50
- options: RenderOptions;
51
- _$setValue(value: unknown, directiveParent: DirectiveParent): void;
52
- _$getTemplate(result: ShadyTemplateResult): HTMLTemplateElement;
53
- }
54
- interface PatchableTemplate {
55
- el: HTMLTemplateElement;
56
- }
57
- interface PatchableTemplateConstructor {
58
- new (...args: any[]): PatchableTemplate;
59
- createElement(html: string, options?: RenderOptions): HTMLTemplateElement;
60
- }
61
- interface PatchableTemplateInstance {
62
- _$template: PatchableTemplate;
63
- }
64
- declare const styledScopes: Set<string>;
65
- declare const scopeCssStore: Map<string, string[]>;
66
- declare const ENABLE_SHADYDOM_NOPATCH = true;
67
- declare var DEV_MODE: boolean;
@@ -1,185 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- var _a;
7
- var _b;
8
- // Scopes that have had styling prepared. Note, must only be done once per
9
- // scope.
10
- const styledScopes = new Set();
11
- // Map of css per scope. This is collected during first scope render, used when
12
- // styling is prepared, and then discarded.
13
- const scopeCssStore = new Map();
14
- const ENABLE_SHADYDOM_NOPATCH = true;
15
- // Note, explicitly use `var` here so that this can be re-defined when
16
- // bundled.
17
- // eslint-disable-next-line no-var
18
- var DEV_MODE = true;
19
- /**
20
- * lit-html patches. These properties cannot be renamed.
21
- * * ChildPart.prototype._$getTemplate
22
- * * ChildPart.prototype._$setValue
23
- */
24
- (_a = globalThis[_b = `litHtmlPolyfillSupport${DEV_MODE ? `DevMode` : ``}`]) !== null && _a !== void 0 ? _a : (globalThis[_b] = (Template, ChildPart) => {
25
- var _a, _b;
26
- // polyfill-support is only needed if ShadyCSS or the ApplyShim is in use
27
- // We test at the point of patching, which makes it safe to load
28
- // webcomponentsjs and polyfill-support in either order
29
- if (window.ShadyCSS === undefined ||
30
- (window.ShadyCSS.nativeShadow && !window.ShadyCSS.ApplyShim)) {
31
- return;
32
- }
33
- // console.log(
34
- // '%c Making lit-html compatible with ShadyDOM/CSS.',
35
- // 'color: lightgreen; font-style: italic'
36
- // );
37
- const wrap = ENABLE_SHADYDOM_NOPATCH &&
38
- ((_a = window.ShadyDOM) === null || _a === void 0 ? void 0 : _a.inUse) &&
39
- ((_b = window.ShadyDOM) === null || _b === void 0 ? void 0 : _b.noPatch) === true
40
- ? window.ShadyDOM.wrap
41
- : (node) => node;
42
- const needsPrepareStyles = (name) => name !== undefined && !styledScopes.has(name);
43
- const cssForScope = (name) => {
44
- let scopeCss = scopeCssStore.get(name);
45
- if (scopeCss === undefined) {
46
- scopeCssStore.set(name, (scopeCss = []));
47
- }
48
- return scopeCss;
49
- };
50
- const prepareStyles = (name, template) => {
51
- // Get styles
52
- const scopeCss = cssForScope(name);
53
- const hasScopeCss = scopeCss.length !== 0;
54
- if (hasScopeCss) {
55
- const style = document.createElement('style');
56
- style.textContent = scopeCss.join('\n');
57
- // Note, it's important to add the style to the *end* of the template so
58
- // it doesn't mess up part indices.
59
- template.content.appendChild(style);
60
- }
61
- // Mark this scope as styled.
62
- styledScopes.add(name);
63
- // Remove stored data since it's no longer needed.
64
- scopeCssStore.delete(name);
65
- // ShadyCSS removes scopes and removes the style under ShadyDOM and leaves
66
- // it under native Shadow DOM
67
- window.ShadyCSS.prepareTemplateStyles(template, name);
68
- // Note, under native Shadow DOM, the style is added to the beginning of the
69
- // template. It must be moved to the *end* of the template so it doesn't
70
- // mess up part indices.
71
- if (hasScopeCss && window.ShadyCSS.nativeShadow) {
72
- // If there were styles but the CSS text was empty, ShadyCSS will
73
- // eliminate the style altogether, so the style here could be null
74
- const style = template.content.querySelector('style');
75
- if (style !== null) {
76
- template.content.appendChild(style);
77
- }
78
- }
79
- };
80
- const scopedTemplateCache = new Map();
81
- /**
82
- * Override to extract style elements from the template
83
- * and store all style.textContent in the shady scope data.
84
- * Note, it's ok to patch Template since it's only used via ChildPart.
85
- */
86
- const originalCreateElement = Template.createElement;
87
- Template.createElement = function (html, options) {
88
- const element = originalCreateElement.call(Template, html, options);
89
- const scope = options === null || options === void 0 ? void 0 : options.scope;
90
- if (scope !== undefined) {
91
- if (!window.ShadyCSS.nativeShadow) {
92
- window.ShadyCSS.prepareTemplateDom(element, scope);
93
- }
94
- // Process styles only if this scope is being prepared. Otherwise,
95
- // leave styles as is for back compat with Lit1.
96
- if (needsPrepareStyles(scope)) {
97
- const scopeCss = cssForScope(scope);
98
- // Remove styles and store textContent.
99
- const styles = element.content.querySelectorAll('style');
100
- // Store the css in this template in the scope css and remove the <style>
101
- // from the template _before_ the node-walk captures part indices
102
- scopeCss.push(...Array.from(styles).map((style) => {
103
- var _a;
104
- (_a = style.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(style);
105
- return style.textContent;
106
- }));
107
- }
108
- }
109
- return element;
110
- };
111
- const renderContainer = document.createDocumentFragment();
112
- const renderContainerMarker = document.createComment('');
113
- const childPartProto = ChildPart.prototype;
114
- /**
115
- * Patch to apply gathered css via ShadyCSS. This is done only once per scope.
116
- */
117
- const setValue = childPartProto._$setValue;
118
- childPartProto._$setValue = function (value, directiveParent = this) {
119
- var _a, _b, _c;
120
- const container = wrap(this._$startNode).parentNode;
121
- const scope = (_a = this.options) === null || _a === void 0 ? void 0 : _a.scope;
122
- if (container instanceof ShadowRoot && needsPrepareStyles(scope)) {
123
- // Note, @apply requires outer => inner scope rendering on initial
124
- // scope renders to apply property values correctly. Style preparation
125
- // is tied to rendering into `shadowRoot`'s and this is typically done by
126
- // custom elements. If this is done in `connectedCallback`, as is typical,
127
- // the code below ensures the right order since content is rendered
128
- // into a fragment first so the hosting element can prepare styles first.
129
- // If rendering is done in the constructor, this won't work, but that's
130
- // not supported in ShadyDOM anyway.
131
- const startNode = this._$startNode;
132
- const endNode = this._$endNode;
133
- // Temporarily move this part into the renderContainer.
134
- renderContainer.appendChild(renderContainerMarker);
135
- this._$startNode = renderContainerMarker;
136
- this._$endNode = null;
137
- // Note, any nested template results render here and their styles will
138
- // be extracted and collected.
139
- setValue.call(this, value, directiveParent);
140
- // Get the template for this result or create a dummy one if a result
141
- // is not being rendered.
142
- // This property needs to remain unminified.
143
- const template = ((_b = value) === null || _b === void 0 ? void 0 : _b['_$litType$'])
144
- ? this._$committedValue._$template.el
145
- : document.createElement('template');
146
- prepareStyles(scope, template);
147
- // Note, this is the temporary startNode.
148
- renderContainer.removeChild(renderContainerMarker);
149
- // When using native Shadow DOM, include prepared style in shadowRoot.
150
- if ((_c = window.ShadyCSS) === null || _c === void 0 ? void 0 : _c.nativeShadow) {
151
- const style = template.content.querySelector('style');
152
- if (style !== null) {
153
- renderContainer.appendChild(style.cloneNode(true));
154
- }
155
- }
156
- container.insertBefore(renderContainer, endNode);
157
- // Move part back to original container.
158
- this._$startNode = startNode;
159
- this._$endNode = endNode;
160
- }
161
- else {
162
- setValue.call(this, value, directiveParent);
163
- }
164
- };
165
- /**
166
- * Patch ChildPart._$getTemplate to look up templates in a cache bucketed
167
- * by element name.
168
- */
169
- childPartProto._$getTemplate = function (result) {
170
- var _a;
171
- const scope = (_a = this.options) === null || _a === void 0 ? void 0 : _a.scope;
172
- let templateCache = scopedTemplateCache.get(scope);
173
- if (templateCache === undefined) {
174
- scopedTemplateCache.set(scope, (templateCache = new Map()));
175
- }
176
- let template = templateCache.get(result.strings);
177
- if (template === undefined) {
178
- templateCache.set(result.strings, (template = new Template(result, this.options)));
179
- }
180
- return template;
181
- };
182
- });
183
- if (ENABLE_SHADYDOM_NOPATCH) {
184
- globalThis[`litHtmlPolyfillSupport${DEV_MODE ? `DevMode` : ``}`].noPatchSupported = ENABLE_SHADYDOM_NOPATCH;
185
- }
@@ -1,52 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- import { Directive, PartInfo, DirectiveClass, DirectiveResult } from './directive';
7
- import { AttributePart, Part, Disconnectable } from './lit-html';
8
- export type { Template } from './lit-html';
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 declare const _$LH: {
21
- boundAttributeSuffix: string;
22
- marker: string;
23
- markerMatch: string;
24
- HTML_RESULT: number;
25
- getTemplateHtml: (strings: TemplateStringsArray, type: 1 | 2) => [any, string[]];
26
- overrideDirectiveResolve: (directiveClass: new (part: PartInfo) => Directive & {
27
- render(): unknown;
28
- }, resolveOverrideFn: (directive: Directive, values: unknown[]) => unknown) => {
29
- new (part: PartInfo): {
30
- _$resolve(this: Directive, _part: Part, values: unknown[]): unknown;
31
- __part: Part;
32
- __attributeIndex: number;
33
- __directive?: Directive;
34
- _$parent: Disconnectable;
35
- _$disconnectableChildren?: Set<Disconnectable>;
36
- _$notifyDirectiveConnectionChanged?(isConnected: boolean): void;
37
- readonly _$isConnected: boolean;
38
- _$initialize(part: Part, parent: Disconnectable, attributeIndex: number): void;
39
- render: ((...props: unknown[]) => unknown) & (() => unknown);
40
- update(_part: Part, props: unknown[]): unknown;
41
- };
42
- };
43
- setDirectiveClass(value: DirectiveResult, directiveClass: DirectiveClass): void;
44
- getAttributePartCommittedValue: (part: AttributePart, value: unknown, index: number | undefined) => unknown;
45
- connectedDisconnectable: (props?: object) => Disconnectable;
46
- resolveDirective: (part: import("./lit-html").ChildPart | AttributePart | import("./lit-html").ElementPart, value: unknown, parent?: import("./lit-html").DirectiveParent, attributeIndex?: number) => unknown;
47
- AttributePart: typeof AttributePart;
48
- PropertyPart: typeof import("./lit-html").PropertyPart;
49
- BooleanAttributePart: typeof import("./lit-html").BooleanAttributePart;
50
- EventPart: typeof import("./lit-html").EventPart;
51
- ElementPart: typeof import("./lit-html").ElementPart;
52
- };
@@ -1,54 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright 2019 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports._$LH = void 0;
9
- const lit_html_1 = require("./lit-html");
10
- /**
11
- * END USERS SHOULD NOT RELY ON THIS OBJECT.
12
- *
13
- * We currently do not make a mangled rollup build of the lit-ssr code. In order
14
- * to keep a number of (otherwise private) top-level exports mangled in the
15
- * client side code, we export a _$LH object containing those members (or
16
- * helper methods for accessing private fields of those members), and then
17
- * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the
18
- * client-side code is being used in `dev` mode or `prod` mode.
19
- * @private
20
- */
21
- exports._$LH = {
22
- boundAttributeSuffix: lit_html_1._$LH._boundAttributeSuffix,
23
- marker: lit_html_1._$LH._marker,
24
- markerMatch: lit_html_1._$LH._markerMatch,
25
- HTML_RESULT: lit_html_1._$LH._HTML_RESULT,
26
- getTemplateHtml: lit_html_1._$LH._getTemplateHtml,
27
- overrideDirectiveResolve: (directiveClass, resolveOverrideFn) => class extends directiveClass {
28
- _$resolve(_part, values) {
29
- return resolveOverrideFn(this, values);
30
- }
31
- },
32
- setDirectiveClass(value, directiveClass) {
33
- // This property needs to remain unminified.
34
- value['_$litDirective$'] = directiveClass;
35
- },
36
- getAttributePartCommittedValue: (part, value, index) => {
37
- // Use the part setter to resolve directives/concatenate multiple parts
38
- // into a final value (captured by passing in a commitValue override)
39
- let committedValue = lit_html_1.noChange;
40
- // Note that _commitValue need not be in `stableProperties` because this
41
- // method is only run on `AttributePart`s created by lit-ssr using the same
42
- // version of the library as this file
43
- part._commitValue = (value) => (committedValue = value);
44
- part._$setValue(value, part, index);
45
- return committedValue;
46
- },
47
- connectedDisconnectable: (props) => (Object.assign(Object.assign({}, props), { _$isConnected: true })),
48
- resolveDirective: lit_html_1._$LH._resolveDirective,
49
- AttributePart: lit_html_1._$LH._AttributePart,
50
- PropertyPart: lit_html_1._$LH._PropertyPart,
51
- BooleanAttributePart: lit_html_1._$LH._BooleanAttributePart,
52
- EventPart: lit_html_1._$LH._EventPart,
53
- ElementPart: lit_html_1._$LH._ElementPart,
54
- };
@@ -1,58 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2020 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- import { html as coreHtml, svg as coreSvg, TemplateResult } from './lit-html';
7
- /**
8
- * Wraps a string so that it behaves like part of the static template
9
- * strings instead of a dynamic value.
10
- *
11
- * Users must take care to ensure that adding the static string to the template
12
- * results in well-formed HTML, or else templates may break unexpectedly.
13
- *
14
- * Note that this function is unsafe to use on untrusted content, as it will be
15
- * directly parsed into HTML. Do not pass user input to this function
16
- * without sanitizing it.
17
- *
18
- * Static values can be changed, but they will cause a complete re-render
19
- * since they effectively create a new template.
20
- */
21
- export declare const unsafeStatic: (value: string) => {
22
- _$litStatic$: string;
23
- };
24
- /**
25
- * Tags a string literal so that it behaves like part of the static template
26
- * strings instead of a dynamic value.
27
- *
28
- * The only values that may be used in template expressions are other tagged
29
- * `literal` results or `unsafeStatic` values (note that untrusted content
30
- * should never be passed to `unsafeStatic`).
31
- *
32
- * Users must take care to ensure that adding the static string to the template
33
- * results in well-formed HTML, or else templates may break unexpectedly.
34
- *
35
- * Static values can be changed, but they will cause a complete re-render since
36
- * they effectively create a new template.
37
- */
38
- export declare const literal: (strings: TemplateStringsArray, ...values: unknown[]) => {
39
- _$litStatic$: unknown;
40
- };
41
- /**
42
- * Wraps a lit-html template tag (`html` or `svg`) to add static value support.
43
- */
44
- export declare const withStatic: (coreTag: typeof coreHtml | typeof coreSvg) => (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult;
45
- /**
46
- * Interprets a template literal as an HTML template that can efficiently
47
- * render to and update a container.
48
- *
49
- * Includes static value support from `lit-html/static`.
50
- */
51
- export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult;
52
- /**
53
- * Interprets a template literal as an SVG template that can efficiently
54
- * render to and update a container.
55
- *
56
- * Includes static value support from `lit-html/static`.
57
- */
58
- export declare const svg: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult;
@@ -1,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.svg = exports.html = exports.withStatic = exports.literal = exports.unsafeStatic = void 0;
4
- /**
5
- * @license
6
- * Copyright 2020 Google LLC
7
- * SPDX-License-Identifier: BSD-3-Clause
8
- */
9
- const lit_html_1 = require("./lit-html");
10
- /**
11
- * Wraps a string so that it behaves like part of the static template
12
- * strings instead of a dynamic value.
13
- *
14
- * Users must take care to ensure that adding the static string to the template
15
- * results in well-formed HTML, or else templates may break unexpectedly.
16
- *
17
- * Note that this function is unsafe to use on untrusted content, as it will be
18
- * directly parsed into HTML. Do not pass user input to this function
19
- * without sanitizing it.
20
- *
21
- * Static values can be changed, but they will cause a complete re-render
22
- * since they effectively create a new template.
23
- */
24
- const unsafeStatic = (value) => ({
25
- ['_$litStatic$']: value,
26
- });
27
- exports.unsafeStatic = unsafeStatic;
28
- const textFromStatic = (value) => {
29
- if (value['_$litStatic$'] !== undefined) {
30
- return value['_$litStatic$'];
31
- }
32
- else {
33
- throw new Error(`Value passed to 'literal' function must be a 'literal' result: ${value}. Use 'unsafeStatic' to pass non-literal values, but
34
- take care to ensure page security.`);
35
- }
36
- };
37
- /**
38
- * Tags a string literal so that it behaves like part of the static template
39
- * strings instead of a dynamic value.
40
- *
41
- * The only values that may be used in template expressions are other tagged
42
- * `literal` results or `unsafeStatic` values (note that untrusted content
43
- * should never be passed to `unsafeStatic`).
44
- *
45
- * Users must take care to ensure that adding the static string to the template
46
- * results in well-formed HTML, or else templates may break unexpectedly.
47
- *
48
- * Static values can be changed, but they will cause a complete re-render since
49
- * they effectively create a new template.
50
- */
51
- const literal = (strings, ...values) => ({
52
- ['_$litStatic$']: values.reduce((acc, v, idx) => acc + textFromStatic(v) + strings[idx + 1], strings[0]),
53
- });
54
- exports.literal = literal;
55
- const stringsCache = new Map();
56
- /**
57
- * Wraps a lit-html template tag (`html` or `svg`) to add static value support.
58
- */
59
- const withStatic = (coreTag) => (strings, ...values) => {
60
- var _a;
61
- const l = values.length;
62
- let staticValue;
63
- let dynamicValue;
64
- const staticStrings = [];
65
- const dynamicValues = [];
66
- let i = 0;
67
- let hasStatics = false;
68
- let s;
69
- while (i < l) {
70
- s = strings[i];
71
- // Collect any unsafeStatic values, and their following template strings
72
- // so that we treat a run of template strings and unsafe static values as
73
- // a single template string.
74
- while (i < l &&
75
- ((dynamicValue = values[i]),
76
- (staticValue = (_a = dynamicValue) === null || _a === void 0 ? void 0 : _a['_$litStatic$'])) !==
77
- undefined) {
78
- s += staticValue + strings[++i];
79
- hasStatics = true;
80
- }
81
- dynamicValues.push(dynamicValue);
82
- staticStrings.push(s);
83
- i++;
84
- }
85
- // If the last value isn't static (which would have consumed the last
86
- // string), then we need to add the last string.
87
- if (i === l) {
88
- staticStrings.push(strings[l]);
89
- }
90
- if (hasStatics) {
91
- const key = staticStrings.join('$$lit$$');
92
- strings = stringsCache.get(key);
93
- if (strings === undefined) {
94
- stringsCache.set(key, (strings = staticStrings));
95
- }
96
- values = dynamicValues;
97
- }
98
- return coreTag(strings, ...values);
99
- };
100
- exports.withStatic = withStatic;
101
- /**
102
- * Interprets a template literal as an HTML template that can efficiently
103
- * render to and update a container.
104
- *
105
- * Includes static value support from `lit-html/static`.
106
- */
107
- exports.html = (0, exports.withStatic)(lit_html_1.html);
108
- /**
109
- * Interprets a template literal as an SVG template that can efficiently
110
- * render to and update a container.
111
- *
112
- * Includes static value support from `lit-html/static`.
113
- */
114
- exports.svg = (0, exports.withStatic)(lit_html_1.svg);
@@ -1,64 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- /**
7
- * Whether the current browser supports `adoptedStyleSheets`.
8
- */
9
- export declare const supportsAdoptingStyleSheets: boolean;
10
- /**
11
- * A CSSResult or native CSSStyleSheet.
12
- *
13
- * In browsers that support constructible CSS style sheets, CSSStyleSheet
14
- * object can be used for styling along side CSSResult from the `css`
15
- * template tag.
16
- */
17
- export declare type CSSResultOrNative = CSSResult | CSSStyleSheet;
18
- export declare type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;
19
- /**
20
- * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.
21
- */
22
- export declare type CSSResultGroup = CSSResultOrNative | CSSResultArray;
23
- /**
24
- * A container for a string of CSS text, that may be used to create a CSSStyleSheet.
25
- *
26
- * CSSResult is the return value of `css`-tagged template literals and
27
- * `unsafeCSS()`. In order to ensure that CSSResults are only created via the
28
- * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.
29
- */
30
- export declare class CSSResult {
31
- ['_$cssResult$']: boolean;
32
- readonly cssText: string;
33
- private constructor();
34
- get styleSheet(): CSSStyleSheet | undefined;
35
- toString(): string;
36
- }
37
- /**
38
- * Wrap a value for interpolation in a [[`css`]] tagged template literal.
39
- *
40
- * This is unsafe because untrusted CSS text can be used to phone home
41
- * or exfiltrate data to an attacker controlled site. Take care to only use
42
- * this with trusted input.
43
- */
44
- export declare const unsafeCSS: (value: unknown) => CSSResult;
45
- /**
46
- * A template literal tag which can be used with LitElement's
47
- * [[LitElement.styles | `styles`]] property to set element styles.
48
- *
49
- * For security reasons, only literal string values and number may be used in
50
- * embedded expressions. To incorporate non-literal values [[`unsafeCSS`]] may
51
- * be used inside an expression.
52
- */
53
- export declare const css: (strings: TemplateStringsArray, ...values: (CSSResultGroup | number)[]) => CSSResult;
54
- /**
55
- * Applies the given styles to a `shadowRoot`. When Shadow DOM is
56
- * available but `adoptedStyleSheets` is not, styles are appended to the
57
- * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).
58
- * Note, when shimming is used, any styles that are subsequently placed into
59
- * the shadowRoot should be placed *before* any shimmed adopted styles. This
60
- * will match spec behavior that gives adopted sheets precedence over styles in
61
- * shadowRoot.
62
- */
63
- export declare const adoptStyles: (renderRoot: ShadowRoot, styles: Array<CSSResultOrNative>) => void;
64
- export declare const getCompatibleStyle: (s: CSSResultOrNative) => CSSResultOrNative;