[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

@ -2,167 +2,165 @@
// @ts-nocheck // @ts-nocheck
// TODO: don't precompile this, but it works for now // TODO: don't precompile this, but it works for now
import { import {
HtmlTag, HtmlTag,
SvelteComponentDev, SvelteComponentDev,
assign, assign,
claim_component, claim_component,
create_component, create_component,
destroy_component, destroy_component,
detach_dev, detach_dev,
dispatch_dev, dispatch_dev,
empty, empty,
exclude_internal_props, exclude_internal_props,
get_spread_object, get_spread_object,
get_spread_update, get_spread_update,
init, init,
insert_dev, insert_dev,
mount_component, mount_component,
noop, noop,
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) {
let html_tag; let html_tag;
let html_anchor; let html_anchor;
const block = { const block = {
c: function create() { c: function create() {
html_anchor = empty(); html_anchor = empty();
this.h(); this.h();
}, },
l: function claim(nodes) { l: function claim(nodes) {
html_anchor = empty(); html_anchor = empty();
this.h(); this.h();
}, },
h: function hydrate() { h: function hydrate() {
html_tag = new HtmlTag(html_anchor); html_tag = new HtmlTag(html_anchor);
}, },
m: function mount(target, anchor) { m: function mount(target, anchor) {
html_tag.m(/*__astro_children*/ ctx[1], target, anchor); html_tag.m(/*__astro_children*/ ctx[1], target, anchor);
insert_dev(target, html_anchor, anchor); insert_dev(target, html_anchor, anchor);
}, },
p: noop, p: noop,
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;
} }
function create_fragment(ctx) { function create_fragment(ctx) {
let component; let component;
let current; let current;
const component_spread_levels = [/*props*/ ctx[2]]; const component_spread_levels = [/*props*/ ctx[2]];
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) {
component_props = assign(component_props, component_spread_levels[i]); component_props = assign(component_props, component_spread_levels[i]);
} }
component = new /*Component*/ ctx[0]({ props: component_props, $$inline: true }); component = new /*Component*/ ctx[0]({ props: component_props, $$inline: true });
const block = { const block = {
c: function create() { c: function create() {
create_component(component.$$.fragment); create_component(component.$$.fragment);
}, },
l: function claim(nodes) { l: function claim(nodes) {
claim_component(component.$$.fragment, nodes); claim_component(component.$$.fragment, nodes);
}, },
m: function mount(target, anchor) { m: function mount(target, anchor) {
mount_component(component, target, anchor); mount_component(component, target, anchor);
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 };
} }
component.$set(component_changes); component.$set(component_changes);
}, },
i: function intro(local) { i: function intro(local) {
if (current) return; if (current) return;
transition_in(component.$$.fragment, local); transition_in(component.$$.fragment, local);
current = true; current = true;
}, },
o: function outro(local) { o: function outro(local) {
transition_out(component.$$.fragment, local); transition_out(component.$$.fragment, local);
current = false; current = false;
}, },
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;
} }
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);
} }
$$props = exclude_internal_props($$props); $$props = exclude_internal_props($$props);
return [Component, __astro_children, props]; return [Component, __astro_children, props];
} }
class App extends SvelteComponentDev { class App extends SvelteComponentDev {
constructor(options) { constructor(options) {
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,
}); });
} }
} }
export default App; export default App;

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());
} }
/** /**
@ -15,10 +15,10 @@ function childrenToTree(children: string[]) {
* @param children the HTML string children * @param children the HTML string children
*/ */
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
@ -26,22 +26,22 @@ export const childrenToVnodes = moize.deep(function childrenToVnodes(h: any, chi
* @param children the HTML string children * @param children the HTML string children
*/ */
export const childrenToH = moize.deep(function childrenToH(renderer: ComponentRenderer<any>, children: string[]): any { export const childrenToH = moize.deep(function childrenToH(renderer: ComponentRenderer<any>, children: string[]): any {
if (!renderer.jsxPragma) return; if (!renderer.jsxPragma) return;
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

@ -4,7 +4,7 @@ import { renderToString } from '@vue/server-renderer';
import { defineComponent, createSSRApp, h as createElement } from 'vue'; import { defineComponent, createSSRApp, h as createElement } from 'vue';
import { createRenderer } from './renderer'; import { createRenderer } from './renderer';
/** /**
* Users might attempt to use :vueAttribute syntax to pass primitive values. * Users might attempt to use :vueAttribute syntax to pass primitive values.
* If so, try to JSON.parse them to get the primitives * If so, try to JSON.parse them to get the primitives
*/ */
@ -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

@ -2,9 +2,9 @@ import SvelteWrapper from '../SvelteWrapper.svelte.client';
import type { SvelteComponent } from 'svelte'; import type { SvelteComponent } from 'svelte';
export default (target: Element, component: SvelteComponent, props: any, children: string) => { export default (target: Element, component: SvelteComponent, props: any, children: string) => {
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,
}) });
} };

View file

@ -261,7 +261,7 @@ async function createSnowpack(astroConfig: AstroConfig, env: Record<string, any>
plugins: [ plugins: [
[fileURLToPath(new URL('../snowpack-plugin.cjs', import.meta.url)), astroPlugOptions], [fileURLToPath(new URL('../snowpack-plugin.cjs', import.meta.url)), astroPlugOptions],
require.resolve('@snowpack/plugin-sass'), require.resolve('@snowpack/plugin-sass'),
[require.resolve('@snowpack/plugin-svelte'), { compilerOptions: { hydratable: true }}], [require.resolve('@snowpack/plugin-svelte'), { compilerOptions: { hydratable: true } }],
require.resolve('@snowpack/plugin-vue'), require.resolve('@snowpack/plugin-vue'),
], ],
devOptions: { devOptions: {