Skip to content

Commit

Permalink
Merge 13f0b7f into b5074c8
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremythuff committed Sep 17, 2021
2 parents b5074c8 + 13f0b7f commit 7875ef5
Show file tree
Hide file tree
Showing 63 changed files with 1,376 additions and 1,315 deletions.
3 changes: 2 additions & 1 deletion .wvr-ud/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dist/bundle/weaver-components.js"
],
"additionalAssets": [
"src/assets/**/*"
"src/assets/**/*",
"dist/bundle/styles.css"
]
}
12 changes: 10 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@
}
],
"buildOptimizer": true,
"optimization": true,
"optimization": {
"scripts": true,
"fonts": {
"inline": true
},
"styles": {
"minify": true,
"inlineCritical": false
}
},
"sourceMap": false,
"extractCss": false,
"extractLicenses": true,
"commonChunk": false,
"namedChunks": false,
Expand Down
89 changes: 44 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"build:docs-development": "compodoc --output ./static/weaver-components/docs/development -p ./projects/wvr-elements/tsconfig.docs.json",
"build:docs-usage": "node scripts/build-wvr-ud.js",
"build:docker": "node scripts/build-docker.js",
"build:link": "npm run build && node scripts/link-self.js",
"build:static": "npm run build:static-docs && npm run build:static-reports",
"build:static-setup": "node scripts/build-wvr-components-static.js",
"build:static-docs": "npm run test:audit && npm run build:static-setup && npm run build:docs-usage && npm run build:docs-development",
Expand All @@ -36,7 +37,6 @@
"publish:npm": "npm run build && node scripts/build-publish.js $1",
"publish:npm-next": "npm run publish:npm next",
"lint": "ng lint",
"link": "npm link ./dist/wvr-elements",
"ng": "ng",
"start": "node scripts/build-wvr-components-style.js && node scripts/build-wvr-components-configuration.js defaults-dev-overrides.env && ng serve --port 4200",
"start:dist": "node scripts/build-wvr-components-style.js && node scripts/build-wvr-components-configuration.js defaults-dist-overrides.env && node scripts/serve-dist.js",
Expand All @@ -52,81 +52,80 @@
"test:ci": "npm run test:audit && npm run test:coverage"
},
"dependencies": {
"@angular/animations": "^12.0.2",
"@angular/common": "^12.0.2",
"@angular/compiler": "^12.0.2",
"@angular/core": "^12.0.2",
"@angular/elements": "^12.0.2",
"@angular/forms": "^12.0.2",
"@angular/localize": "^12.0.2",
"@angular/platform-browser": "^12.0.2",
"@angular/platform-browser-dynamic": "^12.0.2",
"@angular/router": "^12.0.2",
"@ng-bootstrap/ng-bootstrap": "^9.1.1",
"@ngrx/effects": "^12.0.0",
"@ngrx/entity": "^12.0.0",
"@ngrx/router-store": "^12.0.0",
"@ngrx/store": "^12.0.0",
"@ngrx/store-devtools": "^12.0.0",
"@tinymce/tinymce-angular": "^4.2.3",
"@angular/animations": "^12.2.5",
"@angular/common": "^12.2.5",
"@angular/compiler": "^12.2.5",
"@angular/core": "^12.2.5",
"@angular/elements": "^12.2.5",
"@angular/forms": "^12.2.5",
"@angular/localize": "^12.2.5",
"@angular/platform-browser": "^12.2.5",
"@angular/platform-browser-dynamic": "^12.2.5",
"@angular/router": "^12.2.5",
"@ng-bootstrap/ng-bootstrap": "^10.0.0",
"@ngrx/effects": "^12.4.0",
"@ngrx/entity": "^12.4.0",
"@ngrx/router-store": "^12.4.0",
"@ngrx/store": "^12.4.0",
"@ngrx/store-devtools": "^12.4.0",
"@tinymce/tinymce-angular": "^4.2.4",
"@ungap/custom-elements": "^1.0.0",
"bootstrap": "^4.6.0",
"css-element-queries": "^1.2.3",
"handlebars": "^4.7.7",
"json5": "^2.2.0",
"ng-inline-svg": "^13.0.0",
"rxjs": "~6.6.7",
"tinymce": "^5.8.1",
"tslib": "^2.2.0",
"tinymce": "^5.9.2",
"tslib": "^2.3.1",
"web-animations-js": "^2.3.2",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^12.0.2",
"@angular-devkit/schematics": "^12.0.2",
"@angular/cli": "^12.0.2",
"@angular/compiler-cli": "^12.0.2",
"@angular/language-service": "^12.0.2",
"@compodoc/compodoc": "^1.1.11",
"@lhci/cli": "^0.7.2",
"@ngrx/schematics": "^12.0.0",
"@angular-devkit/build-angular": "^12.2.5",
"@angular-devkit/schematics": "^12.2.5",
"@angular/cli": "^12.2.5",
"@angular/compiler-cli": "^12.2.5",
"@angular/language-service": "^12.2.5",
"@compodoc/compodoc": "^1.1.14",
"@lhci/cli": "^0.8.1",
"@ngrx/schematics": "^12.4.0",
"@pickra/copy-code-block": "^1.2.0",
"@types/jasmine": "~3.7.6",
"@types/jasminewd2": "~2.0.9",
"@types/json5": "^2.2.0",
"@types/node": "^15.6.1",
"@types/jasmine": "~3.9.0",
"@types/jasminewd2": "~2.0.10",
"@types/node": "^16.9.1",
"angular-tslint-rules": "^1.20.4",
"chalk": "^4.1.1",
"chalk": "^4.1.2",
"chrome-launcher": "^0.14.0",
"codelyzer": "^6.0.2",
"concat": "^1.0.3",
"console-stamp": "^3.0.2",
"coveralls": "^3.1.0",
"console-stamp": "^3.0.3",
"coveralls": "^3.1.1",
"dotenv-override": "^5.0.1",
"dotenv-override-true": "^6.2.2",
"fs-extra": "^10.0.0",
"glob": "^7.1.7",
"handlebars-loader": "^1.7.1",
"jasmine-core": "~3.7.1",
"jasmine-core": "~3.9.0",
"jasmine-spec-reporter": "~7.0.0",
"jsdom": "^16.6.0",
"karma": "^6.3.2",
"jsdom": "^17.0.0",
"karma": "^6.3.4",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "^2.0.3",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.6.0",
"karma-jasmine-html-reporter": "^1.7.0",
"karma-ng-html2js-preprocessor": "^1.0.0",
"lighthouse": "^7.5.0",
"lighthouse-badges": "^1.1.5",
"ng-packagr": "^12.0.2",
"ngx-build-plus": "^12.0.1",
"lighthouse": "^8.4.0",
"lighthouse-badges": "^1.1.11",
"ng-packagr": "^12.2.1",
"ngx-build-plus": "^12.2.0",
"protractor": "~7.0.0",
"rimraf": "^3.0.2",
"shelljs": "^0.8.4",
"static-server": "^2.2.1",
"ts-node": "~10.0.0",
"ts-node": "~10.2.1",
"tslint": "~6.1.3",
"typescript": "~4.2.4"
"typescript": "~4.3.5"
}
}
13 changes: 4 additions & 9 deletions projects/wvr-elements/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions projects/wvr-elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"wvr-ud": "./scripts/build-wvr-ud.js"
},
"dependencies": {
"tslib": "^2.2.0"
"tslib": "^2.3.1"
},
"peerDependencies": {
"@angular/common": "^12.0.1",
"@angular/core": "^12.0.1",
"@angular/common": "^12.2.5",
"@angular/core": "^12.2.5",
"css-element-queries": "^1.2.3",
"handlebars": "^4.7.7"
}
Expand Down
1 change: 1 addition & 0 deletions projects/wvr-elements/src/lib/core/manifest/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ManifestEntryRequest } from './manifest-entry-request';
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ManifestEffects {
}

