Module @ibyar/aurora - v3.1.0

Aurora

NPM Version NPM Downloads LICENSE lerna GitHub contributors Build Aurora + Example

Ibyar Aurora, is a web framework, that can create and define a Web Component standards ('custom elements', 'Shadow DOM' and 'HTML Templates'), that compatible with other frameworks, using Typescript.

This framework build with-in a embedded JavaScript Engine @ibyar/expressions to execute Template syntax and attributes binding.

npm i -g @ibyar/cli
yarn global add @ibyar/cli
npm i --save @ibyar/aurora
yarn add @ibyar/aurora
README Description NPM, PKG, SRC
@ibyar/cli ibyar cli package NPM Version NPM Downloads PKG SRC
@ibyar/aurora a central package to manage dependance only NPM Version NPM Downloads PKG SRC
@ibyar/core create components, render elements
bind attributes and handling events
NPM Version NPM Downloads PKG SRC
@ibyar/expressions a JavaScript engine, parser and evaluator
build by the guid of V8 JavaScript engine.
Introduce a reactive scope concept to
detect changes for scope variables,
subscriptions based on a wave effect like concept,
(simple what is subscribed will only be reevaluated again).
Follow ESTree structural to generate an ast object.
NPM Version NPM Downloads PKG SRC
@ibyar/elements parse HTML Template,
has tag names, properties for each tag
NPM Version NPM Downloads PKG SRC
@ibyar/pipes implement all supported pipes NPM Version NPM Downloads PKG SRC
@ibyar/directives implement all supported directives NPM Version NPM Downloads PKG SRC
@ibyar/platform utility package for and plural stuff, json patch NPM Version NPM Downloads PKG SRC
@ibyar/decorators ibyar decorators package NPM Version NPM Downloads PKG SRC
typescript Runtime library for TypeScript helpers. NPM Version NPM Downloads PKG SRC
tslib Runtime library for TypeScript helpers. NPM Version NPM Downloads PKG SRC
Support HTML Template
Parsing Attributes
One Way Data Binding
Two Way Data Binding
Event Binding
Template Parser
Template Syntax
Control Flow Syntax
Variables in templates
Template Reference Variables
Template HTML File fetch or embedded
Fragment
camelCase Property Naming
lowercase for root element Property Naming
  • [x] ES Module
  • [x] Dependency Injection
  • [x] Component
  • [x] Directives (Attribute and Structural Directives)
  • [x] Pipes
  • [x] Modules
  • [x] Lifecycle
  • [x] Signals
  • [x] input signal
  • [x] output signal
  • [x] view signal
  • [x] viewChild signal
  • [x] @HostListener [Supported by Component and Attribute directive].
  • [x] @HostBinding [Supported by Component and Attribute directive].
  • [ ] XSS (cross-site-scripting)
  • [x] *if
  • [x] *for is same as ( *forOf )
  • [x] *forIn
  • [x] *forAwait
  • [x] *switch and (*case, *default)

-- support control flow syntax -- see directive syntax structural-directive-syntax-reference

  • [x] class [support Single class binding, Multi-class binding].
  • [x] style [support Single style binding, Multi-style binding]. the Single style binding with units not yet supported.
  • [x] async
  • [x] json
  • [x] lowercase
  • [x] uppercase
  • [x] titlecase
  • [x] keyvalue
  • [x] slice
  • [ ] date
  • [ ] currency
  • [ ] number
  • [ ] percent
  • [ ] i18nPlural
  • [ ] i18nSelect
# always run ibyar cli to pre-build (AOT) your template and view types.
ibyar --build
#or
ibyar --build --watch

in a polyfills.ts file

  • use aurora zone for detect changes
import 'zone.js';
import { bootstrapZone } from '@ibyar/aurora';
bootstrapZone('aurora');
  • or use manual Zone, if you don't like to use Zone.js all the events like rxjs observables, setTimeout and fetch, etc.. can't be detected, use signals to connect to variables changes, provide better debugging experience.
import { bootstrapZone } from '@ibyar/aurora';
bootstrapZone('manual');
  • or use proxy Zone, if you don't like to use Zone.js but still like to have full change detection for your application. it my be hard in debugging your application.
import { bootstrapZone } from '@ibyar/aurora';
bootstrapZone('proxy');
  • you still can control the zone peer component while define your component by add zone t one of the zone types 'aurora', 'manual' and 'proxy'. if aurora is selected, you need to import the Zone.js package.

  • the zone property in the @Component({zone: 'manual'}) is optional and will get the default value from bootstrapZone()


import { Component, HostListener, isModel, OnDestroy, OnInit } from '@ibyar/aurora';
import { interval, Subscription } from 'rxjs';

@Component({
selector: 'pipe-app',
zone: 'AURORA',
template: `
<style>.bs-color{color: var({{currentColor}});}</style>
@for(let color of colors; let i = index, isOdd = odd) {
isOdd :{{ isOdd? 'odd': 'even'}}
color: {{color}}
}
<!-- Local template variables -->

@let name = user.name;
@let name = user.name, age = user.age; <!-- comma separated variable declaration -->
@let greeting = 'Hello, ' + name;
@let data = data$ | async;
@let pi = 3.1459;
@let coordinates = {x: 50, y: 100};
@let longExpression = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit ' +
'sed do eiusmod tempor incididunt ut labore et dolore magna ' +
'Ut enim ad minim veniam...';

<div *for="const color of colors">
color: {{color}} <span *if="color === currentColor" class="bs-color"> Current Color ='{{currentColor}}'</span>
</div>
<table class="table">
<thead>
<tr>
<th class="bs-color" scope="col">pipe</th>
<th class="bs-color" scope="col">expression</th>
<th class="bs-color" scope="col">view</th>
</tr>
</thead>
<tbody>
<tr>
<td>async</td>
<td>observable |> async</td>
<td>{{observable |> async}}</td>
</tr>
<tr>
<td>*</td>
<td>text</td>
<td>{{text}}</td>
</tr>
<tr>
<td>lowercase</td>
<td>text |> lowercase</td>
<td>{{text |> lowercase}}</td>
</tr>
<tr>
<td>titlecase</td>
<td>text |> titlecase</td>
<td>{{text |> titlecase}}</td>
</tr>
<tr>
<td>uppercase</td>
<td>text |> uppercase</td>
<td>{{text |> uppercase}}</td>
</tr>
<tr>
<td>json</td>
<td>obj |> json</td>
<td>{{obj |> json}}</td>
</tr>
<tr>
<td>json <small>pre element</small></td>
<td>obj |> json:undefined:2</td>
<td>
<pre>{{obj |> json:undefined:2}}</pre>
</td>
</tr>
<tr>
<td>keyvalue</td>
<td>keyValueObject |> keyvalue</td>
<td>{{keyValueObject |> keyvalue |> json}}</td>
</tr>
<tr>
<td>keyvalue</td>
<td>keyValueObject |> keyvalue</td>
<td>{{keyValueObject |> keyvalue |> json}}</td>
</tr>
<tr>
<td>keyvalue</td>
<td>keyValueMap |> keyvalue</td>
<td>{{keyValueMap |> keyvalue |> json}}</td>
</tr>
<tr>
<td>slice</td>
<td>array |> slice:1:3</td>
<td>{{array |> slice:1:3}}</td>
</tr>
<tr>
<td>slice</td>
<td>slice(array, 1, 3)</td>
<td>{{slice(array, 1, 3)}}</td>
</tr>
<tr>
<td>call windows method directly</td>
<td>3345.54645 |> Math.trunc</td>
<td>{{3345.54645 |> Math.trunc}}</td>
</tr>
</tbody>
</table>
`
})
export class PipeAppComponent implements OnInit, OnDestroy {

text = 'Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups';
obj = {
a: [1, 2, 3],
b: 'property b',
c: {
d: [],
e: 4,
f: [{ 5: 'g' }]
}
};

keyValueObject = {
1: 100,
a: 'A00'
};
keyValueArray = [200, 300];
keyValueMap = new Map<number, number | string>([[1, 400], [2, 500], [3, 'B200']]);

observable = interval(1000);

array = ['a', 'b', 'c', 'd'];


readonly name = input('name');
readonly age = input.required();
readonly inputWithAlias = input('init-value', { alias: 'alias-name-1' });
readonly requiredInputWithAlias = input.required({ alias: 'alias-name-2' });
readonly event = output<string>();

colors = [
'--bs-blue',
'--bs-indigo',
'--bs-purple',
'--bs-pink',
'--bs-red',
'--bs-orange',
'--bs-yellow',
'--bs-green',
'--bs-teal',
'--bs-cyan',
'--bs-white',
'--bs-gray',
'--bs-gray-dark'
];

currentColor = this.colors[0];

subscription: Subscription;

onInit() {
let index = 0;
this.subscription = this.observable.subscribe(() => {
if (index === this.colors.length) {
index = 0;
}
this.currentColor = this.colors[index++];
if (isModel(this)) {
this.emitChangeModel('currentColor');
}
console.log(this.currentColor);
});
}

@HostListener('currentColor')
onCurrentColorChange() {
console.log(this.currentColor);
}

onDestroy() {
this.subscription.unsubscribe();
}

}

