@aurelia/template-compiler
Advanced tools
Comparing version 2.1.0-dev.202405130849 to 2.1.0-dev.202405280947
@@ -6,2 +6,15 @@ # Change Log | ||
<a name="2.0.0-beta.18"></a> | ||
# 2.0.0-beta.18 (2024-05-23) | ||
### Bug Fixes: | ||
* **di:** use official metadata instead of weakmap (#1977) ([9aeeffa](https://github.com/aurelia/aurelia/commit/9aeeffa)) | ||
* **convention:** use array for bindables isntead of object (#1967) ([f1a73d6](https://github.com/aurelia/aurelia/commit/f1a73d6)) | ||
### Refactorings: | ||
* ***:** resolve previous PR comments (#1968) ([f8ed38d](https://github.com/aurelia/aurelia/commit/f8ed38d)) | ||
<a name="2.0.0-beta.17"></a> | ||
@@ -8,0 +21,0 @@ # 2.0.0-beta.17 (2024-05-11) |
@@ -1,3 +0,3 @@ | ||
import type { Constructable } from '@aurelia/kernel'; | ||
import { IContainer } from '@aurelia/kernel'; | ||
import type { Constructable, IRegistry } from '@aurelia/kernel'; | ||
import { registrableMetadataKey } from '@aurelia/kernel'; | ||
export interface AttributePatternDefinition<T extends string = string> { | ||
@@ -63,2 +63,3 @@ pattern: T; | ||
export interface IAttributeParser { | ||
registerPattern(patterns: AttributePatternDefinition[], Type: Constructable<IAttributePattern>): void; | ||
parse(name: string, value: string): AttrSyntax; | ||
@@ -72,2 +73,3 @@ } | ||
constructor(); | ||
registerPattern(patterns: AttributePatternDefinition[], Type: Constructable<IAttributePattern>): void; | ||
parse(name: string, value: string): AttrSyntax; | ||
@@ -77,5 +79,3 @@ } | ||
readonly name: string; | ||
define<const K extends AttributePatternDefinition, P extends Constructable<IAttributePattern<K['pattern']>> = Constructable<IAttributePattern<K['pattern']>>>(patternDefs: K[], Type: P): P; | ||
getPatternDefinitions(Type: Constructable): AttributePatternDefinition[]; | ||
findAll(container: IContainer): readonly IAttributePattern[]; | ||
create<const K extends AttributePatternDefinition, P extends Constructable<IAttributePattern<K['pattern']>> = Constructable<IAttributePattern<K['pattern']>>>(patternDefs: K[], Type: P): IRegistry; | ||
} | ||
@@ -85,33 +85,38 @@ /** | ||
*/ | ||
export declare function attributePattern<const K extends AttributePatternDefinition>(...patternDefs: K[]): <T extends Constructable<IAttributePattern<K['pattern']>>>(target: T, context: ClassDecoratorContext) => T; | ||
export declare function attributePattern<const K extends AttributePatternDefinition>(...patternDefs: K[]): <T extends Constructable<IAttributePattern<K['pattern']>>>(target: T, context: ClassDecoratorContext<T>) => T; | ||
export declare const AttributePattern: Readonly<AttributePatternKind>; | ||
export declare const DotSeparatedAttributePattern: { | ||
new (): { | ||
'PART.PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'PART.PART.PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
export declare class DotSeparatedAttributePattern { | ||
static [Symbol.metadata]: { | ||
[registrableMetadataKey]: IRegistry; | ||
}; | ||
}; | ||
export declare const RefAttributePattern: { | ||
new (): { | ||
ref(rawName: string, rawValue: string, _parts: readonly string[]): AttrSyntax; | ||
'PART.ref'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'PART.PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'PART.PART.PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
} | ||
export declare class RefAttributePattern { | ||
static [Symbol.metadata]: { | ||
[registrableMetadataKey]: IRegistry; | ||
}; | ||
}; | ||
export declare const EventAttributePattern: { | ||
new (): { | ||
'PART.trigger:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'PART.capture:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'ref'(rawName: string, rawValue: string, _parts: readonly string[]): AttrSyntax; | ||
'PART.ref'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
} | ||
export declare class EventAttributePattern { | ||
static [Symbol.metadata]: { | ||
[registrableMetadataKey]: IRegistry; | ||
}; | ||
}; | ||
export declare const ColonPrefixedBindAttributePattern: { | ||
new (): { | ||
':PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'PART.trigger:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'PART.capture:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
} | ||
export declare class ColonPrefixedBindAttributePattern { | ||
static [Symbol.metadata]: { | ||
[registrableMetadataKey]: IRegistry; | ||
}; | ||
}; | ||
export declare const AtPrefixedTriggerAttributePattern: { | ||
new (): { | ||
'@PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'@PART:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
':PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
} | ||
export declare class AtPrefixedTriggerAttributePattern { | ||
static [Symbol.metadata]: { | ||
[registrableMetadataKey]: IRegistry; | ||
}; | ||
}; | ||
'@PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
'@PART:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax; | ||
} | ||
//# sourceMappingURL=attribute-pattern.d.ts.map |
@@ -5,3 +5,3 @@ export { BindingMode, } from './binding-mode'; | ||
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 { type PartialBindingCommandDefinition, type BindingCommandDecorator, BindingCommandDefinition, type BindingCommandInstance, type BindingCommandStaticAuDefinition, type BindingCommandKind, type IBindableCommandInfo, type ICommandBuildInfo, type IPlainAttrCommandInfo, BindingCommand, AttrBindingCommand, type 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'; | ||
@@ -8,0 +8,0 @@ export { ITemplateElementFactory, } from './template-element-factory'; |
import { IInstruction } from './instructions'; | ||
import { AttrSyntax } from './attribute-pattern'; | ||
import { BindingCommandInstance } from './binding-command'; | ||
import type { IContainer, Constructable } from '@aurelia/kernel'; | ||
import type { IContainer, Constructable, IRegistry } from '@aurelia/kernel'; | ||
import type { IAttributeComponentDefinition, ICompiledElementComponentDefinition, IComponentBindablePropDefinition, IElementComponentDefinition } from './interfaces-template-compiler'; | ||
@@ -51,3 +51,3 @@ import { ITemplateCompiler } from './interfaces-template-compiler'; | ||
name: string; | ||
define<K extends ITemplateCompilerHooks, T extends Constructable<K>>(Type: T): T; | ||
define<K extends ITemplateCompilerHooks, T extends Constructable<K>>(Type: T): IRegistry; | ||
findAll(container: IContainer): readonly ITemplateCompilerHooks[]; | ||
@@ -61,3 +61,3 @@ }>; | ||
*/ | ||
export declare const templateCompilerHooks: <T extends Constructable>(target?: T, _context?: ClassDecoratorContext) => any; | ||
export declare const templateCompilerHooks: <T extends Constructable>(target?: T, context?: ClassDecoratorContext) => any; | ||
//# sourceMappingURL=template-compiler.d.ts.map |
@@ -7,11 +7,10 @@ /** | ||
*/ | ||
export interface ITemplateElementFactory extends TemplateElementFactory { | ||
export interface ITemplateElementFactory { | ||
createTemplate(input: string | Node): HTMLTemplateElement; | ||
} | ||
export declare const ITemplateElementFactory: import("@aurelia/kernel").InterfaceSymbol<ITemplateElementFactory>; | ||
export declare class TemplateElementFactory { | ||
export declare class TemplateElementFactory implements ITemplateElementFactory { | ||
private t; | ||
createTemplate(markup: string): HTMLTemplateElement; | ||
createTemplate(node: Node): HTMLTemplateElement; | ||
createTemplate(input: string | Node): HTMLTemplateElement; | ||
} | ||
//# sourceMappingURL=template-element-factory.d.ts.map |
{ | ||
"name": "@aurelia/template-compiler", | ||
"version": "2.1.0-dev.202405130849", | ||
"version": "2.1.0-dev.202405280947", | ||
"main": "dist/cjs/index.cjs", | ||
@@ -56,5 +56,5 @@ "module": "dist/esm/index.mjs", | ||
"dependencies": { | ||
"@aurelia/metadata": "2.1.0-dev.202405130849", | ||
"@aurelia/kernel": "2.1.0-dev.202405130849", | ||
"@aurelia/expression-parser": "2.1.0-dev.202405130849" | ||
"@aurelia/metadata": "2.1.0-dev.202405280947", | ||
"@aurelia/kernel": "2.1.0-dev.202405280947", | ||
"@aurelia/expression-parser": "2.1.0-dev.202405280947" | ||
}, | ||
@@ -61,0 +61,0 @@ "devDependencies": { |
@@ -1,4 +0,5 @@ | ||
import type { Constructable } from '@aurelia/kernel'; | ||
import { IContainer, Registrable, emptyArray, getResourceKeyFor, resolve } from '@aurelia/kernel'; | ||
import type { Constructable, IRegistry, } from '@aurelia/kernel'; | ||
import { IContainer, registrableMetadataKey, emptyArray, getResourceKeyFor, resolve } from '@aurelia/kernel'; | ||
import { createInterface, objectFreeze, singletonRegistration } from './utilities'; | ||
import { ErrorNames, createMappedError } from './errors'; | ||
@@ -449,2 +450,3 @@ export interface AttributePatternDefinition<T extends string = string> { | ||
export interface IAttributeParser { | ||
registerPattern(patterns: AttributePatternDefinition[], Type: Constructable<IAttributePattern>): void; | ||
parse(name: string, value: string): AttrSyntax; | ||
@@ -466,23 +468,44 @@ } | ||
*/ | ||
private readonly _patterns: Record<string, IAttributePattern>; | ||
private readonly _patterns: Record<string, { patternType: Constructable<IAttributePattern>; pattern?: IAttributePattern }> = {}; | ||
/** @internal */ | ||
private readonly _interpreter: ISyntaxInterpreter; | ||
/** @internal */ | ||
private _initialized: boolean = false; | ||
/** @internal */ | ||
private readonly _allDefinitions: AttributePatternDefinition[] = []; | ||
/** @internal */ | ||
private readonly _container: IContainer; | ||
public constructor() { | ||
const interpreter = this._interpreter = resolve(ISyntaxInterpreter); | ||
const attrPatterns = AttributePattern.findAll(resolve(IContainer)); | ||
const patterns: AttributeParser['_patterns'] = this._patterns = {}; | ||
const allDefs = attrPatterns.reduce<AttributePatternDefinition[]>( | ||
(allDefs, attrPattern) => { | ||
const patternDefs = getAllPatternDefinitions(attrPattern.constructor as Constructable); | ||
patternDefs.forEach(def => patterns[def.pattern] = attrPattern); | ||
return allDefs.concat(patternDefs); | ||
}, | ||
emptyArray as AttributePatternDefinition[] | ||
); | ||
interpreter.add(allDefs); | ||
this._interpreter = resolve(ISyntaxInterpreter); | ||
this._container = resolve(IContainer); | ||
} | ||
public registerPattern(patterns: AttributePatternDefinition[], Type: Constructable<IAttributePattern>): void { | ||
if (this._initialized) throw createMappedError(ErrorNames.attribute_pattern_already_initialized); | ||
const $patterns = this._patterns; | ||
for (const { pattern } of patterns) { | ||
if ($patterns[pattern] != null) throw createMappedError(ErrorNames.attribute_pattern_duplicate, pattern); | ||
$patterns[pattern] = { patternType: Type }; | ||
} | ||
this._allDefinitions.push(...patterns); | ||
} | ||
/** @internal */ | ||
private _initialize(): void { | ||
this._interpreter.add(this._allDefinitions); | ||
const _container = this._container; | ||
for (const [, value] of Object.entries(this._patterns)) { | ||
value.pattern = _container.get(value.patternType); | ||
} | ||
} | ||
public parse(name: string, value: string): AttrSyntax { | ||
// Optimization Idea: move the initialization to an AppTask | ||
if (!this._initialized) { | ||
this._initialize(); | ||
this._initialized = true; | ||
} | ||
let interpretation = this._cache[name]; | ||
@@ -496,3 +519,3 @@ if (interpretation == null) { | ||
} else { | ||
return this._patterns[pattern][pattern](name, value, interpretation.parts as string[]); | ||
return this._patterns[pattern].pattern![pattern](name, value, interpretation.parts as string[]); | ||
} | ||
@@ -504,5 +527,3 @@ } | ||
readonly name: string; | ||
define<const K extends AttributePatternDefinition, P extends Constructable<IAttributePattern<K['pattern']>> = Constructable<IAttributePattern<K['pattern']>>>(patternDefs: K[], Type: P): P; | ||
getPatternDefinitions(Type: Constructable): AttributePatternDefinition[]; | ||
findAll(container: IContainer): readonly IAttributePattern[]; | ||
create<const K extends AttributePatternDefinition, P extends Constructable<IAttributePattern<K['pattern']>> = Constructable<IAttributePattern<K['pattern']>>>(patternDefs: K[], Type: P): IRegistry; | ||
} | ||
@@ -513,107 +534,123 @@ | ||
*/ | ||
export function attributePattern<const K extends AttributePatternDefinition>(...patternDefs: K[]): <T extends Constructable<IAttributePattern<K['pattern']>>>(target: T, context: ClassDecoratorContext) => T { | ||
return function decorator<T extends Constructable<IAttributePattern<K['pattern']>>>(target: T): T { | ||
return AttributePattern.define(patternDefs, target); | ||
export function attributePattern<const K extends AttributePatternDefinition>(...patternDefs: K[]): <T extends Constructable<IAttributePattern<K['pattern']>>>(target: T, context: ClassDecoratorContext<T>) => T { | ||
return function decorator<T extends Constructable<IAttributePattern<K['pattern']>>>(target: T, context: ClassDecoratorContext<T>): T { | ||
const registrable = AttributePattern.create(patternDefs, target); | ||
// Decorators are by nature static, so we need to store the metadata on the class itself, assuming only one set of patterns per class. | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
context.metadata[registrableMetadataKey] = registrable; | ||
return target; | ||
}; | ||
} | ||
const getAllPatternDefinitions = <P extends Constructable>(Type: P): AttributePatternDefinition[] => | ||
patterns.get(Type as Constructable<IAttributePattern>) ?? emptyArray; | ||
const patterns = new WeakMap<Constructable<IAttributePattern>, AttributePatternDefinition[]>(); | ||
export const AttributePattern = /*@__PURE__*/ objectFreeze<AttributePatternKind>({ | ||
name: getResourceKeyFor('attribute-pattern'), | ||
define(patternDefs, Type) { | ||
patterns.set(Type, patternDefs); | ||
return Registrable.define(Type, (container: IContainer) => { | ||
singletonRegistration(IAttributePattern, Type).register(container); | ||
}); | ||
create(patternDefs, Type) { | ||
return { | ||
register(container: IContainer) { | ||
container.get(IAttributeParser).registerPattern(patternDefs, Type); | ||
singletonRegistration(IAttributePattern, Type).register(container); | ||
} | ||
}; | ||
}, | ||
getPatternDefinitions: getAllPatternDefinitions, | ||
findAll: (container) => container.root.getAll(IAttributePattern), | ||
}); | ||
export const DotSeparatedAttributePattern = /*@__PURE__*/ AttributePattern.define( | ||
[ | ||
{ pattern: 'PART.PART', symbols: '.' }, | ||
{ pattern: 'PART.PART.PART', symbols: '.' } | ||
], | ||
class DotSeparatedAttributePattern { | ||
public 'PART.PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], parts[1]); | ||
} | ||
export class DotSeparatedAttributePattern { | ||
public static [Symbol.metadata] = { | ||
[registrableMetadataKey]: /*@__PURE__*/AttributePattern.create( | ||
[ | ||
{ pattern: 'PART.PART', symbols: '.' }, | ||
{ pattern: 'PART.PART.PART', symbols: '.' } | ||
], | ||
DotSeparatedAttributePattern | ||
) | ||
}; | ||
public 'PART.PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], parts[1]); | ||
} | ||
public 'PART.PART.PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, `${parts[0]}.${parts[1]}`, parts[2]); | ||
} | ||
public 'PART.PART.PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, `${parts[0]}.${parts[1]}`, parts[2]); | ||
} | ||
); | ||
} | ||
export const RefAttributePattern = /*@__PURE__*/AttributePattern.define( | ||
[ | ||
{ pattern: 'ref', symbols: '' }, | ||
{ pattern: 'PART.ref', symbols: '.' } | ||
], | ||
class RefAttributePattern { | ||
public 'ref'(rawName: string, rawValue: string, _parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, 'element', 'ref'); | ||
} | ||
export class RefAttributePattern { | ||
public static [Symbol.metadata] = { | ||
[registrableMetadataKey]: /*@__PURE__*/AttributePattern.create( | ||
[ | ||
{ pattern: 'ref', symbols: '' }, | ||
{ pattern: 'PART.ref', symbols: '.' } | ||
], | ||
RefAttributePattern | ||
) | ||
}; | ||
public 'ref'(rawName: string, rawValue: string, _parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, 'element', 'ref'); | ||
} | ||
public 'PART.ref'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
let target = parts[0]; | ||
if (target === 'view-model') { | ||
target = 'component'; | ||
if (__DEV__) { | ||
// eslint-disable-next-line no-console | ||
console.warn(`[aurelia] Detected view-model.ref usage: "${rawName}=${rawValue}".` | ||
+ ` This is deprecated and component.ref should be used instead`); | ||
} | ||
public 'PART.ref'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
let target = parts[0]; | ||
if (target === 'view-model') { | ||
target = 'component'; | ||
if (__DEV__) { | ||
// eslint-disable-next-line no-console | ||
console.warn(`[aurelia] Detected view-model.ref usage: "${rawName}=${rawValue}".` | ||
+ ` This is deprecated and component.ref should be used instead`); | ||
} | ||
return new AttrSyntax(rawName, rawValue, target, 'ref'); | ||
} | ||
return new AttrSyntax(rawName, rawValue, target, 'ref'); | ||
} | ||
); | ||
} | ||
export const EventAttributePattern = /*@__PURE__*/ AttributePattern.define( | ||
[ | ||
{ pattern: 'PART.trigger:PART', symbols: '.:' }, | ||
{ pattern: 'PART.capture:PART', symbols: '.:' }, | ||
], | ||
class EventAttributePattern { | ||
public 'PART.trigger:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'trigger', parts); | ||
} | ||
public 'PART.capture:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'capture', parts); | ||
} | ||
export class EventAttributePattern { | ||
public static [Symbol.metadata] = { | ||
[registrableMetadataKey]: /*@__PURE__*/AttributePattern.create( | ||
[ | ||
{ pattern: 'PART.trigger:PART', symbols: '.:' }, | ||
{ pattern: 'PART.capture:PART', symbols: '.:' }, | ||
], | ||
EventAttributePattern | ||
) | ||
}; | ||
public 'PART.trigger:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'trigger', parts); | ||
} | ||
); | ||
public 'PART.capture:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'capture', parts); | ||
} | ||
} | ||
export const ColonPrefixedBindAttributePattern = /*@__PURE__*/AttributePattern.define( | ||
[{ pattern: ':PART', symbols: ':' }], | ||
class ColonPrefixedBindAttributePattern { | ||
export class ColonPrefixedBindAttributePattern { | ||
public ':PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'bind'); | ||
} | ||
public static [Symbol.metadata] = { | ||
[registrableMetadataKey]: /*@__PURE__*/AttributePattern.create( | ||
[{ pattern: ':PART', symbols: ':' }], | ||
ColonPrefixedBindAttributePattern | ||
) | ||
}; | ||
public ':PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'bind'); | ||
} | ||
); | ||
} | ||
export const AtPrefixedTriggerAttributePattern = /*@__PURE__*/ AttributePattern.define( | ||
[ | ||
{ pattern: '@PART', symbols: '@' }, | ||
{ pattern: '@PART:PART', symbols: '@:' }, | ||
], | ||
class AtPrefixedTriggerAttributePattern { | ||
public '@PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'trigger'); | ||
} | ||
export class AtPrefixedTriggerAttributePattern { | ||
public '@PART:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'trigger', [parts[0], 'trigger', ...parts.slice(1)]); | ||
} | ||
public static [Symbol.metadata] = { | ||
[registrableMetadataKey]: /*@__PURE__*/AttributePattern.create( | ||
[ | ||
{ pattern: '@PART', symbols: '@' }, | ||
{ pattern: '@PART:PART', symbols: '@:' }, | ||
], AtPrefixedTriggerAttributePattern | ||
) | ||
}; | ||
public '@PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'trigger'); | ||
} | ||
); | ||
public '@PART:PART'(rawName: string, rawValue: string, parts: readonly string[]): AttrSyntax { | ||
return new AttrSyntax(rawName, rawValue, parts[0], 'trigger', [parts[0], 'trigger', ...parts.slice(1)]); | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
@@ -627,5 +664,3 @@ /* istanbul ignore next */function testAttributePatternDeco() { | ||
// @ts-expect-error | ||
AttributePattern.define([{ pattern: 'abc', symbols: '.' }], class Def {}); | ||
AttributePattern.getPatternDefinitions(DotSeparatedAttributePattern).map(c => c.pattern); | ||
AttributePattern.create([{ pattern: 'abc', symbols: '.' }], class Def {}); | ||
} |
@@ -12,2 +12,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
export const enum ErrorNames { | ||
attribute_pattern_already_initialized = 88, | ||
attribute_pattern_duplicate = 89, | ||
method_not_implemented = 99, | ||
@@ -43,2 +46,5 @@ | ||
const errorsMap: Record<ErrorNames, string> = { | ||
[ErrorNames.attribute_pattern_already_initialized]: 'AttributeParser is already initialized; cannot add patterns after initialization.', | ||
[ErrorNames.attribute_pattern_duplicate]: 'Attribute pattern "{{0}}" has already been registered.', | ||
[ErrorNames.method_not_implemented]: 'Method {{0}} not implemented', | ||
@@ -45,0 +51,0 @@ |
@@ -52,3 +52,3 @@ export { | ||
AttrBindingCommand, | ||
BindingCommandType, | ||
type BindingCommandType, | ||
CaptureBindingCommand, | ||
@@ -55,0 +55,0 @@ ClassBindingCommand, |
@@ -11,3 +11,5 @@ import { IPlatform, resolve } from '@aurelia/kernel'; | ||
*/ | ||
export interface ITemplateElementFactory extends TemplateElementFactory {} | ||
export interface ITemplateElementFactory { | ||
createTemplate(input: string | Node): HTMLTemplateElement; | ||
} | ||
export const ITemplateElementFactory = /*@__PURE__*/createInterface<ITemplateElementFactory>('ITemplateElementFactory', x => x.singleton(TemplateElementFactory)); | ||
@@ -17,3 +19,3 @@ | ||
export class TemplateElementFactory { | ||
export class TemplateElementFactory implements ITemplateElementFactory { | ||
/** @internal */ | ||
@@ -28,5 +30,2 @@ private readonly p = resolve(IPlatform) as IDomPlatform; | ||
public createTemplate(markup: string): HTMLTemplateElement; | ||
public createTemplate(node: Node): HTMLTemplateElement; | ||
public createTemplate(input: string | Node): HTMLTemplateElement; | ||
public createTemplate(input: string | Node): HTMLTemplateElement { | ||
@@ -33,0 +32,0 @@ if (isString(input)) { |
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
1086693
20351
+ Added@aurelia/expression-parser@2.1.0-dev.202405280947(transitive)
+ Added@aurelia/kernel@2.1.0-dev.202405280947(transitive)
+ Added@aurelia/metadata@2.1.0-dev.202405280947(transitive)
+ Added@aurelia/platform@2.1.0-dev.202405280947(transitive)
- Removed@aurelia/expression-parser@2.1.0-dev.202405130849(transitive)
- Removed@aurelia/kernel@2.1.0-dev.202405130849(transitive)
- Removed@aurelia/metadata@2.1.0-dev.202405130849(transitive)
- Removed@aurelia/platform@2.1.0-dev.202405130849(transitive)