arcdoc-ng-core

<p align="center"> <img src="https://www.e-arc.com/wp-content/themes/earcv3/lib/theme/media/arc-logo.png"> </p> <h1 align="center">Library Core</h1>

Usage no npm install needed!

<script type="module">
  import arcdocNgCore from 'https://cdn.skypack.dev/arcdoc-ng-core';
</script>

README

Library Core

Core library are the set of things which can be used by the consumer to accomplish the different tasks in a typical angular application. The library consists

  1. Modules
  2. Utils
  3. Config
  4. Core
  5. Decorators
  6. Enum
  7. Token

Modules

Since our library is using material design. So here the library import all the necessary modules which we need in a angular application like MatMenuModule, MatCardModule, MatIconModule, MatTabsModule, MatRippleModule etc.

Utils

Some utility function which can be used in all over the library are consist here. They are uuid.

uuid

The customize the uuid generate from this utils so that user can get their unique uuid from here in every calling.

Config

All the configuration which are generally we are used in a angular application are consist here like ARC_ALLOWED_VIDEO_FILE_TYPES_LIST, ARC_ALLOWED_IMAGE_FILE_TYPES_LIST, ARC_RESTRICTED_FILE_EXTENTIONS_LIST, ARC_RESTRICTED_FILE_EXTENTIONS_LIST.

As for example....

This is the config of all the video file type list which is supported by our library.

export const ARC_ALLOWED_VIDEO_FILE_TYPES_LIST = [
  'video/x-flv',
  'video/mp4',
  'video/3gpp',
  'video/quicktime',
  'video/x-msvideo',
  'video/x-ms-wmv'
]; 

This is the config of all the image file type list which is supported by our library.

export const ARC_ALLOWED_IMAGE_FILE_TYPES_LIST = [
  'image/png',
  'image/jpg',
  'image/jpeg',
  'image/gif'
];

This is the config of all the restricted file type list which is supported by our library.

export const ARC_RESTRICTED_FILE_EXTENTIONS_LIST = [
  'application/x-msdownload',
  'application/octet-stream',
  'application/x-bat',
  'application/bat',
  'application/x-newton-compatible-pkg',
  'application/x-msi',
  'application/x-msdos-program',
  'application/textedit'
];

This is the config of all interceptor handler info list.

export const ARC_DEFAULT_INTERCEPTOR_HANDLER_INFO_LIST={};

Core

This section consist the list of modules which we need to expose to the consumer for any angular application.

Decorators

Enum

Generally we are use enum to correct the spelling mistake, capitalization of the variable name. Similarly we are defining all the variable which we are using in the library.

As for example....

export enum ARC_DEFAULT_TOKENS {
    ARC_ENV_VARIABLES = 'ARC_ENV_VARIABLES',
    ARC_APPLICATION_NAME = 'ARC_APPLICATION_NAME',
    ARC_ALLOWED_VIDEO_FILE_TYPES = 'ARC_ALLOWED_VIDEO_FILE_TYPES',
    ARC_DEFAULT_ALLOWED_VIDEO_FILE_TYPES = 'ARC_DEFAULT_ALLOWED_VIDEO_FILE_TYPES',
    ARC_ALLOWED_IMAGE_FILE_TYPES = 'ARC_ALLOWED_IMAGE_FILE_TYPES',
    ARC_DEFAULT_ALLOWED_IMAGE_FILE_TYPES = 'ARC_DEFAULT_ALLOWED_IMAGE_FILE_TYPES',
    ARC_RESTRICTED_FILE_EXTENTIONS = 'ARC_RESTRICTED_FILE_EXTENTIONS',
    ARC_DEFAULT_RESTRICTED_FILE_EXTENTIONS = 'ARC_DEFAULT_RESTRICTED_FILE_EXTENTIONS',
    ARC_INTERCEPTOR_HANDLER_INFO = 'ARC_INTERCEPTOR_HANDLER_INFO',
    ARC_DEFAULT_INTERCEPTOR_HANDLER_INFO = 'ARC_DEFAULT_INTERCEPTOR_HANDLER_INFO'
}

Token

Generally to inject any class in a angular project we are just use @Injectable in the header of the class which we need to inject. Then this class automatically added to the provider of the module. But in here in the library we are using injection token to customize the DI injection and inject the different class to the provider. so that's why we are using this injection token here.

There are two types of token here

  1. One token does not resolve here. It is resolving when the consumer use it in the consumer section.

    As for example

export const ARC_ALLOWED_VIDEO_FILE_TYPES = new InjectionToken<Array<string>>(ARC_DEFAULT_TOKENS.ARC_ALLOWED_VIDEO_FILE_TYPES);
  1. Other token is already resolved here. So in this case we are defining providedIn, factory.

As for example

export const ARC_DEFAULT_ALLOWED_VIDEO_FILE_TYPES = new InjectionToken<Array<string>>(
  ARC_DEFAULT_TOKENS.ARC_DEFAULT_ALLOWED_VIDEO_FILE_TYPES, {
  providedIn: 'root',
  factory: () => ARC_ALLOWED_VIDEO_FILE_TYPES_LIST
});

License

MIT