in index.html add:

    <body>
<pipe-app></pipe-app>
<script type="module" src="path-to-main-file/index.js"></script>
</body>
git clone https://github.com/ibyar/aurora.git
cd aurora
yarn install
yarn build
git clone https://github.com/ibyar/aurora.git
cd aurora
npm install
npm run build

see test app for full example

module.exports = {
entry: './src/index.ts',
module: {
exprContextCritical: false,
rules: [
{
test: /\.tsx?$/,
use: ['@ibyar/cli',],
exclude: /node_modules/,
}
]
}
};
// 1. import default from the plugin module
import {
beforeCompileDirectiveOptions, beforeCompileComponentOptions,
afterDeclarationsCompileComponentOptions,
afterDeclarationsCompileDirectiveOptions,
scanDirectivesOnceAsTransformer,
} from '@ibyar/cli';


// 3. add getCustomTransformer method to the loader config
var config = {
...
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
... // other loader's options
getCustomTransformers: () => ({
before: [
scanDirectivesOnceAsTransformer(),
beforeCompileDirectiveOptions,
beforeCompileComponentOptions,
],
after: [],
afterDeclarations: [
afterDeclarationsCompileComponentOptions,
afterDeclarationsCompileDirectiveOptions,
],
})
}
}
]
}
...
};
import typescript from '@rollup/plugin-typescript';
import {
beforeCompileDirectiveOptions, beforeCompileComponentOptions,
afterDeclarationsCompileComponentOptions,
afterDeclarationsCompileDirectiveOptions,
scanDirectivesOnceAsTransformer,
} from '@ibyar/cli';

export default = {
...,
plugins: [
typescript({
transformers: {
before: [
{ type: 'program', factory: scanDirectivesOnceAsTransformer() },
{ type: 'program', factory: beforeCompileDirectiveOptions },
{ type: 'program', factory: beforeCompileComponentOptions },
],
after: [],
afterDeclarations: [
{ type: 'program', factory: afterDeclarationsCompileComponentOptions },
{ type: 'program', factory: afterDeclarationsCompileDirectiveOptions },
],
}
}),
],
...
};

see test app for full webpack

see test app for full rollup

Namespaces

formValue
input

Enumerations

AllowLabelledFunctionStatement
ClassLiteralPropertyKind
FunctionBodyType
FunctionKind
FunctionNameValidity
FunctionSyntaxKind
LanguageMode
ObjectLiteralPropertyKind
ParseFunctionFlag
ParsingArrowHeadFlag
PatchOperation
PreParserIdentifierType
PropertyKind
PropertyPosition
StaticFlag
SubFunctionKind
VariableDeclarationContext
VariableMode

Classes

