fg-dynamic-component 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"fg-dynamic-component.mjs","sources":["../../../projects/fg-dynamic-component/src/lib/fg-dynamic.component.ts","../../../projects/fg-dynamic-component/src/public-api.ts","../../../projects/fg-dynamic-component/src/fg-dynamic-component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ComponentRef, ElementRef, EventEmitter, Injector, InputSignal, ModelSignal, OnChanges, OnDestroy, Renderer2, Signal, Type, ViewContainerRef, inject, input, model, viewChild, viewChildren } from '@angular/core';\nimport { ControlValueAccessor, FormControl, FormControlDirective, FormGroup, NG_VALUE_ACCESSOR, NgControl, ValidatorFn, Validators } from '@angular/forms';\nimport { Subscription } from 'rxjs';\n\nexport interface FGDynamicItem {\n type?: string | Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);\n inputs?: Record<string, string | unknown>;\n outputs?: Record<string, string | Function>;\n attributes?: Record<string, string | unknown>;\n items?: FGDynamicItem[];\n}\n\n/**\n * Declare components to dynamically load in static and/or dynamic way using the FGDynamicService.\n */\nexport class FGDynamicService {\n private static _components: Record<string, Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>)> = {};\n\n static registerComponent(name: string, type: Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>)): void {\n if (name && type) {\n FGDynamicService._components[name] = type;\n }\n }\n\n static getComponent(name: string): Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>) {\n return FGDynamicService._components[name];\n }\n}\n\n/**\n * Create a standalone signals based dynamic components tree through a JSON configuration with full\n * life-cycle support for inputs, outputs, attributes, reactive forms and expressions binding evaluation.\n */\n@Component({\n\tselector: 'fg-dynamic',\n\ttemplate: `\n <ng-container #viewContainer></ng-container>\n @for (item of configuration()?.items; track $index) {\n <fg-dynamic #dynamicItem [configuration]=\"item\" [(viewModel)]=\"viewModel\" [formGroup]=\"formGroup()\" />\n }\n `,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\tstandalone: true\n})\nexport class FGDynamicComponent implements OnChanges, OnDestroy {\n\tconfiguration: InputSignal<FGDynamicItem> = input.required<FGDynamicItem>();\n\tviewModel: ModelSignal<unknown> = model<unknown>();\n\tformGroup: InputSignal<FormGroup> = input<FormGroup>();\n\n\tprivate _viewContainerRef: Signal<ViewContainerRef> = viewChild.required('viewContainer', {\n read: ViewContainerRef\n });\n private _dynamicItems: Signal<readonly ElementRef<unknown>[]> = viewChildren('dynamicItem', {\n read: ElementRef\n });\n\tprivate _componentRef: ComponentRef<unknown>;\n private _elementRef: ElementRef<HTMLElement> = inject(ElementRef);\n private _renderer: Renderer2 = inject(Renderer2);\n private _outputsSubscriptions: Subscription[] = [];\n private _formControl: FormControl;\n private _formControlDirective: FormControlDirective;\n private _formControlSubscription: Subscription;\n private _component: Type<unknown>;\n private _injector: Injector = inject(Injector);\n\n /**\n * A callback method that is invoked immediately after the default change\n * detector has checked data-bound properties if at least one has changed,\n * and before the view and content children are checked.\n */\n async ngOnChanges(): Promise<void> {\n // Lazy-load a component.\n await this.loadComponentAsync();\n // Instantiates a single component and inserts its host view into this container.\n this.createComponent();\n // Remove the fg-dynamic tag.\n this.removeHostElement();\n // Updates specified input names to new values.\n this.setInputs();\n // Disables/enables the control.\n this.setFormControlStatus();\n // Add synchronous validators to this control.\n this.setFormControlValidators();\n // Set attribute values for an element in the DOM.\n this.setAttributes();\n }\n\n /**\n * A method to lazy-load a component.\n */\n private async loadComponentAsync(): Promise<void> {\n if (this.configuration().type != null && !this._component) {\n let type: Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);\n\n if (typeof(this.configuration().type) === 'string') {\n type = FGDynamicService.getComponent(this.configuration().type as string);\n } else {\n type = this.configuration().type as Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);\n }\n\n try {\n type = (type as () => Promise<Type<unknown>>)();\n } catch {\n type = type;\n } finally {\n if (type instanceof Promise) {\n this._component = await type;\n } else {\n this._component = type as Type<unknown>;\n }\n }\n }\n }\n\n /**\n * Instantiates a single component and inserts its host view into this container.\n */\n private createComponent(): void {\n if (this._component && !this._componentRef && this._viewContainerRef() && !this._formControlDirective) {\n let injector: Injector;\n\n if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && typeof(this.evaluateExpression(this.configuration().attributes['name'], this.viewModel)) === 'string' && this.viewModel()) {\n // Synchronizes a standalone FormControl instance to a form control element.\n this._formControlDirective = new FormControlDirective(null, null, null, null);\n\n // Creates a new injector instance that provides one or more dependencies, according to a given type or types of StaticProvider.\n injector = Injector.create({\n providers: [{\n provide: NgControl,\n useValue: this._formControlDirective\n }],\n parent: this._injector\n });\n }\n\n // Instantiates a single component and inserts its host view into this container.\n this._componentRef = this._viewContainerRef().createComponent(this._component, {\n projectableNodes: this._dynamicItems()?.length > 0 ? [this._dynamicItems().map((e: ElementRef<unknown>): Node => e.nativeElement as Node)] : undefined,\n injector: injector\n });\n\n // When a view uses the ChangeDetectionStrategy#OnPush (checkOnce) change detection strategy, explicitly marks the view as changed so that it can be checked again.\n // Components are normally marked as dirty (in need of rerendering) when inputs have changed or events have fired in the view.\n // Call this method to ensure that a component is checked even if these triggers have not occurred.\n if (this._componentRef?.changeDetectorRef) {\n this._componentRef.changeDetectorRef.markForCheck();\n }\n\n // Register handlers for those events by subscribing to an instance.\n this.handleOutputs();\n // Construct a FormControl with an initial value.\n this.createFormControl();\n }\n }\n\n /**\n * A method to remove the fg-dynamic tag.\n */\n private removeHostElement(): void {\n if (this._elementRef?.nativeElement?.parentElement) {\n const nativeElement: HTMLElement = this._elementRef.nativeElement;\n const parentElement: HTMLElement = nativeElement.parentElement;\n\n // Move all children out of the element\n while (nativeElement.firstChild) {\n parentElement.insertBefore(nativeElement.firstChild, nativeElement);\n }\n\n // Remove the empty element (the host)\n parentElement.removeChild(nativeElement);\n }\n }\n\n /**\n * Register handlers for those events by subscribing to an instance.\n */\n private handleOutputs(): void {\n if (this.configuration()?.outputs && Object.keys(this.configuration().outputs).length > 0 && this._componentRef?.instance) {\n for (const outputName in this.configuration().outputs) {\n if (this._componentRef.instance[outputName] instanceof EventEmitter) {\n this._outputsSubscriptions.push(this._componentRef.instance[outputName].subscribe(($event: unknown): void => {\n // Evaluates JavaScript code and executes it.\n const result: unknown = this.evaluateExpression(this.configuration().outputs[outputName], this.viewModel, $event);\n\n if (result instanceof Function) {\n // Executes a function.\n result($event);\n }\n }));\n }\n }\n }\n }\n\n /**\n * Construct a FormControl with an initial value.\n */\n private createFormControl(): void {\n if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && this.viewModel()) {\n // Evaluates JavaScript code and executes it.\n const name = this.evaluateExpression(this.configuration().attributes['name'], this.viewModel) as string;\n\n if (typeof(name) === 'string') {\n // Construct a FormControl with an initial value.\n this._formControl = new FormControl(this.getModelPropertyValue(this.viewModel(), name, null));\n\n // Add a control to this group. In a strongly-typed group, the control must be in the group's type (possibly as an optional key).\n // If a control with a given name already exists, it would not be replaced with a new one.\n // If you want to replace an existing control, use the FormGroup#setControl setControl method instead.\n // This method also updates the value and validity of the control.\n this.formGroup().addControl(name, this._formControl);\n\n // A multicasting observable that emits an event every time the value of the control changes, in the UI or programmatically.\n this._formControlSubscription = this._formControl.valueChanges.subscribe((value: unknown): void => {\n // Creates a deep clone of an object.\n const viewModel: unknown = structuredClone(this.viewModel());\n\n // Sets the value at path of object.\n // If a portion of path doesn't exist, it's created.\n // Arrays are created for missing index properties while objects are created for all other missing properties.\n // This method mutates object.\n this.setModelPropertyValue(viewModel, name, value);\n // Directly set the signal to a new value, and notify any dependents.\n this.viewModel.set(viewModel);\n });\n\n // Synchronizes a standalone FormControl instance to a form control element.\n this.attachFormControlDirective();\n }\n }\n }\n\n /**\n * Disables/enables the control.\n */\n private setFormControlStatus(): void {\n if (this._formControl && this.configuration().attributes && this.configuration().attributes['disabled'] != null) {\n // Evaluates JavaScript code and executes it.\n const isDisabled: boolean = this.evaluateExpression(this.configuration().attributes['disabled'], this.viewModel) as boolean;\n\n if (typeof(isDisabled) === 'boolean' && ((isDisabled && this._formControl.enabled) || (!isDisabled && this._formControl.disabled))) {\n if (isDisabled) {\n // Disables the control.\n this._formControl.disable({\n onlySelf: true,\n emitEvent: false\n });\n } else {\n // Enables the control.\n this._formControl.enable({\n onlySelf: true,\n emitEvent: false\n });\n }\n }\n }\n }\n\n /**\n * Add synchronous validators to this control.\n */\n private setFormControlValidators(): void {\n if (this._formControl && this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {\n const validators: ValidatorFn[] = [];\n // Validator that requires the control's value to be greater than or equal to the provided number.\n const min = this.evaluateExpression(this.configuration().attributes['min'], this.viewModel) as number;\n\n if (typeof(min) === 'number' && min.toString() !== this._componentRef.location.nativeElement.getAttribute('min')) {\n validators.push(Validators.min(min));\n }\n\n // Validator that requires the control's value to be less than or equal to the provided number.\n const max = this.evaluateExpression(this.configuration().attributes['max'], this.viewModel) as number;\n\n if (typeof(max) === 'number' && max.toString() !== this._componentRef.location.nativeElement.getAttribute('max')) {\n validators.push(Validators.max(max));\n }\n\n // Validator that requires the control have a non-empty value.\n const required = this.evaluateExpression(this.configuration().attributes['required'], this.viewModel) as boolean;\n\n if (required === true && required.toString() !== this._componentRef.location.nativeElement.getAttribute('required')) {\n validators.push(Validators.required);\n }\n\n // Validator that requires the control's value pass an email validation test.\n const email = this.evaluateExpression(this.configuration().attributes['email'], this.viewModel) as boolean;\n\n if (email === true && email.toString() !== this._componentRef.location.nativeElement.getAttribute('email')) {\n validators.push(Validators.email);\n }\n\n // Validator that requires the length of the control's value to be less than or equal to the provided maximum length.\n const maxLength = this.evaluateExpression(this.configuration().attributes['maxlength'], this.viewModel) as number;\n\n if (maxLength > 0 && maxLength.toString() !== this._componentRef.location.nativeElement.getAttribute('maxlength')) {\n validators.push(Validators.maxLength(maxLength));\n }\n\n // Validator that requires the length of the control's value to be greater than or equal to the provided minimum length.\n const minLength = this.evaluateExpression(this.configuration().attributes['minlength'], this.viewModel) as number;\n\n if (minLength > 0 && minLength.toString() !== this._componentRef.location.nativeElement.getAttribute('minlength')) {\n validators.push(Validators.minLength(minLength));\n }\n\n // Validator that requires the control's value to match a regex pattern.\n const pattern = this.evaluateExpression(this.configuration().attributes['pattern'], this.viewModel) as string;\n\n if (typeof(pattern) === 'string' && pattern !== this._componentRef.location.nativeElement.getAttribute('pattern')) {\n validators.push(Validators.pattern(pattern));\n }\n\n if (validators.length > 0) {\n // Empties out the synchronous validator list.\n this._formControl.clearValidators();\n // Add a synchronous validator or validators to this control, without affecting other validators.\n this._formControl.addValidators(validators);\n // Recalculates the value and validation status of the control.\n this._formControl.updateValueAndValidity({\n onlySelf: true,\n emitEvent: false\n });\n }\n }\n }\n\n /**\n * Synchronizes a standalone FormControl instance to a form control element.\n */\n private attachFormControlDirective(): void {\n if (this._formControlDirective && this._componentRef?.injector && this._formControl) {\n this._formControlDirective.valueAccessor = this._componentRef.injector.get<ControlValueAccessor[]>(NG_VALUE_ACCESSOR, null)?.find((_: ControlValueAccessor): true => true);\n this._formControlDirective.form = this._formControl;\n\n // A callback method that is invoked immediately after the default change detector has checked data-bound properties if at least one has changed, and before the view and content children are checked.\n this._formControlDirective.ngOnChanges({\n form: {\n firstChange: true,\n currentValue: this._formControl,\n previousValue: undefined,\n isFirstChange: (): true => true\n }\n });\n }\n }\n\n /**\n * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.\n * @param model The object.\n * @param property The path.\n * @param defaultValue The resolved value.\n */\n private getModelPropertyValue(model: unknown, property: Array<string> | string, defaultValue: unknown): unknown {\n // If path is not defined or it has false value\n if (!property) {\n return undefined\n }\n\n // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.\n const pathArray: string[] = Array.isArray(property) ? property : property.match(/([^[.\\]])+/g);\n // Find value\n const result: unknown = pathArray.reduce((prevObj: unknown, key: string): unknown => prevObj && prevObj[key], model);\n\n // If found value is undefined return default value; otherwise return the value\n return result != null ? result : defaultValue\n }\n\n /**\n * Sets the value at path of object. If a portion of path doesn't exist, it's created.\n * Arrays are created for missing index properties while objects are created for all other missing properties.\n * This method mutates object.\n * @param model The object.\n * @param property The path.\n * @param value The value.\n */\n private setModelPropertyValue(model: unknown, property: Array<string> | string, value: unknown): void {\n const pathArray: string[] = Array.isArray(property) ? property : property.match(/([^[.\\]])+/g);\n\n pathArray.reduce((acc: unknown, key: string, i: number): unknown => {\n if (acc[key] === undefined) {\n acc[key] = {};\n }\n\n if (i === pathArray.length - 1) {\n acc[key] = value;\n }\n\n return acc[key]\n }, model);\n }\n\n /**\n * Updates specified input names to new values.\n */\n private setInputs(): void {\n if (this.configuration()?.inputs && Object.keys(this.configuration().inputs).length > 0 && this._componentRef) {\n for (const inputName in this.configuration().inputs) {\n // Updates a specified input name to a new value.\n // Using this method will properly mark for check component using the OnPush change detection strategy.\n // It will also assure that the OnChanges lifecycle hook runs when a dynamically created component is change-detected.\n this._componentRef.setInput(inputName, this.evaluateExpression(this.configuration().inputs[inputName], this.viewModel));\n }\n }\n }\n\n /**\n * Set attribute values for an element in the DOM.\n */\n private setAttributes(): void {\n if (this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {\n for (const attributeName in this.configuration().attributes) {\n // Evaluates JavaScript code and executes it.\n const value = this.evaluateExpression(this.configuration().attributes[attributeName], this.viewModel) as string;\n\n // Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.\n if (value !== this._componentRef.location.nativeElement.getAttribute(attributeName)) {\n // Implement this callback to set an attribute value for an element in the DOM.\n this._renderer.setAttribute(this._componentRef.location.nativeElement, attributeName, value);\n }\n }\n }\n }\n\n /**\n * Evaluates JavaScript code and executes it.\n * @param value The JavaScript code.\n * @param $vm The view model.\n * @param $event The event.\n * @returns Evaluated expression.\n */\n private evaluateExpression(value: unknown, $vm?: ModelSignal<unknown>, $event?: unknown): unknown {\n if (typeof(value) === 'string' && ((value.includes('$vm') && $vm != null && $vm() != null) || (value.includes('$event') && $event != null))) {\n // Evaluates JavaScript code and executes it.\n return eval(value);\n } else {\n return value;\n }\n }\n\n /**\n * A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.\n */\n\tngOnDestroy(): void {\n // Performs the specified action for each element in an array (Disposes the resources held by the subscription).\n this._outputsSubscriptions?.forEach((s: Subscription): void => s.unsubscribe());\n // Disposes the resources held by the subscription.\n // May, for instance, cancel an ongoing Observable execution or cancel any other type of work that started when the Subscription was created.\n this._formControlSubscription?.unsubscribe();\n // A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.\n this._formControlDirective?.ngOnDestroy();\n // Destroys the component instance and all of the data structures associated with it.\n this._componentRef?.destroy();\n\t}\n}\n","/*\n * Public API Surface of fg-dynamic-component\n */\n\nexport * from './lib/fg-dynamic.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAYA;;AAEG;MACU,gBAAgB,CAAA;aACV,IAAW,CAAA,WAAA,GAA4F,EAAE,CAAC,EAAA;AAEzH,IAAA,OAAO,iBAAiB,CAAC,IAAY,EAAE,IAA6E,EAAA;AAChH,QAAA,IAAI,IAAI,IAAI,IAAI,EAAE;AACd,YAAA,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;SAC7C;KACJ;IAED,OAAO,YAAY,CAAC,IAAY,EAAA;AAC5B,QAAA,OAAO,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KAC7C;;AAGL;;;AAGG;MAYU,kBAAkB,CAAA;AAX/B,IAAA,WAAA,GAAA;AAYC,QAAA,IAAA,CAAA,aAAa,GAA+B,KAAK,CAAC,QAAQ,EAAiB,CAAC;QAC5E,IAAS,CAAA,SAAA,GAAyB,KAAK,EAAW,CAAC;QACnD,IAAS,C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AAA;kBAX9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,CAAA;;;;;AAKN,IAAA,CAAA;oBACJ,eAAe,EAAE,uBAAuB,CAAC,MAAM;AAC/C,oBAAA,UAAU,EAAE,IAAI;AAChB,iBAAA,CAAA;;;AC3CD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"fg-dynamic-component.mjs","sources":["../../../projects/fg-dynamic-component/src/lib/fg-dynamic.component.ts","../../../projects/fg-dynamic-component/src/public-api.ts","../../../projects/fg-dynamic-component/src/fg-dynamic-component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ComponentRef, ElementRef, EventEmitter, Injector, InputSignal, ModelSignal, OnChanges, OnDestroy, Renderer2, Signal, Type, ViewContainerRef, inject, input, model, viewChild, viewChildren } from '@angular/core';\nimport { ControlValueAccessor, FormControl, FormControlDirective, FormGroup, NG_VALUE_ACCESSOR, NgControl, ValidatorFn, Validators } from '@angular/forms';\nimport { Subscription } from 'rxjs';\n\nexport interface IFGDynamicItem {\n type?: string | Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);\n inputs?: Record<string, string | unknown>;\n outputs?: Record<string, string | Function>;\n attributes?: Record<string, string | unknown>;\n items?: IFGDynamicItem[];\n}\n\n/**\n * Declare components to dynamically load in static and/or dynamic way using the FGDynamicService.\n */\nexport class FGDynamicService {\n private static _components: Record<string, Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>)> = {};\n\n static registerComponent(name: string, type: Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>)): void {\n if (name && type) {\n FGDynamicService._components[name] = type;\n }\n }\n\n static getComponent(name: string): Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>) {\n return FGDynamicService._components[name];\n }\n}\n\n/**\n * Create a standalone signals based dynamic components tree through a JSON configuration with full\n * life-cycle support for inputs, outputs, attributes, reactive forms and expressions binding evaluation.\n */\n@Component({\n\tselector: 'fg-dynamic',\n\ttemplate: `\n <ng-container #viewContainer></ng-container>\n @for (item of configuration()?.items; track $index) {\n <fg-dynamic #dynamicItem [configuration]=\"item\" [(viewModel)]=\"viewModel\" [formGroup]=\"formGroup()\" />\n }\n `,\n\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\tstandalone: true,\n\tstyles: [`:host { display: contents; }`]\n})\nexport class FGDynamicComponent implements OnChanges, OnDestroy {\n\tconfiguration: InputSignal<IFGDynamicItem> = input.required<IFGDynamicItem>();\n\tviewModel: ModelSignal<unknown> = model<unknown>();\n\tformGroup: InputSignal<FormGroup> = input<FormGroup>();\n\n\tprivate _viewContainerRef: Signal<ViewContainerRef> = viewChild.required('viewContainer', {\n read: ViewContainerRef\n });\n private _dynamicItems: Signal<readonly ElementRef<unknown>[]> = viewChildren('dynamicItem', {\n read: ElementRef\n });\n\tprivate _componentRef: ComponentRef<unknown>;\n private _renderer: Renderer2 = inject(Renderer2);\n private _outputsSubscriptions: Subscription[] = [];\n private _formControl: FormControl;\n private _formControlDirective: FormControlDirective;\n private _formControlSubscription: Subscription;\n private _managedValidatorFns: ValidatorFn[] = [];\n private _component: Type<unknown>;\n private _injector: Injector = inject(Injector);\n\n /**\n * A callback method that is invoked immediately after the default change\n * detector has checked data-bound properties if at least one has changed,\n * and before the view and content children are checked.\n */\n async ngOnChanges(): Promise<void> {\n try {\n // Lazy-load a component.\n await this.loadComponentAsync();\n // Instantiates a single component and inserts its host view into this container.\n this.createComponent();\n // Updates specified input names to new values.\n this.setInputs();\n // Disables/enables the control.\n this.setFormControlStatus();\n // Add synchronous validators to this control.\n this.setFormControlValidators();\n // Set attribute values for an element in the DOM.\n this.setAttributes();\n } catch (error) {\n console.error('[fg-dynamic] Error during component initialization:', error);\n }\n }\n\n /**\n * A method to lazy-load a component.\n */\n private async loadComponentAsync(): Promise<void> {\n const configurationType: string | Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>) = this.configuration().type;\n\n if (configurationType != null) {\n const requestedType: Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>) | undefined = typeof configurationType === 'string'\n ? FGDynamicService.getComponent(configurationType)\n : configurationType as Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);\n\n if (requestedType == null) {\n return;\n }\n\n let resolvedType: Type<unknown>;\n\n if (typeof requestedType === 'function') {\n // Try to invoke as a lazy loader function: () => Promise<Type<unknown>>\n try {\n const result: Promise<Type<unknown>> = (requestedType as () => Promise<Type<unknown>>)();\n\n resolvedType = result instanceof Promise ? await result : result as Type<unknown>;\n } catch {\n // Not a lazy loader function, treat it as a direct Type\n resolvedType = requestedType as Type<unknown>;\n }\n } else if (requestedType instanceof Promise) {\n resolvedType = await requestedType;\n } else {\n resolvedType = requestedType as Type<unknown>;\n }\n\n // Only re-assign when the resolved type actually changed, so that subsequent\n // input/attribute updates don't tear down the already-instantiated component.\n if (this._component !== resolvedType) {\n this._component = resolvedType;\n }\n }\n }\n\n /**\n * Instantiates a single component and inserts its host view into this container.\n */\n private createComponent(): void {\n // If the component type changed, clean up and recreate it.\n if (this._componentRef && this._component !== this._componentRef.componentType) {\n this.cleanup();\n }\n\n if (this._component && !this._componentRef && this._viewContainerRef() && !this._formControlDirective) {\n let injector: Injector;\n\n if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && typeof(this.evaluateExpression(this.configuration().attributes['name'], this.viewModel)) === 'string' && this.viewModel() != null) {\n // Synchronizes a standalone FormControl instance to a form control element.\n this._formControlDirective = new FormControlDirective(null, null, null, null);\n\n // Creates a new injector instance that provides one or more dependencies, according to a given type or types of StaticProvider.\n injector = Injector.create({\n providers: [{\n provide: NgControl,\n useValue: this._formControlDirective\n }],\n parent: this._injector\n });\n }\n\n // Instantiates a single component and inserts its host view into this container.\n this._componentRef = this._viewContainerRef().createComponent(this._component, {\n projectableNodes: this._dynamicItems()?.length > 0 ? [this._dynamicItems().map((e: ElementRef<unknown>): Node => e.nativeElement as Node)] : undefined,\n injector: injector\n });\n\n // When a view uses the ChangeDetectionStrategy#OnPush (checkOnce) change detection strategy, explicitly marks the view as changed so that it can be checked again.\n // Components are normally marked as dirty (in need of rerendering) when inputs have changed or events have fired in the view.\n // Call this method to ensure that a component is checked even if these triggers have not occurred.\n if (this._componentRef?.changeDetectorRef) {\n this._componentRef.changeDetectorRef.markForCheck();\n }\n\n // Register handlers for those events by subscribing to an instance.\n this.handleOutputs();\n // Construct a FormControl with an initial value.\n this.createFormControl();\n }\n }\n\n /**\n * Register handlers for those events by subscribing to an instance.\n */\n private handleOutputs(): void {\n if (this.configuration()?.outputs && Object.keys(this.configuration().outputs).length > 0 && this._componentRef?.instance) {\n for (const outputName in this.configuration().outputs) {\n if (this._componentRef.instance[outputName] instanceof EventEmitter) {\n this._outputsSubscriptions.push(this._componentRef.instance[outputName].subscribe(($event: unknown): void => {\n // Evaluates JavaScript code and executes it.\n const result: unknown = this.evaluateExpression(this.configuration().outputs[outputName], this.viewModel, $event);\n\n if (result instanceof Function) {\n // Executes a function.\n result($event);\n }\n }));\n }\n }\n }\n }\n\n /**\n * Construct a FormControl with an initial value.\n */\n private createFormControl(): void {\n if (this.formGroup() && this.configuration()?.attributes && this.configuration().attributes['name'] && this.viewModel() != null) {\n // Evaluates JavaScript code and executes it.\n const name = this.evaluateExpression(this.configuration().attributes['name'], this.viewModel) as string;\n\n if (typeof(name) === 'string') {\n // Construct a FormControl with an initial value.\n this._formControl = new FormControl(this.getModelPropertyValue(this.viewModel(), name, null));\n\n // Add a control to this group. In a strongly-typed group, the control must be in the group's type (possibly as an optional key).\n // If a control with a given name already exists, it would not be replaced with a new one.\n // If you want to replace an existing control, use the FormGroup#setControl setControl method instead.\n // This method also updates the value and validity of the control.\n this.formGroup().addControl(name, this._formControl);\n\n // A multicasting observable that emits an event every time the value of the control changes, in the UI or programmatically.\n this._formControlSubscription = this._formControl.valueChanges.subscribe((value: unknown): void => {\n // Creates a deep clone of an object, falling back to a JSON round-trip\n // when the view model contains non-cloneable values (functions, DOM nodes, ...).\n let viewModel: unknown;\n\n try {\n viewModel = structuredClone(this.viewModel());\n } catch {\n viewModel = JSON.parse(JSON.stringify(this.viewModel()));\n }\n\n // Sets the value at path of object.\n // If a portion of path doesn't exist, it's created.\n // Arrays are created for missing index properties while objects are created for all other missing properties.\n // This method mutates object.\n this.setModelPropertyValue(viewModel, name, value);\n // Directly set the signal to a new value, and notify any dependents.\n this.viewModel.set(viewModel);\n });\n\n // Synchronizes a standalone FormControl instance to a form control element.\n this.attachFormControlDirective();\n }\n }\n }\n\n /**\n * Disables/enables the control.\n */\n private setFormControlStatus(): void {\n if (this._formControl && this.configuration().attributes && this.configuration().attributes['disabled'] != null) {\n // Evaluates JavaScript code and executes it.\n const isDisabled: boolean = this.evaluateExpression(this.configuration().attributes['disabled'], this.viewModel) as boolean;\n\n if (typeof(isDisabled) === 'boolean' && ((isDisabled && this._formControl.enabled) || (!isDisabled && this._formControl.disabled))) {\n if (isDisabled) {\n // Disables the control.\n this._formControl.disable({\n onlySelf: true,\n emitEvent: false\n });\n } else {\n // Enables the control.\n this._formControl.enable({\n onlySelf: true,\n emitEvent: false\n });\n }\n }\n }\n }\n\n /**\n * Add synchronous validators to this control.\n */\n private setFormControlValidators(): void {\n if (!this._formControl) {\n return;\n }\n\n // Always remove previously managed validators, even when the current\n // configuration has no validator-bearing attributes.\n if (this._managedValidatorFns.length > 0) {\n this._formControl.removeValidators(this._managedValidatorFns);\n \n this._managedValidatorFns = [];\n \n this._formControl.updateValueAndValidity({\n onlySelf: true,\n emitEvent: false\n });\n }\n\n if (this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {\n const validators: ValidatorFn[] = [];\n // Validator that requires the control's value to be greater than or equal to the provided number.\n const min = this.evaluateExpression(this.configuration().attributes['min'], this.viewModel) as number;\n\n if (typeof(min) === 'number' && min.toString() !== this._componentRef.location.nativeElement.getAttribute('min')) {\n validators.push(Validators.min(min));\n }\n\n // Validator that requires the control's value to be less than or equal to the provided number.\n const max = this.evaluateExpression(this.configuration().attributes['max'], this.viewModel) as number;\n\n if (typeof(max) === 'number' && max.toString() !== this._componentRef.location.nativeElement.getAttribute('max')) {\n validators.push(Validators.max(max));\n }\n\n // Validator that requires the control have a non-empty value.\n const required = this.evaluateExpression(this.configuration().attributes['required'], this.viewModel) as boolean;\n\n if (required === true && required.toString() !== this._componentRef.location.nativeElement.getAttribute('required')) {\n validators.push(Validators.required);\n }\n\n // Validator that requires the control's value pass an email validation test.\n const email = this.evaluateExpression(this.configuration().attributes['email'], this.viewModel) as boolean;\n\n if (email === true && email.toString() !== this._componentRef.location.nativeElement.getAttribute('email')) {\n validators.push(Validators.email);\n }\n\n // Validator that requires the length of the control's value to be less than or equal to the provided maximum length.\n const maxLength = this.evaluateExpression(this.configuration().attributes['maxlength'], this.viewModel) as number;\n\n if (maxLength >= 0 && maxLength.toString() !== this._componentRef.location.nativeElement.getAttribute('maxlength')) {\n validators.push(Validators.maxLength(maxLength));\n }\n\n // Validator that requires the length of the control's value to be greater than or equal to the provided minimum length.\n const minLength = this.evaluateExpression(this.configuration().attributes['minlength'], this.viewModel) as number;\n\n if (minLength >= 0 && minLength.toString() !== this._componentRef.location.nativeElement.getAttribute('minlength')) {\n validators.push(Validators.minLength(minLength));\n }\n\n // Validator that requires the control's value to match a regex pattern.\n const pattern = this.evaluateExpression(this.configuration().attributes['pattern'], this.viewModel) as string;\n\n if (typeof(pattern) === 'string' && pattern !== this._componentRef.location.nativeElement.getAttribute('pattern')) {\n validators.push(Validators.pattern(pattern));\n }\n\n // Track and add the newly built managed validators.\n this._managedValidatorFns = validators;\n\n this._formControl.addValidators(this._managedValidatorFns);\n // Recalculates the value and validation status of the control whenever the\n // managed validator set changes (including when it becomes empty).\n this._formControl.updateValueAndValidity({\n onlySelf: true,\n emitEvent: false\n });\n }\n }\n\n /**\n * Synchronizes a standalone FormControl instance to a form control element.\n */\n private attachFormControlDirective(): void {\n if (this._formControlDirective && this._componentRef?.injector && this._formControl) {\n const valueAccessors: ControlValueAccessor[] | null = this._componentRef.injector.get<ControlValueAccessor[] | null>(NG_VALUE_ACCESSOR, null);\n \n this._formControlDirective.valueAccessor = Array.isArray(valueAccessors) && valueAccessors.length > 0 ? valueAccessors[0] : null;\n this._formControlDirective.form = this._formControl;\n\n // A callback method that is invoked immediately after the default change detector has checked data-bound properties if at least one has changed, and before the view and content children are checked.\n this._formControlDirective.ngOnChanges({\n form: {\n firstChange: true,\n currentValue: this._formControl,\n previousValue: undefined,\n isFirstChange: (): true => true\n }\n });\n }\n }\n\n /**\n * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.\n * @param model The object.\n * @param property The path.\n * @param defaultValue The resolved value.\n */\n private getModelPropertyValue(model: unknown, property: Array<string> | string, defaultValue: unknown): unknown {\n // If path is not defined or it has false value\n if (!property) {\n return undefined\n }\n\n // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.\n const pathArray: string[] = Array.isArray(property) ? property : property.match(/([^[.\\]])+/g);\n // Find value\n const result: unknown = pathArray.reduce((prevObj: unknown, key: string): unknown => prevObj && prevObj[key], model);\n\n // If found value is undefined return default value; otherwise return the value\n return result != null ? result : defaultValue\n }\n\n /**\n * Sets the value at path of object. If a portion of path doesn't exist, it's created.\n * Arrays are created for missing index properties while objects are created for all other missing properties.\n * This method mutates object.\n * @param model The object.\n * @param property The path.\n * @param value The value.\n */\n private setModelPropertyValue(model: unknown, property: Array<string> | string, value: unknown): void {\n const pathArray: string[] = Array.isArray(property) ? property : property.match(/([^[.\\]])+/g);\n\n pathArray.reduce((acc: unknown, key: string, i: number): unknown => {\n if (acc[key] === undefined) {\n acc[key] = {};\n }\n\n if (i === pathArray.length - 1) {\n acc[key] = value;\n }\n\n return acc[key]\n }, model);\n }\n\n /**\n * Updates specified input names to new values.\n */\n private setInputs(): void {\n if (this.configuration()?.inputs && Object.keys(this.configuration().inputs).length > 0 && this._componentRef) {\n for (const inputName in this.configuration().inputs) {\n // Updates a specified input name to a new value.\n // Using this method will properly mark for check component using the OnPush change detection strategy.\n // It will also assure that the OnChanges lifecycle hook runs when a dynamically created component is change-detected.\n this._componentRef.setInput(inputName, this.evaluateExpression(this.configuration().inputs[inputName], this.viewModel));\n }\n }\n }\n\n /**\n * Set attribute values for an element in the DOM.\n */\n private setAttributes(): void {\n if (this.configuration()?.attributes && Object.keys(this.configuration().attributes).length > 0 && this._componentRef?.location?.nativeElement) {\n for (const attributeName in this.configuration().attributes) {\n // Evaluates JavaScript code and executes it.\n const value = this.evaluateExpression(this.configuration().attributes[attributeName], this.viewModel);\n // Convert non-string values to their string form; null/undefined mean \"remove the attribute\".\n const stringValue: string | null = value != null ? String(value) : null;\n\n // Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.\n if (stringValue !== this._componentRef.location.nativeElement.getAttribute(attributeName)) {\n // Implement this callback to set an attribute value for an element in the DOM.\n if (stringValue != null) {\n this._renderer.setAttribute(this._componentRef.location.nativeElement, attributeName, stringValue);\n } else {\n this._renderer.removeAttribute(this._componentRef.location.nativeElement, attributeName);\n }\n }\n }\n }\n }\n\n /**\n * Evaluates JavaScript code and executes it.\n * @param value The JavaScript code.\n * @param $vm The view model.\n * @param $event The event.\n * @returns Evaluated expression.\n */\n private evaluateExpression(value: unknown, $vm?: ModelSignal<unknown>, $event?: unknown): unknown {\n if (typeof(value) === 'string' && ((value.includes('$vm') && $vm != null && $vm() != null) || (value.includes('$event') && $event != null))) {\n // NOTE: This uses eval() by design to support expression binding via the $vm and $event placeholders.\n // Only evaluate expressions from trusted configuration sources — arbitrary JavaScript can be executed here.\n return eval(value);\n } else {\n return value;\n }\n }\n\n /**\n * Cleans up every dynamically created resource: subscriptions, form control, value accessor directive and component reference.\n * Used both on component type change and on destroy.\n */\n private cleanup(): void {\n // Disposes the resources held by the output subscriptions.\n this._outputsSubscriptions?.forEach((s: Subscription): void => s.unsubscribe());\n\n this._outputsSubscriptions = [];\n\n // Disposes the resources held by the form control subscription.\n this._formControlSubscription?.unsubscribe();\n\n this._formControlSubscription = undefined;\n\n // Remove the managed control from the form group.\n if (this._formControl && this.formGroup()) {\n const attributeName = this.configuration()?.attributes?.['name'];\n\n if (attributeName) {\n const controlName = this.evaluateExpression(attributeName, this.viewModel) as string;\n\n // Only remove the control if it is the one this component created, so that\n // a pre-existing control registered under the same name is left untouched.\n if (typeof controlName === 'string' && this.formGroup().get(controlName) === this._formControl) {\n this.formGroup().removeControl(controlName);\n }\n }\n }\n\n this._formControl = undefined;\n this._managedValidatorFns = [];\n\n // A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.\n this._formControlDirective?.ngOnDestroy();\n\n this._formControlDirective = undefined;\n\n // Destroys the component instance and all of the data structures associated with it.\n this._componentRef?.destroy();\n \n this._componentRef = undefined;\n }\n\n /**\n * A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.\n */\n\tngOnDestroy(): void {\n this.cleanup();\n\t}\n}\n","/*\n * Public API Surface of fg-dynamic-component\n */\n\nexport * from './lib/fg-dynamic.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAYA;;AAEG;MACU,gBAAgB,CAAA;aACV,IAAA,CAAA,WAAW,GAA4F,EAAE,CAAC;AAEzH,IAAA,OAAO,iBAAiB,CAAC,IAAY,EAAE,IAA6E,EAAA;AAChH,QAAA,IAAI,IAAI,IAAI,IAAI,EAAE;AACd,YAAA,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI;QAC7C;IACJ;IAEA,OAAO,YAAY,CAAC,IAAY,EAAA;AAC5B,QAAA,OAAO,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC;IAC7C;;AAGJ;;;AAGG;MAaU,kBAAkB,CAAA;AAZ/B,IAAA,WAAA,GAAA;QAaC,IAAA,CAAA,aAAa,GAAgC,KAAK,CAAC,QAAQ;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T,yBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;ACvDL;;AAEG;;ACFH;;AAEG;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fg-dynamic-component",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "author": "Francesco Guagnano <guagnanofrancesco11@gmail.com>",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  "keywords": [
11
11
  "angular",
12
12
  "angular2",
13
- "fg",
13
+ "ng",
14
14
  "dynamic",
15
15
  "component",
16
16
  "input",
@@ -18,24 +18,23 @@
18
18
  "life-cycle"
19
19
  ],
20
20
  "peerDependencies": {
21
- "@angular/common": "17.2.4",
22
- "@angular/core": "17.2.4"
23
- },
24
- "dependencies": {
25
- "tslib": "2.6.2"
21
+ "@angular/common": "22.1.6",
22
+ "@angular/core": "22.1.6"
26
23
  },
27
24
  "sideEffects": false,
28
25
  "module": "fesm2022/fg-dynamic-component.mjs",
29
- "typings": "index.d.ts",
26
+ "typings": "types/fg-dynamic-component.d.ts",
30
27
  "exports": {
31
28
  "./package.json": {
32
29
  "default": "./package.json"
33
30
  },
34
31
  ".": {
35
- "types": "./index.d.ts",
36
- "esm2022": "./esm2022/fg-dynamic-component.mjs",
37
- "esm": "./esm2022/fg-dynamic-component.mjs",
32
+ "types": "./types/fg-dynamic-component.d.ts",
38
33
  "default": "./fesm2022/fg-dynamic-component.mjs"
39
34
  }
35
+ },
36
+ "type": "module",
37
+ "dependencies": {
38
+ "tslib": "^2.3.0"
40
39
  }
41
40
  }
@@ -1,17 +1,18 @@
1
- import { InputSignal, ModelSignal, OnChanges, OnDestroy, Type } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { OnChanges, OnDestroy, InputSignal, Type, ModelSignal } from '@angular/core';
2
3
  import { FormGroup } from '@angular/forms';
3
- import * as i0 from "@angular/core";
4
- export interface FGDynamicItem {
4
+
5
+ interface IFGDynamicItem {
5
6
  type?: string | Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);
6
7
  inputs?: Record<string, string | unknown>;
7
8
  outputs?: Record<string, string | Function>;
8
9
  attributes?: Record<string, string | unknown>;
9
- items?: FGDynamicItem[];
10
+ items?: IFGDynamicItem[];
10
11
  }
11
12
  /**
12
13
  * Declare components to dynamically load in static and/or dynamic way using the FGDynamicService.
13
14
  */
14
- export declare class FGDynamicService {
15
+ declare class FGDynamicService {
15
16
  private static _components;
16
17
  static registerComponent(name: string, type: Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>)): void;
17
18
  static getComponent(name: string): Type<unknown> | Promise<Type<unknown>> | (() => Promise<Type<unknown>>);
@@ -20,19 +21,19 @@ export declare class FGDynamicService {
20
21
  * Create a standalone signals based dynamic components tree through a JSON configuration with full
21
22
  * life-cycle support for inputs, outputs, attributes, reactive forms and expressions binding evaluation.
22
23
  */
23
- export declare class FGDynamicComponent implements OnChanges, OnDestroy {
24
- configuration: InputSignal<FGDynamicItem>;
24
+ declare class FGDynamicComponent implements OnChanges, OnDestroy {
25
+ configuration: InputSignal<IFGDynamicItem>;
25
26
  viewModel: ModelSignal<unknown>;
26
27
  formGroup: InputSignal<FormGroup>;
27
28
  private _viewContainerRef;
28
29
  private _dynamicItems;
29
30
  private _componentRef;
30
- private _elementRef;
31
31
  private _renderer;
32
32
  private _outputsSubscriptions;
33
33
  private _formControl;
34
34
  private _formControlDirective;
35
35
  private _formControlSubscription;
36
+ private _managedValidatorFns;
36
37
  private _component;
37
38
  private _injector;
38
39
  /**
@@ -49,10 +50,6 @@ export declare class FGDynamicComponent implements OnChanges, OnDestroy {
49
50
  * Instantiates a single component and inserts its host view into this container.
50
51
  */
51
52
  private createComponent;
52
- /**
53
- * A method to remove the fg-dynamic tag.
54
- */
55
- private removeHostElement;
56
53
  /**
57
54
  * Register handlers for those events by subscribing to an instance.
58
55
  */
@@ -105,6 +102,11 @@ export declare class FGDynamicComponent implements OnChanges, OnDestroy {
105
102
  * @returns Evaluated expression.
106
103
  */
107
104
  private evaluateExpression;
105
+ /**
106
+ * Cleans up every dynamically created resource: subscriptions, form control, value accessor directive and component reference.
107
+ * Used both on component type change and on destroy.
108
+ */
109
+ private cleanup;
108
110
  /**
109
111
  * A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.
110
112
  */
@@ -112,3 +114,6 @@ export declare class FGDynamicComponent implements OnChanges, OnDestroy {
112
114
  static ɵfac: i0.ɵɵFactoryDeclaration<FGDynamicComponent, never>;
113
115
  static ɵcmp: i0.ɵɵComponentDeclaration<FGDynamicComponent, "fg-dynamic", never, { "configuration": { "alias": "configuration"; "required": true; "isSignal": true; }; "viewModel": { "alias": "viewModel"; "required": false; "isSignal": true; }; "formGroup": { "alias": "formGroup"; "required": false; "isSignal": true; }; }, { "viewModel": "viewModelChange"; }, never, never, true, never>;
114
116
  }
117
+
118
+ export { FGDynamicComponent, FGDynamicService };
119
+ export type { IFGDynamicItem };
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- export * from './public-api';
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmctZHluYW1pYy1jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9wcm9qZWN0cy9mZy1keW5hbWljLWNvbXBvbmVudC9zcmMvZmctZHluYW1pYy1jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcbiJdfQ==