.editorconfig000066400000000000000000000006371516137561000135460ustar00rootroot00000000000000# EditorConfig helps developers define and maintain consistent # coding styles between different editors and IDEs # editorconfig.org root = true [*] # Change these settings to your own preference indent_style = space indent_size = 4 # We recommend you to keep these unchanged end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false .gitignore000066400000000000000000000003261516137561000130540ustar00rootroot00000000000000/node_modules /build /dist .idea/workspace.xml .idea/tasks.xml .idea/profiles_settings.xml .idea/inspectionProfiles/Project_Default.xml .idea/inspectionProfiles/profiles_settings.xml node_modules/.yarn-integrity .idea/000077500000000000000000000000001516137561000120435ustar00rootroot00000000000000.idea/angular-compile.iml000066400000000000000000000005201516137561000156220ustar00rootroot00000000000000 .idea/codeStyleSettings.xml000066400000000000000000000004251516137561000162420ustar00rootroot00000000000000 .idea/inspectionProfiles/000077500000000000000000000000001516137561000157225ustar00rootroot00000000000000.idea/inspectionProfiles/profiles_settings.xml000066400000000000000000000002341516137561000222060ustar00rootroot00000000000000 .idea/misc.xml000066400000000000000000000002561516137561000135230ustar00rootroot00000000000000 .idea/modules.xml000066400000000000000000000004321516137561000142340ustar00rootroot00000000000000 .idea/vcs.xml000066400000000000000000000002471516137561000133630ustar00rootroot00000000000000 .npmignore000066400000000000000000000004271516137561000130650ustar00rootroot00000000000000/.idea /artifacts /build /test /node_modules /*.iml /*.ipr /*.iws /.travis.yml /.scrutinizer.yml /Gruntfile.js /*.lock *.log /corifeus-boot.json # Corifeus / P3X /tsconfig* /dist/node_modules /dist/test /src /src-save /index.ts # need to allow ts for awesome=typscript-loader .travis.yml000066400000000000000000000014701516137561000131760ustar00rootroot00000000000000sudo: required language: node_js node_js: - lts/* before_script: - npm install -g grunt-cli npm - npm install env: global: secure: c1EmMJCCfB1cFe//vM+fw+PzBCYII2szjXyvzQ+GKtBfH4MmYsgupdhLyCYbN0q4ASpb5ajL9ynEQrQMax1mmjGK1BoHdx7HqB1+p3fFDdyfMr59zcbufHjoepjvm1b1bdxmHv4HhKVeyuhcNDQLEFy4FGNLFLkB31Wj/tFhQd9DRxt23ubsdpsG8xHknvqTCOxoZxQZ0PQrtTIKDtJTjVaSkcU5X8SbShs1z6zt6ciiOa+Y1fSHoFU6cjepqPbrfK2LV6+9PEHj0RZ0XbqoPnPcOus7HLUuv2v3CZLxjTGpr97Ah1QzSeEFfqZtS8rddTiUo8LdeXxCkpm6tkhdi4GCYVsTuClfoKOqhkH6Q6/LRVd2ZnvPAzpiwhfSuQCat8tBuB3LJP5Z2gysSHYjoj+mVX79WksKhsNuaJuWSdmEwfXUq/2B9KsFUNxhebW2DdIby7Kz0w1L5UtS83kacT/U/ZVtoA+D8nRxgJ78BukWPPyImZZItfnd1Kht2AVujsNN90n0+p5t8JtRwQBVhJQtwK550OZiwd9WpGuHOmLEKVSKVeCr6hCNDDWl+XDgs9JpLpUEpPY2cWl/ku8GCuM6Z/XDcK0c26LFbohK3LEo4opiLkX3M55NQYYVevIS2/mOaETcYh9qcFU/5lFojrxeiUywW5xbssc2zorNIIY= Gruntfile.js000066400000000000000000000030411516137561000133560ustar00rootroot00000000000000module.exports = (grunt) => { grunt.option('cory-loader-off', true); //node node_modules/protractor/bin/webdriver-manager update const builder = require('corifeus-builder-angular'); /* webdriver-manager/selenium/update-config.json node_modules/protractor/bin/webdriver-manager update */ const loader = new builder.loader(grunt); loader.angular({ root: builder.config.folder.test.angularWebpack.root, replacer: { type: 'p3x', npmio: true, }, config: { clean: { 'cory-publish': [ 'dist' ] } } }); grunt.registerTask('run', builder.config.task.run.angular); grunt.registerTask('default', builder.config.task.build.angular); grunt.registerTask('travis', [ 'cory-npm', 'cory-npm-angular', 'clean', 'copy:cory-build', 'cory:license', 'cory-build-jit', 'cory-replace' ] ); grunt.registerTask('aot', builder.config.task.build.angularAot); grunt.registerTask('aot-jit', builder.config.task.build.angularAotJit); grunt.registerTask('aot-test', ['webpack:cory-build-aot', 'cory-test-connect']); grunt.registerTask('coverage', 'karma:cory-angular'); grunt.registerTask('publish', ['cory-replace', 'cory-npm', 'cory-publish-angular']); //cori-test:angular-protractor // cori-test:angular-karma grunt.registerTask('test-connect', [ 'connect:cory-angular', 'watch:cory-wait' ]) } LICENSE000066400000000000000000000023571516137561000120770ustar00rootroot00000000000000 @license p3x-angular-compile v2020.10.117 🆖 Angular Dynamic Compile - Convert strings to Angular components https://corifeus.com/angular-compile Copyright (c) 2020 Patrik Laszlo / P3X / Corifeus and contributors. MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. README.md000066400000000000000000000207301516137561000123440ustar00rootroot00000000000000[//]: #@corifeus-header [![NPM](https://nodei.co/npm/p3x-angular-compile.png?downloads=true&downloadRank=true)](https://www.npmjs.com/package/p3x-angular-compile/) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://paypal.me/patrikx3) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Corifeus @ Facebook](https://img.shields.io/badge/Facebook-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Build Status](https://api.travis-ci.com/patrikx3/angular-compile.svg?branch=master)](https://travis-ci.com/patrikx3/angular-compile) [![Uptime Robot ratio (30 days)](https://img.shields.io/uptimerobot/ratio/m780749701-41bcade28c1ea8154eda7cca.svg)](https://uptimerobot.patrikx3.com/) # 🆖 Angular Dynamic Compile - Convert strings to Angular components v2020.10.116 **Bugs are evident™ - MATRIX️** ### NodeJs LTS Version Requirement ```txt >=12.13.0 ``` ### Built on NodeJs ```txt v12.18.3 ``` The ```async``` and ```await``` keywords are required. Only the latest LTS variant is supported. Install NodeJs: https://nodejs.org/en/download/package-manager/ # Built on Angular ```text 10.1.0 ``` # Description [//]: #@corifeus-header:end # Use case Dynamically compile standard strings to fully functional Angular components. Supports imports, exports, and standard context. ## NPM It is an ```ESNEXT``` bundle by default. ## Install ```bash npm install --save p3x-angular-compile # or yarn add p3x-angular-compile ``` ## Check out how it works and code https://angular-compile.corifeus.com https://github.com/patrikx3/angular-compile/blob/master/test/angular-webpack/angular/page.ts#L115 ## IMPORTANT Make sure Ivy is disabled in the `tsconfig.json`: ```json "angularCompilerOptions": { "enableIvy": false } ``` Make sure AOT is disabled in the `angular.json`: ```json { "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/workspace", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", // make sure it is false "aot": false, "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "src/styles.scss" ], "scripts": [] } } } ``` When you work with P3X Angular Compile, you have to disable AOT as well, so like this: ```bash ng serve --aot=false ``` ## Usage ```typescript import { CompileModule} from "p3x-angular-compile" // the module settings @NgModule({ imports: [ CorifeusWebMaterialModule, // Optional CompileModule, // Required ], declarations: [ Page, ], providers: [ ], bootstrap: [ Page ] }) export class Module { }; ``` #### Template ```html *ngIf="isEnabled" [p3x-compile]="template" [p3x-compile-ctx]="this" [p3x-compile-error-handler]="handleCompileErrorHandler" [p3x-compile-module]="dataModule" > ``` #### Code ```typescript // A page example export class Page { isEnabled: boolean = true; dataModule : any = { //schemas: [CUSTOM_ELEMENTS_SCHEMA], //declarations: [], imports: [ MatButtonModule ], exports: [ ] } template: string = ""; handleCompileErrorHandler(error: Error) { console.error(error) } alert() { alert('ok'); } } ``` ### Options [Reference for the Angular module settings which are available.]( https://github.com/angular/angular/blob/master/packages/core/src/metadata/ng_module.ts) ## Dev environment end test ```bash npm install -g yarn git clone https://github.com/patrikx3/angular-compile.git cd angular-compile npm install grunt run|default ``` [http://localhost:8080](http://localhost:8080) # Errors ## Type x is part of the declarations of 2 modules Basically, you need a shared component. https://stackoverflow.com/questions/42993580/angular-2-type-childcomponent-is-a-part-of-the-declarations-of-2-modules-par ## AOT + JIT ### Since Angular 5.x.x + We cannot use AOT + JIT at once. #### Info https://github.com/angular/angular/issues/20156#issuecomment-341767899 On the issue, you can see: ```text To reduce the payload, we do not ship the compiler in AOT. ``` So right now, it is not possible. Although, there are some hacks, but you are on your own... https://github.com/angular/angular/issues/20156#issuecomment-468686933 ### Size If you want very small bundle, use ```gzip```. [//]: #@corifeus-footer --- 🙏 This is an open-source project. Star this repository, if you like it, or even donate to maintain the servers and the development. Thank you so much! Possible, this server, rarely, is down, please, hang on for 15-30 minutes and the server will be back up. All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https://corifeus.com)) could have minor errors, since I am developing in my free time. However, it is usually stable. **Note about versioning:** Versions are cut in Major.Minor.Patch schema. Major is always the current year. Minor is either 4 (January - June) or 10 (July - December). Patch is incremental by every build. If there is a breaking change, it should be noted in the readme. --- [**P3X-ANGULAR-COMPILE**](https://corifeus.com/angular-compile) Build v2020.10.116 [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) ## P3X Sponsor [IntelliJ - The most intelligent Java IDE](https://www.jetbrains.com/?from=patrikx3) [![JetBrains](https://cdn.corifeus.com/assets/svg/jetbrains-logo.svg)](https://www.jetbrains.com/?from=patrikx3) [//]: #@corifeus-footer:end angular-compile.iml000066400000000000000000000006241516137561000146470ustar00rootroot00000000000000 index.ts000066400000000000000000000000271516137561000125410ustar00rootroot00000000000000export * from "./src"; package.json000066400000000000000000000034561516137561000133610ustar00rootroot00000000000000{ "name": "p3x-angular-compile", "version": "2020.10.117", "corifeus": { "prefix": "p3x-", "publish": true, "type": "p3x", "code": "Logico", "nodejs": "v12.18.3", "opencollective": false, "reponame": "angular-compile", "build": true, "angular": "10.1.0" }, "description": "🆖 Angular Dynamic Compile - Convert strings to Angular components", "main": "dist/index.js", "typings": "dist/index", "scripts": { "test": "grunt travis" }, "repository": { "type": "git", "url": "git+https://github.com/patrikx3/angular-compile.git" }, "keywords": [ "p3x", "angular", "ng", "compile", "html", "angular", "dynamic", "aot" ], "author": "Patrik Laszlo ", "license": "MIT", "bugs": { "url": "https://github.com/patrikx3/angular-compile/issues" }, "homepage": "https://corifeus.com/angular-compile", "devDependencies": { "corifeus-builder-angular": "^2020.10.115", "@angular/router": "=10.1.0", "@types/node": "^14.6.4", "@types/js-cookie": "^2.2.6", "@types/tinycolor2": "^1.4.2", "js-cookie": "^2.2.1", "tinycolor2": "^1.4.1", "@angular/animations": "=10.1.0", "@angular/cdk": "^10.2.0", "@angular/material": "^10.2.0", "@fortawesome/fontawesome-free": "^5.14.0", "@types/lodash": "^4.14.161", "corifeus-web": "^2020.4.253", "hammerjs": "^2.0.8", "lodash": "^4.17.20", "material-design-icons": "^3.0.1", "roboto-fontface": "^0.10.0" }, "dependencies": { "lodash": "^4.17.20" }, "engines": { "node": ">=12.13.0" } }src-save/000077500000000000000000000000001516137561000126065ustar00rootroot00000000000000src-save/CompileService.ts000066400000000000000000000067411516137561000160770ustar00rootroot00000000000000/* import { Component, NgModule, Injectable, Compiler, ViewContainerRef, ModuleWithProviders, Type, Optional } from '@angular/core'; import { CommonModule } from '@angular/common'; import { BrowserModule } from '@angular/platform-browser'; import { cloneDeep } from 'lodash'; export interface CompileOptions { template: string; container: ViewContainerRef; imports?: Array | ModuleWithProviders | any[]>; context?: any, onCompiled?: Function, onError?: Function; module?: NgModule; } const cache : any = {}; export class CompileServiceConfig { module: NgModule } let SingletonDefaultModule: NgModule; @Injectable() export class CompileService { constructor( private compiler: Compiler, @Optional() config: CompileServiceConfig, ) { if (config !== undefined && config !== null) { if (config.module !== undefined && config.module !== null) { SingletonDefaultModule = config.module; } } } public async compile(opts: CompileOptions) { try { const factory = await this.createFactory(opts); opts.container.clear(); const cmp : any = opts.container.createComponent(factory); cmp.instance.context = opts.context; } catch (e) { if (opts.onError) { opts.onError(e) } else { console.error(e); } } } private async createFactory(opts: CompileOptions) { const cacheKey = opts.template; if (Object.keys(cache).indexOf(cacheKey) > -1) { return cache[cacheKey]; } cache[cacheKey] = (async() => { try { @Component({ template: opts.template }) class TemplateComponent { context: any } let module : NgModule = {}; if (opts.module !== undefined) { module = cloneDeep(opts.module); } else if (SingletonDefaultModule !== undefined && SingletonDefaultModule !== null) { module = cloneDeep(SingletonDefaultModule); } module.imports = module.imports || []; module.imports.push( CommonModule ); module.imports.push( BrowserModule ); if (opts.imports !== undefined) { module.imports = module.imports.concat(opts.imports) } if (module.declarations === undefined) { module.declarations = [ TemplateComponent ]; } else { module.declarations.push(TemplateComponent); } @NgModule(module) class TemplateModule { } const component = await this.compiler.compileModuleAndAllComponentsAsync(TemplateModule); const factory = component.componentFactories.find((comp) => comp.componentType === TemplateComponent ); cache[cacheKey] = factory; if (opts.onCompiled) { opts.onCompiled(component); } return factory; } catch (e) { delete cache[cacheKey]; throw e; } })(); return cache[cacheKey]; } } */src/000077500000000000000000000000001516137561000116525ustar00rootroot00000000000000src/CompileAttribute.ts000066400000000000000000000130111516137561000154720ustar00rootroot00000000000000import { Component, Input, Injectable, // OnInit, OnChanges, SimpleChanges, Type, ModuleWithProviders, NgModule, Compiler, NgModuleFactory, // Inject, } from '@angular/core'; import {CommonModule} from '@angular/common'; //import { BrowserModule } from '@angular/platform-browser'; //let SingletonDefaultModule: NgModule; import {cloneDeep} from 'lodash'; //import { CorifeusMaterialModule } from 'corifeus-web-material'; function reverse(str: string) { return str.split('').reverse().join('') } function random() { return (Math.floor(Math.random() * (99999999999999999 - 10000000000000000)) + 10000000000000000).toString(16) } let currentIdTime: number; let currentId = 0; function nextId() : string { const now = Date.now(); if (currentIdTime !== now) { currentId = 0; currentIdTime = now } const comingId = ++currentId; const randomHex = reverse(random()).padStart(15, '0'); const timeHex = reverse(currentIdTime.toString(16).padStart(12, '0')) const comingIdHex = reverse(comingId.toString(16).padStart(3, '0')) const newId : string = `p3x-angular-compile-${timeHex}${comingIdHex}${randomHex}`; //console.log(newId) return newId } //const cache : any = {}; @Component({ selector: '[p3x-compile]', template: ` ` }) @Injectable() export class CompileAttribute implements OnChanges { //export class CompileAttribute implements OnChanges ,OnInit { @Input('p3x-compile') html: string; @Input('p3x-compile-ctx') context: any; @Input('p3x-compile-error-handler') errorHandler: Function = undefined; dynamicComponent: any; dynamicModule: NgModuleFactory | any; @Input('p3x-compile-module') module: NgModule; @Input('p3x-compile-imports') imports: Array | ModuleWithProviders | any[]>; constructor( // private container: ViewContainerRef, // private service: CompileService private compiler: Compiler, // @Inject('config') private config:CompileServiceConfig ) { } /* // not requires, since ngOnChanges does it first time change ngOnInit() { //console.log('ng init') // this.update(); } */ ngOnChanges(changes: SimpleChanges) { //console.log('ng one changes') this.update(); } update() { try { if (this.html === undefined || this.html === null || this.html.trim() === '') { // this.container.clear(); this.dynamicComponent = undefined; this.dynamicModule = undefined; return; } /* // looks like Angular already is caching //console.log('html', this.html) const cacheKey = this.html; //console.log(Object.keys(cache).indexOf(cacheKey), cache) if (cache.hasOwnProperty(cacheKey)) { const currentCache = cache[cacheKey]; this.dynamicComponent = currentCache.dynamicComponent this.dynamicModule = currentCache.dynamicModule return ; } */ this.dynamicComponent = this.createNewComponent(this.html, this.context); this.dynamicModule = this.compiler.compileModuleSync(this.createComponentModule(this.dynamicComponent)); /* cache[cacheKey] = { dynamicComponent: this.dynamicComponent, dynamicModule: this.dynamicModule, }; */ } catch (e) { if (this.errorHandler === undefined) { throw e; } else { this.errorHandler(e); } } /* // now we use it with ngComponentOutlet, since about angular 5 await this.service.compile({ template: this.html, container: this.container, context: this.context, imports: this.imports, module: this.module }) */ } private createComponentModule(componentType: any) { let module: NgModule = {}; if (this.module !== undefined) { module = cloneDeep(this.module); } /* else if (SingletonDefaultModule !== undefined && SingletonDefaultModule !== null) { module = cloneDeep(SingletonDefaultModule); } */ module.imports = module.imports || []; module.imports.push(CommonModule); if (this.imports !== undefined) { module.imports = module.imports.concat(this.imports) } if (module.declarations === undefined) { module.declarations = [ componentType ]; } else { module.declarations.push(componentType); } module.entryComponents = [ componentType ]; @NgModule(module) class RuntimeComponentModule { } return RuntimeComponentModule; } private createNewComponent(html: string, context: any) { const selector : string = nextId() @Component({ selector: selector, template: html }) class DynamicComponent { context: any = context; } return DynamicComponent; } } src/CompileModule.ts000066400000000000000000000017031516137561000147610ustar00rootroot00000000000000//import { CompileService, CompileServiceConfig, } from "./CompileService"; import {CompileAttribute} from "./CompileAttribute"; import { NgModule, //ModuleWithProviders, } from '@angular/core'; import {CommonModule} from '@angular/common'; /* import { BrowserModule } from '@angular/platform-browser'; import { Compiler } from '@angular/core'; import {JitCompilerFactory} from '@angular/compiler'; export function createJitCompiler () { return new JitCompilerFactory([{useDebug: false, useJit: true}]).createCompiler(); } */ /* export class CompileServiceConfig { module: NgModule } */ // exports = component @NgModule({ imports: [ CommonModule ], declarations: [ CompileAttribute, ], providers: [ // CompileService, // { provide: Compiler, useFactory: createJitCompiler}, ], exports: [ CompileAttribute, ], entryComponents: [] }) export class CompileModule { } src/index.ts000066400000000000000000000001511516137561000133260ustar00rootroot00000000000000//export * from "./CompileService"; export * from "./CompileAttribute"; export * from "./CompileModule"; test/000077500000000000000000000000001516137561000120425ustar00rootroot00000000000000test/angular-webpack/000077500000000000000000000000001516137561000151055ustar00rootroot00000000000000test/angular-webpack/angular/000077500000000000000000000000001516137561000165365ustar00rootroot00000000000000test/angular-webpack/angular/bundle.aot.ts000066400000000000000000000004711516137561000211430ustar00rootroot00000000000000import './modules/material/bundle' import {enableProdMode} from '@angular/core'; enableProdMode(); //import 'corifeus-web/src/bundle'; import {platformBrowser} from '@angular/platform-browser'; import {ModuleNgFactory} from './module.ngfactory'; platformBrowser().bootstrapModuleFactory(ModuleNgFactory); test/angular-webpack/angular/bundle.ts000066400000000000000000000005131516137561000203560ustar00rootroot00000000000000import {enableProdMode} from '@angular/core'; declare var process: any; if (process.env === 'production') { enableProdMode(); } import './modules/material/bundle' import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {Module} from './module'; platformBrowserDynamic().bootstrapModule(Module); test/angular-webpack/angular/module.ts000066400000000000000000000014401516137561000203720ustar00rootroot00000000000000import { NgModule, } from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; import {CorifeusMaterialModule} from './modules/material' import {Page} from './page'; import { CompileModule, } from '../../../src'; import {MatDividerModule} from '@angular/material/divider' import "../assets/style.scss"; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; export const routes: Routes = [ { path: '', component: Page, }, ]; @NgModule({ imports: [ BrowserAnimationsModule, CorifeusMaterialModule, MatDividerModule, RouterModule.forRoot(routes), CompileModule ], declarations: [ Page, ], providers: [], bootstrap: [Page] }) export class Module { }; test/angular-webpack/angular/modules/000077500000000000000000000000001516137561000202065ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/000077500000000000000000000000001516137561000220045ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/boot.ts000066400000000000000000000030221516137561000233140ustar00rootroot00000000000000import { Injectable, Inject, } from '@angular/core'; import { log } from './index'; import { ThemeService, } from './services/theme'; import { SettingsService, LocaleService } from '../web'; //let booted = false @Injectable() export class Boot { constructor( private settings: SettingsService, private locale: LocaleService, private theme: ThemeService, ) { // if (booted === true) { // return // } // booted = true log('booted'); const module = 'material'; settings.register(module, require('./json/settings.json')); locale.register(module, { en: require('./json/translation/english.json'), hu: require('./json/translation/hungarian.json'), }); this.theme.boot(); //TODO uglify breaks CSS imports //FIXME material icons, roboto, font-awesome // @import url(https://fonts.googleapis.com/css?family=Roboto); // @import url(https://fonts.googleapis.com/icon?family=Material+Icons); // @import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css); /* const css = ` `; const head = document.head || document.getElementsByTagName('head')[0]; const style = document.createElement('style'); style.type = 'text/css'; style.appendChild(document.createTextNode(css)); head.appendChild(style); */ } } test/angular-webpack/angular/modules/material/bundle.ts000066400000000000000000000003741516137561000236310ustar00rootroot00000000000000import 'hammerjs'; //import '@angular/material'; //import 'font-awesome/css/font-awesome.css'; import 'roboto-fontface/css/roboto/sass/roboto-fontface.scss' import 'material-design-icons/iconfont/material-icons.css' import './scss/material/_all.scss'; test/angular-webpack/angular/modules/material/component/000077500000000000000000000000001516137561000240065ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/component/cory-mat-http-404.ts000066400000000000000000000033571516137561000274030ustar00rootroot00000000000000import { Component, OnDestroy } from '@angular/core'; import { Subscription } from 'rxjs' import {State, LocaleService, LocaleSubject} from '../../web'; @Component({ selector: 'cory-mat-http-404', template: `
404
{{ i18n.material.http['404'] }}
{{ url }}
`, }) export class Http404 implements OnDestroy { url: string; i18n: any; letKeep404: any; timeout: any; subscriptions$: Array = [] constructor( public locale: LocaleService ) { history.replaceState({}, State.RequestPath, State.RequestPath); const its404 = () => { State.NotFound = true; window.corifeus.core.http.status = 404; } let maxWait = 10000; let waiter = 0; this.letKeep404 = setInterval(() => { its404(); if (window.corifeus.core.http.counter === 0) { waiter++; if (waiter > 10) { clearInterval(this.letKeep404); } } }, 100) this.timeout = setTimeout(() => { clearInterval(this.letKeep404); its404(); }, maxWait); this.subscriptions$.push( this.locale.subscribe((data: LocaleSubject) => { this.i18n = data.locale.data; }) ) this.url = State.RequestPath } ngOnDestroy() { this.subscriptions$.forEach(subs$ => subs$.unsubscribe()) clearInterval(this.letKeep404); clearTimeout(this.timeout) } } test/angular-webpack/angular/modules/material/component/cory-mat-loading.ts000066400000000000000000000010441516137561000275230ustar00rootroot00000000000000import { Input, Component, } from '@angular/core'; @Component({ selector: 'cory-mat-loading', template: ` `, }) export class Loading { @Input('cory-visible') visible: boolean = false; get requestCount() { return window.corifeus.core.http.counter; } constructor() { // console.log(this.visible); } } test/angular-webpack/angular/modules/material/component/cory-mat-theme/000077500000000000000000000000001516137561000266415ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/component/cory-mat-theme/cory-mat-theme-button.ts000066400000000000000000000043611516137561000333610ustar00rootroot00000000000000import { Component, Input, OnDestroy, } from '@angular/core'; import { Subscription } from 'rxjs' import { LocaleService, SettingsService, LocaleSubject, MediaQueryService, MediaQuerySettingType, MediaQuerySetting } from "../../../web"; // requires to be in a mat-menu @Component({ selector: 'cory-mat-theme-button', template: ` `, }) export class ThemeButton implements OnDestroy { subscriptions$: Array = [] @Input('cory-tooltip-position') matTooltipPosition: string = "left"; @Input('color') color: string = 'default'; i18n: any; settings: any; tooltip: string; currentWidthAlias: string; constructor( protected locale: LocaleService, protected settingsAll: SettingsService, private mediaQuery: MediaQueryService ) { this.settings = settingsAll.data.material; this.subscriptions$.push( this.locale.subscribe((data: LocaleSubject) => { this.i18n = data.locale.data; this.setTooltip(); }) ) this.subscriptions$.push( this.mediaQuery.subscribe((settings: MediaQuerySetting[]) => { settings.forEach((setting) => this.setTooltip(setting.name)) }) ) } private setTooltip(alias?: string) { if (alias !== undefined) { this.currentWidthAlias = alias; } switch (this.currentWidthAlias) { case 'small': this.tooltip = this.locale.data.material.title.theme; break; case 'large': this.tooltip = undefined; break; } } ngOnDestroy(): void { this.subscriptions$.forEach(subs$ => subs$.unsubscribe()) } } test/angular-webpack/angular/modules/material/component/cory-mat-theme/cory-mat-theme-menu.ts000066400000000000000000000052241516137561000330110ustar00rootroot00000000000000import { Component, Inject, OnDestroy, } from '@angular/core'; import { LocaleService, SettingsService, LocaleSubject } from "../../../web"; import { ThemeService } from '../../services/theme'; import { NotifyService } from '../../services/notify/notify'; import {template} from 'lodash'; import { Subscription } from 'rxjs' // requires to be in a mat-menu @Component({ selector: 'cory-mat-theme-menu', template: `
`, }) export class ThemeMenu implements OnDestroy { subscriptions$: Array = [] i18n: any; settings: any; constructor( private notify: NotifyService, public theme: ThemeService, public locale: LocaleService, protected settingsAll: SettingsService ) { this.settings = settingsAll.data.material; this.subscriptions$.push( this.locale.subscribe((data: LocaleSubject) => { this.i18n = data.locale.data.material; }) ) } public clickChangeTheme(theme: string) { try { const oldTheme = this.theme.current; this.theme.setTheme(theme) const parameters = ({ old: this.i18n.themes.material[oldTheme], 'current': this.i18n.themes.material[theme] }); const templateFactory = template(this.i18n.message.theme.changed); this.notify.info(templateFactory(parameters)); } catch (e) { this.notify.error(e); } } public get themeLight() { return this.settings.themes.material.filter((theme: string) => { return theme.startsWith('cory-mat-theme-light') }) } public get themeDark() { return this.settings.themes.material.filter((theme: string) => { return theme.startsWith('cory-mat-theme-dark') }) } ngOnDestroy(): void { this.subscriptions$.forEach(subs$ => subs$.unsubscribe()) } } test/angular-webpack/angular/modules/material/component/cory-mat-translation/000077500000000000000000000000001516137561000300755ustar00rootroot00000000000000cory-mat-translation-button.ts000066400000000000000000000042531516137561000357720ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/component/cory-mat-translationimport { Component, Input, OnDestroy, } from '@angular/core'; import { LocaleService, SettingsService, LocaleSubject, MediaQueryService, MediaQuerySettingType, MediaQuerySetting } from "../../../web"; import { Subscription } from 'rxjs' // requires to be in a mat-menu @Component({ selector: 'cory-mat-translation-button', template: ` `, }) export class TranslationButton implements OnDestroy { subscriptions$: Array = [] @Input('color') color: string = 'default'; @Input('cory-tooltip-position') matTooltipPosition: string = 'left'; i18n: any; settings: any; tooltip: string; currentWidthAlias: string; constructor( protected locale: LocaleService, protected settingsAll: SettingsService, private mediaQuery: MediaQueryService ) { this.settings = settingsAll.data.material; this.subscriptions$.push( this.locale.subscribe((data: LocaleSubject) => { this.i18n = data.locale.data; this.setTooltip(); }) ) this.subscriptions$.push( this.mediaQuery.subscribe((settings: MediaQuerySetting[]) => { settings.forEach((setting) => this.setTooltip(setting.name)) }) ) } private setTooltip(alias?: string) { if (alias !== undefined) { this.currentWidthAlias = alias; } switch (this.currentWidthAlias) { case 'small': this.tooltip = this.locale.data.material.title.language; break; case 'large': this.tooltip = undefined; break; } } ngOnDestroy(): void { this.subscriptions$.forEach(subs$ => subs$.unsubscribe()) } } cory-mat-translation-menu.ts000066400000000000000000000035201516137561000354170ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/component/cory-mat-translationimport { Component, Inject, OnDestroy, } from '@angular/core'; import { LocaleService, SettingsService, LocaleSubject } from "../../../web"; import { NotifyService } from '../../services/notify/notify'; import { Subscription } from 'rxjs' // requires to be in a mat-menu @Component({ selector: 'cory-mat-translation-menu', template: `
`, }) export class TranslationMenu implements OnDestroy { subscriptions$: Array = [] i18n: any; settings: any; constructor( private notify: NotifyService, public locale: LocaleService, protected settingsAll: SettingsService ) { this.settings = settingsAll.data.core; this.subscriptions$.push( this.locale.subscribe((data: LocaleSubject) => { this.i18n = data.locale.data; }) ) } public clickChangeTranslate(translation: string) { try { this.locale.setTranslation(translation); this.notify.info(this.settingsAll.data.core.translations.display[translation]); } catch (e) { console.error(e); } } get translationKeys() { return Object.keys(this.settings.translations.language) } ngOnDestroy(): void { this.subscriptions$.forEach(subs$ => subs$.unsubscribe()) } } test/angular-webpack/angular/modules/material/component/index.ts000066400000000000000000000006601516137561000254670ustar00rootroot00000000000000export { Loading } from './cory-mat-loading'; export { ThemeMenu } from './cory-mat-theme/cory-mat-theme-menu'; export { ThemeButton } from './cory-mat-theme/cory-mat-theme-button'; export { TranslationMenu } from './cory-mat-translation/cory-mat-translation-menu'; export { TranslationButton } from './cory-mat-translation/cory-mat-translation-button'; export { Http404 } from './cory-mat-http-404'; test/angular-webpack/angular/modules/material/index.ts000066400000000000000000000003641516137561000234660ustar00rootroot00000000000000export * from './component'; export * from './module'; import {log} from '../web'; export * from './services'; const logMaterial = log.factory('material'); export {logMaterial as log}; export * from './boot'; export * from './services'; test/angular-webpack/angular/modules/material/json/000077500000000000000000000000001516137561000227555ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/json/settings.json000066400000000000000000000012671516137561000255160ustar00rootroot00000000000000{ "cookie": { "theme": "cory-layout-theme" }, "themes": { "material": [ "cory-mat-theme-light-indigo-pink", "cory-mat-theme-light-forest", "cory-mat-theme-light-beach", "cory-mat-theme-light-facebook", "cory-mat-theme-light-deeppurple-amber", "cory-mat-theme-dark-wood", "cory-mat-theme-dark-matrix", "cory-mat-theme-dark-pink-bluegray", "cory-mat-theme-dark-purple-green" ] }, "translations": { "interface": { "en": "The user interface is English.", "hu": "A felhasználói felület Magyar." } } } test/angular-webpack/angular/modules/material/json/translation/000077500000000000000000000000001516137561000253135ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/json/translation/english.json000066400000000000000000000024501516137561000276400ustar00rootroot00000000000000{ "http": { "404": "Not found" }, "themes": { "material": { "cory-mat-theme-light-forest": "Forest", "cory-mat-theme-dark-wood": "Wood", "cory-mat-theme-light-beach": "Beach", "cory-mat-theme-dark-matrix": "Matrix", "cory-mat-theme-light-deeppurple-amber": "Deep Purple Amber", "cory-mat-theme-light-indigo-pink": "Indigo pink", "cory-mat-theme-dark-pink-bluegray": "Pink bluegray", "cory-mat-theme-dark-purple-green": "Purple green", "cory-mat-theme-light-facebook": "Facebook" } }, "title": { "menu": "Menu", "theme": "Theme", "language": "Language", "ok": "OK", "error": "Error", "authorization": " Identification", "username": "Username", "password": "Password", "autoLogin": "Keep logged in", "save": "Save" }, "button": { "login": "Login" }, "invalid": { "required": "Required", "username": "Invalid username", "password": "Invalid password" }, "message": { "unauthorized": "Unauthorized login.", "loggedIn": "You signed in.", "theme": { "changed": "Theme - ${current}." } } } test/angular-webpack/angular/modules/material/json/translation/hungarian.json000066400000000000000000000025321516137561000301640ustar00rootroot00000000000000{ "http": { "404": "Not found" }, "themes": { "material": { "cory-mat-theme-light-forest": "Erdő", "cory-mat-theme-dark-wood": "Fa", "cory-mat-theme-light-beach": "Strand", "cory-mat-theme-dark-matrix": "Matrix", "cory-mat-theme-light-deeppurple-amber": "Mély lila borostyán", "cory-mat-theme-light-indigo-pink": "Indigó rózsaszín", "cory-mat-theme-dark-pink-bluegray": "Rózsaszín kék-szürke", "cory-mat-theme-dark-purple-green": "Lila Zöld", "cory-mat-theme-light-facebook": "Facebook" } }, "title": { "menu": "Menü", "theme": "Smink", "language": "Nyelv", "ok": "OK", "error": "Hiba", "authorization": " Azonosítás", "username": "Felhasználó", "password": "Jelszó", "autoLogin": "Maradj belépve", "save": "Mentés" }, "button": { "login": "Belépés" }, "invalid": { "required": "Kötelező", "username": "Érvénytelen felhasználó", "password": "Érvénytelen jelszó" }, "message": { "unauthorized": "Illetéktelen belépés.", "loggedIn": "Bejelentkezett.", "theme": { "changed": "Smink - ${current}." } } } test/angular-webpack/angular/modules/material/module.ts000066400000000000000000000126061516137561000236460ustar00rootroot00000000000000import {NgModule, ModuleWithProviders} from '@angular/core'; import {CorifeusModule} from '../web/module'; import {MatIconModule} from '@angular/material/icon' import {MatProgressBarModule} from '@angular/material/progress-bar' import {MatMenuModule,} from '@angular/material/menu' import {MatButtonModule,} from '@angular/material/button' import {MatTooltipModule,} from '@angular/material/tooltip' import {MatToolbarModule,} from '@angular/material/toolbar' import {MatCardModule,} from '@angular/material/card' import {MatSnackBarModule,} from '@angular/material/snack-bar' import {Boot} from './boot'; import {ThemeService} from './services/theme' import {NotifyService} from './services/notify/notify' import {NotifyComponent} from './services/notify/notify-component' import {Http404} from './component/cory-mat-http-404' import {Loading} from './component/cory-mat-loading' import {ThemeButton} from './component/cory-mat-theme/cory-mat-theme-button' import {ThemeMenu} from './component/cory-mat-theme/cory-mat-theme-menu' import {TranslationButton} from './component/cory-mat-translation/cory-mat-translation-button' import {TranslationMenu} from './component/cory-mat-translation/cory-mat-translation-menu' import { CommonModule } from '@angular/common' /* fix: allow users to disable the sanity checks @NgModule({ providers: [ {provide: MATERIAL_SANITY_CHECKS, useValue: false} ] // other config }); https://github.com/angular/material2/issues/4125 */ // https://github.com/angular/material2/pull/4178 // exports = component /*** * NEVER USE A EXPORT * AS, NEED THE EXACT COMPONENT FOR INJECTABLE FUNCTION!!!! const materialModules = [ MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatCommonModule, MatDatepickerModule, MatDialogModule, MatExpansionModule, MatGridListModule, MatIconModule, MatInputModule, MatLineModule, MatListModule, MatMenuModule, MatNativeDateModule, MatOptionModule, MatPaginatorModule, MatProgressBarModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule, MatSliderModule, MatSlideToggleModule, MatSnackBarModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule, MatTooltipModule, // OverlayContainer, // MatSelectionList, ] */ @NgModule({ imports: [ CorifeusModule, CommonModule, // material /* MatAutocompleteModule, MatButtonToggleModule, MatChipsModule, MatCommonModule, MatDatepickerModule, MatDialogModule, MatExpansionModule, MatGridListModule, MatLineModule, MatListModule, MatNativeDateModule, MatOptionModule, MatPaginatorModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule, MatSliderModule, MatSlideToggleModule, MatSortModule, MatTableModule, MatTabsModule, */ // OverlayContainer, // MatSelectionList, MatIconModule, MatProgressBarModule, MatMenuModule, MatButtonModule, MatTooltipModule, MatToolbarModule, MatCardModule, MatSnackBarModule, // material modules ], declarations: [ NotifyComponent, // OverlayContainer, Loading, ThemeMenu, ThemeButton, TranslationMenu, TranslationButton, Http404, ], // do not need export providers providers: [ Boot, ThemeService, NotifyService, ], exports: [ CorifeusModule, // material modules /* MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatCheckboxModule, MatChipsModule, MatCommonModule, MatDatepickerModule, MatDialogModule, MatExpansionModule, MatGridListModule, MatInputModule, MatLineModule, MatListModule, MatNativeDateModule, MatOptionModule, MatPaginatorModule, MatProgressSpinnerModule, MatRadioModule, MatRippleModule, MatSelectModule, MatSidenavModule, MatSliderModule, MatSlideToggleModule, MatSortModule, MatTableModule, MatTabsModule, MatToolbarModule, MatTooltipModule, // OverlayContainer, // MatSelectionList, // material modules */ MatIconModule, MatProgressBarModule, MatMenuModule, MatButtonModule, MatTooltipModule, MatToolbarModule, MatCardModule, MatSnackBarModule, Loading, ThemeMenu, ThemeButton, TranslationMenu, TranslationButton, Http404, ], entryComponents: [ NotifyComponent, // OverlayContainer, ] }) export class CorifeusMaterialModule { constructor(boot: Boot) { } public static forRoot(): ModuleWithProviders { return { ngModule: CorifeusMaterialModule, // providers: providers, }; } } test/angular-webpack/angular/modules/material/scss/000077500000000000000000000000001516137561000227575ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/scss/_all.scss000066400000000000000000000007541516137561000245710ustar00rootroot00000000000000@import 'material/all'; .cory-shake { animation: shake 0.82s cubic-bezier(.36, .07, .19, .97) both; transform: translate3d(0, 0, 0); backface-visibility: hidden; perspective: 1000px; } @keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } } test/angular-webpack/angular/modules/material/scss/material/000077500000000000000000000000001516137561000245555ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/scss/material/_all.scss000066400000000000000000000054241516137561000263660ustar00rootroot00000000000000$mat-theme-ignore-duplication-warnings: true; /* @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); @import url('https://fonts.googleapis.com/css?family=Roboto'); */ body { font-family: Roboto, Arial, sans-serif; padding: 0; margin: 0; } @import '~@fortawesome/fontawesome-free/css/all.min.css'; @import '~@angular/material/theming'; @include mat-core(); @import 'variables'; @import 'mixins'; @import 'material-customization'; @import 'hover'; @import 'theme/cory-mat-theme-dark-matrix'; @import 'theme/cory-mat-theme-light-forest'; @import 'theme/cory-mat-theme-light-beach'; @import 'theme/cory-mat-theme-light-indigo-pink'; @import 'theme/cory-mat-theme-light-deeppurple-amber'; @import 'theme/cory-mat-theme-dark-wood'; @import 'theme/cory-mat-theme-dark-pink-bluegray'; @import 'theme/cory-mat-theme-dark-purple-green'; @import 'theme/cory-mat-theme-light-facebook'; @import 'toolbar'; .cory-mat-fill-horizontal { flex: 1 1 auto; } body.cory-mat-theme-dark { color: white; } .cory-mat-theme-dark { color: white; .cory-mat-menu-divider { margin-top: 3px; margin-bottom: 3px; border-bottom: 1px solid rgba(255, 255, 255, 0.2); } .cory-mat-menu-item-active, .cory-mat-menu-item-active:hover { background-color: rgba(255, 255, 255, 0.2) !important; } } .cory-mat-theme-light { color: white; .cory-mat-menu-divider { margin-top: 3px; margin-bottom: 3px; border-bottom: 1px solid rgba(0, 0, 0, 0.1); } .cory-mat-menu-item-active, .cory-mat-menu-item-active:hover { background-color: rgba(128, 128, 128, 0.2) !important; } } .cory-mat-hide-xsmall { @media screen and (max-width: $cory-mat-size-xsmall) { display: none; }; } .cory-mat-container { margin-top: 0px !important; margin-bottom: 0px !important; .mat-card { margin-top: 10px; margin-bottom: 10px; box-shadow: 0px 0px 100px 0px rgba(0, 0, 0, 0.25) !important; @media screen and (max-width: $cory-mat-size-xsmall) { margin-top: 0px; margin-bottom: 0px; }; } margin-left: 0; margin-right: 0; @media screen and (min-width: $cory-mat-size-xsmall) { margin-top: 20px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; } @media screen and (min-width: $cory-mat-size-medium) { width: $cory-mat-size-medium - 100; margin-left: auto; margin-right: auto; }; } body { height: 100vh; min-height: 100vh; } .cory-mat-header { position: fixed; top: 0px; left: 0px; width: 100%; z-index: 1; } .cory-mat-footer { position: fixed; bottom: 0px; left: 0px; width: 100%; z-index: 1; } test/angular-webpack/angular/modules/material/scss/material/_hover.scss000066400000000000000000000014431516137561000267360ustar00rootroot00000000000000.cory-mat-theme-dark, .cory-mat-theme-light { a:hover mat-icon, button:hover mat-icon, a:hover svg, button:hover svg, svg:hover, .cory-hover-rotate:hover img, a.cory-hover-rotate:hover img, button.cory-hover-rotate:hover img, img.emoji:hover, mat-icon:hover, .fa:hover, .fas:hover, .fab:hover, .far:hover, button:hover .fa, button:hover .fas, button:hover .fab, button:hover .far, a:hover .fa, a:hover .fas, a:hover .fab, a:hover .far { transition: all 500ms !important; transform: scale(1.2) rotate(360deg) !important;; } .cory-hover-scale:hover img, a.cory-hover-scale:hover img, button.cory-hover-scale:hover img { transition: all 500ms !important;; transform: scale(1.5) !important;; } } test/angular-webpack/angular/modules/material/scss/material/_material-customization.scss000066400000000000000000000003201516137561000323100ustar00rootroot00000000000000 snack-bar-container { position: relative; min-height: 50px; min-width: 333px !important; color: white !important; background-color: rgba(0, 0, 0, 0.9) !important; overflow: hidden; } test/angular-webpack/angular/modules/material/scss/material/_mixins.scss000066400000000000000000000223331516137561000271230ustar00rootroot00000000000000@mixin cory-mat-theme-link($color, $hover) { mat-card { a { color: $color; text-decoration: none; } a:hover { color: $hover; text-decoration: underline; } } } @mixin cory-mat-theme-container($color) { .cory-mat-header { .mat-toolbar.mat-primary { background: none; } background: linear-gradient(to left, $color, darken($color, 5%)); // background-color: black; } .cory-mat-footer { .mat-toolbar.mat-primary { background: none; } background: linear-gradient(to right, $color, darken($color, 5%)); // background-color: $color; } } @function cory-mat-color-paletta($type, $color) { $cory-mat-color-paletta-obj: ''; @if ($type == 'light') { $cory-mat-color-paletta-obj: ( 50: lighten($color, 50%), 100: lighten($color, 40%), 200: lighten($color, 30%), 300: lighten($color, 20%), 400: lighten($color, 10%), 500: $color, 600: darken($color, 10%), 700: darken($color, 20%), 800: darken($color, 30%), 900: darken($color, 40%), A100: lighten($color, 40%), A200: lighten($color, 30%), A400: lighten($color, 10%), A700: darken($color, 30%), contrast: ( 50: $black-87-opacity, 100: $black-87-opacity, 200: $black-87-opacity, 300: $black-87-opacity, 400: white, 500: white, 600: $white-87-opacity, 700: $white-87-opacity, 800: $white-87-opacity, 900: $white-87-opacity, A100: $black-87-opacity, A200: $black-87-opacity, A400: white, A700: $white-87-opacity, ) ); } @else { $cory-mat-color-paletta-obj: ( 50: lighten($color, 50%), 100: lighten($color, 40%), 200: lighten($color, 30%), 300: lighten($color, 20%), 400: lighten($color, 10%), 500: $color, 600: darken($color, 10%), 700: darken($color, 20%), 800: darken($color, 30%), 900: darken($color, 40%), A100: lighten($color, 40%), A200: lighten($color, 30%), A400: lighten($color, 10%), A700: darken($color, 30%), contrast: ( 0: $black-87-opacity, 50: $black-87-opacity, 100: $black-87-opacity, 200: $black-87-opacity, 300: $black-87-opacity, 400: $black-87-opacity, 500: $black-87-opacity, 600: $white-87-opacity, 700: $white-87-opacity, 800: $white-87-opacity, 900: $white-87-opacity, A100: $black-87-opacity, A200: $black-87-opacity, A400: $black-87-opacity, A700: $white-87-opacity, ) ); } @return mat-palette($cory-mat-color-paletta-obj); } ; @mixin cory-mat-theme-button($type, $theme) { $primary: map-get($theme, primary); $accent: map-get($theme, accent); $warn: map-get($theme, warn); @include mat-button-theme($theme); @if ($type == 'light') { /* // disabled [mat-raised-button].mat-default:hover { background-color: rgba(black, 0.05); color: black; } */ [mat-raised-button].mat-primary:not([disabled]):hover { background-color: mat-color($primary, 800); } [mat-raised-button].mat-accent:not([disabled]):hover { background-color: mat-color($accent, 800); } [mat-raised-button].mat-warn:not([disabled]):hover { background-color: mat-color($warn, 800); } } @else { /* // disabled [mat-raised-button]:hover { background-color: mat-color($primary); color: black; } */ [mat-raised-button].mat-primary:not([disabled]):hover { background-color: mat-color($primary, 400); } [mat-raised-button].mat-accent:not([disabled]):hover { background-color: mat-color($accent, 400); } [mat-raised-button].mat-warn:not([disabled]):hover { background-color: mat-color($warn, 400); } } } @mixin cory-mat-theme-toolbar($type, $theme) { @include mat-toolbar-theme($theme); $primary: mat-color(map-get($theme, primary)); $accent: mat-color(map-get($theme, accent)); $warn: mat-color(map-get($theme, warn)); .mat-toolbar.mat-primary { background: linear-gradient(to right, $primary, darken($primary, 5%)); } } @mixin cory-mat-autofill() { // fix webkit-autofill input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active, input.webkit-autofill, input.webkit-autofill:focus, input.webkit-autofill:active, input.webkit-autofill:hover { transition: all 5000s ease-in-out 0s; transition-property: background-color, color; // background-color: mat-color($mat-yellow, 500); } } @mixin cory-mat-theme($type, $primary, $accent) { $theme: ''; $darker-primary: cory-mat-color-paletta($type, mat-color($primary, 700)); $darker-accent: cory-mat-color-paletta($type, mat-color($accent, 700)); $darker-theme: ''; $reverse-primary: $accent; $reverse-accent: $primary; $reverse-theme: ''; $reverse-darker-primary: cory-mat-color-paletta($type, mat-color($accent, 700)); $reverse-darker-accent: cory-mat-color-paletta($type, mat-color($primary, 700)); $reverse-darker-theme: ''; @if $type == "light" { $warn: mat-palette($mat-red); $theme: mat-light-theme($primary, $accent, $warn); $reverse-theme: mat-light-theme($reverse-primary, $reverse-accent, $warn); $darker-theme: mat-light-theme($darker-primary, $darker-accent, $warn); $reverse-darker-theme: mat-light-theme($reverse-darker-primary, $reverse-darker-accent, $warn); background-color: mat-color($primary, A100); background: radial-gradient(circle, mat-color($primary, A100, 0.5), mat-color($primary, A400, 0.5)); $link: mat-palette($accent, 500); $link-hover: mat-palette($accent, A700); @include cory-mat-theme-link(mat-color($link), mat-color($link-hover)); //fixme this is something weird, to snackbar need black, but still it is not black :) .cory-mat-bg { background-color: map_get($mat-grey, 900); // background: radial-gradient(circle, mat-color($mat-grey, 1000), mat-color($mat-grey, 900)); background: radial-gradient(circle, #000000, #212121); } } @else { $warn: mat-palette($mat-red); $theme: mat-dark-theme($primary, $accent, $warn); $reverse-theme: mat-dark-theme($reverse-primary, $reverse-accent, $warn); $darker-theme: mat-dark-theme($darker-primary, $darker-accent, $warn); $reverse-darker-theme: mat-dark-theme($reverse-darker-primary, $reverse-darker-accent, $warn); background-color: map_get($mat-grey, 900); // background: radial-gradient(circle, mat-color($mat-grey, 1000), mat-color($mat-grey, 900)); background: radial-gradient(circle, #000000, #212121); $link: mat-palette($accent, A400); $link-hover: mat-palette($accent, A200); @include cory-mat-theme-link(mat-color($link), mat-color($link-hover)); } // @include angular-material-theme($theme); @include mat-core-theme($theme); @include mat-autocomplete-theme($theme); // card @include mat-card-theme($theme); @include mat-datepicker-theme($theme); @include mat-table-theme($theme); @include mat-checkbox-theme($theme); @include mat-chips-theme($theme); @include mat-dialog-theme($theme); @include mat-grid-list-theme($theme); @include mat-icon-theme($theme); @include mat-list-theme($theme); @include mat-menu-theme($theme); @include mat-radio-theme($theme); @include mat-select-theme($theme); @include mat-sidenav-theme($reverse-theme); @include mat-slider-theme($theme); @include mat-tabs-theme($theme); @include mat-tooltip-theme($theme); @include mat-expansion-panel-theme($theme); @include mat-form-field-theme($theme); @include mat-paginator-theme($theme); @include mat-stepper-theme($theme); @include mat-snack-bar-theme($theme); // background: linear-gradient(darken($color, 10%), $color); @include cory-mat-theme-toolbar($type, $theme); @include cory-mat-theme-button($type, $reverse-theme); @include mat-button-toggle-theme($reverse-theme); @include mat-input-theme($reverse-theme); @include mat-slide-toggle-theme($reverse-theme); @include mat-progress-bar-theme($reverse-darker-theme); @include mat-progress-spinner-theme($reverse-darker-theme); @include cory-mat-theme-container(mat-color($primary)); @include cory-mat-autofill(); } test/angular-webpack/angular/modules/material/scss/material/_toolbar.scss000066400000000000000000000002521516137561000272520ustar00rootroot00000000000000.mat-toolbar.mat-primary.cory-mat-toolbar-clear { background: none !important; margin: 0px !important; padding: 0px !important; height: 0px !important; } test/angular-webpack/angular/modules/material/scss/material/_variables.scss000066400000000000000000000003501516137561000275570ustar00rootroot00000000000000$cory-mat-size-xsmall: 600px; $cory-mat-size-small: 960px; $cory-mat-size-medium: 1280px; $cory-mat-size-large: 1920px; $cory-mat-fixed-height-top: 69px; $cory-mat-fixed-height-bottom: 69px; $cory-mat-fixed-height-collapsed: 60px; test/angular-webpack/angular/modules/material/scss/material/theme/000077500000000000000000000000001516137561000256575ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/scss/material/theme/_cory-mat-theme-dark-matrix.scss000066400000000000000000000177621516137561000340040ustar00rootroot00000000000000@import "../mixins"; .cory-mat-theme-dark-matrix { $mat-matrix: ( 50 : #e0ffe0, 100 : #b3ffb3, 200 : #80ff80, 300 : #4dff4d, 400 : #26ff26, 500 : #00ff00, 600 : #00ff00, 700 : #00ff00, 800 : #00ff00, 900 : #00ff00, A100 : #ffffff, A200 : #f2fff2, A400 : #bfffbf, A700 : #a6ffa6, contrast: ( 50 : #000000, 100 : #000000, 200 : #000000, 300 : #000000, 400 : #000000, 500 : #000000, 600 : #000000, 700 : #000000, 800 : #000000, 900 : #000000, A100 : #000000, A200 : #000000, A400 : #000000, A700 : #000000, ) ); $mat-matrikxlow: ( 50 : #e7f9e7, 100 : #c2f0c2, 200 : #99e699, 300 : #70db70, 400 : #52d452, 500 : #33cc33, 600 : #2ec72e, 700 : #27c027, 800 : #20b920, 900 : #14ad14, A100 : #e0ffe0, A200 : #adffad, A400 : #7aff7a, A700 : #60ff60, contrast: ( 50 : #000000, 100 : #000000, 200 : #000000, 300 : #000000, 400 : #000000, 500 : #000000, 600 : #000000, 700 : #000000, 800 : #ffffff, 900 : #ffffff, A100 : #000000, A200 : #000000, A400 : #000000, A700 : #000000, ) ); $mat-matrixwarm: ( 50 : #f9e0e0, 100 : #f0b3b3, 200 : #e68080, 300 : #db4d4d, 400 : #d42626, 500 : #cc0000, 600 : #c70000, 700 : #c00000, 800 : #b90000, 900 : #ad0000, A100 : #ffd7d7, A200 : #ffa4a4, A400 : #ff7171, A700 : #ff5858, contrast: ( 50 : #000000, 100 : #000000, 200 : #000000, 300 : #ffffff, 400 : #ffffff, 500 : #ffffff, 600 : #ffffff, 700 : #ffffff, 800 : #ffffff, 900 : #ffffff, A100 : #000000, A200 : #000000, A400 : #000000, A700 : #000000, ) ); $mat-matrixaccent: ( 50 : #f9e7f9, 100 : #f0c2f0, 200 : #e699e6, 300 : #db70db, 400 : #d452d4, 500 : #cc33cc, 600 : #c72ec7, 700 : #c027c0, 800 : #b920b9, 900 : #ad14ad, A100 : #ffe0ff, A200 : #ffadff, A400 : #ff7aff, A700 : #ff60ff, contrast: ( 50 : #000000, 100 : #000000, 200 : #000000, 300 : #000000, 400 : #000000, 500 : #ffffff, 600 : #ffffff, 700 : #ffffff, 800 : #ffffff, 900 : #ffffff, A100 : #000000, A200 : #000000, A400 : #000000, A700 : #000000, ) ); $primary: mat-palette($mat-matrix); $accent: mat-palette($mat-matrikxlow); $warn: mat-palette($mat-matrixaccent); $white: map_get($mat-matrix, 500); $white2: map_get($mat-matrixaccent, 500); $foreground: ( base: $white, //white, divider: rgba($white, 0.12), //$white-12-opacity, dividers: rgba($white, 0.12), //$white-12-opacity, disabled: rgba($white, 0.8), // rgba(white, 0.3), disabled-button: rgba($white, 0.3), // rgba(white, 0.3), disabled-text: rgba($white, 0.3), // rgba(white, 0.3), hint-text: rgba($white, 0.3), // rgba(white, 0.3), secondary-text: rgba($white, 0.3), // rgba(white, 0.3), icon: $white, // white, icons: $white, // white, text: $white, // white, slider-min: white, slider-off: $white, //rgba(white, 0.3), slider-off-active: $white, //rgba(white, 0.3), ); $background: ( status-bar: black, app-bar: rgba(black, 0.90), //map_get($mat-grey, 900), background: rgba(black, 0.80), //#303030, hover: rgba(map_get($mat-matrix, A700), 0.4), //rgba(white, 0.04), card: rgba(black, 0.80), //map_get($mat-grey, 800), dialog: rgba(black, 0.80), //map_get($mat-grey, 800), disabled-button: rgba(map_get($mat-matrix, A700), 0.12), // $white-12-opacity, raised-button: rgba(black, 0.80), //map-get($mat-grey, 800), focused-button: rgba(map_get($mat-matrix, A700), 0.06), //$white-6-opacity, selected-button: rgba(black, 0.90), //map_get($mat-grey, 900), selected-disabled-button: rgba(black, 0.80), //map_get($mat-grey, 800), disabled-button-toggle: rgba(black, 1.00), //map_get($mat-grey, 1000), // unselected-chip: map_get($mat-grey, 700), // disabled-list-option: black, unselected-chip: rgba(black, 0.90), // map_get($mat-grey, 300), disabled-list-option: rgba(black, 0.80), // map_get($mat-grey, 200), ); $theme_highlight: ( primary: $warn, accent: $primary, warn: $accent, is-dark: true, foreground: $foreground, background: $background, ); $theme: ( primary: $primary, accent: $accent, warn: $warn, is-dark: true, foreground: $foreground, background: $background, ); $theme_reverse: ( primary: $accent, accent: $primary, warn: $warn, is-dark: true, foreground: $foreground, background: $background, ); // @mixin angular-material-theme($theme) { // this is new again // @include mat-ripple-theme($theme_reverse); // @include mat-option-theme($theme_reverse); // @include mat-optgroup-theme($theme_reverse); // @include mat-pseudo-checkbox-theme($theme_reverse); @include mat-autocomplete-theme($theme_reverse); // card @include mat-card-theme($theme_reverse); @include mat-checkbox-theme($theme_reverse); @include mat-chips-theme($theme_reverse); @include mat-dialog-theme($theme_reverse); @include mat-grid-list-theme($theme_reverse); @include mat-icon-theme($theme_reverse); @include mat-list-theme($theme_reverse); @include mat-menu-theme($theme_reverse); @include mat-radio-theme($theme_reverse); @include mat-select-theme($theme_reverse); $background_sidenav: map-merge($background, ( card: white )); @include mat-sidenav-theme(( primary: $accent, accent: $primary, warn: $warn, is-dark: true, foreground: $foreground, background: $background_sidenav, )); @include mat-slider-theme($theme_reverse); @include mat-tabs-theme($theme_reverse); @include mat-tooltip-theme($theme_reverse); // background: linear-gradient(darken($color, 10%), $color); @include mat-button-toggle-theme($theme_reverse); @include mat-input-theme($theme_reverse); @include mat-slide-toggle-theme($theme_reverse); @include mat-progress-bar-theme($theme_highlight); @include mat-progress-spinner-theme($theme_highlight); @include mat-toolbar-theme($theme_reverse); //@include mat-button-theme($theme_reverse); @include mat-expansion-panel-theme($theme); @include mat-form-field-theme($theme); @include mat-paginator-theme($theme); @include mat-stepper-theme($theme); @include mat-snack-bar-theme($theme_highlight); @include mat-datepicker-theme($theme_reverse); @include cory-mat-theme-container(mat-color($primary)); @include cory-mat-theme-toolbar('dark', $theme); @include cory-mat-theme-button('dark', $theme_reverse); @include cory-mat-theme-link(map_get($mat-matrixaccent, 500), map_get($mat-matrixaccent, A400)); @include cory-mat-autofill(); background-color: rgba(0, 0, 0, 0.5); background: radial-gradient(circle, rgba(black, 0.9), rgba(black, 0.8)); // @include cory-mat-theme('dark', $primary, $accent); } _cory-mat-theme-dark-pink-bluegray.scss000066400000000000000000000003501516137561000351530ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/scss/material/theme@import "../mixins"; .cory-mat-theme-dark-pink-bluegray { $primary: mat-palette($mat-pink, 700, 500, 900); $accent: mat-palette($mat-blue-grey, A200, A100, A400); @include cory-mat-theme('dark', $primary, $accent); } _cory-mat-theme-dark-purple-green.scss000066400000000000000000000003441516137561000350120ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/scss/material/theme@import "../mixins"; .cory-mat-theme-dark-purple-green { $primary: mat-palette($mat-purple, 700, 500, 900); $accent: mat-palette($mat-green, A200, A100, A400); @include cory-mat-theme('dark', $primary, $accent); } test/angular-webpack/angular/modules/material/scss/material/theme/_cory-mat-theme-dark-wood.scss000066400000000000000000000003141516137561000334310ustar00rootroot00000000000000@import "../mixins"; .cory-mat-theme-dark-wood { $primary: mat-palette($mat-brown); $accent: mat-palette($mat-green, 600, 400, 700); @include cory-mat-theme('dark', $primary, $accent); } test/angular-webpack/angular/modules/material/scss/material/theme/_cory-mat-theme-light-beach.scss000066400000000000000000000003351516137561000337140ustar00rootroot00000000000000@import "../mixins"; .cory-mat-theme-light-beach { $primary: mat-palette($mat-orange, 800, 700, 900); $accent: mat-palette($mat-brown, 800, 700, 900); @include cory-mat-theme('light', $primary, $accent); } _cory-mat-theme-light-deeppurple-amber.scss000066400000000000000000000003401516137561000360200ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/scss/material/theme@import "../mixins"; .cory-mat-theme-light-deeppurple-amber { $primary: mat-palette($mat-deep-purple); $accent: mat-palette($mat-amber, A200, A100, A400); @include cory-mat-theme('light', $primary, $accent); } _cory-mat-theme-light-facebook.scss000066400000000000000000000025041516137561000343440ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/scss/material/theme@import "../mixins"; /* Color Hex RGB #3b5998 (59,89,152) #8b9dc3 (139,157,195) #dfe3ee (223,227,238) #f7f7f7 (247,247,247) #ffffff (255,255,255) */ .cory-mat-theme-light-facebook { $fb-dark: #3b5998; $fb-blue: #8b9dc3; $fb-medium: #dfe3ee; $fb-light: #f7f7f7; $mat-facebook: ( 50: $fb-medium, 100: lighten($fb-dark, 20%), 200: lighten($fb-dark, 15%), 300: lighten($fb-dark, 10%), 400: lighten($fb-dark, 5%), 500: $fb-dark, 600: darken($fb-dark, 5%), 700: darken($fb-dark, 10%), 800: darken($fb-dark, 15%), 900: darken($fb-dark, 25%), A100: $fb-blue, A200: darken($fb-blue, 10%), A400: darken($fb-blue, 20%), A700: darken($fb-blue, 30%), contrast: ( 50: $fb-light, 100: white, 200: white, 300: white, 400: white, 500: white, 600: $fb-light, 700: $fb-light, 800: $fb-light, 900: $fb-light, A100: $fb-light, A200: $fb-light, A400: $fb-light, A700: $fb-light, ) ); $primary: mat-palette($mat-facebook); $accent: mat-palette($mat-facebook, A100, 400, A200); @include cory-mat-theme('light', $primary, $accent); } test/angular-webpack/angular/modules/material/scss/material/theme/_cory-mat-theme-light-forest.scss000066400000000000000000000003231516137561000341510ustar00rootroot00000000000000@import "../mixins"; .cory-mat-theme-light-forest { $primary: mat-palette($mat-green, 600); $accent: mat-palette($mat-brown, 700, 500, 900); @include cory-mat-theme('light', $primary, $accent); } _cory-mat-theme-light-indigo-pink.scss000066400000000000000000000003261516137561000350030ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/scss/material/theme@import "../mixins"; .cory-mat-theme-light-indigo-pink { $primary: mat-palette($mat-indigo); $accent: mat-palette($mat-pink, A200, A100, A400); @include cory-mat-theme('light', $primary, $accent); } test/angular-webpack/angular/modules/material/services/000077500000000000000000000000001516137561000236275ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/services/index.ts000066400000000000000000000001431516137561000253040ustar00rootroot00000000000000export * from './notify/notify'; export * from './notify/notify-component' export * from './theme';test/angular-webpack/angular/modules/material/services/notify/000077500000000000000000000000001516137561000251375ustar00rootroot00000000000000test/angular-webpack/angular/modules/material/services/notify/notify-component.ts000066400000000000000000000072541516137561000310270ustar00rootroot00000000000000import { Injectable, Component, AfterViewInit, ViewChild, ElementRef, HostListener, Inject, OnDestroy, } from '@angular/core'; import {ThemeService} from '../theme' import {ColorService} from '../../../web' import {MAT_SNACK_BAR_DATA, MatSnackBarRef} from '@angular/material/snack-bar'; import { Subscription } from 'rxjs' import { DomSanitizer } from '@angular/platform-browser' import {LocaleService, LocaleSubject} from '../../../web'; @Component({ template: `
{{ data.options.icon }}  
{{ this.i18n.title.ok }} `, styles: [` .message { position: relative; top: -6px; } [mat-button]{ position: absolute; top: 10px; right: 4px; min-width: auto !important; } `], }) @Injectable() export class NotifyComponent implements AfterViewInit, OnDestroy { @ViewChild('elementButton', {read: ElementRef, static: false}) elementButton: ElementRef; @ViewChild('elementIcon', {read: ElementRef, static: false}) elementIcon: ElementRef; @ViewChild('elementMessage', {read: ElementRef, static: false}) elementMessage: ElementRef; inited: boolean = false; public data: { message: string, options: any }; i18n: any; subscriptions$: Array = [] constructor( public ctx: MatSnackBarRef, private locale: LocaleService, private theme: ThemeService, private color: ColorService, @Inject(MAT_SNACK_BAR_DATA) data: any, private _sanitizer: DomSanitizer, ) { this.subscriptions$.push( this.locale.subscribe((subject: LocaleSubject) => { this.i18n = subject.locale.data.material; }) ) this.data = data; } calculateWidth() { const snackElement = document.getElementsByTagName('snack-bar-container')[0]; //fixme cache the colors let backgroundColor = window.getComputedStyle(snackElement).getPropertyValue('background-color'); let color = window.getComputedStyle(snackElement).getPropertyValue('color'); let buttonColor = window.getComputedStyle(this.elementButton.nativeElement).color; let iconColor = window.getComputedStyle(this.elementIcon.nativeElement).color; buttonColor = this.color.getReadableColor(buttonColor, backgroundColor) iconColor = this.color.getReadableColor(iconColor, backgroundColor); color = this.color.getReadableColor(color, backgroundColor); this.elementIcon.nativeElement.style.color = iconColor; this.elementButton.nativeElement.style.color = buttonColor; this.elementMessage.nativeElement.style.color = color; } ngAfterViewInit() { /* this.subscriptions$.push( this.ctx.afterOpened().subscribe(() => { this.calculateWidth(); }) ) */ } onResize() { this.ctx.dismiss(); } @HostListener('window:keydown', ['$event']) onKeyDown(event: Event) { // if (!isDevMode()) { this.ctx.dismiss(); // } } transformHtml(html: string): any { return this._sanitizer.bypassSecurityTrustHtml(html); } ngOnDestroy(): void { this.subscriptions$.forEach(subs$ => subs$.unsubscribe()) } } test/angular-webpack/angular/modules/material/services/notify/notify.ts000066400000000000000000000035271516137561000270260ustar00rootroot00000000000000import { Injectable, OnDestroy, } from '@angular/core'; declare var process: any; const isDevMode = () => { return process.env !== 'production' } import {MatSnackBar, MatSnackBarConfig} from '@angular/material/snack-bar'; import {LocaleService, LocaleSubject} from '../../../web'; import {NotifyComponent} from './notify-component' const duration = isDevMode() ? 100000 : 3000; export interface NotifyOptions { icon: string, } import { Subscription } from 'rxjs' @Injectable() export class NotifyService implements OnDestroy { i18n: any; subscriptions$: Array = [] constructor( private snackBar: MatSnackBar, private locale: LocaleService, ) { this.subscriptions$.push( this.locale.subscribe((subject: LocaleSubject) => { this.i18n = subject.locale.data.material; }) ) } info(message: string, coryOptions?: NotifyOptions | string, config?: MatSnackBarConfig) { if (config === undefined) { config = { duration: duration } } if (typeof (coryOptions) === 'string') { coryOptions = { icon: coryOptions } } if (coryOptions === undefined) { coryOptions = { icon: 'info' } } config.data = config.data || {}; config.data.message = message; config.data.options = coryOptions; this.snackBar.openFromComponent(NotifyComponent, config); } error(error: Error) { this.info(`${error.message}`, { icon: 'error' }); console.error(error); } ngOnDestroy(): void { this.subscriptions$.forEach(subs$ => subs$.unsubscribe()) } } test/angular-webpack/angular/modules/material/services/theme.ts000066400000000000000000000046231516137561000253060ustar00rootroot00000000000000import { Injectable, } from '@angular/core'; import {kebabCase} from 'lodash'; import {SettingsService, CookieService} from '../../web'; //import {OverlayContainer} from '@angular/material'; export type ThemeType = "dark" | "light"; @Injectable() export class ThemeService { public current: string; private original: string; private all: string[]; private settings: any; public type: ThemeType; public usingCookie = false; constructor( private cookies: CookieService, private settingsAll: SettingsService, // private overlayContainer: OverlayContainer ) { } boot() { this.settings = this.settingsAll.data.material; this.original = this.settings.themes.material[0] this.current = this.original; this.all = this.settings.themes.material.map((element: string) => { return kebabCase(element) }) const fromCookie = this.cookies.get(this.settings.cookie.theme); try { if (fromCookie !== undefined) { this.usingCookie = true; this.setTheme(fromCookie); } else { this.setTheme(this.original); } } catch (e) { this.setTheme(this.original); } } setTheme(newTheme: string) { newTheme = kebabCase(newTheme); if (this.all.indexOf(newTheme) > -1) { const body = document.getElementsByTagName("body")[0]; body.classList.remove(this.current); // this.overlayContainer.getContainerElement().classList.remove(this.current); this.current = newTheme; body.classList.add(this.current); // this.overlayContainer.getContainerElement().classList.add(this.current); //this.overlayContainer.themeClass = newTheme; this.cookies.set(this.settings.cookie.theme, this.current); if (this.current.startsWith('cory-mat-theme-dark')) { this.type = "dark"; body.classList.add('cory-mat-theme-dark'); body.classList.remove('cory-mat-theme-light'); } else { this.type = "light"; body.classList.add('cory-mat-theme-light') body.classList.remove('cory-mat-theme-dark'); } return; } throw new Error(`undefined ${newTheme}`); } } test/angular-webpack/angular/modules/web/000077500000000000000000000000001516137561000207635ustar00rootroot00000000000000test/angular-webpack/angular/modules/web/boot.ts000066400000000000000000000041411516137561000222760ustar00rootroot00000000000000import { Injectable, Inject, } from '@angular/core'; import {PlatformLocation} from '@angular/common' import {log as defaultLog} from './util/log'; const IsBot = require("./util/is-bot.js"); const log = defaultLog.factory('boot'); declare global { interface Window { corifeusLoader: number, corifeus: { booted: boolean, app: { web: any, server: any } core: { http: { counter: number, status: number, counterUrlMap: any, error: Array } } }; } } window.corifeusLoader = 0 window.corifeus = { booted: false, core: { http: { status: 200, counter: 0, counterUrlMap: {}, error: [], } }, app: { web: {}, server: {} } } let httpCounter = 0; Object.defineProperty(window.corifeus.core.http, 'counter', { get: () => { return httpCounter; }, set: (value) => { httpCounter = value; } }) import {SettingsService, LocaleService} from "./"; import {RouterService} from "./services/router"; @Injectable() export class Boot { constructor( private settings: SettingsService, private locale: LocaleService, private routerService: RouterService, private location: PlatformLocation ) { } boot() { log('booted'); this.settings.boot(); const module = 'core'; const body = document.getElementsByTagName("body")[0]; const corySeo = document.createElement('div'); body.appendChild(corySeo) corySeo.id = 'cory-seo'; this.settings.register(module, require('./json/settings.json')); // after settings this.locale.boot(); if (!IsBot()) { corySeo.style.display = 'none'; } window.corifeus.booted = true; this.location.onPopState(() => { this.routerService.scrollToTop(); }); } } test/angular-webpack/angular/modules/web/index.ts000066400000000000000000000004321516137561000224410ustar00rootroot00000000000000// dirs //export * from '../src-save/directive'; //export * from './forms'; export * from './modules'; //export * from '../src-save/pipe'; export * from './services'; export * from './util'; // files export * from './boot'; export * from './module'; export * from './polyfills'; test/angular-webpack/angular/modules/web/json/000077500000000000000000000000001516137561000217345ustar00rootroot00000000000000test/angular-webpack/angular/modules/web/json/settings.json000066400000000000000000000007101516137561000244650ustar00rootroot00000000000000{ "server": { "url": "" }, "cookie": { "language": "cory-layout-language", "token": "corifeus-token" }, "header": { "token": "Authorization" }, "translations": { "language": { "en": "English", "hu": "Magyar" }, "display": { "en": "The user interface is English.", "hu": "A felhasználói felület Magyar." } } } test/angular-webpack/angular/modules/web/module.ts000066400000000000000000000044461516137561000226300ustar00rootroot00000000000000import { NgModule, ModuleWithProviders, } from '@angular/core'; import {RouterModule} from '@angular/router'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import {Boot} from './boot'; import {ColorService} from './services/color' //import {JsonPipe} from '../src-save/pipe/json' //import {KeysPipe} from '../src-save/pipe/keys' //import {HtmlPipe} from '../src-save/pipe/html' import {HttpShareService} from './services/http/http-share' import {AuthInterceptor} from './services/http/auth-interceptor' import {CookieService} from './services/cookie' import {RouterService} from './services/router' import {SettingsService} from './services/settings' import {LocaleService} from './services/locale' import {MediaQueryService} from './services/media-query' import {IpInfoService} from './modules/ip-info' import {AuthService,} from './modules/auth' //import {FocusDirective} from '../src-save/directive/autofocus' /*** * NEVER USE A EXPORT * AS, NEED THE EXACT COMPONENT FOR INJECTABLE FUNCTION!!!! */ let booted = false @NgModule({ imports: [ HttpClientModule, RouterModule, ], // export declarations: [ // KeysPipe, // HtmlPipe, // JsonPipe, // SubmittedRequired, // FocusDirective ], // does not need export providers: [ RouterService, CookieService, SettingsService, LocaleService, MediaQueryService, HttpShareService, ColorService, // modules IpInfoService, AuthService, { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }, // order is important Boot, ], exports: [ HttpClientModule, RouterModule, // KeysPipe, // HtmlPipe, // JsonPipe, // FocusDirective // SubmittedRequired, ], entryComponents: [], }) export class CorifeusModule { constructor(private boot: Boot) { if (booted === true) { return } booted = true this.boot.boot(); } public static forRoot(): ModuleWithProviders { return { ngModule: CorifeusModule, // providers: providers, }; } } test/angular-webpack/angular/modules/web/modules/000077500000000000000000000000001516137561000224335ustar00rootroot00000000000000test/angular-webpack/angular/modules/web/modules/auth.ts000066400000000000000000000043661516137561000237550ustar00rootroot00000000000000import { Injectable, Inject } from '@angular/core'; //import { // CookieService, //} from '../services/cookie'; import { HttpShareService, } from '../services/http/http-share'; import {HttpClient} from '@angular/common/http'; import { SettingsService, } from '../services/settings'; @Injectable() export class AuthService { constructor( private settings: SettingsService, // private cookie: CookieService, private http: HttpClient, private httpShare: HttpShareService, ) { } public async login(login: any) { return new Promise(async (resolve, reject) => { const observable: any = await this.http.post(`${this.settings.data.core.server.url}/api/core/auth/login`, login, { observe: 'response' }).subscribe((response: any) => { try { if (response.headers.has(this.settings.data.core.header.token)) { this.httpShare.token = response.headers.get(this.settings.data.core.header.token); } } catch (e) { window.corifeus.core.http.error.push(e); } const body: any = response.body; // console.log(this.httpShare.token); resolve(Token(body.token)); }, (err: Error) => { this.httpShare.token = ''; reject(err) }) }); } public async verify() { await this.http.get(`${this.settings.data.core.server.url}/api/core/auth/verify`).toPromise(); return Token(this.httpShare.token); } public async prolongate() { const response = await this.http.get(`${this.settings.data.core.server.url}/api/core/auth/prolongate`).toPromise(); this.httpShare.token = `${response['token']}`; return Token(this.httpShare.token); } } export function Token(token: String): any { try { if (token === '') { return token; } const data = token.split('-'); const info = JSON.parse(atob(data[0])); return info; } catch (e) { console.error(e); throw e; } } test/angular-webpack/angular/modules/web/modules/index.ts000066400000000000000000000000621516137561000241100ustar00rootroot00000000000000export * from './auth'; export * from './ip-info';test/angular-webpack/angular/modules/web/modules/ip-info.ts000066400000000000000000000005371516137561000243510ustar00rootroot00000000000000import {Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; @Injectable() export class IpInfoService { constructor(private http: HttpClient) { } public get get() { const response = this.http.get('https://server.patrikx3.com/api/patrikx3/ipinfo/get').toPromise(); return response; } } test/angular-webpack/angular/modules/web/polyfills.ts000066400000000000000000000004261516137561000233520ustar00rootroot00000000000000//import 'core-js/es6'; import 'core-js/es7/reflect.js'; import 'zone.js'; declare var process: any; if (process.env === 'production') { // Production } else { // Development Error['stackTraceLimit'] = Infinity; require('zone.js/dist/long-stack-trace-zone'); } test/angular-webpack/angular/modules/web/services/000077500000000000000000000000001516137561000226065ustar00rootroot00000000000000test/angular-webpack/angular/modules/web/services/color.ts000066400000000000000000000032151516137561000242750ustar00rootroot00000000000000import { Injectable, OnInit, ElementRef } from '@angular/core'; const tinycolor = require('tinycolor2'); const colorCalculatorCache = {} @Injectable() export class ColorService { public getReadableColor(fg: any, bg: any, step: number = 5) { let fgColor = tinycolor(fg); let bgColor = tinycolor(bg); const key = `${fgColor.toHexString()}${bgColor.toHexString()}`; if (colorCalculatorCache.hasOwnProperty(key)) { // console.log(key) // console.log(colorCalculatorCache) return colorCalculatorCache[key]; } // console.log('----------------------------------------------------') // console.log(fgColor.toHexString()) const max = Math.ceil(100 / step); let count = 0; const read = () => { while (!tinycolor.isReadable(fgColor, bgColor) && count < max) { fgColor = fgColor[method](step); //console.log(`${method} BG-${bgColor.toHexString()} => FG-${fgColor.toHexString()}`) count++; } } let method = 'lighten'; read(); if (count >= max) { count = 0; method = 'darken' fgColor = tinycolor(fg); read(); } if (count >= max) { fgColor = tinycolor(fg); fgColor = tinycolor.mostReadable(bgColor, [fgColor]); } // console.log(fgColor.toHexString()) // console.log('----------------------------------------------------') const result = fgColor.toHexString(); colorCalculatorCache[key] = result; return result; } } test/angular-webpack/angular/modules/web/services/cookie.ts000066400000000000000000000007401516137561000244300ustar00rootroot00000000000000import { Injectable } from '@angular/core'; //import * as Cookies from 'js-cookie'; import * as cookie from 'js-cookie'; @Injectable() export class CookieService { public get(name: string): string { return cookie.get(name); } public set(name: string, value: string | any, options?: Cookies.CookieAttributes): void { cookie.set(name, value, options) } public getAll(): { [key: string]: string } { return cookie.get(); } } test/angular-webpack/angular/modules/web/services/http/000077500000000000000000000000001516137561000235655ustar00rootroot00000000000000test/angular-webpack/angular/modules/web/services/http/auth-interceptor.ts000066400000000000000000000154131516137561000274360ustar00rootroot00000000000000import { Injectable } from '@angular/core'; import { HttpEvent, HttpInterceptor, HttpHeaders, HttpHandler, HttpRequest, } from '@angular/common/http'; import {Observable} from 'rxjs'; //import 'rxjs/add/observable/throw' import {tap} from 'rxjs/operators'; //import 'rxjs/add/operator/finally'; import { HttpShareService, } from './http-share'; import {State} from './state'; import {CookieService} from '../cookie'; import {SettingsService} from '../settings'; @Injectable() export class AuthInterceptor implements HttpInterceptor { cookie: CookieService = new CookieService(); settings: SettingsService = new SettingsService(); httpShare: HttpShareService = new HttpShareService() constructor() { } private handleFinally(url: string) { if (window.corifeus.core.http.counterUrlMap[url] === 1) { delete window.corifeus.core.http.counterUrlMap[url]; } else { window.corifeus.core.http.counterUrlMap[url]--; } window.corifeus.core.http.counter-- } intercept(req: HttpRequest, next: HttpHandler): Observable> { window.corifeus.core.http.counter++; let interceptedRequest = req; const url: any = req.url; if (window.corifeus.core.http.counterUrlMap.hasOwnProperty(url)) { window.corifeus.core.http.counterUrlMap[url]++; } else { window.corifeus.core.http.counterUrlMap[url] = 1; } State.NotFound = false; window.corifeus.core.http.status = 200; if (this.settings.data.core.server.url !== undefined && this.settings.data.core.server.url !== null && this.settings.data.core.server.url !== '') { if (url.startsWith(this.settings.data.core.server.url) && !url.startsWith(`${this.settings.data.core.server.url}/api/core/auth/login`)) { let headers = new HttpHeaders(); if (this.httpShare.token !== '') { headers = new HttpHeaders({ [this.settings.data.core.header.token]: `${this.httpShare.token}`, }); } interceptedRequest = req.clone({ headers: headers }); } } return next.handle(interceptedRequest).pipe( tap( (event: any) => { if (event.type !== 0) { this.handleFinally(url); } }, (err: any) => { this.handleFinally(url); } ), ) /* handle.do((event: any) => { // const eventType : string = typeof event; if (event.type !== 0) { this.handleFinally(url); } }, (err: any) => { this.handleFinally(url); }); */ // return handle; } } /* import { Injectable } from '@angular/core'; import { Http, ConnectionBackend, RequestOptions, RequestOptionsArgs, Request, Response, Headers } from '@angular/http'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/catch'; import { State } from './state'; import { CookieService } from '../cookie'; import { SettingsService } from '../settings'; import { HttpShareService } from './http-share'; let share : HttpShareService; @Injectable() export class HttpInterceptor extends Http { cookie: CookieService = new CookieService(); settings: SettingsService = new SettingsService(); constructor( backend: ConnectionBackend, defaultOptions: RequestOptions, ) { super(backend, defaultOptions); if (share === undefined) { share = new HttpShareService(); } } /* private handleError(err: Response, caught: Observable<{}>) { window.corifeus.core.http.counter--; State.NotFound = true; window.corifeus.core.http.status = 404; } */ /* private handleFinally(urlString: string) { if (window.corifeus.core.http.counterUrlMap[urlString] === 1) { delete window.corifeus.core.http.counterUrlMap[urlString]; } else { window.corifeus.core.http.counterUrlMap[urlString]--; } window.corifeus.core.http.counter-- } public get data() { return share; } request(url: string | Request, options?: RequestOptionsArgs): Observable { window.corifeus.core.http.counter++; const urlString = url instanceof Request ? url.url : url; if (window.corifeus.core.http.counterUrlMap.hasOwnProperty(urlString)) { window.corifeus.core.http.counterUrlMap[urlString]++; } else { window.corifeus.core.http.counterUrlMap[urlString] = 1; } State.NotFound = false; window.corifeus.core.http.status = 200; if (this.settings.data.core.server.url !== undefined && this.settings.data.core.server.url !== null && this.settings.data.core.server.url !== '') { if (url instanceof Request) { if (url.url.startsWith(this.settings.data.core.server.url)) { url.headers = url.headers || new Headers(); url.headers.set(this.settings.data.core.header.token, share.token) url.headers.set(this.settings.data.core.header.tokenAuto, share.tokenAuto) } } else { if (url.startsWith(this.settings.data.core.server.url)) { options.headers = options.headers || new Headers(); options.headers.set(this.settings.data.core.header.token, share.token) options.headers.set(this.settings.data.core.header.tokenAuto, share.tokenAuto) } } } const response = super.request(url, options); response.subscribe( (response: Response) => { try { if (response.headers.has(this.settings.data.core.header.token)) { share.token = response.headers.get(this.settings.data.core.header.token); } if (response.headers.has(this.settings.data.core.header.tokenAuto)) { share.tokenAuto = response.headers.get(this.settings.data.core.header.tokenAuto); } } catch (e) { window.corifeus.core.http.error.push(e); console.error(e); } }, (e: any) => { this.handleFinally(urlString); window.corifeus.core.http.error.push(e); }, () => { this.handleFinally(urlString) } ); return response; } } */ test/angular-webpack/angular/modules/web/services/http/http-share.ts000066400000000000000000000020261516137561000262140ustar00rootroot00000000000000import {Injectable} from '@angular/core'; let booted = false; const data = { token: '', }; import {Token} from '../../modules/auth'; import {CookieService} from '../cookie'; import {SettingsService} from '../settings'; const cookie: CookieService = new CookieService(); const settings: SettingsService = new SettingsService(); export class HttpShareService { constructor() { } public get requestCount() { return window.corifeus.core.http.counter; } public get token() { if (!booted) { booted = true; data.token = cookie.get(settings.data.core.cookie.token); } return data.token; } public set token(value) { booted = true; data.token = value; const cookieSettings: Cookies.CookieAttributes = {}; cookieSettings.expires = new Date(this.tokenInfo.expiry); cookie.set(settings.data.core.cookie.token, value, cookieSettings); } public get tokenInfo(): any { return Token(this.token); } } test/angular-webpack/angular/modules/web/services/http/index.ts000066400000000000000000000001331516137561000252410ustar00rootroot00000000000000export * from './http-share'; export * from './state'; export * from './auth-interceptor'; test/angular-webpack/angular/modules/web/services/http/state.ts000066400000000000000000000003401516137561000252520ustar00rootroot00000000000000export interface StateInterface { NotFound: boolean, RequestPath: string, } let State: StateInterface = { NotFound: false, RequestPath: location.pathname + location.search + location.hash } export {State}; test/angular-webpack/angular/modules/web/services/index.ts000066400000000000000000000003141516137561000242630ustar00rootroot00000000000000// dirs export * from './http'; // files export * from './color'; export * from './cookie'; export * from './locale'; export * from './settings'; export * from './router'; export * from './media-query'; test/angular-webpack/angular/modules/web/services/locale.ts000066400000000000000000000070401516137561000244160ustar00rootroot00000000000000import { Injectable, Inject } from '@angular/core'; //import * as moment from 'moment'; import {CookieService,} from '../services/cookie'; import {SettingsService} from '../services/settings'; import {IpInfoService,} from '../modules/ip-info'; import {log as logDefault} from '../util/log' const log = logDefault.factory('locale'); let currentLanguage = 'en'; const totalTranslations = {}; import {BehaviorSubject} from 'rxjs'; const subject = new BehaviorSubject({ action: 'empty' }); export interface LocaleSubject { action: string locale: LocaleService, } let cookieEmpty = true; const IsBot = require("../util/is-bot.js"); @Injectable() export class LocaleService { constructor( private ipInfo: IpInfoService, private settings: SettingsService, private cookie: CookieService, ) { } public async boot() { const fromCookie = this.cookie.get(this.settings.data.core.cookie.language); if (fromCookie !== undefined) { log(`using cookie language: ${fromCookie}`) this.setTranslation(fromCookie); } else if (!IsBot()) { let ipLanguage; try { const response: any = await this.ipInfo.get; if (!response.hasOwnProperty('country')) { this.setTranslation(currentLanguage); return; } ipLanguage = response.country.toLowerCase() if (Object.keys(this.settings.data.core.translations.language).indexOf(ipLanguage) > -1) { log(`using locale from IPINFO ${ipLanguage}`) this.setTranslation(ipLanguage); } } catch (e) { window.corifeus.core.http.error.push(e); console.error(e) } if (ipLanguage === undefined) { log(`using default language: ${ipLanguage}`) this.setTranslation(currentLanguage); } } else { this.setTranslation(currentLanguage); } } public register(module: string, translations: any) { log(`[ ${module.toUpperCase()} ]`) Object.keys(translations).forEach((lang: string) => { totalTranslations[lang] = totalTranslations[lang] || {}; // if (totalTranslations[lang][module] !== undefined) { // throw new Error(`Already registered locale langauge module (${module})`); // } totalTranslations[lang][module] = translations[lang]; }) subject.next({ action: 'set-translation', locale: this }) } public setTranslation(setTranslation: string) { log(`setTranslation '${setTranslation}'`) if (this.settings.data.core.translations.language.hasOwnProperty(setTranslation)) { currentLanguage = setTranslation; this.cookie.set(this.settings.data.core.cookie.language, currentLanguage); subject.next({ action: 'set-translation', locale: this }) //moment.locale(currentLanguage); cookieEmpty = false; return true; } throw new Error(`setTranslation '${setTranslation}' failed`); } public subscribe(subscriber: any) { return subject.subscribe({ next: subscriber }); } public get current() { return currentLanguage; } public get data() { return totalTranslations[currentLanguage]; } } test/angular-webpack/angular/modules/web/services/media-query.ts000066400000000000000000000110261516137561000254000ustar00rootroot00000000000000import { Injectable, NgZone, OnDestroy, } from '@angular/core'; import {Observable, BehaviorSubject} from 'rxjs'; import {log as defaultLog} from '../util/log'; const log = defaultLog.factory('media query'); export enum MediaQuerySettingType { Width } let mediaQuerySettingId = 0 export interface MediaQuerySetting { name: string, min: number, max: number, type: MediaQuerySettingType, _id: number, } @Injectable() export class MediaQueryService implements OnDestroy { settings: MediaQuerySetting[] = []; lastResult: MediaQuerySetting[] = []; width: number; height: number; subject: BehaviorSubject; onResize: EventListener; debounce: any; constructor( private ngZone: NgZone ) { this.subject = new BehaviorSubject([]); this.register([ { name: 'small', min: 0, max: 599, type: MediaQuerySettingType.Width }, { name: 'large', min: 600, max: Infinity, type: MediaQuerySettingType.Width } ]) const debounceTime = 500; this.onResize = (evt: Event) => { clearTimeout(this.debounce); this.debounce = setTimeout(() => { // console.log('debounced') this.ngZone.run(() => { this.width = window.innerWidth; this.height = window.innerHeight; this.findMediaQuery() }); }, debounceTime) } this.debounce = setTimeout(() => { this.onResize(null); }, debounceTime) window.addEventListener('resize', this.onResize) } public register(settings: MediaQuerySetting[]) { const unregisterIds : Array = [] for (let setting of settings) { let found = false; for (let useSetting of this.settings) { if (useSetting.name === setting.name && useSetting.type === setting.type) { found = true; console.warn(`corifeus-web media-query service has duplicate settings`) break; } } if (found === false) { mediaQuerySettingId++ unregisterIds.push(mediaQuerySettingId) setting._id = mediaQuerySettingId this.settings.push(setting); } } this.findMediaQuery(); const self = this return ((unregisterIds: Array) => { return function() { const newSettings : MediaQuerySetting[] = [] for(let setting of self.settings) { let keep = true for(let unregisterId of unregisterIds) { if (setting._id === unregisterId) { keep = false break; } } if (keep) { newSettings.push(setting) } } self.settings = newSettings } })(unregisterIds); } private findMediaQuery() { let results: MediaQuerySetting[] = []; this.settings.forEach((setting) => { // console.log(setting) switch (setting.type) { case MediaQuerySettingType.Width: // console.log('---------------------------'); const minFound = this.width >= setting.min; const maxFound = this.width <= setting.max; //console.log(setting.min, this.width, setting.max); //console.log(minFound, this.width, maxFound); if (minFound && maxFound) { results.push(setting); } break; } }) if (JSON.stringify(results) !== JSON.stringify(this.lastResult)) { this.lastResult = results; if (this.subject !== undefined) { this.subject.next(results); } } } public subscribe(subscriber: any) { return this.subject.subscribe({ next: subscriber }); } ngOnDestroy() { window.removeEventListener('resize', this.onResize) clearTimeout(this.debounce); } } test/angular-webpack/angular/modules/web/services/router.ts000066400000000000000000000074561516137561000245120ustar00rootroot00000000000000import { Injectable, OnDestroy } from '@angular/core'; import { Router as AngularRouter, NavigationExtras, NavigationEnd, } from '@angular/router'; const IsBot = require("../util/is-bot.js"); let debounceGoogleAnalyticsTimeout: any; import {SettingsService} from './settings'; import { Subscription } from 'rxjs' @Injectable() export class RouterService implements OnDestroy { subscriptions$: Array = [] analytics = false constructor(private router: AngularRouter, private settings: SettingsService ) { if (navigator.userAgent !== 'corifeus-server-renderer') { const startGa = () => { if (!IsBot()) { window['gtag']('config', settings.data.core.integration.google.analytics, { 'page_path': location.pathname } ); this.subscriptions$.push( this.router.events.subscribe((event: any) => { if (event instanceof NavigationEnd) { clearTimeout(debounceGoogleAnalyticsTimeout); debounceGoogleAnalyticsTimeout = setTimeout(() => { //console.log(event.urlAfterRedirects) window['gtag']('config', settings.data.core.integration.google.analytics, { 'page_path': event.urlAfterRedirects } ); }, 333) } }) ) } } setTimeout(() => { if (settings.data.core.hasOwnProperty('integration') && settings.data.core.integration.hasOwnProperty('google') && settings.data.core.integration.google.hasOwnProperty('analytics') && settings.data.core.integration.google.analytics !== '') { const loadSettings = setInterval(() => { if (window['gtag'] !== undefined) { this.analytics = true clearInterval(loadSettings) startGa(); } else { console.info('corifeus-web is waiting for gtag to be available') } }, 333) } }) } }; scrollToTop() { window.scrollTo(0, 0); const elements = document.querySelectorAll('[cdk-scrollable]'); for (let i = 0; i < elements.length; ++i) { const element = elements[i]; element.scrollTop = 0; //.scrollTo(0, 0); } const sideNavDivs = document.getElementsByTagName('mat-sidenav-content'); for (let i = 0; i < sideNavDivs.length; i++) { const sideNavDiv = sideNavDivs[i]; sideNavDiv.scrollTop = 0; } } navigateTop(commands: any[], extras?: NavigationExtras): Promise { this.scrollToTop(); return this.navigate(commands, extras); } navigate(commands: any[], extras?: NavigationExtras): Promise { return this.router.navigate(commands, extras); } get events() { return this.router.events; } ngOnDestroy(): void { this.subscriptions$.forEach(subs$ => subs$.unsubscribe()) } public collectAnalytics(pagePath: string) { if (this.analytics) { window['gtag']('config', this.settings.data.core.integration.google.analytics, { 'page_path': pagePath } ); } } } test/angular-webpack/angular/modules/web/services/settings.ts000066400000000000000000000117721516137561000250260ustar00rootroot00000000000000import { Injectable } from '@angular/core'; import {log as defulatLog} from '../util/log'; const log = defulatLog.factory('settings'); let totalSettings: any = {}; let extendSettings: any = {}; @Injectable() export class SettingsService { constructor() { } public register(module: string, settings: any) { log(`[${module.toUpperCase()}] register`) // if (totalSettings[module] !== undefined) { // throw new Error(`Already registered setting module (${module})`); // } totalSettings[module] = Object.assign(totalSettings[module] || {}, settings) if (extendSettings[module] !== undefined && extendSettings[module].length > 0 ) { for(let extendSetting of extendSettings[module]) { totalSettings[module] = Object.assign(totalSettings[module], extendSetting) } } log(`[${module.toUpperCase()}] registered`, totalSettings) } public extend(module: string, settings: any) { if (totalSettings[module] === undefined) { log(`[${module.toUpperCase()}] extend not ready, waiting for register`, settings) extendSettings[module] = extendSettings[module] || []; extendSettings[module].push(settings) return; } log(`[${module.toUpperCase()}] extend`, settings) totalSettings[module] = Object.assign(totalSettings[module], settings) log(`[${module.toUpperCase()}] done`, totalSettings) } get data(): any { return totalSettings; } boot() { } afterInitWaiter: any; afterInit() { log('afterInit'); const coreSettings = totalSettings['core']; if (coreSettings === undefined) { log('afterInit waiting for construction') this.afterInitWaiter = setTimeout(() => { this.afterInit() }) return } if (coreSettings.hasOwnProperty('integration')) { log('afterInit - integration'); const head = document.getElementsByTagName("head")[0]; // yandex if (coreSettings.integration.hasOwnProperty('yandex')) { log('afterInit - integration - yandex'); // yandex-verification if (coreSettings.integration.yandex.hasOwnProperty('verification')) { log('afterInit - integration - yandex - verification'); const meta = document.createElement('meta'); meta.name = "yandex-verification"; meta.content = coreSettings.integration.yandex['verification']; head.appendChild(meta); } } // google if (coreSettings.integration.hasOwnProperty('google')) { log('afterInit - integration - google'); // google-site-verification if (coreSettings.integration.google.hasOwnProperty('site-verification')) { log('afterInit - integration - google - site-verification'); const meta = document.createElement('meta'); meta.name = "google-site-verification"; meta.content = coreSettings.integration.google['site-verification']; head.appendChild(meta); } // google analytics if (coreSettings.integration.google.hasOwnProperty('analytics')) { log('afterInit - integration - google - analytics'); const script = document.createElement("script"); script.type = 'text/javascript'; script.async = true script.src = `https://www.googletagmanager.com/gtag/js?id=${coreSettings.integration.google.analytics}` head.appendChild(script); const scriptInline =document.createElement("script"); scriptInline.type = 'text/javascript'; scriptInline.innerHTML = ` window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', '${coreSettings.integration.google.analytics}'); ` head.appendChild(scriptInline); log('afterInit - integration - google - analytics - load script'); } } // microsoft if (coreSettings.integration.hasOwnProperty('microsoft')) { log('afterInit - integration - google - microsoft'); // msvalidate.01 / bing if (coreSettings.integration.microsoft.hasOwnProperty('msvalidate.01')) { log('afterInit - integration - google - microsoft - msvalidate'); const meta = document.createElement('meta'); meta.name = "msvalidate.01"; meta.content = coreSettings.integration.microsoft['msvalidate.01']; head.appendChild(meta); } } } } } test/angular-webpack/angular/modules/web/util/000077500000000000000000000000001516137561000217405ustar00rootroot00000000000000test/angular-webpack/angular/modules/web/util/index.ts000066400000000000000000000002761516137561000234240ustar00rootroot00000000000000export * from './log'; export function decodeEntities(encodedString: string) { var div = document.createElement('div'); div.innerHTML = encodedString; return div.textContent; } test/angular-webpack/angular/modules/web/util/is-bot.js000066400000000000000000000015101516137561000234700ustar00rootroot00000000000000const pattern = new RegExp('spider|bot|yahoo|bing|google|yandex|lynx|curl|embedly|quora|outbrain|pinterest|vkShare|W3C_Validator|crawl|borg|slurp|archiver|netresearch|lycos|scooter|altavista|teoma|oegp|charlotte|http client|htdig|ichiro|mogimogi|larbin|pompos|scrubby|searchsight|semanticdiscovery|snappy|speedy|voila|vortex|voyager|zao|zeal|dataparksearch|findlinks|browsermob|httpmonitor|bingpreview|pagepeeker|webthumb|url2png|zooshot|gomeza|google sketchup|read later|pingdom|facebook|rackspace|scan|link|ezine|preview|dig|tarantula|urllib|jakarta|wget|rget|monitor|libwww|moozilla|seer|spice|snoopy|feedfetcher|wordpress|java|netfront|archive|xenu|feed|appmanager|covario|perl|host|lwp|page speed|ptst|digext|nutch|sleuth|yottaamonitor|bubing|corifeus', 'i'); module.exports = () => { return pattern.test(navigator.userAgent); }; test/angular-webpack/angular/modules/web/util/log.ts000066400000000000000000000014601516137561000230720ustar00rootroot00000000000000declare var process: any; const isDevMode = () => { return process.env !== 'production' } export function logFactory(module: string): any { let log: any; if (!isDevMode()) { log = function (...args: any[]) { }; } else { log = function log(...args: any[]) { args.unshift(`[${module.toUpperCase()}] `); const result = {}; for (let index = 0; index < args.length; index++) { const stringIndex: string = String(index); result[stringIndex] = args[index]; } console.log.apply(console.log, args); } } log.factory = (innerModule: string) => { return logFactory(`${module}] [${innerModule}`); } return log; } const log = logFactory('corifeus') export {log}; test/angular-webpack/angular/page.ts000066400000000000000000000133241516137561000200250ustar00rootroot00000000000000import { Component, Injectable, ViewChild, ViewContainerRef, OnInit, NgModule, CUSTOM_ELEMENTS_SCHEMA, OnDestroy } from '@angular/core'; import { MatButtonModule, } from '@angular/material/button'; @Component({ selector: 'p3x-compile-test', template: `

