|
|
|
@ -6,6 +6,7 @@ import Wrapper from './wrappers/shared/Wrapper';
|
|
|
|
|
export interface BlockOptions {
|
|
|
|
|
parent?: Block;
|
|
|
|
|
name: string;
|
|
|
|
|
type: string;
|
|
|
|
|
renderer?: Renderer;
|
|
|
|
|
comment?: string;
|
|
|
|
|
key?: string;
|
|
|
|
@ -17,6 +18,7 @@ export default class Block {
|
|
|
|
|
parent?: Block;
|
|
|
|
|
renderer: Renderer;
|
|
|
|
|
name: string;
|
|
|
|
|
type: string;
|
|
|
|
|
comment?: string;
|
|
|
|
|
|
|
|
|
|
wrappers: Wrapper[];
|
|
|
|
@ -64,6 +66,7 @@ export default class Block {
|
|
|
|
|
this.parent = options.parent;
|
|
|
|
|
this.renderer = options.renderer;
|
|
|
|
|
this.name = options.name;
|
|
|
|
|
this.type = options.type;
|
|
|
|
|
this.comment = options.comment;
|
|
|
|
|
|
|
|
|
|
this.wrappers = [];
|
|
|
|
@ -369,11 +372,20 @@ export default class Block {
|
|
|
|
|
|
|
|
|
|
${!this.builders.init.is_empty() && this.builders.init}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
${properties}
|
|
|
|
|
};
|
|
|
|
|
`.replace(/(#+)(\w*)/g, (_match: string, sigil: string, name: string) => {
|
|
|
|
|
return sigil === '#' ? this.alias(name) : sigil.slice(1) + name;
|
|
|
|
|
${dev
|
|
|
|
|
? deindent`
|
|
|
|
|
const block = {
|
|
|
|
|
${properties}
|
|
|
|
|
};
|
|
|
|
|
@dispatch_dev("SvelteRegisterBlock", { block, id: ${this.name || 'create_fragment'}.name, type: "${this.type}", source: "${this.comment ? this.comment.replace(/"/g, '\\"') : ''}", ctx });
|
|
|
|
|
return block;`
|
|
|
|
|
: deindent`
|
|
|
|
|
return {
|
|
|
|
|
${properties}
|
|
|
|
|
};`
|
|
|
|
|
}
|
|
|
|
|
`.replace(/([^{])(#+)(\w*)/g, (_match: string, pre: string, sigil: string, name: string) => {
|
|
|
|
|
return pre + (sigil === '#' ? this.alias(name) : sigil.slice(1) + name);
|
|
|
|
|
});
|
|
|
|
|
/* eslint-enable @typescript-eslint/indent,indent */
|
|
|
|
|
}
|
|
|
|
|