[ci] npm run format

This commit is contained in:
natemoo-re 2021-04-15 15:56:27 +00:00 committed by GitHub Actions
parent 22ca9e0aac
commit 2a7aa765b4
10 changed files with 171 additions and 173 deletions

View file

@ -21,10 +21,10 @@ import {
not_equal, not_equal,
transition_in, transition_in,
transition_out, transition_out,
validate_slots validate_slots,
} from "svelte/internal"; } from 'svelte/internal';
const file = "App.svelte"; const file = 'App.svelte';
// (5:0) <Component {...props}> // (5:0) <Component {...props}>
function create_default_slot(ctx) { function create_default_slot(ctx) {
@ -51,15 +51,15 @@ function create_default_slot(ctx) {
d: function destroy(detaching) { d: function destroy(detaching) {
if (detaching) detach_dev(html_anchor); if (detaching) detach_dev(html_anchor);
if (detaching) html_tag.d(); if (detaching) html_tag.d();
} },
}; };
dispatch_dev("SvelteRegisterBlock", { dispatch_dev('SvelteRegisterBlock', {
block, block,
id: create_default_slot.name, id: create_default_slot.name,
type: "slot", type: 'slot',
source: "(5:0) <Component {...props}>", source: '(5:0) <Component {...props}>',
ctx ctx,
}); });
return block; return block;
@ -72,7 +72,7 @@ function create_fragment(ctx) {
let component_props = { let component_props = {
$$slots: { default: [create_default_slot] }, $$slots: { default: [create_default_slot] },
$$scope: { ctx } $$scope: { ctx },
}; };
for (let i = 0; i < component_spread_levels.length; i += 1) { for (let i = 0; i < component_spread_levels.length; i += 1) {
@ -93,9 +93,7 @@ function create_fragment(ctx) {
current = true; current = true;
}, },
p: function update(ctx, [dirty]) { p: function update(ctx, [dirty]) {
const component_changes = (dirty & /*props*/ 4) const component_changes = dirty & /*props*/ 4 ? get_spread_update(component_spread_levels, [get_spread_object(/*props*/ ctx[2])]) : {};
? get_spread_update(component_spread_levels, [get_spread_object(/*props*/ ctx[2])])
: {};
if (dirty & /*$$scope*/ 16) { if (dirty & /*$$scope*/ 16) {
component_changes.$$scope = { dirty, ctx }; component_changes.$$scope = { dirty, ctx };
@ -114,15 +112,15 @@ function create_fragment(ctx) {
}, },
d: function destroy(detaching) { d: function destroy(detaching) {
destroy_component(component, detaching); destroy_component(component, detaching);
} },
}; };
dispatch_dev("SvelteRegisterBlock", { dispatch_dev('SvelteRegisterBlock', {
block, block,
id: create_fragment.name, id: create_fragment.name,
type: "component", type: 'component',
source: "", source: '',
ctx ctx,
}); });
return block; return block;
@ -130,20 +128,20 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {
let { $$slots: slots = {}, $$scope } = $$props; let { $$slots: slots = {}, $$scope } = $$props;
validate_slots("App", slots, []); validate_slots('App', slots, []);
const { __astro_component: Component, __astro_children, ...props } = $$props; const { __astro_component: Component, __astro_children, ...props } = $$props;
$$self.$$set = $$new_props => { $$self.$$set = ($$new_props) => {
$$invalidate(3, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props))); $$invalidate(3, ($$props = assign(assign({}, $$props), exclude_internal_props($$new_props))));
}; };
$$self.$capture_state = () => ({ Component, __astro_children, props }); $$self.$capture_state = () => ({ Component, __astro_children, props });
$$self.$inject_state = $$new_props => { $$self.$inject_state = ($$new_props) => {
$$invalidate(3, $$props = assign(assign({}, $$props), $$new_props)); $$invalidate(3, ($$props = assign(assign({}, $$props), $$new_props)));
}; };
if ($$props && "$$inject" in $$props) { if ($$props && '$$inject' in $$props) {
$$self.$inject_state($$props.$$inject); $$self.$inject_state($$props.$$inject);
} }
@ -156,11 +154,11 @@ class App extends SvelteComponentDev {
super(options); super(options);
init(this, options, instance, create_fragment, not_equal, {}); init(this, options, instance, create_fragment, not_equal, {});
dispatch_dev("SvelteRegisterComponent", { dispatch_dev('SvelteRegisterComponent', {
component: this, component: this,
tagName: "App", tagName: 'App',
options, options,
id: create_fragment.name id: create_fragment.name,
}); });
} }
} }