P3X Angular Compile Example

Corifeus.com Wiki
How it works from the code in GitHub, some examples

Go ahead and inspect the elements and click away!!!

Template 1



Template 2



Template 3



Template 4 - Re-use the same context



Pure Router Link with JIT Angular

 


Router Link with p3x-angular-compile

` }) @Injectable() export class Page implements OnInit, OnDestroy { data1: string; data2: string = 'init'; data3: string = 'Just simple string red'; counter1: number = 0; counter2: number = 0; interval: any; dataRouterLink: string = '' compileForm: string = `` dataMaterialDefault: string = ` ` dataMaterial: string = ` ` dataMaterialModule: any = { // schemas: [CUSTOM_ELEMENTS_SCHEMA], // declarations: [], imports: [ MatButtonModule ], exports: [] } constructor( // private compileHtmlService: CompileService ) { } private update1() { this.counter1++; this.data1 = `
P3X Angular Compile
Click me via a angular compile!
{{ context.counter1}}
`; } public formClick() { alert('form click'); } private update2() { this.counter2++; this.data2 = `
Attribute
Click me via an other attribute!
{{ context.counter2}}
`; } chars: string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' getRandomChar() { return this.chars[Math.floor(Math.random() * (62 - 0)) + 0] } randomRouterLink() { let counter = 0; let randomString = ''; let randomString2 = ''; while (counter < 10) { counter++; randomString += this.getRandomChar(); randomString2 += this.getRandomChar(); } this.dataRouterLink = `${randomString}` this.dataMaterial = ` ${this.dataMaterialDefault}   ${randomString2} ` } ngOnInit() { this.update1(); this.update2(); this.randomRouterLink() /* let is = false; let newData = '123'; let defaultData = ''; let count = 0; this.interval = setInterval(() => { is = !is; if (is) { count++; defaultData = defaultData + newData; this.data3 = defaultData + defaultData; if (count > 10) { count = 0; defaultData = newData; } } else { this.data3 = '
321
' } }, 1000) */ } ngOnDestroy() { clearInterval(this.interval); } } test/angular-webpack/angular/polyfills.ts000066400000000000000000000004471516137561000211300ustar00rootroot00000000000000//import 'corifeus-web/src/polyfills'; import 'core-js/es6'; import 'core-js/es7/reflect.js'; import 'zone.js'; if (process.env.ENV === 'production') { // Production } else { // Development Error['stackTraceLimit'] = Infinity; require('zone.js/dist/long-stack-trace-zone'); } test/angular-webpack/assets/000077500000000000000000000000001516137561000164075ustar00rootroot00000000000000test/angular-webpack/assets/style.scss000066400000000000000000000007131516137561000204450ustar00rootroot00000000000000@import '../angular/modules/material/scss/all'; .p3x-angular-compile-element { padding: 5px; } .cory-mat-theme-light { .p3x-angular-compile-element { border: dashed 2px rgba(black, 0.1); background-color: rgba(black, 0.05); padding: 5px; } } .cory-mat-theme-dark { .p3x-angular-compile-element { border: dashed 2px rgba(white, 0.1); background-color: rgba(white, 0.05); padding: 5px; } } test/angular-webpack/index.html000066400000000000000000000034271516137561000171100ustar00rootroot00000000000000 P3X Angular Compile
tsconfig.aot.json000066400000000000000000000015531516137561000143600ustar00rootroot00000000000000{ "compilerOptions": { "skipLibCheck": true, "outDir": "build/aot", "target": "es2018", "module": "esnext", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, "lib": [ "es2018", "dom" ] }, "include": [ "src/angular/**/*", "test/angular-webpack/**/*" ], "exclude": [ "src/angular/bundle.ts", "test/angular-webpack/angular/bundle.ts", "test/angular-karma", "build/browser" ], "angularCompilerOptions-save": { "annotationsAs": "decorators", "preserveWhitespaces": false }, "angularCompilerOptions": { "enableIvy": false } } tsconfig.build.json000066400000000000000000000016351516137561000146750ustar00rootroot00000000000000{ "compilerOptions": { "skipLibCheck": true, "declaration": true, "baseUrl": "./", "target": "es2018", "module": "esnext", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": true, "outDir": "./dist", "suppressImplicitAnyIndexErrors": true, "lib": [ "es2018", "dom" ], "paths": { "*": [ "node_modules/@types/*", "*" ] } }, "includes": [ "src/**/*" ], "exclude": [ "node_modules", "test", "src-save" ], "angularCompilerOptions": { "strictMetadataEmit": true, "skipTemplateCodegen": true, "annotateForClosureCompiler": true, "enableIvy": false } } tsconfig.json000066400000000000000000000020131516137561000135660ustar00rootroot00000000000000{ "compilerOptions": { "skipLibCheck": true, "baseUrl": "./", "target": "es2018", "module": "esnext", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, "lib": [ "es2018", "dom" ], "paths": { "*": [ "node_modules/@types/*", "*" ] } }, "includes": [ "src/angular/**/*", "test/angular-webpack/**/*" ], "exclude": [ "node_modules", "src/angular/bundle.aot.ts", "test/angular-karma-disabled", "test/angular-webpack/angular/bundle.aot.ts", "build/browser" ], "angularCompilerOptions-save": { "annotationsAs": "decorators", "preserveWhitespaces": false }, "angularCompilerOptions": { "enableIvy": false } }