[ci] npm run format
This commit is contained in:
parent
22ca9e0aac
commit
2a7aa765b4
10 changed files with 171 additions and 173 deletions
|
@ -21,10 +21,10 @@ import {
|
|||
not_equal,
|
||||
transition_in,
|
||||
transition_out,
|
||||
validate_slots
|
||||
} from "svelte/internal";
|
||||
validate_slots,
|
||||
} from 'svelte/internal';
|
||||
|
||||
const file = "App.svelte";
|
||||
const file = 'App.svelte';
|
||||
|
||||
// (5:0) <Component {...props}>
|
||||
function create_default_slot(ctx) {
|
||||
|
@ -51,15 +51,15 @@ function create_default_slot(ctx) {
|
|||
d: function destroy(detaching) {
|
||||
if (detaching) detach_dev(html_anchor);
|
||||
if (detaching) html_tag.d();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
dispatch_dev("SvelteRegisterBlock", {
|
||||
dispatch_dev('SvelteRegisterBlock', {
|
||||
block,
|
||||
id: create_default_slot.name,
|
||||
type: "slot",
|
||||
source: "(5:0) <Component {...props}>",
|
||||
ctx
|
||||
type: 'slot',
|
||||
source: '(5:0) <Component {...props}>',
|
||||
ctx,
|
||||
});
|
||||
|
||||
return block;
|
||||
|
@ -72,7 +72,7 @@ function create_fragment(ctx) {
|
|||
|
||||
let component_props = {
|
||||
$$slots: { default: [create_default_slot] },
|
||||
$$scope: { ctx }
|
||||
$$scope: { ctx },
|
||||
};
|
||||
|
||||
for (let i = 0; i < component_spread_levels.length; i += 1) {
|
||||
|
@ -93,9 +93,7 @@ function create_fragment(ctx) {
|
|||
current = true;
|
||||
},
|
||||
p: function update(ctx, [dirty]) {
|
||||
const component_changes = (dirty & /*props*/ 4)
|
||||
? get_spread_update(component_spread_levels, [get_spread_object(/*props*/ ctx[2])])
|
||||
: {};
|
||||
const component_changes = dirty & /*props*/ 4 ? get_spread_update(component_spread_levels, [get_spread_object(/*props*/ ctx[2])]) : {};
|
||||
|
||||
if (dirty & /*$$scope*/ 16) {
|
||||
component_changes.$$scope = { dirty, ctx };
|
||||
|
@ -114,15 +112,15 @@ function create_fragment(ctx) {
|
|||
},
|
||||
d: function destroy(detaching) {
|
||||
destroy_component(component, detaching);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
dispatch_dev("SvelteRegisterBlock", {
|
||||
dispatch_dev('SvelteRegisterBlock', {
|
||||
block,
|
||||
id: create_fragment.name,
|
||||
type: "component",
|
||||
source: "",
|
||||
ctx
|
||||
type: 'component',
|
||||
source: '',
|
||||
ctx,
|
||||
});
|
||||
|
||||
return block;
|
||||
|
@ -130,20 +128,20 @@ function create_fragment(ctx) {
|
|||
|
||||
function instance($$self, $$props, $$invalidate) {
|
||||
let { $$slots: slots = {}, $$scope } = $$props;
|
||||
validate_slots("App", slots, []);
|
||||
validate_slots('App', slots, []);
|
||||
const { __astro_component: Component, __astro_children, ...props } = $$props;
|
||||
|
||||
$$self.$$set = $$new_props => {
|
||||
$$invalidate(3, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
|
||||
$$self.$$set = ($$new_props) => {
|
||||
$$invalidate(3, ($$props = assign(assign({}, $$props), exclude_internal_props($$new_props))));
|
||||
};
|
||||
|
||||
$$self.$capture_state = () => ({ Component, __astro_children, props });
|
||||
|
||||
$$self.$inject_state = $$new_props => {
|
||||
$$invalidate(3, $$props = assign(assign({}, $$props), $$new_props));
|
||||
$$self.$inject_state = ($$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);
|
||||
}
|
||||
|
||||
|
@ -156,11 +154,11 @@ class App extends SvelteComponentDev {
|
|||
super(options);
|
||||
init(this, options, instance, create_fragment, not_equal, {});
|
||||
|
||||
dispatch_dev("SvelteRegisterComponent", {
|
||||
dispatch_dev('SvelteRegisterComponent', {
|
||||
component: this,
|
||||
tagName: "App",
|
||||
tagName: 'App',
|
||||
options,
|
||||
id: create_fragment.name
|
||||
id: create_fragment.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
// @ts-nocheck
|
||||
// TODO: don't precompile this, but it works for now
|
||||
/* 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 { __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;
|
||||
|
|
|
@ -13,7 +13,7 @@ const Preact: ComponentRenderer<ComponentType> = {
|
|||
renderStatic(Component) {
|
||||
return async (props, ...children) => {
|
||||
return renderToString(h(Component, props, childrenToVnodes(h, children)));
|
||||
}
|
||||
};
|
||||
},
|
||||
imports: {
|
||||
preact: ['render', 'Fragment', 'h'],
|
||||
|
|
|
@ -10,7 +10,7 @@ const ReactRenderer: ComponentRenderer<ComponentType> = {
|
|||
renderStatic(Component) {
|
||||
return async (props, ...children) => {
|
||||
return ReactDOMServer.renderToString(React.createElement(Component, props, childrenToVnodes(React.createElement, children)));
|
||||
}
|
||||
};
|
||||
},
|
||||
imports: {
|
||||
react: ['default: React'],
|
||||
|
|
|
@ -40,7 +40,7 @@ export function createRenderer(renderer: SupportedComponentRenderer) {
|
|||
...innerContext,
|
||||
props: serializeProps(props),
|
||||
children: `[${childrenToH(renderer, children) ?? ''}]`,
|
||||
childrenAsString: `\`${children}\``
|
||||
childrenAsString: `\`${children}\``,
|
||||
})}
|
||||
${typeof wrapperEnd === 'function' ? wrapperEnd(innerContext) : wrapperEnd}
|
||||
`;
|
||||
|
|
|
@ -11,7 +11,7 @@ const SvelteRenderer: ComponentRenderer<SvelteComponent> = {
|
|||
};
|
||||
},
|
||||
imports: {
|
||||
'astro/frontend/runtime/svelte': ['default: render']
|
||||
'astro/frontend/runtime/svelte': ['default: render'],
|
||||
},
|
||||
render({ Component, root, props, childrenAsString }) {
|
||||
return `render(${root}, ${Component}, ${props}, ${childrenAsString});`;
|
||||
|
|
|
@ -6,7 +6,7 @@ import moize from 'moize';
|
|||
|
||||
/** @internal */
|
||||
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[]) {
|
||||
const tree = childrenToTree(children);
|
||||
const vnodes = tree.map(subtree => toH(h, subtree));
|
||||
const vnodes = tree.map((subtree) => toH(h, subtree));
|
||||
return vnodes;
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* 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 innerH = (name: any, attrs: Record<string, any> | null = null, _children: string[] | null = null) => {
|
||||
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 */
|
||||
if (attrs && attrs.key) attrs.key = undefined;
|
||||
const __SERIALIZED = `${renderer.jsxPragmaName}("${name}", ${attrs ? JSON.stringify(attrs) : 'null'}${childStr})` as string;
|
||||
return { ...vnode, __SERIALIZED }
|
||||
}
|
||||
return { ...vnode, __SERIALIZED };
|
||||
};
|
||||
const serializeChild = (child: unknown) => {
|
||||
if (typeof child === 'string') return `\`${child}\``;
|
||||
if (typeof child === 'number' || typeof child === 'boolean') return `${child}`;
|
||||
if (child === null) return `null`;
|
||||
if ((child as any).__SERIALIZED) return (child as any).__SERIALIZED;
|
||||
return innerH(child).__SERIALIZED;
|
||||
}
|
||||
return tree.map(subtree => toH(innerH, subtree).__SERIALIZED);
|
||||
})
|
||||
};
|
||||
return tree.map((subtree) => toH(innerH, subtree).__SERIALIZED);
|
||||
});
|
||||
|
|
|
@ -31,12 +31,12 @@ const Vue: ComponentRenderer<VueComponent> = {
|
|||
return async (props, ...children) => {
|
||||
const App = defineComponent({
|
||||
components: {
|
||||
Component
|
||||
Component,
|
||||
},
|
||||
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);
|
||||
|
|
|
@ -5,6 +5,6 @@ export default (target: Element, component: SvelteComponent, props: any, childre
|
|||
new SvelteWrapper({
|
||||
target,
|
||||
props: { __astro_component: component, __astro_children: children, ...props },
|
||||
hydrate: true
|
||||
})
|
||||
}
|
||||
hydrate: true,
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue