@aurelia/template-compiler
Advanced tools
Comparing version 2.0.0-beta.16 to 2.0.0-beta.17
@@ -6,2 +6,22 @@ # Change Log | ||
<a name="2.0.0-beta.17"></a> | ||
# 2.0.0-beta.17 (2024-05-11) | ||
### Features: | ||
* **template:** support spread syntax with spread command and ... (#1965) ([ccae63b](https://github.com/aurelia/aurelia/commit/ccae63b)) | ||
* **template:** auto infer binding expression when empty (#1963) ([3359939](https://github.com/aurelia/aurelia/commit/3359939)) | ||
### Bug Fixes: | ||
* **compiler:** fix order when spreading custom attribute into element bindable, improve doc, add tests ([ccae63b](https://github.com/aurelia/aurelia/commit/ccae63b)) | ||
* **(state:** auto infer binding expression when empty ([ccae63b](https://github.com/aurelia/aurelia/commit/ccae63b)) | ||
* **au-slot:** separate parent scope selection from host scope selection (#1961) ([ff605fb](https://github.com/aurelia/aurelia/commit/ff605fb)) | ||
### Refactorings: | ||
* **kernel:** mark side effect free (#1964) ([22c8f71](https://github.com/aurelia/aurelia/commit/22c8f71)) | ||
<a name="2.0.0-beta.16"></a> | ||
@@ -8,0 +28,0 @@ # 2.0.0-beta.16 (2024-05-03) |
@@ -113,7 +113,2 @@ import type { Constructable } from '@aurelia/kernel'; | ||
}; | ||
export declare const SpreadAttributePattern: { | ||
new (): { | ||
'...$attrs'(rawName: string, rawValue: string, _parts: readonly string[]): AttrSyntax; | ||
}; | ||
}; | ||
//# sourceMappingURL=attribute-pattern.d.ts.map |
@@ -133,7 +133,7 @@ import { IExpressionParser } from '@aurelia/expression-parser'; | ||
} | ||
export declare class SpreadBindingCommand implements BindingCommandInstance { | ||
export declare class SpreadValueBindingCommand implements BindingCommandInstance { | ||
static readonly $au: BindingCommandStaticAuDefinition; | ||
get ignoreAttr(): boolean; | ||
build(_info: ICommandBuildInfo): IInstruction; | ||
build(info: ICommandBuildInfo): IInstruction; | ||
} | ||
//# sourceMappingURL=binding-command.d.ts.map |
export { BindingMode, } from './binding-mode'; | ||
export { type StringBindingMode, type IAttributeComponentDefinition, type ICompiledElementComponentDefinition, type IComponentBindablePropDefinition, type IElementComponentDefinition, type ProcessContentHook, type IDomPlatform, ITemplateCompiler, } from './interfaces-template-compiler'; | ||
export { IAttrMapper, type IsTwoWayPredicate } from './attribute-mapper'; | ||
export { type AttributePatternDefinition, type AttributePatternKind, IAttributePattern, IAttributeParser, AttributeParser, ISyntaxInterpreter, SyntaxInterpreter, AttrSyntax, AttributePattern, Interpretation, ColonPrefixedBindAttributePattern, AtPrefixedTriggerAttributePattern, DotSeparatedAttributePattern, EventAttributePattern, RefAttributePattern, SpreadAttributePattern, attributePattern, } from './attribute-pattern'; | ||
export { type PartialBindingCommandDefinition, type BindingCommandDecorator, BindingCommandDefinition, type BindingCommandInstance, type BindingCommandStaticAuDefinition, type BindingCommandKind, type IBindableCommandInfo, type ICommandBuildInfo, type IPlainAttrCommandInfo, BindingCommand, AttrBindingCommand, BindingCommandType, CaptureBindingCommand, ClassBindingCommand, DefaultBindingCommand, ForBindingCommand, FromViewBindingCommand, OneTimeBindingCommand, RefBindingCommand, SpreadBindingCommand, StyleBindingCommand, ToViewBindingCommand, TriggerBindingCommand, TwoWayBindingCommand, bindingCommand, } from './binding-command'; | ||
export { IResourceResolver, IBindablesInfoResolver, type IElementBindablesInfo, type IAttributeBindablesInfo, ITemplateCompilerHooks, TemplateCompiler, TemplateCompilerHooks, templateCompilerHooks, } from './template-compiler'; | ||
export { type AttributePatternDefinition, type AttributePatternKind, IAttributePattern, IAttributeParser, AttributeParser, ISyntaxInterpreter, SyntaxInterpreter, AttrSyntax, AttributePattern, Interpretation, ColonPrefixedBindAttributePattern, AtPrefixedTriggerAttributePattern, DotSeparatedAttributePattern, EventAttributePattern, RefAttributePattern, attributePattern, } from './attribute-pattern'; | ||
export { type PartialBindingCommandDefinition, type BindingCommandDecorator, BindingCommandDefinition, type BindingCommandInstance, type BindingCommandStaticAuDefinition, type BindingCommandKind, type IBindableCommandInfo, type ICommandBuildInfo, type IPlainAttrCommandInfo, BindingCommand, AttrBindingCommand, BindingCommandType, CaptureBindingCommand, ClassBindingCommand, DefaultBindingCommand, ForBindingCommand, FromViewBindingCommand, OneTimeBindingCommand, RefBindingCommand, SpreadValueBindingCommand, StyleBindingCommand, ToViewBindingCommand, TriggerBindingCommand, TwoWayBindingCommand, bindingCommand, } from './binding-command'; | ||
export { IResourceResolver, IBindingCommandResolver, type IElementBindablesInfo, type IAttributeBindablesInfo, ITemplateCompilerHooks, TemplateCompiler, TemplateCompilerHooks, templateCompilerHooks, generateElementName, } from './template-compiler'; | ||
export { ITemplateElementFactory, } from './template-element-factory'; | ||
export { AttributeBindingInstruction, HydrateAttributeInstruction, HydrateElementInstruction, HydrateLetElementInstruction, HydrateTemplateController, IInstruction, InstructionType, InterpolationInstruction, IteratorBindingInstruction, LetBindingInstruction, ListenerBindingInstruction, MultiAttrInstruction, PropertyBindingInstruction, RefBindingInstruction, SetAttributeInstruction, SetClassAttributeInstruction, SetPropertyInstruction, SetStyleAttributeInstruction, SpreadBindingInstruction, SpreadElementPropBindingInstruction, StylePropertyBindingInstruction, TextBindingInstruction } from './instructions'; | ||
export { AttributeBindingInstruction, HydrateAttributeInstruction, HydrateElementInstruction, HydrateLetElementInstruction, HydrateTemplateController, IInstruction, InstructionType, InterpolationInstruction, IteratorBindingInstruction, LetBindingInstruction, ListenerBindingInstruction, MultiAttrInstruction, PropertyBindingInstruction, RefBindingInstruction, SetAttributeInstruction, SetClassAttributeInstruction, SetPropertyInstruction, SetStyleAttributeInstruction, SpreadTransferedBindingInstruction, SpreadElementPropBindingInstruction, SpreadValueBindingInstruction, StylePropertyBindingInstruction, TextBindingInstruction } from './instructions'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -24,4 +24,5 @@ import { type ForOfStatement, type Interpolation, type IsBindingBehavior } from '@aurelia/expression-parser'; | ||
setStyleAttribute: "hg"; | ||
spreadBinding: "hs"; | ||
spreadTransferedBinding: "hs"; | ||
spreadElementProp: "hp"; | ||
spreadValueBinding: "svb"; | ||
}>; | ||
@@ -221,10 +222,21 @@ export type InstructionType = typeof InstructionType[keyof typeof InstructionType]; | ||
} | ||
export declare class SpreadBindingInstruction { | ||
export declare class SpreadTransferedBindingInstruction { | ||
readonly type = "hs"; | ||
} | ||
/** | ||
* When spreading any attribute bindings onto an element, | ||
* it's possible that some attributes will be targeting the bindable properties of a custom element | ||
* This instruction is used to express that | ||
*/ | ||
export declare class SpreadElementPropBindingInstruction { | ||
readonly instructions: IInstruction; | ||
readonly instruction: IInstruction; | ||
readonly type = "hp"; | ||
constructor(instructions: IInstruction); | ||
constructor(instruction: IInstruction); | ||
} | ||
export declare class SpreadValueBindingInstruction { | ||
target: '$bindables' | '$element'; | ||
from: string; | ||
readonly type = "svb"; | ||
constructor(target: '$bindables' | '$element', from: string); | ||
} | ||
//# sourceMappingURL=instructions.d.ts.map |
@@ -7,2 +7,3 @@ import { IInstruction } from './instructions'; | ||
import { ITemplateCompiler } from './interfaces-template-compiler'; | ||
export declare const generateElementName: () => string; | ||
export declare class TemplateCompiler implements ITemplateCompiler { | ||
@@ -25,13 +26,14 @@ static register: <C extends Constructable>(this: C, container: IContainer) => void; | ||
} | ||
export interface IBindablesInfoResolver<TElementDef extends IElementComponentDefinition = IElementComponentDefinition, TAttrDef extends IAttributeComponentDefinition = IAttributeComponentDefinition> { | ||
get(def: TAttrDef): IAttributeBindablesInfo; | ||
get(def: TElementDef): IElementBindablesInfo; | ||
} | ||
export declare const IBindablesInfoResolver: import("@aurelia/kernel").InterfaceSymbol<IBindablesInfoResolver<IElementComponentDefinition<string>, IAttributeComponentDefinition<string>>>; | ||
export interface IResourceResolver<TElementDef extends IElementComponentDefinition = IElementComponentDefinition, TAttrDef extends IAttributeComponentDefinition = IAttributeComponentDefinition> { | ||
el(c: IContainer, name: string): TElementDef | null; | ||
attr(c: IContainer, name: string): TAttrDef | null; | ||
command(c: IContainer, name: string): BindingCommandInstance | null; | ||
bindables(def: TAttrDef): IAttributeBindablesInfo; | ||
bindables(def: TElementDef): IElementBindablesInfo; | ||
bindables(def: TAttrDef | TElementDef): IAttributeBindablesInfo | IElementBindablesInfo; | ||
} | ||
export declare const IResourceResolver: import("@aurelia/kernel").InterfaceSymbol<IResourceResolver<IElementComponentDefinition<string>, IAttributeComponentDefinition<string>>>; | ||
export interface IBindingCommandResolver { | ||
get(c: IContainer, name: string): BindingCommandInstance | null; | ||
} | ||
export declare const IBindingCommandResolver: import("@aurelia/kernel").InterfaceSymbol<IBindingCommandResolver>; | ||
/** | ||
@@ -38,0 +40,0 @@ * An interface describing the hooks a compilation process should invoke. |
{ | ||
"name": "@aurelia/template-compiler", | ||
"version": "2.0.0-beta.16", | ||
"version": "2.0.0-beta.17", | ||
"main": "dist/cjs/index.cjs", | ||
@@ -56,5 +56,5 @@ "module": "dist/esm/index.mjs", | ||
"dependencies": { | ||
"@aurelia/metadata": "2.0.0-beta.16", | ||
"@aurelia/kernel": "2.0.0-beta.16", | ||
"@aurelia/expression-parser": "2.0.0-beta.16" | ||
"@aurelia/metadata": "2.0.0-beta.17", | ||
"@aurelia/kernel": "2.0.0-beta.17", | ||
"@aurelia/expression-parser": "2.0.0-beta.17" | ||
}, | ||
@@ -61,0 +61,0 @@ "devDependencies": { |
@@ -614,11 +614,2 @@ import type { Constructable } from '@aurelia/kernel'; | ||
export const SpreadAttributePattern = /*@__PURE__*/ AttributePattern.define( | ||
[{ pattern: '...$attrs', symbols: '' }], | ||
class SpreadAttributePattern { | ||
public '...$attrs'(rawName: string, rawValue: string, _parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, '', '...$attrs'); | ||
} | ||
} | ||
); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
@@ -625,0 +616,0 @@ /* istanbul ignore next */function testAttributePatternDeco() { |
@@ -12,5 +12,5 @@ import { IExpressionParser } from '@aurelia/expression-parser'; | ||
RefBindingInstruction, | ||
SpreadBindingInstruction, | ||
SpreadValueBindingInstruction, | ||
} from './instructions'; | ||
import { aliasRegistration, definitionTypeElement, etIsFunction, etIsProperty, isString, objectFreeze, singletonRegistration } from './utilities'; | ||
import { aliasRegistration, etIsFunction, etIsProperty, isString, objectFreeze, singletonRegistration } from './utilities'; | ||
@@ -218,2 +218,3 @@ import type { | ||
let value = info.attr.rawValue; | ||
value = value === '' ? camelCase(target) : value; | ||
if (info.bindable == null) { | ||
@@ -225,7 +226,2 @@ target = attrMapper.map(info.node, target) | ||
} else { | ||
// if it looks like: <my-el value.bind> | ||
// it means : <my-el value.bind="value"> | ||
if (value === '' && info.def.type === definitionTypeElement) { | ||
value = camelCase(target); | ||
} | ||
target = info.bindable.name; | ||
@@ -248,2 +244,3 @@ } | ||
let value = info.attr.rawValue; | ||
value = value === '' ? camelCase(target) : value; | ||
if (info.bindable == null) { | ||
@@ -255,7 +252,2 @@ target = attrMapper.map(info.node, target) | ||
} else { | ||
// if it looks like: <my-el value.bind> | ||
// it means : <my-el value.bind="value"> | ||
if (value === '' && info.def.type === definitionTypeElement) { | ||
value = camelCase(target); | ||
} | ||
target = info.bindable.name; | ||
@@ -278,2 +270,3 @@ } | ||
let value = attr.rawValue; | ||
value = value === '' ? camelCase(target) : value; | ||
if (info.bindable == null) { | ||
@@ -285,7 +278,2 @@ target = attrMapper.map(info.node, target) | ||
} else { | ||
// if it looks like: <my-el value.bind> | ||
// it means : <my-el value.bind="value"> | ||
if (value === '' && info.def.type === definitionTypeElement) { | ||
value = camelCase(target); | ||
} | ||
target = info.bindable.name; | ||
@@ -308,2 +296,3 @@ } | ||
let value = attr.rawValue; | ||
value = value === '' ? camelCase(target) : value; | ||
if (info.bindable == null) { | ||
@@ -315,7 +304,2 @@ target = attrMapper.map(info.node, target) | ||
} else { | ||
// if it looks like: <my-el value.bind> | ||
// it means : <my-el value.bind="value"> | ||
if (value === '' && info.def.type === definitionTypeElement) { | ||
value = camelCase(target); | ||
} | ||
target = info.bindable.name; | ||
@@ -337,6 +321,7 @@ } | ||
const bindable = info.bindable; | ||
let value = attr.rawValue; | ||
let target = attr.target; | ||
let defDefaultMode: string | number; | ||
let mode: string | number; | ||
let target = attr.target; | ||
let value = attr.rawValue; | ||
value = value === '' ? camelCase(target) : value; | ||
if (bindable == null) { | ||
@@ -349,7 +334,2 @@ mode = attrMapper.isTwoWay(info.node, target) ? InternalBindingMode.twoWay : InternalBindingMode.toView; | ||
} else { | ||
// if it looks like: <my-el value.bind> | ||
// it means : <my-el value.bind="value"> | ||
if (value === '' && info.def.type === definitionTypeElement) { | ||
value = camelCase(target); | ||
} | ||
defDefaultMode = (info.def as IAttributeComponentDefinition).defaultBindingMode ?? 0; | ||
@@ -449,3 +429,7 @@ mode = bindable.mode === 0 || bindable.mode == null | ||
public build(info: ICommandBuildInfo, exprParser: IExpressionParser): IInstruction { | ||
return new AttributeBindingInstruction(info.attr.target, exprParser.parse(info.attr.rawValue, etIsProperty), info.attr.target); | ||
const attr = info.attr; | ||
const target = attr.target; | ||
let value = attr.rawValue; | ||
value = value === '' ? camelCase(target) : value; | ||
return new AttributeBindingInstruction(target, exprParser.parse(value, etIsProperty), target); | ||
} | ||
@@ -499,12 +483,12 @@ } | ||
export class SpreadBindingCommand implements BindingCommandInstance { | ||
export class SpreadValueBindingCommand implements BindingCommandInstance { | ||
public static readonly $au: BindingCommandStaticAuDefinition = { | ||
type: bindingCommandTypeName, | ||
name: '...$attrs', | ||
name: 'spread', | ||
}; | ||
public get ignoreAttr() { return true; } | ||
public get ignoreAttr() { return false; } | ||
public build(_info: ICommandBuildInfo): IInstruction { | ||
return new SpreadBindingInstruction(); | ||
public build(info: ICommandBuildInfo): IInstruction { | ||
return new SpreadValueBindingInstruction(info.attr.target as '$bindables' | '$element', info.attr.rawValue); | ||
} | ||
} |
@@ -34,2 +34,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
compiler_attr_mapper_duplicate_mapping = 719, | ||
compiler_no_reserved_spread_syntax = 720, | ||
compiler_no_reserved_$bindable = 721, | ||
compiler_no_dom_api = 722, | ||
no_spread_template_controller = 9998, | ||
@@ -60,4 +63,7 @@ } | ||
[ErrorNames.compiler_slot_without_shadowdom]: `Template compilation error: detected a usage of "<slot>" element without specifying shadow DOM options in element: {{0}}`, | ||
[ErrorNames.compiler_no_spread_tc]: `Spreading template controller "{{0}}" is not supported.`, | ||
[ErrorNames.compiler_attr_mapper_duplicate_mapping]: `Attribute {{0}} has been already registered for {{1:element}}`, | ||
[ErrorNames.compiler_no_spread_tc]: `Spreading template controller "{{0}}" is not supported.`, | ||
[ErrorNames.compiler_no_reserved_spread_syntax]: `Spreading syntax "...xxx" is reserved. Encountered "...{{0}}"`, | ||
[ErrorNames.compiler_no_reserved_$bindable]: `Usage of $bindables is only allowed on custom element. Encountered: <{{0}} {{1}}="{{2}}">`, | ||
[ErrorNames.compiler_no_dom_api]: 'Invalid platform object provided to the compilation, no DOM API found.', | ||
@@ -64,0 +70,0 @@ [ErrorNames.no_spread_template_controller]: 'Spread binding does not support spreading custom attributes/template controllers. Did you build the spread instruction manually?', |
@@ -37,3 +37,2 @@ export { | ||
RefAttributePattern, | ||
SpreadAttributePattern, | ||
attributePattern, | ||
@@ -62,3 +61,3 @@ } from './attribute-pattern'; | ||
RefBindingCommand, | ||
SpreadBindingCommand, | ||
SpreadValueBindingCommand, | ||
StyleBindingCommand, | ||
@@ -73,3 +72,3 @@ ToViewBindingCommand, | ||
IResourceResolver, | ||
IBindablesInfoResolver, | ||
IBindingCommandResolver, | ||
type IElementBindablesInfo, | ||
@@ -81,2 +80,3 @@ type IAttributeBindablesInfo, | ||
templateCompilerHooks, | ||
generateElementName, | ||
} from './template-compiler'; | ||
@@ -107,6 +107,7 @@ | ||
SetStyleAttributeInstruction, | ||
SpreadBindingInstruction, | ||
SpreadTransferedBindingInstruction, | ||
SpreadElementPropBindingInstruction, | ||
SpreadValueBindingInstruction, | ||
StylePropertyBindingInstruction, | ||
TextBindingInstruction | ||
} from './instructions'; |
@@ -29,4 +29,5 @@ import { | ||
/** @internal */ export const setStyleAttribute = 'hg'; | ||
/** @internal */ export const spreadBinding = 'hs'; | ||
/** @internal */ export const spreadTransferedBinding = 'hs'; | ||
/** @internal */ export const spreadElementProp = 'hp'; | ||
/** @internal */ export const spreadValueBinding = 'svb'; | ||
@@ -52,4 +53,5 @@ export const InstructionType = /*@__PURE__*/ objectFreeze({ | ||
setStyleAttribute, | ||
spreadBinding, | ||
spreadTransferedBinding, | ||
spreadElementProp, | ||
spreadValueBinding, | ||
}); | ||
@@ -281,11 +283,24 @@ export type InstructionType = typeof InstructionType[keyof typeof InstructionType]; | ||
export class SpreadBindingInstruction { | ||
public readonly type = spreadBinding; | ||
export class SpreadTransferedBindingInstruction { | ||
public readonly type = spreadTransferedBinding; | ||
} | ||
/** | ||
* When spreading any attribute bindings onto an element, | ||
* it's possible that some attributes will be targeting the bindable properties of a custom element | ||
* This instruction is used to express that | ||
*/ | ||
export class SpreadElementPropBindingInstruction { | ||
public readonly type = spreadElementProp; | ||
public constructor( | ||
public readonly instructions: IInstruction, | ||
public readonly instruction: IInstruction, | ||
) {} | ||
} | ||
export class SpreadValueBindingInstruction { | ||
public readonly type = spreadValueBinding; | ||
public constructor( | ||
public target: '$bindables' | '$element', | ||
public from: string, | ||
) {} | ||
} |
@@ -1,3 +0,1 @@ | ||
import { IDomPlatform } from './interfaces-template-compiler'; | ||
export type IRenderLocation<T extends ChildNode = ChildNode> = T & { | ||
@@ -13,20 +11,2 @@ $start?: IRenderLocation<T>; | ||
/** @internal */ | ||
export const createElement | ||
= <K extends string>(p: IDomPlatform, name: K): K extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[K] : HTMLElement => p.document.createElement(name) as any; | ||
/** @internal */ | ||
export const createComment = (p: IDomPlatform, text: string) => p.document.createComment(text); | ||
/** @internal */ | ||
export const createLocation = (p: IDomPlatform) => { | ||
const locationEnd = createComment(p, auLocationEnd) as IRenderLocation; | ||
locationEnd.$start = createComment(p, auLocationStart) as IRenderLocation; | ||
return locationEnd; | ||
}; | ||
/** @internal */ | ||
export const createText = (p: IDomPlatform, text: string) => p.document.createTextNode(text); | ||
/** @internal */ | ||
export const insertBefore = <T extends Node>(parent: Node, newChildNode: T, target: Node | null) => { | ||
@@ -50,10 +30,2 @@ return parent.insertBefore(newChildNode, target); | ||
/** @internal */ | ||
export const getPreviousSibling = (node: Node) => node.previousSibling; | ||
/** @internal */ | ||
export const appendChild = <T extends Node>(parent: Node, child: T) => { | ||
return parent.appendChild(child); | ||
}; | ||
/** @internal */ | ||
export const appendToTemplate = <T extends Node>(parent: HTMLTemplateElement, child: T) => { | ||
@@ -60,0 +32,0 @@ return parent.content.appendChild(child); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1070550
19990
+ Added@aurelia/expression-parser@2.0.0-beta.17(transitive)
+ Added@aurelia/kernel@2.0.0-beta.17(transitive)
+ Added@aurelia/metadata@2.0.0-beta.17(transitive)
+ Added@aurelia/platform@2.0.0-beta.17(transitive)
- Removed@aurelia/expression-parser@2.0.0-beta.16(transitive)
- Removed@aurelia/kernel@2.0.0-beta.16(transitive)
- Removed@aurelia/metadata@2.0.0-beta.16(transitive)
- Removed@aurelia/platform@2.0.0-beta.16(transitive)