@ecopages/lit 0.2.0-beta.31 → 0.2.0-beta.32

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.
@@ -1,52 +1,45 @@
1
- import { render } from "@lit-labs/ssr";
2
- import { html as staticHtml, unsafeStatic } from "lit/static-html.js";
3
- const LIT_HTML_TEMPLATE_SLOT_MARKER = "<--content-->";
4
- const LIT_COMPONENT_CHILDREN_SLOT_MARKER = "<!--eco-lit-component-children-->";
5
- const ESCAPED_COMPONENT_CHILDREN_SLOT_MARKER = "&lt;!--eco-lit-component-children--&gt;";
6
- const DOUBLE_ESCAPED_COMPONENT_CHILDREN_SLOT_MARKER = "&amp;lt;!--eco-lit-component-children--&amp;gt;";
1
+ import { render } from '@lit-labs/ssr';
2
+ import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
3
+ export const LIT_HTML_TEMPLATE_SLOT_MARKER = '<--content-->';
4
+ export const LIT_COMPONENT_CHILDREN_SLOT_MARKER = '<!--eco-lit-component-children-->';
5
+ const ESCAPED_COMPONENT_CHILDREN_SLOT_MARKER = '&lt;!--eco-lit-component-children--&gt;';
6
+ const DOUBLE_ESCAPED_COMPONENT_CHILDREN_SLOT_MARKER = '&amp;lt;!--eco-lit-component-children--&amp;gt;';
7
7
  const DUPLICATE_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE = /\sshadowroot=(['"])(open|closed)\1(?=\sshadowrootmode=\1\2\1)/g;
8
- function normalizeLitHtml(markup) {
9
- return markup.replace(DUPLICATE_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, "");
8
+ export function normalizeLitHtml(markup) {
9
+ return markup.replace(DUPLICATE_DECLARATIVE_SHADOW_ROOT_ATTRIBUTE, '');
10
10
  }
11
- function injectLitRenderedChildren(template, renderedChildren) {
12
- for (const marker of [
13
- LIT_COMPONENT_CHILDREN_SLOT_MARKER,
14
- ESCAPED_COMPONENT_CHILDREN_SLOT_MARKER,
15
- DOUBLE_ESCAPED_COMPONENT_CHILDREN_SLOT_MARKER
16
- ]) {
17
- if (template.includes(marker)) {
18
- return template.split(marker).join(renderedChildren);
11
+ export function injectLitRenderedChildren(template, renderedChildren) {
12
+ for (const marker of [
13
+ LIT_COMPONENT_CHILDREN_SLOT_MARKER,
14
+ ESCAPED_COMPONENT_CHILDREN_SLOT_MARKER,
15
+ DOUBLE_ESCAPED_COMPONENT_CHILDREN_SLOT_MARKER,
16
+ ]) {
17
+ if (template.includes(marker)) {
18
+ return template.split(marker).join(renderedChildren);
19
+ }
19
20
  }
20
- }
21
- if (template.includes(LIT_HTML_TEMPLATE_SLOT_MARKER)) {
22
- return template.split(LIT_HTML_TEMPLATE_SLOT_MARKER).join(renderedChildren);
23
- }
24
- if (template.includes("</body>")) {
25
- return template.replace("</body>", `${renderedChildren}</body>`);
26
- }
27
- if (template.includes("</html>")) {
28
- return template.replace("</html>", `${renderedChildren}</html>`);
29
- }
30
- return `${template}${renderedChildren}`;
21
+ if (template.includes(LIT_HTML_TEMPLATE_SLOT_MARKER)) {
22
+ return template.split(LIT_HTML_TEMPLATE_SLOT_MARKER).join(renderedChildren);
23
+ }
24
+ if (template.includes('</body>')) {
25
+ return template.replace('</body>', `${renderedChildren}</body>`);
26
+ }
27
+ if (template.includes('</html>')) {
28
+ return template.replace('</html>', `${renderedChildren}</html>`);
29
+ }
30
+ return `${template}${renderedChildren}`;
31
31
  }
32
- async function renderLitValueToString(value) {
33
- if (typeof value === "string") {
34
- let renderedHtml2 = "";
35
- for (const chunk of render(staticHtml`${unsafeStatic(value)}`)) {
36
- renderedHtml2 += chunk;
32
+ export async function renderLitValueToString(value) {
33
+ if (typeof value === 'string') {
34
+ let renderedHtml = '';
35
+ for (const chunk of render(staticHtml `${unsafeStatic(value)}`)) {
36
+ renderedHtml += chunk;
37
+ }
38
+ return normalizeLitHtml(renderedHtml);
39
+ }
40
+ let renderedHtml = '';
41
+ for (const chunk of render(value)) {
42
+ renderedHtml += chunk;
37
43
  }
38
- return normalizeLitHtml(renderedHtml2);
39
- }
40
- let renderedHtml = "";
41
- for (const chunk of render(value)) {
42
- renderedHtml += chunk;
43
- }
44
- return normalizeLitHtml(renderedHtml);
44
+ return normalizeLitHtml(renderedHtml);
45
45
  }
46
- export {
47
- LIT_COMPONENT_CHILDREN_SLOT_MARKER,
48
- LIT_HTML_TEMPLATE_SLOT_MARKER,
49
- injectLitRenderedChildren,
50
- normalizeLitHtml,
51
- renderLitValueToString
52
- };