AbstractAuroraZone
AbstractDefinition
AbstractExpressionNode
AbstractForDirective
AbstractParser
AccessorProperty
ArrayExpression
ArrayPattern
ArrowFunctionExpression
AssignmentExpression
AssignmentPattern
AsyncPipe
AsyncPipeProvider
AsyncPipeScope
AsyncPipeTransform
AsyncRelativeTimeFormatPipe
Attribute
AttributeDirective
AuroraZone
AwaitExpression
AwaitPromise
BaseNode
BinaryExpression
BindExpression
BlockStatement
BreakStatement
CallExpression
CaseOfSwitchDirective
CatchClauseNode
ChainExpression
ChangeDetectorRef
ChildRef
ChunkPipe
Class
ClassBody
ClassDeclaration
ClassDirective
ClassExpression
ClassLiteralProperty
ClassRegistry
CommentExpression
CommentNode
ComponentRender
Components
Computed
ConditionalExpression
ContinueStatement
DebuggerStatement
Decorator
DefaultCaseOfSwitchDirective
DefaultExpression
DiffPipe
DirectiveRegistry
DomAttributeDirectiveNode
DomElementNode
DomFragmentNode
DomParentNode
DomStructuralDirectiveNode
DomStructuralDirectiveSuccessorNode
DoWhileNode
ElementAttribute
ElementMutation
EmbeddedViewRef
EmbeddedViewRefImpl
EmptyStatement
EscapeHTMLCharacter
EventEmitter
EveryPipe
ExpressionStatement
ExpressionVisitor
ForAwaitDirective
ForAwaitOfNode
ForContext
ForDirective
ForInContext
ForInDirective
ForInNode
FormValueSignal
ForNode
ForOfContext
ForOfDirective
ForOfNode
FunctionDeclaration
FunctionExpression
GroupingExpression
HostBindingRef
HTMLParser
Identifier
IfStatement
IfThenElseDirective
InfixExpressionNode
InjectionProvider
InjectionToken
InputPropertyRef
InputSignal
JavaScriptInlineParser
JavaScriptParser
JSONPatch
JSONPipe
KeyValuePipe
LabeledStatement
Lazy
ListenerRef
Literal
LiveAttribute
LiveTextContent
LocalTemplateVariables
LogicalExpression
LowerCasePipe
ManualAuroraZone
MemberExpression
MetaProperty
MethodDefinition
ModuleScope
ModuleScopeResolver
MutationObservable
MutationSubscription
NewExpression
NodeParser
NodeParserHelper
ObjectExpression
ObjectLiteralProperty
ObjectPattern
OutputPropertyRef
OutputSignal
PipelineExpression
PipeProvider
PreTemplateLiteral
PrivateIdentifier
Program
Property
PropertyDefinition
PropertyKindInfo
PropertyRef
ProxyAuroraZone
ReactiveControlScope
ReactiveNode
ReactiveScope
ReactiveSignalScope
ReadOnlyScope
ReadOnlySignal
ReflectComponents
RestElement
ReturnStatement
ReturnValue
Scope
ScopeProxyHandler
ScopeSubscription
SequenceExpression
Signal
SignalScope
SlicePipe
SpreadElement
Stack
StaticBlock
StructuralDirective
StyleDirective
Subscription
Super
SwitchCase
SwitchDirective
SwitchStatement
SwitchView
TaggedTemplateExpression
TemplateLiteral
TemplateLiteralExpressionNode
TemplateParser
TemplateRef
TemplateRefImpl
TemplateStringLiteral
TerminateReturnType
TextContent
ThisExpression
ThrowStatement
TitleCasePipe
ToJSONPipe
Token
TokenExpression
TokenStream
TokenStreamer
TokenStreamImpl
TryCatchNode
UnaryExpression
UpdateExpression
UpperCasePipe
ValueChangeObserver
VariableDeclarationNode
VariableDeclarator
ViewChildSignal
ViewContainerRef
ViewContainerRefImpl
ViewRef
WebModuleScope
WhileNode
WithStatement
YieldDelegateValue
YieldExpression
YieldValue