View file

@ -2,11 +2,11 @@
// @ts-nocheck // @ts-nocheck
// TODO: don't precompile this, but it works for now // TODO: don't precompile this, but it works for now
/* App.svelte generated by Svelte v3.37.0 */ /* App.svelte generated by Svelte v3.37.0 */
import { create_ssr_component, validate_component } from "svelte/internal"; import { create_ssr_component, validate_component } from 'svelte/internal';
const App = create_ssr_component(($$result, $$props, $$bindings, slots) => { const App = create_ssr_component(($$result, $$props, $$bindings, slots) => {
const { __astro_component: Component, __astro_children, ...props } = $$props; const { __astro_component: Component, __astro_children, ...props } = $$props;
return `${validate_component(Component, "Component").$$render($$result, Object.assign(props), {}, { default: () => `${__astro_children}` })}`; return `${validate_component(Component, 'Component').$$render($$result, Object.assign(props), {}, { default: () => `${__astro_children}` })}`;
}); });
export default App; export default App;

View file

@ -13,7 +13,7 @@ const Preact: ComponentRenderer<ComponentType> = {
renderStatic(Component) { renderStatic(Component) {
return async (props, ...children) => { return async (props, ...children) => {
return renderToString(h(Component, props, childrenToVnodes(h, children))); return renderToString(h(Component, props, childrenToVnodes(h, children)));
} };
}, },
imports: { imports: {
preact: ['render', 'Fragment', 'h'], preact: ['render', 'Fragment', 'h'],

View file

@ -10,7 +10,7 @@ const ReactRenderer: ComponentRenderer<ComponentType> = {
renderStatic(Component) { renderStatic(Component) {
return async (props, ...children) => { return async (props, ...children) => {
return ReactDOMServer.renderToString(React.createElement(Component, props, childrenToVnodes(React.createElement, children))); return ReactDOMServer.renderToString(React.createElement(Component, props, childrenToVnodes(React.createElement, children)));
} };
}, },
imports: { imports: {
react: ['default: React'], react: ['default: React'],

View file

@ -40,7 +40,7 @@ export function createRenderer(renderer: SupportedComponentRenderer) {
...innerContext, ...innerContext,
props: serializeProps(props), props: serializeProps(props),
children: `[${childrenToH(renderer, children) ?? ''}]`, children: `[${childrenToH(renderer, children) ?? ''}]`,
childrenAsString: `\`${children}\`` childrenAsString: `\`${children}\``,
})} })}
${typeof wrapperEnd === 'function' ? wrapperEnd(innerContext) : wrapperEnd} ${typeof wrapperEnd === 'function' ? wrapperEnd(innerContext) : wrapperEnd}
`; `;

View file

@ -11,7 +11,7 @@ const SvelteRenderer: ComponentRenderer<SvelteComponent> = {
}; };
}, },
imports: { imports: {
'astro/frontend/runtime/svelte': ['default: render'] 'astro/frontend/runtime/svelte': ['default: render'],
}, },
render({ Component, root, props, childrenAsString }) { render({ Component, root, props, childrenAsString }) {
return `render(${root}, ${Component}, ${props}, ${childrenAsString});`; return `render(${root}, ${Component}, ${props}, ${childrenAsString});`;

View file

@ -6,7 +6,7 @@ import moize from 'moize';
/** @internal */ /** @internal */
function childrenToTree(children: string[]) { function childrenToTree(children: string[]) {
return children.map(child => (unified().use(parse, { fragment: true }).parse(child) as any).children.pop()); return children.map((child) => (unified().use(parse, { fragment: true }).parse(child) as any).children.pop());
} }
/** /**
@ -16,9 +16,9 @@ function childrenToTree(children: string[]) {
*/ */
export const childrenToVnodes = moize.deep(function childrenToVnodes(h: any, children: string[]) { export const childrenToVnodes = moize.deep(function childrenToVnodes(h: any, children: string[]) {
const tree = childrenToTree(children); const tree = childrenToTree(children);
const vnodes = tree.map(subtree => toH(h, subtree)); const vnodes = tree.map((subtree) => toH(h, subtree));
return vnodes; return vnodes;
}) });
/** /**
* Converts an HTML fragment string into h function calls as a string * Converts an HTML fragment string into h function calls as a string
@ -30,18 +30,18 @@ export const childrenToH = moize.deep(function childrenToH(renderer: ComponentRe
const tree = childrenToTree(children); const tree = childrenToTree(children);
const innerH = (name: any, attrs: Record<string, any> | null = null, _children: string[] | null = null) => { const innerH = (name: any, attrs: Record<string, any> | null = null, _children: string[] | null = null) => {
const vnode = renderer.jsxPragma?.(name, attrs, _children); const vnode = renderer.jsxPragma?.(name, attrs, _children);
const childStr = _children ? `, [${_children.map(child => serializeChild(child)).join(',')}]` : ''; const childStr = _children ? `, [${_children.map((child) => serializeChild(child)).join(',')}]` : '';
/* fix(react): avoid hard-coding keys into the serialized tree */ /* fix(react): avoid hard-coding keys into the serialized tree */
if (attrs && attrs.key) attrs.key = undefined; if (attrs && attrs.key) attrs.key = undefined;
const __SERIALIZED = `${renderer.jsxPragmaName}("${name}", ${attrs ? JSON.stringify(attrs) : 'null'}${childStr})` as string; const __SERIALIZED = `${renderer.jsxPragmaName}("${name}", ${attrs ? JSON.stringify(attrs) : 'null'}${childStr})` as string;
return { ...vnode, __SERIALIZED } return { ...vnode, __SERIALIZED };
} };
const serializeChild = (child: unknown) => { const serializeChild = (child: unknown) => {
if (typeof child === 'string') return `\`${child}\``; if (typeof child === 'string') return `\`${child}\``;
if (typeof child === 'number' || typeof child === 'boolean') return `${child}`; if (typeof child === 'number' || typeof child === 'boolean') return `${child}`;
if (child === null) return `null`; if (child === null) return `null`;
if ((child as any).__SERIALIZED) return (child as any).__SERIALIZED; if ((child as any).__SERIALIZED) return (child as any).__SERIALIZED;
return innerH(child).__SERIALIZED; return innerH(child).__SERIALIZED;
} };
return tree.map(subtree => toH(innerH, subtree).__SERIALIZED); return tree.map((subtree) => toH(innerH, subtree).__SERIALIZED);
}) });

View file

@ -31,12 +31,12 @@ const Vue: ComponentRenderer<VueComponent> = {
return async (props, ...children) => { return async (props, ...children) => {
const App = defineComponent({ const App = defineComponent({
components: { components: {
Component Component,
}, },
data() { data() {
return { props } return { props };
}, },
template: `<Component v-bind="props">${children.join('\n')}</Component>` template: `<Component v-bind="props">${children.join('\n')}</Component>`,
}); });
const app = createSSRApp(App); const app = createSSRApp(App);

View file

@ -5,6 +5,6 @@ export default (target: Element, component: SvelteComponent, props: any, childre
new SvelteWrapper({ new SvelteWrapper({
target, target,
props: { __astro_component: component, __astro_children: children, ...props }, props: { __astro_component: component, __astro_children: children, ...props },
hydrate: true hydrate: true,
}) });
} };