let path = entry.path;
if (!!request.options.pathVariables) {
if (!!request.options && !!request.options.pathVariables) {
const pathVariables = new Map<string, string>(Object.entries(request.options.pathVariables));
pathVariables.forEach((v, k) => {
path = path.split(`:${k}`)
Expand Down
34 changes: 34 additions & 0 deletions projects/wvr-elements/src/lib/core/ng-bindings.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ChangeDetectorRef, Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';

export interface CdRefBindingSubject {
subject: BehaviorSubject<any>;
cdRef: ChangeDetectorRef;
}

/**
* A registry for AngularJS binding subjects.
*/
@Injectable({
providedIn: 'root'
})
export class NgBindingsService {

private readonly subjects: { [key: string]: Array<CdRefBindingSubject> };

constructor() {
this.subjects = {};
}

putSubject(key: string, subject: CdRefBindingSubject): Array<CdRefBindingSubject> {
let subjects = this.subjects[key];
if (!subjects) {
subjects = [];
this.subjects[key] = subjects;
}
this.subjects[key].push(subject);

return this.subjects[key];
}

}
3 changes: 2 additions & 1 deletion projects/wvr-elements/src/lib/core/rest/rest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class RestService {

if (request.decode) {
request.decode.forEach(prop => {
body[prop] = atob(body[prop]);
body[prop] = Buffer.from(body[prop], 'base64')
.toString();
});
}

Expand Down
4 changes: 2 additions & 2 deletions projects/wvr-elements/src/lib/core/wvr-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { WvrManifestComponent } from '../wvr-manifest/wvr-manifest.component';
import { WvrModalComponent } from '../wvr-modal/wvr-modal.component';
import { WvrNavLiComponent } from '../wvr-nav-list/wvr-nav-li/wvr-nav-li.component';
import { WvrNavListComponent } from '../wvr-nav-list/wvr-nav-list.component';
import { WvrTabComponent } from '../wvr-tabs/wvr-tab/wvr-tab.component';
import { WvrTabsComponent } from '../wvr-tabs/wvr-tabs.component';
import { WvrTextComponent } from '../wvr-text/wvr-text.component';
import { WvrThemeComponent } from '../wvr-theme/wvr-theme.component';
Expand All @@ -33,6 +32,7 @@ import { AnimationService } from './animation.service';
import { ComponentRegistryService } from './component-registry.service';
import { LayoutEffects } from './layout/layout.effects';
import { ManifestEffects } from './manifest/manifest.effects';
import { NgBindingsService } from './ng-bindings.service';
import { RestEffects } from './rest/rest.effects';
import { metaReducers, ROOT_REDUCER } from './store';
import { ThemeEffects } from './theme/theme.effects';
Expand All @@ -59,7 +59,6 @@ export const WVR_ELEMENTS: Array<WvrElementDesc> = [
{ component: WvrNavLiComponent, selector: 'wvre-nav-li', lazy: true },
{ component: WvrTextComponent, selector: 'wvre-text', lazy: true },
{ component: WvrTabsComponent, selector: 'wvre-tabs', lazy: true },
{ component: WvrTabComponent, selector: 'wvre-tab', lazy: true },
{ component: WvrThemeComponent, selector: 'wvre-theme', lazy: false },
{ component: WvrWysiwygComponent, selector: 'wvre-wysiwyg', lazy: true }
];
Expand Down Expand Up @@ -103,6 +102,7 @@ const PROVIDERS = [
AnimationService,
ActionRegistryService,
ComponentRegistryService,
NgBindingsService,
ThemeService
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';
import { projectSourceContent } from '../utility';

@Directive({
selector: '[wvrContentProjection]'
})
export class WvrContentProjectionDirective implements AfterViewInit {

@Input('wvrContentProjection') parentElementRef: ElementRef;

/* tslint:disable-next-line:no-input-rename */
@Input('template') template: string;

constructor(private readonly elementRef: ElementRef) {

}

ngAfterViewInit(): void {
projectSourceContent(this.elementRef, this.parentElementRef, `template[${this.template}]`);
}

}
1 change: 1 addition & 0 deletions projects/wvr-elements/src/lib/shared/utility/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { obtainConfigPath, registerWeaverElements, showWeaverElements, weaverBootstrap, WvrElementDesc } from './bootstrap.utility';
export { debounce } from './decorators.utilty';
export { preserveContent, projectContent, projectSourceContent } from './projection.utility';
export { wvrCompile, wvrParseProjectedContent } from './template.utility';
export { wvrTimeout } from './timing.utility';
52 changes: 52 additions & 0 deletions projects/wvr-elements/src/lib/shared/utility/projection.utility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { ElementRef } from '@angular/core';

const projectContent = (elementRef: ElementRef, templateSelector: string, targetSelector: string): void => {
const element: Element = elementRef.nativeElement.querySelector(targetSelector);
project(element, elementRef, templateSelector);
};

const projectSourceContent = (elementRef: ElementRef, sourceElementRef: ElementRef, templateSelector: string): void => {
const element: Element = elementRef.nativeElement;
project(element, sourceElementRef, templateSelector);
};

const project = (element: Element, sourceElementRef: ElementRef, templateSelector: string): void => {
const templates: Array<HTMLTemplateElement> = Array.from(sourceElementRef.nativeElement.querySelectorAll(templateSelector));
if (!!element) {
templates.forEach((template: HTMLTemplateElement) => {
const clone: Node = template.children.length === 0 && template.content.children.length > 0
? template.content.cloneNode(true)
: template;
Array.from((clone as Element).children)
.forEach((elem: Element) => {
element.appendChild(elem);
});
});
}
// hide target element if nothing to project
if (!!element && !templates.length) {
(element as HTMLElement).hidden = true;
}
};

const preserveContent = (elementRef: ElementRef, templateSelector: string, targetSelector: string): void => {
const element: Element = elementRef.nativeElement.querySelector(targetSelector);
const template: HTMLTemplateElement = elementRef.nativeElement.querySelector(templateSelector);
if (!!element && !!template) {
Array.from(element.children)
.filter((elem: Element) => elem.nodeName !== 'TEMPLATE')
.forEach((elem: Element) => {
if (template.children.length) {
template.replaceChild(elem, template.children[0]);
} else {
template.appendChild(elem);
}
});
}
};

export {
projectContent,
projectSourceContent,
preserveContent
};

0 comments on commit 7875ef5

Please sign in to comment.