Interfaces

AbstractType
AfterContentChecked
AfterContentInit
AfterViewChecked
AfterViewInit
AsyncIterableInfo
AttrRef
AwaitPromiseInfo
BaseComponent
BaseFormAssociatedComponent
BootstrapMetadata
CanFindScope
ChildOptions
ComponentOptions
ComponentRef
ConstructorOfView
ControlScope
CustomElement
DatePipeConfig
DeclarationExpression
DirectiveNodeOptions
DirectiveOptions
DirectiveRef
DoCheck
DragAndDropModel
EvaluateNode
EvaluateType
ExpressionNodConstructor
ExpressionNode
FormAssociatedComponent
FormAssociatedCustomElement
HTMLComponent
HTMLElementOptions
InjectableOptions
InjectableRef
InputOptions
InputWithoutTransform
InputWithTransform
KeyValue
LiveRegionModel
MetadataContext
ModuleContext
ModuleImport
ModuleOptions
ModuleSourceProvider
OnChanges
OnDestroy
OnInit
PipeOptions
PipeRef
PipeTransform
Position
RelationshipModel
ResolverConfig
SourceLocation
Tag
Type
ValueControl
ViewChildOpt
ViewContainerComponentOptions
ViewContainerOptions
VisitorControl
WidgetModel

Type Aliases

AriaActiveDescendantElement
AriaActiveDescendantElementRole
AriaAtomic
AriaAutocomplete
AriaBusy
AriaChecked
AriaColCount
AriaColCountRole
AriaColIndex
AriaColIndexRole
AriaColSpan
AriaColSpanRole
AriaControlsElements
AriaDescribedByElements
AriaDescription
AriaDetailsElements
AriaDisabled
AriaDropEffect
AriaErrorMessageElement
AriaErrorMessageElementRole
AriaExpanded
AriaFlowToElements
AriaGrabbed
AriaHasPopup
AriaHidden
AriaInvalid
AriaLabel
AriaLabelledByElements
AriaLevel
AriaLive
AriaModal
AriaMultiline
AriaMultiSelectable
AriaOrientation
AriaOwnsElements
AriaPlaceholder
AriaPosInSet
AriaPressed
AriaReadonly
AriaRelevant
AriaRequired
AriaRowCount
AriaRowIndex
AriaRowSpan
AriaSelected
AriaSetSize
AriaSort
AriaValueMax
AriaValueMin
AriaValueNow
AriaValueText
AssignmentOperator
BinaryOperator
ClassInfo
CleanupFn
CleanupRegister
CompareFn
ComponentModelClass
Context
DeclarationType
DiffOptions
DiffPatch
DomChild
DomNode
DomRenderNode
ElementID
EvaluateCallback
ExpressionEventMap
ExpressionEventPath
ExpressionEventPathBracketNotation
ExpressionEventPathDotNotation
ForDeclaration
FunctionInfo
HoistableDeclaration
HTMLFormElement
InlineParserOptions
InputOptionsWithoutTransform
InputOptionsWithTransform
LexicalDeclaration
LogicalOperator
MetadataClass
MethodDefinitionKind
ModelType
NodeContextType
NodeDeserializer
NodeJsonType
NodeType
OutputEventInit
OutputOptions
ɵɵ0CaseDirective0ɵɵ
ɵɵ0ClassDirective0ɵɵ
ɵɵ0DefaultDirective0ɵɵ
ɵɵ0ForAwaitDirective0ɵɵ
ɵɵ0ForDirective0ɵɵ
ɵɵ0ForInDirective0ɵɵ
ɵɵ0ForOfDirective0ɵɵ
ɵɵ0IfDirective0ɵɵ
ɵɵ0StyleDirective0ɵɵ
ɵɵ0SwitchDirective0ɵɵ
ParserOptions
PatchArray
PatchObject
PositionMark
ProgramSourceType
Provider
ProviderType
Range
RangeOrVoid
RevocableProxy
SignalDestroyRef
TagClassRef
TemplateUrl
TerminateType
TrackBy
UnaryOperator
UpdateOperator
ValueChangedCallback
VisitNodeType
VisitorCallback
WriteValueMode
WriteValueOptions
ZoneType

Variables

ARIAMixinAttributes
Attrs
classRegistryProvider
CustomElementRegex
DATE_PIPE_DEFAULT_OPTIONS
DefaultTag
DIRECTIVE_HOST_TOKEN
directiveRegistry
DragAndDropAttributes
DragAndDropAttributesMap
EmptyElements
expressionVisitor
GlobalAttributes
htmlParser
IdentifierPartRegex
IdentifierRegex
IdentifierStartRegex
LiveRegionAttributes
LiveRegionAttributesMap
LOCALE_ID
metadataHoler
NATIVE_HOST_TOKEN
NativeTags
PatchRoot
RelationshipAttributes
RelationshipAttributesMap
ShadowElements
SUCCESSORS_TOKEN
templateParser
VIEW_TOKEN
VoidElements
WidgetAttributes
WidgetAttributesMap

Functions

addProvider
addViewToModelClass
bindsSuper
bootstrapZone
buildExpressionNodes
buildViewClassNameFromSelector
canAttachShadow
classPropertyKindFor
clearSignalScope
Component
computed
createChangeDetectorRef
createClassInfo
createLiveAttribute
createModelChangeDetectorRef
createProxyForContext
createRevocableProxyForContext
createRootURL
customElement
deleteDirective
deserialize
deserializeNode
Deserializer
diff
Directive
effect
fetchFromCache
fetchHtml
fetchHtmlFromModule
findByTagName
findReactiveScopeByEventMap
findScopeByEventMap
forkProvider
formValue
functionKind2String
functionKindFor
functionKindForImpl
getAllAttributes
getClassRef
getComponentView
getDeserializerType
getLanguageMode
getPipelineNames
getRootZone
getTagName
getTagsForAttr
getVariableMode
hasAttr
hasAttrCustomElement
hasBindingHook
hasNativeAttr
HostBinding
HostListener
htmlFullPath
initCustomElementView
inject
Injectable
input
isAccessor
isAccessorFunction
isAfterContentChecked
isAfterContentInit
isAfterViewChecked
isAfterViewInit
isArrowFunction
isAsyncFunction
isAsyncGeneratorFunction
isAsyncModule
isAutocapitalizeInheritingElement
isAwaitAsIdentifierDisallowed
isBaseConstructor
isClassConstructor
isClassMembersInitializerFunction
isComponentModelClass
isComputed
isConciseMethod
isConstructable
isDataAttributes
isDefaultConstructor
isDerivedConstructor
isDoCheck
isDOMDirectiveNode
isEmptyElement
isFormAssociatedCustomElement
isFormAssociatedCustomElementByConstructor
isFormAssociatedCustomElementByElement
isFormAssociatedCustomElementByTag
isFormElement
isFormLabelableElement
isGeneratorFunction
isGetterFunction
isHTMLComponent
isHTMLComponentOfType
isHTMLElement
isHTMLUnknownElement
isHTMLUnknownElementTagName
isInputSignal
isInRange
isLazy
isListedFormElement
isLiveTextContent
isLocalTemplateVariables
isModule
isOnChanges
isOnDestroy
isOnInit
isOutputSignal
isPipeTransform
isReactive
isReadOnlySignal
isResettableElement
isResumableFunction
isSetterFunction
isSignal
isSloppy
isStatic
isStrict
isStrictFunctionWithoutPrototype
isSubmittableElement
isTagNameNative
isValidCustomElementName
isValueControl
isViewChildSignal
isVoidElement
lazy
makeClassDecorator
makeClassMemberDecorator
Metadata
methodKindFor
Module
output
parseStringTemplate
parseTextChild
Pipe
provide
provideDirective
pushNewSignalScope
pushSignalScope
removeProvider
serializeNode
signal
ToCamelCase
untracked
view
viewChild