_id stringlengths 21 254 | text stringlengths 1 93.7k | metadata dict |
|---|---|---|
angular/packages/examples/core/ts/bootstrap/bootstrap.ts_0_684 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
@Component({
selector: 'app-root',
template: 'Hello {{ name }}!',
standalone: false,
})
class MyApp {
name: string = 'World';
}
@NgModule({imports: [BrowserModule], bootstrap: [MyApp]})
class AppModule {}
export function main() {
platformBrowserDynamic().bootstrapModule(AppModule);
}
| {
"end_byte": 684,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/bootstrap/bootstrap.ts"
} |
angular/packages/examples/core/ts/platform/platform.ts_0_2106 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {ApplicationRef, Component, DoBootstrap, NgModule, Type} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
@Component({
selector: 'app-root',
template: ` <h1>Component One</h1> `,
standalone: false,
})
export class ComponentOne {}
@Component({
selector: 'app-root',
template: ` <h1>Component Two</h1> `,
standalone: false,
})
export class ComponentTwo {}
@Component({
selector: 'app-root',
template: ` <h1>Component Three</h1> `,
standalone: false,
})
export class ComponentThree {}
@Component({
selector: 'app-root',
template: ` <h1>Component Four</h1> `,
standalone: false,
})
export class ComponentFour {}
@NgModule({imports: [BrowserModule], declarations: [ComponentOne, ComponentTwo]})
export class AppModule implements DoBootstrap {
// #docregion componentSelector
ngDoBootstrap(appRef: ApplicationRef) {
this.fetchDataFromApi().then((componentName: string) => {
if (componentName === 'ComponentOne') {
appRef.bootstrap(ComponentOne);
} else {
appRef.bootstrap(ComponentTwo);
}
});
}
// #enddocregion
fetchDataFromApi(): Promise<string> {
return new Promise((resolve) => {
setTimeout(() => {
resolve('ComponentTwo');
}, 2000);
});
}
}
@NgModule({imports: [BrowserModule], declarations: [ComponentThree]})
export class AppModuleTwo implements DoBootstrap {
// #docregion cssSelector
ngDoBootstrap(appRef: ApplicationRef) {
appRef.bootstrap(ComponentThree, '#root-element');
}
// #enddocregion cssSelector
}
@NgModule({imports: [BrowserModule], declarations: [ComponentFour]})
export class AppModuleThree implements DoBootstrap {
// #docregion domNode
ngDoBootstrap(appRef: ApplicationRef) {
const element = document.querySelector('#root-element');
appRef.bootstrap(ComponentFour, element);
}
// #enddocregion domNode
}
| {
"end_byte": 2106,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/platform/platform.ts"
} |
angular/packages/examples/core/ts/pipes/pipeTransFormEx_module.ts_0_449 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {NgModule} from '@angular/core';
import {TruncatePipe as SimpleTruncatePipe} from './simple_truncate';
import {TruncatePipe} from './truncate';
@NgModule({declarations: [SimpleTruncatePipe, TruncatePipe]})
export class TruncateModule {}
| {
"end_byte": 449,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/pipes/pipeTransFormEx_module.ts"
} |
angular/packages/examples/core/ts/pipes/truncate.ts_0_506 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// #docregion
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'truncate',
standalone: false,
})
export class TruncatePipe implements PipeTransform {
transform(value: string, length: number, symbol: string) {
return value.split(' ').slice(0, length).join(' ') + symbol;
}
}
| {
"end_byte": 506,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/pipes/truncate.ts"
} |
angular/packages/examples/core/ts/pipes/simple_truncate.ts_0_468 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// #docregion
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'truncate',
standalone: false,
})
export class TruncatePipe implements PipeTransform {
transform(value: string) {
return value.split(' ').slice(0, 2).join(' ') + '...';
}
}
| {
"end_byte": 468,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/pipes/simple_truncate.ts"
} |
angular/packages/examples/core/ts/metadata/directives.ts_0_1935 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/* tslint:disable:no-console */
import {Component, Directive, EventEmitter, NgModule} from '@angular/core';
// #docregion component-input
@Component({
selector: 'app-bank-account',
inputs: ['bankName', 'id: account-id'],
template: ` Bank Name: {{ bankName }} Account Id: {{ id }} `,
standalone: false,
})
export class BankAccountComponent {
bankName: string | null = null;
id: string | null = null;
// this property is not bound, and won't be automatically updated by Angular
normalizedBankName: string | null = null;
}
@Component({
selector: 'app-my-input',
template: ` <app-bank-account bankName="RBC" account-id="4747"> </app-bank-account> `,
standalone: false,
})
export class MyInputComponent {}
// #enddocregion component-input
// #docregion component-output-interval
@Directive({
selector: 'app-interval-dir',
outputs: ['everySecond', 'fiveSecs: everyFiveSeconds'],
standalone: false,
})
export class IntervalDirComponent {
everySecond = new EventEmitter<string>();
fiveSecs = new EventEmitter<string>();
constructor() {
setInterval(() => this.everySecond.emit('event'), 1000);
setInterval(() => this.fiveSecs.emit('event'), 5000);
}
}
@Component({
selector: 'app-my-output',
template: `
<app-interval-dir (everySecond)="onEverySecond()" (everyFiveSeconds)="onEveryFiveSeconds()">
</app-interval-dir>
`,
standalone: false,
})
export class MyOutputComponent {
onEverySecond() {
console.log('second');
}
onEveryFiveSeconds() {
console.log('five seconds');
}
}
// #enddocregion component-output-interval
@NgModule({
declarations: [BankAccountComponent, MyInputComponent, IntervalDirComponent, MyOutputComponent],
})
export class AppModule {}
| {
"end_byte": 1935,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/metadata/directives.ts"
} |
angular/packages/examples/core/ts/metadata/metadata.ts_0_1187 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Attribute, Component, Directive, Pipe} from '@angular/core';
class CustomDirective {}
@Component({
selector: 'greet',
template: 'Hello {{name}}!',
standalone: false,
})
class Greet {
name: string = 'World';
}
// #docregion attributeFactory
@Component({
selector: 'page',
template: 'Title: {{title}}',
standalone: false,
})
class Page {
title: string;
constructor(@Attribute('title') title: string) {
this.title = title;
}
}
// #enddocregion
// #docregion attributeMetadata
@Directive({
selector: 'input',
standalone: false,
})
class InputAttrDirective {
constructor(@Attribute('type') type: string) {
// type would be 'text' in this example
}
}
// #enddocregion
@Directive({
selector: 'input',
standalone: false,
})
class InputDirective {
constructor() {
// Add some logic.
}
}
@Pipe({
name: 'lowercase',
standalone: false,
})
class Lowercase {
transform(v: string, args: any[]) {
return v.toLowerCase();
}
}
| {
"end_byte": 1187,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/metadata/metadata.ts"
} |
angular/packages/examples/core/ts/metadata/lifecycle_hooks_spec.ts_0_5145 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {
AfterContentChecked,
AfterContentInit,
AfterViewChecked,
AfterViewInit,
Component,
DoCheck,
Input,
OnChanges,
OnDestroy,
OnInit,
SimpleChanges,
Type,
} from '@angular/core';
import {TestBed} from '@angular/core/testing';
(function () {
describe('lifecycle hooks examples', () => {
it('should work with ngOnInit', () => {
// #docregion OnInit
@Component({
selector: 'my-cmp',
template: `...`,
standalone: false,
})
class MyComponent implements OnInit {
ngOnInit() {
// ...
}
}
// #enddocregion
expect(createAndLogComponent(MyComponent)).toEqual([['ngOnInit', []]]);
});
it('should work with ngDoCheck', () => {
// #docregion DoCheck
@Component({
selector: 'my-cmp',
template: `...`,
standalone: false,
})
class MyComponent implements DoCheck {
ngDoCheck() {
// ...
}
}
// #enddocregion
expect(createAndLogComponent(MyComponent)).toEqual([['ngDoCheck', []]]);
});
it('should work with ngAfterContentChecked', () => {
// #docregion AfterContentChecked
@Component({
selector: 'my-cmp',
template: `...`,
standalone: false,
})
class MyComponent implements AfterContentChecked {
ngAfterContentChecked() {
// ...
}
}
// #enddocregion
expect(createAndLogComponent(MyComponent)).toEqual([['ngAfterContentChecked', []]]);
});
it('should work with ngAfterContentInit', () => {
// #docregion AfterContentInit
@Component({
selector: 'my-cmp',
template: `...`,
standalone: false,
})
class MyComponent implements AfterContentInit {
ngAfterContentInit() {
// ...
}
}
// #enddocregion
expect(createAndLogComponent(MyComponent)).toEqual([['ngAfterContentInit', []]]);
});
it('should work with ngAfterViewChecked', () => {
// #docregion AfterViewChecked
@Component({
selector: 'my-cmp',
template: `...`,
standalone: false,
})
class MyComponent implements AfterViewChecked {
ngAfterViewChecked() {
// ...
}
}
// #enddocregion
expect(createAndLogComponent(MyComponent)).toEqual([['ngAfterViewChecked', []]]);
});
it('should work with ngAfterViewInit', () => {
// #docregion AfterViewInit
@Component({
selector: 'my-cmp',
template: `...`,
standalone: false,
})
class MyComponent implements AfterViewInit {
ngAfterViewInit() {
// ...
}
}
// #enddocregion
expect(createAndLogComponent(MyComponent)).toEqual([['ngAfterViewInit', []]]);
});
it('should work with ngOnDestroy', () => {
// #docregion OnDestroy
@Component({
selector: 'my-cmp',
template: `...`,
standalone: false,
})
class MyComponent implements OnDestroy {
ngOnDestroy() {
// ...
}
}
// #enddocregion
expect(createAndLogComponent(MyComponent)).toEqual([['ngOnDestroy', []]]);
});
it('should work with ngOnChanges', () => {
// #docregion OnChanges
@Component({
selector: 'my-cmp',
template: `...`,
standalone: false,
})
class MyComponent implements OnChanges {
@Input() prop: number = 0;
ngOnChanges(changes: SimpleChanges) {
// changes.prop contains the old and the new value...
}
}
// #enddocregion
const log = createAndLogComponent(MyComponent, ['prop']);
expect(log.length).toBe(1);
expect(log[0][0]).toBe('ngOnChanges');
const changes: SimpleChanges = log[0][1][0];
expect(changes['prop'].currentValue).toBe(true);
});
});
function createAndLogComponent(clazz: Type<any>, inputs: string[] = []): any[] {
const log: any[] = [];
createLoggingSpiesFromProto(clazz, log);
const inputBindings = inputs.map((input) => `[${input}] = true`).join(' ');
@Component({
template: `<my-cmp ${inputBindings}></my-cmp>`,
standalone: false,
})
class ParentComponent {}
const fixture = TestBed.configureTestingModule({
declarations: [ParentComponent, clazz],
}).createComponent(ParentComponent);
fixture.detectChanges();
fixture.destroy();
return log;
}
function createLoggingSpiesFromProto(clazz: Type<any>, log: any[]) {
const proto = clazz.prototype;
// For ES2015+ classes, members are not enumerable in the prototype.
Object.getOwnPropertyNames(proto).forEach((method) => {
if (method === 'constructor') {
return;
}
proto[method] = (...args: any[]) => {
log.push([method, args]);
};
});
}
})();
| {
"end_byte": 5145,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/metadata/lifecycle_hooks_spec.ts"
} |
angular/packages/examples/core/ts/metadata/encapsulation.ts_0_720 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component, ViewEncapsulation} from '@angular/core';
// #docregion longform
@Component({
selector: 'app-root',
template: `
<h1>Hello World!</h1>
<span class="red">Shadow DOM Rocks!</span>
`,
styles: [
`
:host {
display: block;
border: 1px solid black;
}
h1 {
color: blue;
}
.red {
background-color: red;
}
`,
],
encapsulation: ViewEncapsulation.ShadowDom,
standalone: false,
})
class MyApp {}
// #enddocregion
| {
"end_byte": 720,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/metadata/encapsulation.ts"
} |
angular/packages/examples/core/ts/change_detect/change-detection.ts_0_2448 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/* tslint:disable:no-console */
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Input,
NgModule,
} from '@angular/core';
import {FormsModule} from '@angular/forms';
// #docregion mark-for-check
@Component({
selector: 'app-root',
template: `Number of ticks: {{ numberOfTicks }}`,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false,
})
class AppComponent {
numberOfTicks = 0;
constructor(private ref: ChangeDetectorRef) {
setInterval(() => {
this.numberOfTicks++;
// require view to be updated
this.ref.markForCheck();
}, 1000);
}
}
// #enddocregion mark-for-check
// #docregion detach
class DataListProvider {
// in a real application the returned data will be different every time
get data() {
return [1, 2, 3, 4, 5];
}
}
@Component({
selector: 'giant-list',
template: ` <li *ngFor="let d of dataProvider.data">Data {{ d }}</li> `,
standalone: false,
})
class GiantList {
constructor(
private ref: ChangeDetectorRef,
public dataProvider: DataListProvider,
) {
ref.detach();
setInterval(() => {
this.ref.detectChanges();
}, 5000);
}
}
@Component({
selector: 'app',
providers: [DataListProvider],
template: ` <giant-list></giant-list> `,
standalone: false,
})
class App {}
// #enddocregion detach
// #docregion reattach
class DataProvider {
data = 1;
constructor() {
setInterval(() => {
this.data = 2;
}, 500);
}
}
@Component({
selector: 'live-data',
inputs: ['live'],
template: 'Data: {{dataProvider.data}}',
standalone: false,
})
class LiveData {
constructor(
private ref: ChangeDetectorRef,
public dataProvider: DataProvider,
) {}
@Input()
set live(value: boolean) {
if (value) {
this.ref.reattach();
} else {
this.ref.detach();
}
}
}
@Component({
selector: 'app',
providers: [DataProvider],
template: `
Live Update: <input type="checkbox" [(ngModel)]="live" />
<live-data [live]="live"></live-data>
`,
standalone: false,
})
class App1 {
live = true;
}
// #enddocregion reattach
@NgModule({declarations: [AppComponent, GiantList, App, LiveData, App1], imports: [FormsModule]})
class CoreExamplesModule {}
| {
"end_byte": 2448,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/ts/change_detect/change-detection.ts"
} |
angular/packages/examples/core/debug/ts/debug_element/debug_element.ts_0_346 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {DebugElement} from '@angular/core';
let debugElement: DebugElement = undefined!;
let predicate: any;
debugElement.query(predicate);
| {
"end_byte": 346,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/core/debug/ts/debug_element/debug_element.ts"
} |
angular/packages/examples/testing/BUILD.bazel_0_388 | load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "testing_examples",
srcs = glob(["**/*.ts"]),
tsconfig = "//packages:tsconfig-test",
deps = [
"@npm//@types/jasmine",
"@npm//@types/node",
],
)
filegroup(
name = "files_for_docgen",
srcs = glob([
"**/*.ts",
]),
)
| {
"end_byte": 388,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/testing/BUILD.bazel"
} |
angular/packages/examples/testing/ts/testing.ts_0_1646 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
let db: any;
class MyService {}
class MyMockService implements MyService {}
describe('some component', () => {
it('does something', () => {
// This is a test.
});
});
// tslint:disable-next-line:ban
fdescribe('some component', () => {
it('has a test', () => {
// This test will run.
});
});
describe('another component', () => {
it('also has a test', () => {
throw 'This test will not run.';
});
});
xdescribe('some component', () => {
it('has a test', () => {
throw 'This test will not run.';
});
});
describe('another component', () => {
it('also has a test', () => {
// This test will run.
});
});
describe('some component', () => {
// tslint:disable-next-line:ban
fit('has a test', () => {
// This test will run.
});
it('has another test', () => {
throw 'This test will not run.';
});
});
describe('some component', () => {
xit('has a test', () => {
throw 'This test will not run.';
});
it('has another test', () => {
// This test will run.
});
});
describe('some component', () => {
beforeEach(() => {
db.connect();
});
it('uses the db', () => {
// Database is connected.
});
});
describe('some component', () => {
afterEach((done: Function) => {
db.reset().then((_: any) => done());
});
it('uses the db', () => {
// This test can leave the database in a dirty state.
// The afterEach will ensure it gets reset.
});
});
| {
"end_byte": 1646,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/testing/ts/testing.ts"
} |
angular/packages/examples/common/main.ts_0_427 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import 'zone.js/lib/browser/rollup-main';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {TestsAppModule} from './test_module';
platformBrowserDynamic().bootstrapModule(TestsAppModule);
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/main.ts"
} |
angular/packages/examples/common/start-server.js_0_552 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = async function (config) {
const {port} = await protractorUtils.runServer(config.workspace, config.server, '--port', []);
const serverUrl = `http://localhost:${port}`;
protractor.browser.baseUrl = serverUrl;
};
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/start-server.js"
} |
angular/packages/examples/common/test_module.ts_0_1551 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component, NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import * as locationExample from './location/ts/module';
import * as ngComponentOutletExample from './ngComponentOutlet/ts/module';
import * as ngIfExample from './ngIf/ts/module';
import * as ngTemplateOutletExample from './ngTemplateOutlet/ts/module';
import * as pipesExample from './pipes/ts/module';
@Component({
selector: 'example-app:not(y)',
template: '<router-outlet></router-outlet>',
standalone: false,
})
export class TestsAppComponent {}
@NgModule({
imports: [
locationExample.AppModule,
ngComponentOutletExample.AppModule,
ngIfExample.AppModule,
ngTemplateOutletExample.AppModule,
pipesExample.AppModule,
// Router configuration so that the individual e2e tests can load their
// app components.
RouterModule.forRoot([
{path: 'location', component: locationExample.AppComponent},
{path: 'ngComponentOutlet', component: ngComponentOutletExample.AppComponent},
{path: 'ngIf', component: ngIfExample.AppComponent},
{path: 'ngTemplateOutlet', component: ngTemplateOutletExample.AppComponent},
{path: 'pipes', component: pipesExample.AppComponent},
]),
],
declarations: [TestsAppComponent],
bootstrap: [TestsAppComponent],
})
export class TestsAppModule {}
| {
"end_byte": 1551,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/test_module.ts"
} |
angular/packages/examples/common/BUILD.bazel_0_1433 | load("//tools:defaults.bzl", "esbuild", "http_server", "ng_module", "protractor_web_test_suite", "ts_library")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "common_examples",
srcs = glob(
["**/*.ts"],
exclude = ["**/*_spec.ts"],
),
deps = [
"//packages/common",
"//packages/core",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/router",
"//packages/zone.js/lib",
"@npm//rxjs",
],
)
ts_library(
name = "common_tests_lib",
testonly = True,
srcs = glob(["**/*_spec.ts"]),
tsconfig = "//packages/examples:tsconfig-e2e.json",
deps = [
"//packages/examples/test-utils",
"//packages/private/testing",
"@npm//@types/jasminewd2",
"@npm//protractor",
],
)
esbuild(
name = "app_bundle",
entry_point = ":main.ts",
deps = [":common_examples"],
)
http_server(
name = "devserver",
srcs = ["//packages/examples:index.html"],
additional_root_paths = ["angular/packages/examples"],
deps = [":app_bundle"],
)
protractor_web_test_suite(
name = "protractor_tests",
on_prepare = ":start-server.js",
server = ":devserver",
deps = [
":common_tests_lib",
"@npm//selenium-webdriver",
],
)
filegroup(
name = "files_for_docgen",
srcs = glob([
"**/*.ts",
]),
)
| {
"end_byte": 1433,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/BUILD.bazel"
} |
angular/packages/examples/common/ngComponentOutlet/ts/module.ts_0_2995 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {
Component,
Injectable,
Injector,
Input,
NgModule,
OnInit,
TemplateRef,
ViewChild,
ViewContainerRef,
} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
// #docregion SimpleExample
@Component({
selector: 'hello-world',
template: 'Hello World!',
standalone: false,
})
export class HelloWorld {}
@Component({
selector: 'ng-component-outlet-simple-example',
template: `<ng-container *ngComponentOutlet="HelloWorld"></ng-container>`,
standalone: false,
})
export class NgComponentOutletSimpleExample {
// This field is necessary to expose HelloWorld to the template.
HelloWorld = HelloWorld;
}
// #enddocregion
// #docregion CompleteExample
@Injectable()
export class Greeter {
suffix = '!';
}
@Component({
selector: 'complete-component',
template: `{{ label }}: <ng-content></ng-content> <ng-content></ng-content>{{ greeter.suffix }}`,
standalone: false,
})
export class CompleteComponent {
@Input() label!: string;
constructor(public greeter: Greeter) {}
}
@Component({
selector: 'ng-component-outlet-complete-example',
template: ` <ng-template #ahoj>Ahoj</ng-template>
<ng-template #svet>Svet</ng-template>
<ng-container
*ngComponentOutlet="
CompleteComponent;
inputs: myInputs;
injector: myInjector;
content: myContent
"
></ng-container>`,
standalone: false,
})
export class NgComponentOutletCompleteExample implements OnInit {
// This field is necessary to expose CompleteComponent to the template.
CompleteComponent = CompleteComponent;
myInputs = {'label': 'Complete'};
myInjector: Injector;
@ViewChild('ahoj', {static: true}) ahojTemplateRef!: TemplateRef<any>;
@ViewChild('svet', {static: true}) svetTemplateRef!: TemplateRef<any>;
myContent?: any[][];
constructor(
injector: Injector,
private vcr: ViewContainerRef,
) {
this.myInjector = Injector.create({
providers: [{provide: Greeter, deps: []}],
parent: injector,
});
}
ngOnInit() {
// Create the projectable content from the templates
this.myContent = [
this.vcr.createEmbeddedView(this.ahojTemplateRef).rootNodes,
this.vcr.createEmbeddedView(this.svetTemplateRef).rootNodes,
];
}
}
// #enddocregion
@Component({
selector: 'example-app',
template: `<ng-component-outlet-simple-example></ng-component-outlet-simple-example>
<hr />
<ng-component-outlet-complete-example></ng-component-outlet-complete-example>`,
standalone: false,
})
export class AppComponent {}
@NgModule({
imports: [BrowserModule],
declarations: [
AppComponent,
NgComponentOutletSimpleExample,
NgComponentOutletCompleteExample,
HelloWorld,
CompleteComponent,
],
})
export class AppModule {}
| {
"end_byte": 2995,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/ngComponentOutlet/ts/module.ts"
} |
angular/packages/examples/common/ngComponentOutlet/ts/e2e_test/ngComponentOutlet_spec.ts_0_926 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {$, browser, by, element, ExpectedConditions} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../test-utils';
function waitForElement(selector: string) {
const EC = ExpectedConditions;
// Waits for the element with id 'abc' to be present on the dom.
browser.wait(EC.presenceOf($(selector)), 20000);
}
describe('ngComponentOutlet', () => {
const URL = '/ngComponentOutlet';
afterEach(verifyNoBrowserErrors);
describe('ng-component-outlet-example', () => {
it('should render simple', () => {
browser.get(URL);
waitForElement('ng-component-outlet-simple-example');
expect(element.all(by.css('hello-world')).getText()).toEqual(['Hello World!']);
});
});
});
| {
"end_byte": 926,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/ngComponentOutlet/ts/e2e_test/ngComponentOutlet_spec.ts"
} |
angular/packages/examples/common/location/ts/module.ts_0_866 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {APP_BASE_HREF} from '@angular/common';
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {HashLocationComponent} from './hash_location_component';
import {PathLocationComponent} from './path_location_component';
@Component({
selector: 'example-app',
template: `<hash-location></hash-location><path-location></path-location>`,
standalone: false,
})
export class AppComponent {}
@NgModule({
declarations: [AppComponent, PathLocationComponent, HashLocationComponent],
providers: [{provide: APP_BASE_HREF, useValue: '/'}],
imports: [BrowserModule],
})
export class AppModule {}
| {
"end_byte": 866,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/location/ts/module.ts"
} |
angular/packages/examples/common/location/ts/path_location_component.ts_0_881 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// #docregion LocationComponent
import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';
import {Component} from '@angular/core';
@Component({
selector: 'path-location',
providers: [Location, {provide: LocationStrategy, useClass: PathLocationStrategy}],
template: `
<h1>PathLocationStrategy</h1>
Current URL is: <code>{{ location.path() }}</code
><br />
Normalize: <code>/foo/bar/</code> is: <code>{{ location.normalize('foo/bar') }}</code
><br />
`,
standalone: false,
})
export class PathLocationComponent {
location: Location;
constructor(location: Location) {
this.location = location;
}
}
// #enddocregion
| {
"end_byte": 881,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/location/ts/path_location_component.ts"
} |
angular/packages/examples/common/location/ts/hash_location_component.ts_0_881 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// #docregion LocationComponent
import {HashLocationStrategy, Location, LocationStrategy} from '@angular/common';
import {Component} from '@angular/core';
@Component({
selector: 'hash-location',
providers: [Location, {provide: LocationStrategy, useClass: HashLocationStrategy}],
template: `
<h1>HashLocationStrategy</h1>
Current URL is: <code>{{ location.path() }}</code
><br />
Normalize: <code>/foo/bar/</code> is: <code>{{ location.normalize('foo/bar') }}</code
><br />
`,
standalone: false,
})
export class HashLocationComponent {
location: Location;
constructor(location: Location) {
this.location = location;
}
}
// #enddocregion
| {
"end_byte": 881,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/location/ts/hash_location_component.ts"
} |
angular/packages/examples/common/location/ts/e2e_test/location_component_spec.ts_0_922 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {$, browser, by, element, protractor} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../test-utils';
function waitForElement(selector: string) {
const EC = (<any>protractor).ExpectedConditions;
// Waits for the element with id 'abc' to be present on the dom.
browser.wait(EC.presenceOf($(selector)), 20000);
}
describe('Location', () => {
afterEach(verifyNoBrowserErrors);
it('should verify paths', () => {
browser.get('/location/#/bar/baz');
waitForElement('hash-location');
expect(element.all(by.css('path-location code')).get(0).getText()).toEqual('/location');
expect(element.all(by.css('hash-location code')).get(0).getText()).toEqual('/bar/baz');
});
});
| {
"end_byte": 922,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/location/ts/e2e_test/location_component_spec.ts"
} |
angular/packages/examples/common/ngTemplateOutlet/ts/module.ts_0_1343 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
// #docregion NgTemplateOutlet
@Component({
selector: 'ng-template-outlet-example',
template: `
<ng-container *ngTemplateOutlet="greet"></ng-container>
<hr />
<ng-container *ngTemplateOutlet="eng; context: myContext"></ng-container>
<hr />
<ng-container *ngTemplateOutlet="svk; context: myContext"></ng-container>
<hr />
<ng-template #greet><span>Hello</span></ng-template>
<ng-template #eng let-name
><span>Hello {{ name }}!</span></ng-template
>
<ng-template #svk let-person="localSk"
><span>Ahoj {{ person }}!</span></ng-template
>
`,
standalone: false,
})
export class NgTemplateOutletExample {
myContext = {$implicit: 'World', localSk: 'Svet'};
}
// #enddocregion
@Component({
selector: 'example-app',
template: `<ng-template-outlet-example></ng-template-outlet-example>`,
standalone: false,
})
export class AppComponent {}
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent, NgTemplateOutletExample],
})
export class AppModule {}
| {
"end_byte": 1343,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/ngTemplateOutlet/ts/module.ts"
} |
angular/packages/examples/common/ngTemplateOutlet/ts/e2e_test/ngTemplateOutlet_spec.ts_0_984 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {$, browser, by, element, ExpectedConditions} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../test-utils';
function waitForElement(selector: string) {
const EC = ExpectedConditions;
// Waits for the element with id 'abc' to be present on the dom.
browser.wait(EC.presenceOf($(selector)), 20000);
}
describe('ngTemplateOutlet', () => {
const URL = '/ngTemplateOutlet';
afterEach(verifyNoBrowserErrors);
describe('ng-template-outlet-example', () => {
it('should render', () => {
browser.get(URL);
waitForElement('ng-template-outlet-example');
expect(element.all(by.css('ng-template-outlet-example span')).getText()).toEqual([
'Hello',
'Hello World!',
'Ahoj Svet!',
]);
});
});
});
| {
"end_byte": 984,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/ngTemplateOutlet/ts/e2e_test/ngTemplateOutlet_spec.ts"
} |
angular/packages/examples/common/pipes/ts/percent_pipe.ts_0_870 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {registerLocaleData} from '@angular/common';
import {Component} from '@angular/core';
// we need to import data for the french locale
import localeFr from './locale-fr';
// registering french data
registerLocaleData(localeFr);
// #docregion PercentPipe
@Component({
selector: 'percent-pipe',
template: `<div>
<!--output '26%'-->
<p>A: {{ a | percent }}</p>
<!--output '0,134.950%'-->
<p>B: {{ b | percent: '4.3-5' }}</p>
<!--output '0 134,950 %'-->
<p>B: {{ b | percent: '4.3-5' : 'fr' }}</p>
</div>`,
standalone: false,
})
export class PercentPipeComponent {
a: number = 0.259;
b: number = 1.3495;
}
// #enddocregion
| {
"end_byte": 870,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/percent_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/locale-fr.ts_0_2674 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// THIS CODE IS GENERATED - DO NOT MODIFY
// See angular/tools/gulp-tasks/cldr/extract.js
const u = undefined;
function plural(n: number): number {
let i = Math.floor(Math.abs(n));
if (i === 0 || i === 1) return 1;
return 5;
}
export default [
'fr',
[['AM', 'PM'], u, u],
u,
[
['D', 'L', 'M', 'M', 'J', 'V', 'S'],
['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'],
['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
['di', 'lu', 'ma', 'me', 'je', 've', 'sa'],
],
u,
[
['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
[
'janv.',
'févr.',
'mars',
'avr.',
'mai',
'juin',
'juil.',
'août',
'sept.',
'oct.',
'nov.',
'déc.',
],
[
'janvier',
'février',
'mars',
'avril',
'mai',
'juin',
'juillet',
'août',
'septembre',
'octobre',
'novembre',
'décembre',
],
],
u,
[['av. J.-C.', 'ap. J.-C.'], u, ['avant Jésus-Christ', 'après Jésus-Christ']],
1,
[6, 0],
['dd/MM/y', 'd MMM y', 'd MMMM y', 'EEEE d MMMM y'],
['HH:mm', 'HH:mm:ss', 'HH:mm:ss z', 'HH:mm:ss zzzz'],
['{1} {0}', "{1} 'à' {0}", u, u],
[',', '\u202f', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'],
['#,##0.###', '#,##0 %', '#,##0.00 ¤', '#E0'],
'EUR',
'€',
'euro',
{
'ARS': ['$AR', '$'],
'AUD': ['$AU', '$'],
'BEF': ['FB'],
'BMD': ['$BM', '$'],
'BND': ['$BN', '$'],
'BZD': ['$BZ', '$'],
'CAD': ['$CA', '$'],
'CLP': ['$CL', '$'],
'CNY': [u, '¥'],
'COP': ['$CO', '$'],
'CYP': ['£CY'],
'EGP': [u, '£E'],
'FJD': ['$FJ', '$'],
'FKP': ['£FK', '£'],
'FRF': ['F'],
'GBP': ['£GB', '£'],
'GIP': ['£GI', '£'],
'HKD': [u, '$'],
'IEP': ['£IE'],
'ILP': ['£IL'],
'ITL': ['₤IT'],
'JPY': [u, '¥'],
'KMF': [u, 'FC'],
'LBP': ['£LB', '£L'],
'MTP': ['£MT'],
'MXN': ['$MX', '$'],
'NAD': ['$NA', '$'],
'NIO': [u, '$C'],
'NZD': ['$NZ', '$'],
'RHD': ['$RH'],
'RON': [u, 'L'],
'RWF': [u, 'FR'],
'SBD': ['$SB', '$'],
'SGD': ['$SG', '$'],
'SRD': ['$SR', '$'],
'TOP': [u, '$T'],
'TTD': ['$TT', '$'],
'TWD': [u, 'NT$'],
'USD': ['$US', '$'],
'UYU': ['$UY', '$'],
'WST': ['$WS'],
'XCD': [u, '$'],
'XPF': ['FCFP'],
'ZMW': [u, 'Kw'],
},
'ltr',
plural,
];
| {
"end_byte": 2674,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/locale-fr.ts"
} |
angular/packages/examples/common/pipes/ts/currency_pipe.ts_0_1256 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {registerLocaleData} from '@angular/common';
import {Component} from '@angular/core';
// we need to import data for the french locale
import localeFr from './locale-fr';
// registering french data
registerLocaleData(localeFr);
// #docregion CurrencyPipe
@Component({
selector: 'currency-pipe',
template: `<div>
<!--output '$0.26'-->
<p>A: {{ a | currency }}</p>
<!--output 'CA$0.26'-->
<p>A: {{ a | currency: 'CAD' }}</p>
<!--output 'CAD0.26'-->
<p>A: {{ a | currency: 'CAD' : 'code' }}</p>
<!--output 'CA$0,001.35'-->
<p>B: {{ b | currency: 'CAD' : 'symbol' : '4.2-2' }}</p>
<!--output '$0,001.35'-->
<p>B: {{ b | currency: 'CAD' : 'symbol-narrow' : '4.2-2' }}</p>
<!--output '0 001,35 CA$'-->
<p>B: {{ b | currency: 'CAD' : 'symbol' : '4.2-2' : 'fr' }}</p>
<!--output 'CLP1' because CLP has no cents-->
<p>B: {{ b | currency: 'CLP' }}</p>
</div>`,
standalone: false,
})
export class CurrencyPipeComponent {
a: number = 0.259;
b: number = 1.3495;
}
// #enddocregion
| {
"end_byte": 1256,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/currency_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/module.ts_0_2541 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AsyncObservablePipeComponent, AsyncPromisePipeComponent} from './async_pipe';
import {CurrencyPipeComponent} from './currency_pipe';
import {DatePipeComponent, DeprecatedDatePipeComponent} from './date_pipe';
import {I18nPluralPipeComponent, I18nSelectPipeComponent} from './i18n_pipe';
import {JsonPipeComponent} from './json_pipe';
import {KeyValuePipeComponent} from './keyvalue_pipe';
import {LowerUpperPipeComponent} from './lowerupper_pipe';
import {NumberPipeComponent} from './number_pipe';
import {PercentPipeComponent} from './percent_pipe';
import {SlicePipeListComponent, SlicePipeStringComponent} from './slice_pipe';
import {TitleCasePipeComponent} from './titlecase_pipe';
@Component({
selector: 'example-app',
template: `
<h1>Pipe Example</h1>
<h2><code>async</code></h2>
<async-promise-pipe></async-promise-pipe>
<async-observable-pipe></async-observable-pipe>
<h2><code>date</code></h2>
<date-pipe></date-pipe>
<h2><code>json</code></h2>
<json-pipe></json-pipe>
<h2><code>lower</code>, <code>upper</code></h2>
<lowerupper-pipe></lowerupper-pipe>
<h2><code>titlecase</code></h2>
<titlecase-pipe></titlecase-pipe>
<h2><code>number</code></h2>
<number-pipe></number-pipe>
<percent-pipe></percent-pipe>
<currency-pipe></currency-pipe>
<h2><code>slice</code></h2>
<slice-string-pipe></slice-string-pipe>
<slice-list-pipe></slice-list-pipe>
<h2><code>i18n</code></h2>
<i18n-plural-pipe></i18n-plural-pipe>
<i18n-select-pipe></i18n-select-pipe>
<h2><code>keyvalue</code></h2>
<keyvalue-pipe></keyvalue-pipe>
`,
standalone: false,
})
export class AppComponent {}
@NgModule({
declarations: [
AsyncPromisePipeComponent,
AsyncObservablePipeComponent,
AppComponent,
JsonPipeComponent,
DatePipeComponent,
DeprecatedDatePipeComponent,
LowerUpperPipeComponent,
TitleCasePipeComponent,
NumberPipeComponent,
PercentPipeComponent,
CurrencyPipeComponent,
SlicePipeStringComponent,
SlicePipeListComponent,
I18nPluralPipeComponent,
I18nSelectPipeComponent,
KeyValuePipeComponent,
],
imports: [BrowserModule],
})
export class AppModule {}
| {
"end_byte": 2541,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/module.ts"
} |
angular/packages/examples/common/pipes/ts/async_pipe.ts_0_2023 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component} from '@angular/core';
import {Observable, Observer} from 'rxjs';
// #docregion AsyncPipePromise
@Component({
selector: 'async-promise-pipe',
template: `<div>
<code>promise|async</code>:
<button (click)="clicked()">{{ arrived ? 'Reset' : 'Resolve' }}</button>
<span>Wait for it... {{ greeting | async }}</span>
</div>`,
standalone: false,
})
export class AsyncPromisePipeComponent {
greeting: Promise<string> | null = null;
arrived: boolean = false;
private resolve: Function | null = null;
constructor() {
this.reset();
}
reset() {
this.arrived = false;
this.greeting = new Promise<string>((resolve, reject) => {
this.resolve = resolve;
});
}
clicked() {
if (this.arrived) {
this.reset();
} else {
this.resolve!('hi there!');
this.arrived = true;
}
}
}
// #enddocregion
// #docregion AsyncPipeObservable
@Component({
selector: 'async-observable-pipe',
template: '<div><code>observable|async</code>: Time: {{ time | async }}</div>',
standalone: false,
})
export class AsyncObservablePipeComponent {
time = new Observable<string>((observer: Observer<string>) => {
setInterval(() => observer.next(new Date().toString()), 1000);
});
}
// #enddocregion
// For some reason protractor hangs on setInterval. So we will run outside of angular zone so that
// protractor will not see us. Also we want to have this outside the docregion so as not to confuse
// the reader.
function setInterval(fn: Function, delay: number) {
const zone = (window as any)['Zone'].current;
let rootZone = zone;
while (rootZone.parent) {
rootZone = rootZone.parent;
}
rootZone.run(() => {
window.setInterval(function (this: unknown) {
zone.run(fn, this, arguments as any);
}, delay);
});
}
| {
"end_byte": 2023,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/async_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/lowerupper_pipe.ts_0_721 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component} from '@angular/core';
// #docregion LowerUpperPipe
@Component({
selector: 'lowerupper-pipe',
template: `<div>
<label>Name: </label><input #name (keyup)="change(name.value)" type="text" />
<p>In lowercase:</p>
<pre>'{{ value | lowercase }}'</pre>
<p>In uppercase:</p>
<pre>'{{ value | uppercase }}'</pre>
</div>`,
standalone: false,
})
export class LowerUpperPipeComponent {
value: string = '';
change(value: string) {
this.value = value;
}
}
// #enddocregion
| {
"end_byte": 721,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/lowerupper_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/slice_pipe.ts_0_1283 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component} from '@angular/core';
// #docregion SlicePipe_string
@Component({
selector: 'slice-string-pipe',
template: `<div>
<p>{{ str }}[0:4]: '{{ str | slice: 0 : 4 }}' - output is expected to be 'abcd'</p>
<p>{{ str }}[4:0]: '{{ str | slice: 4 : 0 }}' - output is expected to be ''</p>
<p>{{ str }}[-4]: '{{ str | slice: -4 }}' - output is expected to be 'ghij'</p>
<p>{{ str }}[-4:-2]: '{{ str | slice: -4 : -2 }}' - output is expected to be 'gh'</p>
<p>{{ str }}[-100]: '{{ str | slice: -100 }}' - output is expected to be 'abcdefghij'</p>
<p>{{ str }}[100]: '{{ str | slice: 100 }}' - output is expected to be ''</p>
</div>`,
standalone: false,
})
export class SlicePipeStringComponent {
str: string = 'abcdefghij';
}
// #enddocregion
// #docregion SlicePipe_list
@Component({
selector: 'slice-list-pipe',
template: `<ul>
<li *ngFor="let i of collection | slice: 1 : 3">{{ i }}</li>
</ul>`,
standalone: false,
})
export class SlicePipeListComponent {
collection: string[] = ['a', 'b', 'c', 'd'];
}
// #enddocregion
| {
"end_byte": 1283,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/slice_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/keyvalue_pipe.ts_0_857 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component} from '@angular/core';
// #docregion KeyValuePipe
@Component({
selector: 'keyvalue-pipe',
template: `<span>
<p>Object</p>
<div *ngFor="let item of object | keyvalue">{{ item.key }}:{{ item.value }}</div>
<p>Map</p>
<div *ngFor="let item of map | keyvalue">{{ item.key }}:{{ item.value }}</div>
<p>Natural order</p>
<div *ngFor="let item of map | keyvalue: null">{{ item.key }}:{{ item.value }}</div>
</span>`,
standalone: false,
})
export class KeyValuePipeComponent {
object: {[key: number]: string} = {2: 'foo', 1: 'bar'};
map = new Map([
[2, 'foo'],
[1, 'bar'],
]);
}
// #enddocregion
| {
"end_byte": 857,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/keyvalue_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/titlecase_pipe.ts_0_1039 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component} from '@angular/core';
// #docregion TitleCasePipe
@Component({
selector: 'titlecase-pipe',
template: `<div>
<p>{{ 'some string' | titlecase }}</p>
<!-- output is expected to be "Some String" -->
<p>{{ 'tHIs is mIXeD CaSe' | titlecase }}</p>
<!-- output is expected to be "This Is Mixed Case" -->
<p>{{ "it's non-trivial question" | titlecase }}</p>
<!-- output is expected to be "It's Non-trivial Question" -->
<p>{{ 'one,two,three' | titlecase }}</p>
<!-- output is expected to be "One,two,three" -->
<p>{{ 'true|false' | titlecase }}</p>
<!-- output is expected to be "True|false" -->
<p>{{ 'foo-vs-bar' | titlecase }}</p>
<!-- output is expected to be "Foo-vs-bar" -->
</div>`,
standalone: false,
})
export class TitleCasePipeComponent {}
// #enddocregion
| {
"end_byte": 1039,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/titlecase_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/i18n_pipe.ts_0_1001 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component} from '@angular/core';
// #docregion I18nPluralPipeComponent
@Component({
selector: 'i18n-plural-pipe',
template: `<div>{{ messages.length | i18nPlural: messageMapping }}</div>`,
standalone: false,
})
export class I18nPluralPipeComponent {
messages: any[] = ['Message 1'];
messageMapping: {[k: string]: string} = {
'=0': 'No messages.',
'=1': 'One message.',
'other': '# messages.',
};
}
// #enddocregion
// #docregion I18nSelectPipeComponent
@Component({
selector: 'i18n-select-pipe',
template: `<div>{{ gender | i18nSelect: inviteMap }}</div>`,
standalone: false,
})
export class I18nSelectPipeComponent {
gender: string = 'male';
inviteMap: any = {'male': 'Invite him.', 'female': 'Invite her.', 'other': 'Invite them.'};
}
//#enddocregion
| {
"end_byte": 1001,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/i18n_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/date_pipe.ts_0_2018 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {registerLocaleData} from '@angular/common';
import {Component} from '@angular/core';
// we need to import data for the french locale
import localeFr from './locale-fr';
// registering french data
registerLocaleData(localeFr);
@Component({
selector: 'date-pipe',
template: `<div>
<!--output 'Jun 15, 2015'-->
<p>Today is {{ today | date }}</p>
<!--output 'Monday, June 15, 2015'-->
<p>Or if you prefer, {{ today | date: 'fullDate' }}</p>
<!--output '9:43 AM'-->
<p>The time is {{ today | date: 'shortTime' }}</p>
<!--output 'Monday, June 15, 2015 at 9:03:01 AM GMT+01:00' -->
<p>The full date/time is {{ today | date: 'full' }}</p>
<!--output 'Lundi 15 Juin 2015 à 09:03:01 GMT+01:00'-->
<p>The full date/time in french is: {{ today | date: 'full' : '' : 'fr' }}</p>
<!--output '2015-06-15 05:03 PM GMT+9'-->
<p>The custom date is {{ today | date: 'yyyy-MM-dd HH:mm a z' : '+0900' }}</p>
<!--output '2015-06-15 09:03 AM GMT+9'-->
<p>
The custom date with fixed timezone is
{{ fixedTimezone | date: 'yyyy-MM-dd HH:mm a z' : '+0900' }}
</p>
</div>`,
standalone: false,
})
export class DatePipeComponent {
today = Date.now();
fixedTimezone = '2015-06-15T09:03:01+0900';
}
@Component({
selector: 'deprecated-date-pipe',
template: `<div>
<!--output 'Sep 3, 2010'-->
<p>Today is {{ today | date }}</p>
<!--output 'Friday, September 3, 2010'-->
<p>Or if you prefer, {{ today | date: 'fullDate' }}</p>
<!--output '12:05 PM'-->
<p>The time is {{ today | date: 'shortTime' }}</p>
<!--output '2010-09-03 12:05 PM'-->
<p>The custom date is {{ today | date: 'yyyy-MM-dd HH:mm a' }}</p>
</div>`,
standalone: false,
})
export class DeprecatedDatePipeComponent {
today = Date.now();
}
| {
"end_byte": 2018,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/date_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/json_pipe.ts_0_622 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component} from '@angular/core';
// #docregion JsonPipe
@Component({
selector: 'json-pipe',
template: `<div>
<p>Without JSON pipe:</p>
<pre>{{ object }}</pre>
<p>With JSON pipe:</p>
<pre>{{ object | json }}</pre>
</div>`,
standalone: false,
})
export class JsonPipeComponent {
object: Object = {foo: 'bar', baz: 'qux', nested: {xyz: 3, numbers: [1, 2, 3, 4, 5]}};
}
// #enddocregion
| {
"end_byte": 622,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/json_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/number_pipe.ts_0_1002 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {registerLocaleData} from '@angular/common';
import {Component} from '@angular/core';
// we need to import data for the french locale
import localeFr from './locale-fr';
registerLocaleData(localeFr, 'fr');
// #docregion NumberPipe
@Component({
selector: 'number-pipe',
template: `<div>
<p>
No specified formatting:
{{ pi | number }}
<!--output: '3.142'-->
</p>
<p>
With digitsInfo parameter specified:
{{ pi | number: '4.1-5' }}
<!--output: '0,003.14159'-->
</p>
<p>
With digitsInfo and locale parameters specified:
{{ pi | number: '4.1-5' : 'fr' }}
<!--output: '0 003,14159'-->
</p>
</div>`,
standalone: false,
})
export class NumberPipeComponent {
pi: number = 3.14159265359;
}
// #enddocregion
| {
"end_byte": 1002,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/number_pipe.ts"
} |
angular/packages/examples/common/pipes/ts/e2e_test/pipe_spec.ts_0_4416 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {$, browser, by, element, ExpectedConditions} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../test-utils';
function waitForElement(selector: string) {
const EC = ExpectedConditions;
// Waits for the element with id 'abc' to be present on the dom.
browser.wait(EC.presenceOf($(selector)), 20000);
}
describe('pipe', () => {
afterEach(verifyNoBrowserErrors);
const URL = '/pipes';
describe('async', () => {
it('should resolve and display promise', () => {
browser.get(URL);
waitForElement('async-promise-pipe');
expect(element.all(by.css('async-promise-pipe span')).get(0).getText()).toEqual(
'Wait for it...',
);
element(by.css('async-promise-pipe button')).click();
expect(element.all(by.css('async-promise-pipe span')).get(0).getText()).toEqual(
'Wait for it... hi there!',
);
});
});
describe('lowercase/uppercase', () => {
it('should work properly', () => {
browser.get(URL);
waitForElement('lowerupper-pipe');
element(by.css('lowerupper-pipe input')).sendKeys('Hello World!');
expect(element.all(by.css('lowerupper-pipe pre')).get(0).getText()).toEqual("'hello world!'");
expect(element.all(by.css('lowerupper-pipe pre')).get(1).getText()).toEqual("'HELLO WORLD!'");
});
});
describe('titlecase', () => {
it('should work properly', () => {
browser.get(URL);
waitForElement('titlecase-pipe');
expect(element.all(by.css('titlecase-pipe p')).get(0).getText()).toEqual('Some String');
expect(element.all(by.css('titlecase-pipe p')).get(1).getText()).toEqual(
'This Is Mixed Case',
);
expect(element.all(by.css('titlecase-pipe p')).get(2).getText()).toEqual(
"It's Non-trivial Question",
);
expect(element.all(by.css('titlecase-pipe p')).get(3).getText()).toEqual('One,two,three');
expect(element.all(by.css('titlecase-pipe p')).get(4).getText()).toEqual('True|false');
expect(element.all(by.css('titlecase-pipe p')).get(5).getText()).toEqual('Foo-vs-bar');
});
});
describe('keyvalue', () => {
it('should work properly', () => {
browser.get(URL);
waitForElement('keyvalue-pipe');
expect(element.all(by.css('keyvalue-pipe div')).get(0).getText()).toEqual('1:bar');
expect(element.all(by.css('keyvalue-pipe div')).get(1).getText()).toEqual('2:foo');
expect(element.all(by.css('keyvalue-pipe div')).get(2).getText()).toEqual('1:bar');
expect(element.all(by.css('keyvalue-pipe div')).get(3).getText()).toEqual('2:foo');
});
});
describe('number', () => {
it('should work properly', () => {
browser.get(URL);
waitForElement('number-pipe');
const examples = element.all(by.css('number-pipe p'));
expect(examples.get(0).getText()).toEqual('No specified formatting: 3.142');
expect(examples.get(1).getText()).toEqual('With digitsInfo parameter specified: 0,003.14159');
expect(examples.get(2).getText()).toEqual(
'With digitsInfo and locale parameters specified: 0\u202f003,14159',
);
});
});
describe('percent', () => {
it('should work properly', () => {
browser.get(URL);
waitForElement('percent-pipe');
const examples = element.all(by.css('percent-pipe p'));
expect(examples.get(0).getText()).toEqual('A: 26%');
expect(examples.get(1).getText()).toEqual('B: 0,134.950%');
expect(examples.get(2).getText()).toEqual('B: 0\u202f134,950 %');
});
});
describe('currency', () => {
it('should work properly', () => {
browser.get(URL);
waitForElement('currency-pipe');
const examples = element.all(by.css('currency-pipe p'));
expect(examples.get(0).getText()).toEqual('A: $0.26');
expect(examples.get(1).getText()).toEqual('A: CA$0.26');
expect(examples.get(2).getText()).toEqual('A: CAD0.26');
expect(examples.get(3).getText()).toEqual('B: CA$0,001.35');
expect(examples.get(4).getText()).toEqual('B: $0,001.35');
expect(examples.get(5).getText()).toEqual('B: 0\u202f001,35 $CA');
expect(examples.get(6).getText()).toEqual('B: CLP1');
});
});
});
| {
"end_byte": 4416,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/pipes/ts/e2e_test/pipe_spec.ts"
} |
angular/packages/examples/common/ngIf/ts/module.ts_0_3503 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component, NgModule, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {Subject} from 'rxjs';
// #docregion NgIfSimple
@Component({
selector: 'ng-if-simple',
template: `
<button (click)="show = !show">{{ show ? 'hide' : 'show' }}</button>
show = {{ show }}
<br />
<div *ngIf="show">Text to show</div>
`,
standalone: false,
})
export class NgIfSimple {
show = true;
}
// #enddocregion
// #docregion NgIfElse
@Component({
selector: 'ng-if-else',
template: `
<button (click)="show = !show">{{ show ? 'hide' : 'show' }}</button>
show = {{ show }}
<br />
<div *ngIf="show; else elseBlock">Text to show</div>
<ng-template #elseBlock>Alternate text while primary text is hidden</ng-template>
`,
standalone: false,
})
export class NgIfElse {
show = true;
}
// #enddocregion
// #docregion NgIfThenElse
@Component({
selector: 'ng-if-then-else',
template: `
<button (click)="show = !show">{{ show ? 'hide' : 'show' }}</button>
<button (click)="switchPrimary()">Switch Primary</button>
show = {{ show }}
<br />
<div *ngIf="show; then thenBlock; else elseBlock">this is ignored</div>
<ng-template #primaryBlock>Primary text to show</ng-template>
<ng-template #secondaryBlock>Secondary text to show</ng-template>
<ng-template #elseBlock>Alternate text while primary text is hidden</ng-template>
`,
standalone: false,
})
export class NgIfThenElse implements OnInit {
thenBlock: TemplateRef<any> | null = null;
show = true;
@ViewChild('primaryBlock', {static: true}) primaryBlock: TemplateRef<any> | null = null;
@ViewChild('secondaryBlock', {static: true}) secondaryBlock: TemplateRef<any> | null = null;
switchPrimary() {
this.thenBlock = this.thenBlock === this.primaryBlock ? this.secondaryBlock : this.primaryBlock;
}
ngOnInit() {
this.thenBlock = this.primaryBlock;
}
}
// #enddocregion
// #docregion NgIfAs
@Component({
selector: 'ng-if-as',
template: `
<button (click)="nextUser()">Next User</button>
<br />
<div *ngIf="userObservable | async as user; else loading">
Hello {{ user.last }}, {{ user.first }}!
</div>
<ng-template #loading let-user>Waiting... (user is {{ user | json }})</ng-template>
`,
standalone: false,
})
export class NgIfAs {
userObservable = new Subject<{first: string; last: string}>();
first = ['John', 'Mike', 'Mary', 'Bob'];
firstIndex = 0;
last = ['Smith', 'Novotny', 'Angular'];
lastIndex = 0;
nextUser() {
let first = this.first[this.firstIndex++];
if (this.firstIndex >= this.first.length) this.firstIndex = 0;
let last = this.last[this.lastIndex++];
if (this.lastIndex >= this.last.length) this.lastIndex = 0;
this.userObservable.next({first, last});
}
}
// #enddocregion
@Component({
selector: 'example-app',
template: `
<ng-if-simple></ng-if-simple>
<hr />
<ng-if-else></ng-if-else>
<hr />
<ng-if-then-else></ng-if-then-else>
<hr />
<ng-if-as></ng-if-as>
<hr />
`,
standalone: false,
})
export class AppComponent {}
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent, NgIfSimple, NgIfElse, NgIfThenElse, NgIfAs],
})
export class AppModule {}
| {
"end_byte": 3503,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/ngIf/ts/module.ts"
} |
angular/packages/examples/common/ngIf/ts/e2e_test/ngIf_spec.ts_0_2747 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {$, browser, by, element, ExpectedConditions} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../test-utils';
function waitForElement(selector: string) {
const EC = ExpectedConditions;
// Waits for the element with id 'abc' to be present on the dom.
browser.wait(EC.presenceOf($(selector)), 20000);
}
describe('ngIf', () => {
const URL = '/ngIf';
afterEach(verifyNoBrowserErrors);
describe('ng-if-simple', () => {
let comp = 'ng-if-simple';
it('should hide/show content', () => {
browser.get(URL);
waitForElement(comp);
expect(element.all(by.css(comp)).get(0).getText()).toEqual('hide show = true\nText to show');
element(by.css(comp + ' button')).click();
expect(element.all(by.css(comp)).get(0).getText()).toEqual('show show = false');
});
});
describe('ng-if-else', () => {
let comp = 'ng-if-else';
it('should hide/show content', () => {
browser.get(URL);
waitForElement(comp);
expect(element.all(by.css(comp)).get(0).getText()).toEqual('hide show = true\nText to show');
element(by.css(comp + ' button')).click();
expect(element.all(by.css(comp)).get(0).getText()).toEqual(
'show show = false\nAlternate text while primary text is hidden',
);
});
});
describe('ng-if-then-else', () => {
let comp = 'ng-if-then-else';
it('should hide/show content', () => {
browser.get(URL);
waitForElement(comp);
expect(element.all(by.css(comp)).get(0).getText()).toEqual(
'hideSwitch Primary show = true\nPrimary text to show',
);
element
.all(by.css(comp + ' button'))
.get(1)
.click();
expect(element.all(by.css(comp)).get(0).getText()).toEqual(
'hideSwitch Primary show = true\nSecondary text to show',
);
element
.all(by.css(comp + ' button'))
.get(0)
.click();
expect(element.all(by.css(comp)).get(0).getText()).toEqual(
'showSwitch Primary show = false\nAlternate text while primary text is hidden',
);
});
});
describe('ng-if-as', () => {
let comp = 'ng-if-as';
it('should hide/show content', () => {
browser.get(URL);
waitForElement(comp);
expect(element.all(by.css(comp)).get(0).getText()).toEqual(
'Next User\nWaiting... (user is null)',
);
element(by.css(comp + ' button')).click();
expect(element.all(by.css(comp)).get(0).getText()).toEqual('Next User\nHello Smith, John!');
});
});
});
| {
"end_byte": 2747,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/common/ngIf/ts/e2e_test/ngIf_spec.ts"
} |
angular/packages/examples/http/BUILD.bazel_0_54 | package(default_visibility = ["//visibility:public"])
| {
"end_byte": 54,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/http/BUILD.bazel"
} |
angular/packages/examples/service-worker/registration-options/ngsw-worker.js_0_516 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// Mock `ngsw-worker.js` used for testing the examples.
// Immediately takes over and unregisters itself.
self.addEventListener('install', (evt) => evt.waitUntil(self.skipWaiting()));
self.addEventListener('activate', (evt) =>
evt.waitUntil(self.clients.claim().then(() => self.registration.unregister())),
);
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/registration-options/ngsw-worker.js"
} |
angular/packages/examples/service-worker/registration-options/main.ts_0_412 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import 'zone.js/lib/browser/rollup-main';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './module';
platformBrowserDynamic().bootstrapModule(AppModule);
| {
"end_byte": 412,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/registration-options/main.ts"
} |
angular/packages/examples/service-worker/registration-options/module.ts_0_1284 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// tslint:disable: no-duplicate-imports
import {Component} from '@angular/core';
// #docregion registration-options
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {ServiceWorkerModule, SwRegistrationOptions} from '@angular/service-worker';
// #enddocregion registration-options
import {SwUpdate} from '@angular/service-worker';
// tslint:enable: no-duplicate-imports
@Component({
selector: 'example-app',
template: 'SW enabled: {{ swu.isEnabled }}',
standalone: false,
})
export class AppComponent {
constructor(readonly swu: SwUpdate) {}
}
// #docregion registration-options
@NgModule({
// #enddocregion registration-options
bootstrap: [AppComponent],
declarations: [AppComponent],
// #docregion registration-options
imports: [BrowserModule, ServiceWorkerModule.register('ngsw-worker.js')],
providers: [
{
provide: SwRegistrationOptions,
useFactory: () => ({enabled: location.search.includes('sw=true')}),
},
],
})
export class AppModule {}
// #enddocregion registration-options
| {
"end_byte": 1284,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/registration-options/module.ts"
} |
angular/packages/examples/service-worker/registration-options/start-server.js_0_552 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = async function (config) {
const {port} = await protractorUtils.runServer(config.workspace, config.server, '--port', []);
const serverUrl = `http://localhost:${port}`;
protractor.browser.baseUrl = serverUrl;
};
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/registration-options/start-server.js"
} |
angular/packages/examples/service-worker/registration-options/BUILD.bazel_0_1515 | load("//tools:defaults.bzl", "esbuild", "http_server", "ng_module", "protractor_web_test_suite", "ts_library")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "sw_registration_options_examples",
srcs = glob(
["**/*.ts"],
exclude = ["**/*_spec.ts"],
),
deps = [
"//packages/core",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/service-worker",
"//packages/zone.js/lib",
],
)
ts_library(
name = "sw_registration_options_e2e_tests_lib",
testonly = True,
srcs = glob(["**/e2e_test/*_spec.ts"]),
tsconfig = "//packages/examples:tsconfig-e2e.json",
deps = [
"//packages/examples/test-utils",
"//packages/private/testing",
"@npm//@types/jasminewd2",
"@npm//protractor",
],
)
esbuild(
name = "app_bundle",
entry_point = ":main.ts",
deps = [":sw_registration_options_examples"],
)
http_server(
name = "devserver",
srcs = [
"ngsw-worker.js",
"//packages/examples:index.html",
],
additional_root_paths = ["angular/packages/examples"],
deps = [":app_bundle"],
)
protractor_web_test_suite(
name = "protractor_tests",
on_prepare = "start-server.js",
server = ":devserver",
deps = [
":sw_registration_options_e2e_tests_lib",
"@npm//selenium-webdriver",
],
)
filegroup(
name = "files_for_docgen",
srcs = glob([
"**/*.ts",
]),
)
| {
"end_byte": 1515,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/registration-options/BUILD.bazel"
} |
angular/packages/examples/service-worker/registration-options/e2e_test/registration-options_spec.ts_0_803 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../test-utils';
describe('SW `SwRegistrationOptions` example', () => {
const pageUrl = '/registration-options';
const appElem = element(by.css('example-app'));
afterEach(verifyNoBrowserErrors);
it('not register the SW by default', () => {
browser.get(pageUrl);
expect(appElem.getText()).toBe('SW enabled: false');
});
it('register the SW when navigating to `?sw=true`', () => {
browser.get(`${pageUrl}?sw=true`);
expect(appElem.getText()).toBe('SW enabled: true');
});
});
| {
"end_byte": 803,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/registration-options/e2e_test/registration-options_spec.ts"
} |
angular/packages/examples/service-worker/push/ngsw-worker.js_0_516 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// Mock `ngsw-worker.js` used for testing the examples.
// Immediately takes over and unregisters itself.
self.addEventListener('install', (evt) => evt.waitUntil(self.skipWaiting()));
self.addEventListener('activate', (evt) =>
evt.waitUntil(self.clients.claim().then(() => self.registration.unregister())),
);
| {
"end_byte": 516,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/push/ngsw-worker.js"
} |
angular/packages/examples/service-worker/push/main.ts_0_412 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import 'zone.js/lib/browser/rollup-main';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './module';
platformBrowserDynamic().bootstrapModule(AppModule);
| {
"end_byte": 412,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/push/main.ts"
} |
angular/packages/examples/service-worker/push/module.ts_0_1752 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// tslint:disable: no-duplicate-imports
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {ServiceWorkerModule} from '@angular/service-worker';
// #docregion inject-sw-push
import {SwPush} from '@angular/service-worker';
// #enddocregion inject-sw-push
// tslint:enable: no-duplicate-imports
const PUBLIC_VAPID_KEY_OF_SERVER = '...';
@Component({
selector: 'example-app',
template: 'SW enabled: {{ swPush.isEnabled }}',
standalone: false,
})
// #docregion inject-sw-push
export class AppComponent {
constructor(readonly swPush: SwPush) {}
// #enddocregion inject-sw-push
// #docregion subscribe-to-push
private async subscribeToPush() {
try {
const sub = await this.swPush.requestSubscription({
serverPublicKey: PUBLIC_VAPID_KEY_OF_SERVER,
});
// TODO: Send to server.
} catch (err) {
console.error('Could not subscribe due to:', err);
}
}
// #enddocregion subscribe-to-push
private subscribeToNotificationClicks() {
// #docregion subscribe-to-notification-clicks
this.swPush.notificationClicks.subscribe(({action, notification}) => {
// TODO: Do something in response to notification click.
});
// #enddocregion subscribe-to-notification-clicks
}
// #docregion inject-sw-push
}
// #enddocregion inject-sw-push
@NgModule({
bootstrap: [AppComponent],
declarations: [AppComponent],
imports: [BrowserModule, ServiceWorkerModule.register('ngsw-worker.js')],
})
export class AppModule {}
| {
"end_byte": 1752,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/push/module.ts"
} |
angular/packages/examples/service-worker/push/start-server.js_0_552 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
const protractorUtils = require('@bazel/protractor/protractor-utils');
const protractor = require('protractor');
module.exports = async function (config) {
const {port} = await protractorUtils.runServer(config.workspace, config.server, '--port', []);
const serverUrl = `http://localhost:${port}`;
protractor.browser.baseUrl = serverUrl;
};
| {
"end_byte": 552,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/push/start-server.js"
} |
angular/packages/examples/service-worker/push/BUILD.bazel_0_1451 | load("//tools:defaults.bzl", "esbuild", "http_server", "ng_module", "protractor_web_test_suite", "ts_library")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "sw_push_examples",
srcs = glob(
["**/*.ts"],
exclude = ["**/*_spec.ts"],
),
deps = [
"//packages/core",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/service-worker",
"//packages/zone.js/lib",
],
)
ts_library(
name = "sw_push_e2e_tests_lib",
testonly = True,
srcs = glob(["**/e2e_test/*_spec.ts"]),
tsconfig = "//packages/examples:tsconfig-e2e.json",
deps = [
"//packages/examples/test-utils",
"//packages/private/testing",
"@npm//@types/jasminewd2",
"@npm//protractor",
],
)
esbuild(
name = "app_bundle",
entry_point = ":main.ts",
deps = [":sw_push_examples"],
)
http_server(
name = "devserver",
srcs = [
"ngsw-worker.js",
"//packages/examples:index.html",
],
additional_root_paths = ["angular/packages/examples"],
deps = [":app_bundle"],
)
protractor_web_test_suite(
name = "protractor_tests",
on_prepare = "start-server.js",
server = ":devserver",
deps = [
":sw_push_e2e_tests_lib",
"@npm//selenium-webdriver",
],
)
filegroup(
name = "files_for_docgen",
srcs = glob([
"**/*.ts",
]),
)
| {
"end_byte": 1451,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/push/BUILD.bazel"
} |
angular/packages/examples/service-worker/push/e2e_test/push_spec.ts_0_594 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../test-utils';
describe('SW `SwPush` example', () => {
const pageUrl = '/push';
const appElem = element(by.css('example-app'));
afterEach(verifyNoBrowserErrors);
it('should be enabled', () => {
browser.get(pageUrl);
expect(appElem.getText()).toBe('SW enabled: true');
});
});
| {
"end_byte": 594,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/service-worker/push/e2e_test/push_spec.ts"
} |
angular/packages/examples/platform-browser/BUILD.bazel_0_435 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "platform_browser_examples",
srcs = glob(["**/*.ts"]),
deps = [
"//packages/compiler",
"//packages/core",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
],
)
filegroup(
name = "files_for_docgen",
srcs = glob([
"**/*.ts",
]),
)
| {
"end_byte": 435,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/platform-browser/BUILD.bazel"
} |
angular/packages/examples/platform-browser/dom/debug/ts/by/by.ts_0_604 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {DebugElement} from '@angular/core';
import {By} from '@angular/platform-browser';
let debugElement: DebugElement = undefined!;
class MyDirective {}
// #docregion by_all
debugElement.query(By.all());
// #enddocregion
// #docregion by_css
debugElement.query(By.css('[attribute]'));
// #enddocregion
// #docregion by_directive
debugElement.query(By.directive(MyDirective));
// #enddocregion
| {
"end_byte": 604,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/platform-browser/dom/debug/ts/by/by.ts"
} |
angular/packages/examples/platform-browser/dom/debug/ts/debug_element_view_listener/providers.ts_0_635 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
@Component({
selector: 'my-component',
template: 'text',
standalone: false,
})
class MyAppComponent {}
@NgModule({imports: [BrowserModule], bootstrap: [MyAppComponent]})
class AppModule {}
platformBrowserDynamic().bootstrapModule(AppModule);
| {
"end_byte": 635,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/platform-browser/dom/debug/ts/debug_element_view_listener/providers.ts"
} |
angular/packages/examples/router/route_functional_guards.ts_0_3626 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Component, inject, Injectable} from '@angular/core';
import {bootstrapApplication} from '@angular/platform-browser';
import {
ActivatedRoute,
ActivatedRouteSnapshot,
CanActivateChildFn,
CanActivateFn,
CanDeactivateFn,
CanMatchFn,
provideRouter,
ResolveFn,
Route,
RouterStateSnapshot,
UrlSegment,
} from '@angular/router';
@Component({
template: '',
standalone: false,
})
export class App {}
@Component({
template: '',
standalone: false,
})
export class TeamComponent {}
// #docregion CanActivateFn
@Injectable()
class UserToken {}
@Injectable()
class PermissionsService {
canActivate(currentUser: UserToken, userId: string): boolean {
return true;
}
canMatch(currentUser: UserToken): boolean {
return true;
}
}
const canActivateTeam: CanActivateFn = (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
) => {
return inject(PermissionsService).canActivate(inject(UserToken), route.params['id']);
};
// #enddocregion
// #docregion CanActivateFnInRoute
bootstrapApplication(App, {
providers: [
provideRouter([
{
path: 'team/:id',
component: TeamComponent,
canActivate: [canActivateTeam],
},
]),
],
});
// #enddocregion
// #docregion CanActivateChildFn
const canActivateChildExample: CanActivateChildFn = (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
) => {
return inject(PermissionsService).canActivate(inject(UserToken), route.params['id']);
};
bootstrapApplication(App, {
providers: [
provideRouter([
{
path: 'team/:id',
component: TeamComponent,
canActivateChild: [canActivateChildExample],
children: [],
},
]),
],
});
// #enddocregion
// #docregion CanDeactivateFn
@Component({
template: '',
standalone: false,
})
export class UserComponent {
hasUnsavedChanges = true;
}
bootstrapApplication(App, {
providers: [
provideRouter([
{
path: 'user/:id',
component: UserComponent,
canDeactivate: [(component: UserComponent) => !component.hasUnsavedChanges],
},
]),
],
});
// #enddocregion
// #docregion CanMatchFn
const canMatchTeam: CanMatchFn = (route: Route, segments: UrlSegment[]) => {
return inject(PermissionsService).canMatch(inject(UserToken));
};
bootstrapApplication(App, {
providers: [
provideRouter([
{
path: 'team/:id',
component: TeamComponent,
canMatch: [canMatchTeam],
},
]),
],
});
// #enddocregion
// #docregion ResolveDataUse
@Component({
template: '',
standalone: false,
})
export class HeroDetailComponent {
constructor(private activatedRoute: ActivatedRoute) {}
ngOnInit() {
this.activatedRoute.data.subscribe(({hero}) => {
// do something with your resolved data ...
});
}
}
// #enddocregion
// #docregion ResolveFn
interface Hero {
name: string;
}
@Injectable()
export class HeroService {
getHero(id: string) {
return {name: `Superman-${id}`};
}
}
export const heroResolver: ResolveFn<Hero> = (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
) => {
return inject(HeroService).getHero(route.paramMap.get('id')!);
};
bootstrapApplication(App, {
providers: [
provideRouter([
{
path: 'detail/:id',
component: HeroDetailComponent,
resolve: {hero: heroResolver},
},
]),
],
});
// #enddocregion
| {
"end_byte": 3626,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/router/route_functional_guards.ts"
} |
angular/packages/examples/router/BUILD.bazel_0_382 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "router",
srcs = glob(
["**/*.ts"],
),
deps = [
"//packages/core",
"//packages/platform-browser",
"//packages/router",
],
)
filegroup(
name = "files_for_docgen",
srcs = glob([
"**/*.ts",
]),
)
| {
"end_byte": 382,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/router/BUILD.bazel"
} |
angular/packages/examples/router/activated-route/main.ts_0_412 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import 'zone.js/lib/browser/rollup-main';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './module';
platformBrowserDynamic().bootstrapModule(AppModule);
| {
"end_byte": 412,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/router/activated-route/main.ts"
} |
angular/packages/examples/router/activated-route/module.ts_0_1289 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
// #docregion activated-route
import {Component, NgModule} from '@angular/core';
// #enddocregion activated-route
import {BrowserModule} from '@angular/platform-browser';
// #docregion activated-route
import {ActivatedRoute, RouterModule} from '@angular/router';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
// #enddocregion activated-route
// #docregion activated-route
@Component({
// #enddocregion activated-route
selector: 'example-app',
template: '...',
standalone: false,
})
export class ActivatedRouteComponent {
constructor(route: ActivatedRoute) {
const id: Observable<string> = route.params.pipe(map((p) => p['id']));
const url: Observable<string> = route.url.pipe(map((segments) => segments.join('')));
// route.data includes both `data` and `resolve`
const user = route.data.pipe(map((d) => d['user']));
}
}
// #enddocregion activated-route
@NgModule({
imports: [BrowserModule, RouterModule.forRoot([])],
declarations: [ActivatedRouteComponent],
bootstrap: [ActivatedRouteComponent],
})
export class AppModule {}
| {
"end_byte": 1289,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/router/activated-route/module.ts"
} |
angular/packages/examples/router/activated-route/BUILD.bazel_0_826 | load("//tools:defaults.bzl", "esbuild", "http_server", "ng_module")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "router_activated_route_examples",
srcs = glob(
["**/*.ts"],
),
deps = [
"//packages/core",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/router",
"//packages/zone.js/lib",
"@npm//rxjs",
],
)
esbuild(
name = "app_bundle",
entry_point = ":main.ts",
deps = [":router_activated_route_examples"],
)
http_server(
name = "devserver",
srcs = ["//packages/examples:index.html"],
additional_root_paths = ["angular/packages/examples"],
deps = [":app_bundle"],
)
filegroup(
name = "files_for_docgen",
srcs = glob([
"**/*.ts",
]),
)
| {
"end_byte": 826,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/router/activated-route/BUILD.bazel"
} |
angular/packages/examples/router/utils/functional_guards.ts_0_802 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Injectable} from '@angular/core';
import {mapToCanActivate, mapToResolve, Route} from '@angular/router';
// #docregion CanActivate
@Injectable({providedIn: 'root'})
export class AdminGuard {
canActivate() {
return true;
}
}
const route: Route = {
path: 'admin',
canActivate: mapToCanActivate([AdminGuard]),
};
// #enddocregion
// #docregion Resolve
@Injectable({providedIn: 'root'})
export class ResolveUser {
resolve() {
return {name: 'Bob'};
}
}
const userRoute: Route = {
path: 'user',
resolve: {
user: mapToResolve(ResolveUser),
},
};
// #enddocregion
| {
"end_byte": 802,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/router/utils/functional_guards.ts"
} |
angular/packages/examples/router/testing/BUILD.bazel_0_717 | load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "test_lib",
testonly = True,
srcs = glob(["**/*.spec.ts"]),
deps = [
"//packages/common",
"//packages/core",
"//packages/core/testing",
"//packages/router",
"//packages/router/testing",
],
)
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node"],
deps = [
":test_lib",
],
)
karma_web_test_suite(
name = "test_web",
deps = [
":test_lib",
],
)
filegroup(
name = "files_for_docgen",
srcs = glob([
"**/*.ts",
]),
)
| {
"end_byte": 717,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/router/testing/BUILD.bazel"
} |
angular/packages/examples/router/testing/test/router_testing_harness_examples.spec.ts_0_3018 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {AsyncPipe} from '@angular/common';
import {Component, inject} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {ActivatedRoute, CanActivateFn, provideRouter, Router} from '@angular/router';
import {RouterTestingHarness} from '@angular/router/testing';
describe('navigate for test examples', () => {
// #docregion RoutedComponent
it('navigates to routed component', async () => {
@Component({standalone: true, template: 'hello {{name}}'})
class TestCmp {
name = 'world';
}
TestBed.configureTestingModule({
providers: [provideRouter([{path: '', component: TestCmp}])],
});
const harness = await RouterTestingHarness.create();
const activatedComponent = await harness.navigateByUrl('/', TestCmp);
expect(activatedComponent).toBeInstanceOf(TestCmp);
expect(harness.routeNativeElement?.innerHTML).toContain('hello world');
});
// #enddocregion
it('testing a guard', async () => {
@Component({standalone: true, template: ''})
class AdminComponent {}
@Component({standalone: true, template: ''})
class LoginComponent {}
// #docregion Guard
let isLoggedIn = false;
const isLoggedInGuard: CanActivateFn = () => {
return isLoggedIn ? true : inject(Router).parseUrl('/login');
};
TestBed.configureTestingModule({
providers: [
provideRouter([
{path: 'admin', canActivate: [isLoggedInGuard], component: AdminComponent},
{path: 'login', component: LoginComponent},
]),
],
});
const harness = await RouterTestingHarness.create('/admin');
expect(TestBed.inject(Router).url).toEqual('/login');
isLoggedIn = true;
await harness.navigateByUrl('/admin');
expect(TestBed.inject(Router).url).toEqual('/admin');
// #enddocregion
});
it('test a ActivatedRoute', async () => {
// #docregion ActivatedRoute
@Component({
standalone: true,
imports: [AsyncPipe],
template: `search: {{ (route.queryParams | async)?.query }}`,
})
class SearchCmp {
constructor(
readonly route: ActivatedRoute,
readonly router: Router,
) {}
async searchFor(thing: string) {
await this.router.navigate([], {queryParams: {query: thing}});
}
}
TestBed.configureTestingModule({
providers: [provideRouter([{path: 'search', component: SearchCmp}])],
});
const harness = await RouterTestingHarness.create();
const activatedComponent = await harness.navigateByUrl('/search', SearchCmp);
await activatedComponent.searchFor('books');
harness.detectChanges();
expect(TestBed.inject(Router).url).toEqual('/search?query=books');
expect(harness.routeNativeElement?.innerHTML).toContain('books');
// #enddocregion
});
});
| {
"end_byte": 3018,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/examples/router/testing/test/router_testing_harness_examples.spec.ts"
} |
angular/packages/bazel/index.bzl_0_738 | # Copyright Google LLC All Rights Reserved.
#
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file at https://angular.dev/license
""" Public API surface is re-exported here.
Users should not load files under "/src"
"""
load("//packages/bazel/src/ng_package:ng_package.bzl", _ng_package = "ng_package_macro")
load("//packages/bazel/src/ng_module:ng_module.bzl", _ng_module = "ng_module_macro")
load("//packages/bazel/src/types_bundle:index.bzl", _types_bundle = "types_bundle")
ng_module = _ng_module
ng_package = _ng_package
types_bundle = _types_bundle
# DO NOT ADD PUBLIC API without including in the documentation generation
# Run `yarn bazel build //packages/bazel/docs` to verify
| {
"end_byte": 738,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/index.bzl"
} |
angular/packages/bazel/BUILD.bazel_0_1897 | # BEGIN-DEV-ONLY
load("//tools:defaults.bzl", "pkg_npm")
pkg_npm(
name = "npm_package",
package_name = "@angular/bazel",
srcs = glob(
["*"],
exclude = ["yarn.lock"],
) + [
"//packages/bazel/src:package_assets",
"//packages/bazel/src/ng_module:package_assets",
"//packages/bazel/src/ng_package:package_assets",
"//packages/bazel/src/ngc-wrapped:package_assets",
"//packages/bazel/src/types_bundle:package_assets",
"//packages/bazel/third_party/github.com/bazelbuild/bazel/src/main/protobuf:package_assets",
],
substitutions = {
"(#|//)\\s+BEGIN-DEV-ONLY[\\w\\W]+?(#|//)\\s+END-DEV-ONLY": "",
# The partial compilation transition is applied in the user workspace. We do not want to require
# users having to define the build setting, so we directly point the flag label to the place where
# we expect `@angular/bazel` being located. Note: This expects the `@npm//` workspace to be used.
"//packages/bazel/src:partial_compilation": "@npm//@angular/bazel/src:partial_compilation",
# Substitutions to account for label changes when `@angular/bazel` is consumed externally.
# NodeJS binaries are pre-built and should be consumed through the NPM bin scripts of the package.
"//packages/bazel/src/types_bundle:types_bundler": "@npm//@angular/bazel/bin:types_bundler",
"//packages/bazel/": "//@angular/bazel/",
"@npm//@bazel/concatjs/internal:": "//@bazel/concatjs/internal:",
},
# Do not add more to this list.
# Dependencies on the full npm_package cause long re-builds.
visibility = [
"//integration:__subpackages__",
],
deps = [
"//packages/bazel/src/ng_package:lib",
"//packages/bazel/src/ngc-wrapped:ngc_lib",
"//packages/bazel/src/types_bundle:lib",
],
)
# END-DEV-ONLY
| {
"end_byte": 1897,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/BUILD.bazel"
} |
angular/packages/bazel/test/ng_package/outside_package.txt_0_47 | This file is not part of the example packages.
| {
"end_byte": 47,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/outside_package.txt"
} |
angular/packages/bazel/test/ng_package/example_package.golden_0_6263 | LICENSE
README.md
_index.scss
a11y
a11y/index.d.ts
arbitrary-npm-package-main.js
arbitrary_bin.txt
arbitrary_genfiles.txt
extra-styles.css
fesm2022
fesm2022/a11y.mjs
fesm2022/a11y.mjs.map
fesm2022/imports.mjs
fesm2022/imports.mjs.map
fesm2022/secondary.mjs
fesm2022/secondary.mjs.map
fesm2022/waffels.mjs
fesm2022/waffels.mjs.map
imports
imports/index.d.ts
index.d.ts
logo.png
package.json
secondary
secondary/index.d.ts
some-file.txt
--- LICENSE ---
The MIT License
Copyright (c) 2010-2024 Google LLC. https://angular.dev/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.md ---
Angular
=======
The sources for this package are in the main [Angular](https://github.com/angular/angular) repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in [Angular documentation](https://angular.dev/overview).
License: MIT
--- _index.scss ---
/// test file which should ship as part of the NPM package.
--- a11y/index.d.ts ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
export declare class A11yModule {
static ɵfac: i0.ɵɵFactoryDeclaration<A11yModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<A11yModule, never, never, never>;
static ɵinj: i0.ɵɵInjectorDeclaration<A11yModule>;
}
export { }
--- arbitrary-npm-package-main.js ---
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
const x = 1;
--- arbitrary_bin.txt ---
World
--- arbitrary_genfiles.txt ---
Hello
--- extra-styles.css ---
.special {
color: goldenrod;
}
--- fesm2022/a11y.mjs ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
import { NgModule } from '@angular/core';
class A11yModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: A11yModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "0.0.0", ngImport: i0, type: A11yModule });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: A11yModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: A11yModule, decorators: [{
type: NgModule,
args: [{}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { A11yModule };
//# sourceMappingURL=a11y.mjs.map
--- fesm2022/imports.mjs ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
import { Injectable } from '@angular/core';
class MySecondService {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MySecondService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MySecondService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MySecondService, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}] });
class MyService {
secondService;
constructor(secondService) {
this.secondService = secondService;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MyService, deps: [{ token: MySecondService }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MyService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MyService, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}], ctorParameters: () => [{ type: MySecondService }] });
/**
* Generated bundle index. Do not edit.
*/
export { MyService };
//# sourceMappingURL=imports.mjs.map
--- fesm2022/secondary.mjs ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
import { NgModule } from '@angular/core';
class SecondaryModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: SecondaryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "0.0.0", ngImport: i0, type: SecondaryModule });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: SecondaryModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: SecondaryModule, decorators: [{
type: NgModule,
args: [{}]
}] });
const a = 1;
/**
* Generated bundle index. Do not edit.
*/
export { SecondaryModule, a };
//# sourceMappingURL=secondary.mjs.map | {
"end_byte": 6263,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example_package.golden"
} |
angular/packages/bazel/test/ng_package/example_package.golden_6266_9418 | --- fesm2022/waffels.mjs ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
import { NgModule } from '@angular/core';
class MyModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MyModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "0.0.0", ngImport: i0, type: MyModule });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MyModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: MyModule, decorators: [{
type: NgModule,
args: [{}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { MyModule };
//# sourceMappingURL=waffels.mjs.map
--- imports/index.d.ts ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
declare class MySecondService {
static ɵfac: i0.ɵɵFactoryDeclaration<MySecondService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<MySecondService>;
}
export declare class MyService {
secondService: MySecondService;
constructor(secondService: MySecondService);
static ɵfac: i0.ɵɵFactoryDeclaration<MyService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<MyService>;
}
export { }
--- index.d.ts ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
export declare class MyModule {
static ɵfac: i0.ɵɵFactoryDeclaration<MyModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<MyModule, never, never, never>;
static ɵinj: i0.ɵɵInjectorDeclaration<MyModule>;
}
export { }
--- logo.png ---
611871c1f492a69a8a5f57e01096b145
--- package.json ---
{
"name": "example",
"version": "0.0.0",
"exports": {
".": {
"sass": "./_index.scss",
"types": "./index.d.ts",
"default": "./fesm2022/waffels.mjs"
},
"./package.json": {
"default": "./package.json"
},
"./a11y": {
"types": "./a11y/index.d.ts",
"default": "./fesm2022/a11y.mjs"
},
"./imports": {
"types": "./imports/index.d.ts",
"default": "./fesm2022/imports.mjs"
},
"./secondary": {
"types": "./secondary/index.d.ts",
"default": "./fesm2022/secondary.mjs"
}
},
"module": "./fesm2022/waffels.mjs",
"typings": "./index.d.ts",
"type": "module"
}
--- secondary/index.d.ts ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
export declare const a = 1;
export declare class SecondaryModule {
static ɵfac: i0.ɵɵFactoryDeclaration<SecondaryModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<SecondaryModule, never, never, never>;
static ɵinj: i0.ɵɵInjectorDeclaration<SecondaryModule>;
}
export { }
--- some-file.txt ---
This file is just copied into the package.
| {
"end_byte": 9418,
"start_byte": 6266,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example_package.golden"
} |
angular/packages/bazel/test/ng_package/example_with_ts_library_package.golden_0_4670 | LICENSE
README.md
fesm2022
fesm2022/example-with-ts-library.mjs
fesm2022/example-with-ts-library.mjs.map
fesm2022/portal.mjs
fesm2022/portal.mjs.map
fesm2022/utils.mjs
fesm2022/utils.mjs.map
index.d.ts
package.json
portal
portal/index.d.ts
utils
utils/index.d.ts
--- LICENSE ---
The MIT License
Copyright (c) 2010-2024 Google LLC. https://angular.dev/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.md ---
Angular
=======
The sources for this package are in the main [Angular](https://github.com/angular/angular) repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in [Angular documentation](https://angular.dev/overview).
License: MIT
--- fesm2022/example-with-ts-library.mjs ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
const VERSION = '0.0.0';
export { VERSION };
//# sourceMappingURL=example-with-ts-library.mjs.map
--- fesm2022/portal.mjs ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
import { NgModule } from '@angular/core';
class PortalModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: PortalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "0.0.0", ngImport: i0, type: PortalModule });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: PortalModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0", ngImport: i0, type: PortalModule, decorators: [{
type: NgModule,
args: [{}]
}] });
const a = 1;
/**
* Generated bundle index. Do not edit.
*/
export { PortalModule, a };
//# sourceMappingURL=portal.mjs.map
--- fesm2022/utils.mjs ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
function dispatchFakeEvent(el, ev) {
el.dispatchEvent(ev);
}
export { dispatchFakeEvent };
//# sourceMappingURL=utils.mjs.map
--- index.d.ts ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
export declare const VERSION = "0.0.0";
export { }
--- package.json ---
{
"name": "example-with-ts-library",
"version": "0.0.0",
"schematics": "Custom property that should be preserved.",
"module": "./fesm2022/example-with-ts-library.mjs",
"typings": "./index.d.ts",
"type": "module",
"exports": {
"./package.json": {
"default": "./package.json"
},
".": {
"types": "./index.d.ts",
"default": "./fesm2022/example-with-ts-library.mjs"
},
"./portal": {
"types": "./portal/index.d.ts",
"default": "./fesm2022/portal.mjs"
},
"./utils": {
"types": "./utils/index.d.ts",
"default": "./fesm2022/utils.mjs"
}
}
}
--- portal/index.d.ts ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
import * as i0 from '@angular/core';
export declare const a = 1;
export declare class PortalModule {
static ɵfac: i0.ɵɵFactoryDeclaration<PortalModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<PortalModule, never, never, never>;
static ɵinj: i0.ɵɵInjectorDeclaration<PortalModule>;
}
export { }
--- utils/index.d.ts ---
/**
* @license Angular v0.0.0
* (c) 2010-2024 Google LLC. https://angular.io/
* License: MIT
*/
export declare function dispatchFakeEvent(el: HTMLElement, ev: Event): void;
export { }
| {
"end_byte": 4670,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example_with_ts_library_package.golden"
} |
angular/packages/bazel/test/ng_package/core_package.spec.ts_0_5683 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {runfiles} from '@bazel/runfiles';
import path from 'path';
import shx from 'shelljs';
import {matchesObjectWithOrder} from './test_utils';
// Resolve the "npm_package" directory by using the runfile resolution. Note that we need to
// resolve the "package.json" of the package since otherwise NodeJS would resolve the "main"
// file, which is not necessarily at the root of the "npm_package".
shx.cd(path.dirname(runfiles.resolve('angular/packages/core/npm_package/package.json')));
/**
* Utility functions that allows me to create fs paths
* p`${foo}/some/${{bar}}/path` rather than path.join(foo, 'some',
*/
function p(templateStringArray: TemplateStringsArray) {
const segments = [];
for (const entry of templateStringArray) {
segments.push(...entry.split('/').filter((s) => s !== ''));
}
return path.join(...segments);
}
describe('@angular/core ng_package', () => {
describe('misc root files', () => {
describe('README.md', () => {
it('should have a README.md file with basic info', () => {
expect(shx.cat('README.md')).toContain(`Angular`);
expect(shx.cat('README.md')).toContain(`https://github.com/angular/angular`);
});
});
});
describe('primary entry-point', () => {
describe('package.json', () => {
const packageJson = 'package.json';
it('should have a package.json file', () => {
expect(shx.grep('"name":', packageJson)).toContain(`@angular/core`);
});
it('should contain correct version number with the PLACEHOLDER string replaced', () => {
expect(shx.grep('"version":', packageJson)).toMatch(/\d+\.\d+\.\d+(?!-PLACEHOLDER)/);
});
it('should contain module resolution mappings', () => {
const data = JSON.parse(shx.cat(packageJson)) as any;
expect(data).toEqual(
jasmine.objectContaining({
module: `./fesm2022/core.mjs`,
typings: `./index.d.ts`,
exports: matchesObjectWithOrder({
'./schematics/*': {default: './schematics/*.js'},
'./event-dispatch-contract.min.js': {default: './event-dispatch-contract.min.js'},
'./package.json': {default: './package.json'},
'.': {
types: './index.d.ts',
default: './fesm2022/core.mjs',
},
'./primitives/event-dispatch': {
types: './primitives/event-dispatch/index.d.ts',
default: './fesm2022/primitives/event-dispatch.mjs',
},
'./primitives/signals': {
types: './primitives/signals/index.d.ts',
default: './fesm2022/primitives/signals.mjs',
},
'./rxjs-interop': {
types: './rxjs-interop/index.d.ts',
default: './fesm2022/rxjs-interop.mjs',
},
'./testing': {
types: './testing/index.d.ts',
default: './fesm2022/testing.mjs',
},
}),
}),
);
});
it('should contain metadata for ng update', () => {
interface PackageJson {
'ng-update': {packageGroup: string[]};
}
expect(shx.cat(packageJson)).not.toContain('NG_UPDATE_PACKAGE_GROUP');
expect(
(JSON.parse(shx.cat(packageJson)) as PackageJson)['ng-update'].packageGroup,
).toContain('@angular/core');
});
});
describe('typescript support', () => {
it('should not have amd module names', () => {
expect(shx.cat('index.d.ts')).not.toContain('<amd-module name');
});
it('should have an index d.ts file', () => {
expect(shx.cat('index.d.ts')).toContain('export declare');
});
// The `r3_symbols` file was needed for View Engine ngcc processing.
// This test ensures we no longer ship it by accident.
it('should not have an r3_symbols d.ts file', () => {
expect(shx.test('-e', 'src/r3_symbols.d.ts')).toBe(false);
});
});
describe('fesm2022', () => {
it('should have a fesm2022 file in the /fesm2022 directory', () => {
expect(shx.cat('fesm2022/core.mjs')).toContain(`export {`);
});
it('should have a source map', () => {
expect(shx.cat('fesm2022/core.mjs.map')).toContain(
`{"version":3,"file":"core.mjs","sources":`,
);
});
it('should have the version info in the header', () => {
expect(shx.cat('fesm2022/core.mjs')).toMatch(
/@license Angular v\d+\.\d+\.\d+(?!-PLACEHOLDER)/,
);
});
});
});
describe('secondary entry-point', () => {
describe('typings', () => {
const typingsFile = p`testing/index.d.ts`;
it('should have a typings file', () => {
expect(shx.cat(typingsFile)).toContain('export declare');
});
});
describe('fesm2022', () => {
it('should have a fesm2022 file in the /fesm2022 directory', () => {
expect(shx.cat('fesm2022/testing.mjs')).toContain(`export {`);
});
it('should have a source map', () => {
expect(shx.cat('fesm2022/testing.mjs.map')).toContain(
`{"version":3,"file":"testing.mjs","sources":`,
);
});
it('should have the version info in the header', () => {
expect(shx.cat('fesm2022/testing.mjs')).toMatch(
/@license Angular v\d+\.\d+\.\d+(?!-PLACEHOLDER)/,
);
});
});
});
});
| {
"end_byte": 5683,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/core_package.spec.ts"
} |
angular/packages/bazel/test/ng_package/common_package.spec.ts_0_4800 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {runfiles} from '@bazel/runfiles';
import fs from 'fs';
import path from 'path';
import shx from 'shelljs';
import {matchesObjectWithOrder} from './test_utils';
// Resolve the "npm_package" directory by using the runfile resolution. Note that we need to
// resolve the "package.json" of the package since otherwise NodeJS would resolve the "main"
// file, which is not necessarily at the root of the "npm_package".
shx.cd(path.dirname(runfiles.resolve('angular/packages/common/npm_package/package.json')));
describe('@angular/common ng_package', () => {
describe('should have the locales files', () => {
it('/locales', () => {
const files = shx.ls('locales').stdout.split('\n');
expect(files.some((n) => n.endsWith('.d.ts'))).toBe(true, `.d.ts files don't exist`);
expect(files.some((n) => n.endsWith('.mjs'))).toBe(true, `.mjs files don't exist`);
});
it('/locales/extra', () => {
const files = shx.ls('locales/extra').stdout.split('\n');
expect(files.some((n) => n.endsWith('.d.ts'))).toBe(true, `.d.ts files don't exist`);
expect(files.some((n) => n.endsWith('.mjs'))).toBe(true, `.mjs files don't exist`);
});
});
it('should have right fesm files', () => {
const expected = [
'common.mjs',
'common.mjs.map',
'http',
'http.mjs',
'http.mjs.map',
'http/testing.mjs',
'http/testing.mjs.map',
'testing.mjs',
'testing.mjs.map',
'upgrade.mjs',
'upgrade.mjs.map',
];
expect(
shx
.ls('-R', 'fesm2022')
.stdout.split('\n')
.filter((n) => !!n)
.sort(),
).toEqual(expected);
});
it('should have the correct source map paths', () => {
expect(shx.grep('sourceMappingURL', 'fesm2022/common.mjs')).toMatch(
'//# sourceMappingURL=common.mjs.map',
);
expect(shx.grep('sourceMappingURL', 'fesm2022/http.mjs')).toMatch(
'//# sourceMappingURL=http.mjs.map',
);
expect(shx.grep('sourceMappingURL', 'fesm2022/http/testing.mjs')).toMatch(
'//# sourceMappingURL=testing.mjs.map',
);
expect(shx.grep('sourceMappingURL', 'fesm2022/testing.mjs')).toMatch(
'//# sourceMappingURL=testing.mjs.map',
);
expect(shx.grep('sourceMappingURL', 'fesm2022/upgrade.mjs')).toMatch(
'//# sourceMappingURL=upgrade.mjs.map',
);
});
describe('should have module resolution properties in the package.json file for', () => {
interface PackageJson {
main: string;
es2022: string;
module: string;
typings: string;
exports: object;
}
// https://github.com/angular/common-builds/blob/master/package.json
it('/', () => {
const actual = JSON.parse(
fs.readFileSync('package.json', {encoding: 'utf-8'}),
) as PackageJson;
expect(actual).toEqual(
jasmine.objectContaining({
module: `./fesm2022/common.mjs`,
typings: `./index.d.ts`,
exports: matchesObjectWithOrder({
'./locales/global/*': {default: './locales/global/*.js'},
'./locales/*': {types: './locales/*.d.ts', default: './locales/*.mjs'},
'./package.json': {default: './package.json'},
'.': {
types: './index.d.ts',
default: './fesm2022/common.mjs',
},
'./http': {
types: './http/index.d.ts',
default: './fesm2022/http.mjs',
},
'./http/testing': {
types: './http/testing/index.d.ts',
default: './fesm2022/http/testing.mjs',
},
'./testing': {
types: './testing/index.d.ts',
default: './fesm2022/testing.mjs',
},
'./upgrade': {
types: './upgrade/index.d.ts',
default: './fesm2022/upgrade.mjs',
},
}),
}),
);
});
// https://github.com/angular/common-builds/blob/master/http
it('/http', () => {
expect(fs.existsSync('http/index.d.ts')).toBe(true);
});
// https://github.com/angular/common-builds/blob/master/testing
it('/testing', () => {
expect(fs.existsSync('testing/index.d.ts')).toBe(true);
});
// https://github.com/angular/common-builds/blob/master/http/testing
it('/http/testing', () => {
expect(fs.existsSync('http/testing/index.d.ts')).toBe(true);
});
// https://github.com/angular/common-builds/blob/master/upgrade
it('/upgrade', () => {
expect(fs.existsSync('upgrade/index.d.ts')).toBe(true);
});
});
});
| {
"end_byte": 4800,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/common_package.spec.ts"
} |
angular/packages/bazel/test/ng_package/example_package.spec.ts_0_6787 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {runfiles} from '@bazel/runfiles';
import crypto from 'crypto';
import {createPatch} from 'diff';
import fs from 'fs';
import path from 'path';
type TestPackage = {
displayName: string;
packagePath: string;
goldenFilePath: string;
};
const packagesToTest: TestPackage[] = [
{
displayName: 'Example NPM package',
// Resolve the "npm_package" directory by using the runfile resolution. Note that we need to
// resolve the "package.json" of the package since otherwise NodeJS would resolve the "main"
// file, which is not necessarily at the root of the "npm_package".
packagePath: path.dirname(
runfiles.resolve('angular/packages/bazel/test/ng_package/example/npm_package/package.json'),
),
goldenFilePath: runfiles.resolvePackageRelative('./example_package.golden'),
},
{
displayName: 'Example with ts_library NPM package',
// Resolve the "npm_package" directory by using the runfile resolution. Note that we need to
// resolve the "package.json" of the package since otherwise NodeJS would resolve the "main"
// file, which is not necessarily at the root of the "npm_package".
packagePath: path.dirname(
runfiles.resolve(
'angular/packages/bazel/test/ng_package/example-with-ts-library/npm_package/package.json',
),
),
goldenFilePath: runfiles.resolvePackageRelative('./example_with_ts_library_package.golden'),
},
];
/**
* Gets all entries in a given directory (files and directories) recursively,
* indented based on each entry's depth.
*
* @param directoryPath Path of the directory for which to get entries.
* @param depth The depth of this directory (used for indentation).
* @returns Array of all indented entries (files and directories).
*/
function getIndentedDirectoryStructure(directoryPath: string, depth = 0): string[] {
const result: string[] = [];
if (fs.statSync(directoryPath).isDirectory()) {
// We need to sort the directories because on Windows "readdirsync" is not sorted. Since we
// compare these in a golden file, the order needs to be consistent across different platforms.
fs.readdirSync(directoryPath)
.sort()
.forEach((f) => {
const filePath = path.posix.join(directoryPath, f);
result.push(
' '.repeat(depth) + filePath,
...getIndentedDirectoryStructure(filePath, depth + 1),
);
});
}
return result;
}
/**
* Gets all file contents in a given directory recursively. Each file's content will be
* prefixed with a one-line header with the file name.
*
* @param directoryPath Path of the directory for which file contents are collected.
* @returns Array of all files' contents.
*/
function getDescendantFilesContents(directoryPath: string): string[] {
const result: string[] = [];
if (fs.statSync(directoryPath).isDirectory()) {
// We need to sort the directories because on Windows "readdirsync" is not sorted. Since we
// compare these in a golden file, the order needs to be consistent across different platforms.
fs.readdirSync(directoryPath)
.sort()
.forEach((dir) => {
result.push(...getDescendantFilesContents(path.posix.join(directoryPath, dir)));
});
}
// Binary files should equal the same as in the srcdir.
else if (path.extname(directoryPath) === '.png') {
result.push(`--- ${directoryPath} ---`, '', hashFileContents(directoryPath), '');
}
// Note that we don't want to include ".map" files in the golden file since these are not
// consistent across different environments (e.g. path delimiters)
else if (path.extname(directoryPath) !== '.map') {
result.push(`--- ${directoryPath} ---`, '', readFileContents(directoryPath), '');
}
return result;
}
/** Accepts the current package output by overwriting the gold file in source control. */
function acceptNewPackageGold(testPackage: TestPackage) {
process.chdir(testPackage.packagePath);
fs.writeFileSync(testPackage.goldenFilePath, getCurrentPackageContent(), 'utf-8');
}
/** Gets the content of the current package. Depends on the current working directory. */
function getCurrentPackageContent() {
return [...getIndentedDirectoryStructure('.'), ...getDescendantFilesContents('.')]
.join('\n')
.replace(/bazel-out\/.*\/bin/g, 'bazel-bin');
}
/** Compares the current package output to the gold file in source control in a jasmine test. */
function runPackageGoldTest(testPackage: TestPackage) {
const {displayName, packagePath, goldenFilePath} = testPackage;
process.chdir(packagePath);
// Gold file content from source control. We expect that the output of the package matches this.
const expected = readFileContents(goldenFilePath);
// Actual file content generated from the rule.
const actual = getCurrentPackageContent();
// Without the `--accept` flag, compare the actual to the expected in a jasmine test.
it(`Package "${displayName}"`, () => {
if (actual !== expected) {
// Compute the patch and strip the header
let patch = createPatch(goldenFilePath, expected, actual, 'Golden file', 'Generated file', {
context: 5,
});
const endOfHeader = patch.indexOf('\n', patch.indexOf('\n') + 1) + 1;
patch = patch.substring(endOfHeader);
// Use string concatentation instead of whitespace inside a single template string
// to make the structure message explicit.
const failureMessage =
`example ng_package differs from golden file\n` +
` Diff:\n` +
` ${patch}\n\n` +
` To accept the new golden file, run:\n` +
` yarn bazel run ${process.env['BAZEL_TARGET']}.accept\n`;
fail(failureMessage);
}
});
}
/**
* Reads the contents of the specified file. Additionally it strips all carriage return (CR)
* characters from the given content. We do this since the content that will be pulled into the
* golden file needs to be consistent across all platforms.
*/
function readFileContents(filePath: string): string {
return fs.readFileSync(filePath, 'utf8').replace(/\r/g, '');
}
function hashFileContents(filePath: string): string {
return crypto.createHash('md5').update(fs.readFileSync(filePath)).digest('hex');
}
// This spec file can be invoked as a `nodejs_binary` to update the golden files.
if (process.argv.slice(2).includes('--accept')) {
for (let p of packagesToTest) {
acceptNewPackageGold(p);
}
} else {
describe('Comparing test packages to golds', () => {
for (let p of packagesToTest) {
runPackageGoldTest(p);
}
});
}
| {
"end_byte": 6787,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example_package.spec.ts"
} |
angular/packages/bazel/test/ng_package/BUILD.bazel_0_2708 | load("//tools:defaults.bzl", "jasmine_node_test", "nodejs_binary", "ts_library")
exports_files([
"package.json",
"outside_package.txt",
])
# The tests in this package must run in separate targets, since they change
# working directory and therefore have mutable global state that causes test
# isolation failures.
ts_library(
name = "test_utils_lib",
testonly = True,
srcs = ["test_utils.ts"],
deps = [
"//packages:types",
],
)
ts_library(
name = "core_spec_lib",
testonly = True,
srcs = ["core_package.spec.ts"],
deps = [
":test_utils_lib",
"//packages:types",
"@npm//@bazel/runfiles",
"@npm//@types/shelljs",
],
)
jasmine_node_test(
name = "core_package",
srcs = [":core_spec_lib"],
data = [
"//packages/core:npm_package",
"@npm//@types/shelljs",
"@npm//shelljs",
],
)
ts_library(
name = "common_spec_lib",
testonly = True,
srcs = ["common_package.spec.ts"],
deps = [
":test_utils_lib",
"//packages:types",
"@npm//@bazel/runfiles",
"@npm//@types/shelljs",
],
)
jasmine_node_test(
name = "common_package",
srcs = [":common_spec_lib"],
data = [
"//packages/common:npm_package",
"@npm//shelljs",
],
)
ts_library(
name = "example_spec_lib",
testonly = True,
srcs = ["example_package.spec.ts"],
deps = [
"//packages:types",
"@npm//@bazel/runfiles",
"@npm//@types/diff",
],
)
jasmine_node_test(
name = "example_package",
srcs = [":example_spec_lib"],
data = [
"example_package.golden",
"example_with_ts_library_package.golden",
"//packages/bazel/test/ng_package/example:npm_package",
"//packages/bazel/test/ng_package/example-with-ts-library:npm_package",
],
# We don't want to run the example_package golden test with Ivy yet. Currently the golden
# file is based on non-ivy output and therefore won't work for ngc and Ivy at the same time.
# TODO: Update test to rely on Ivy partial compilation after View Engine's removal, update the
# golden files as appropriate for the change in compilation.
deps = ["@npm//diff"],
)
nodejs_binary(
name = "example_package.accept",
testonly = True,
data = [
"example_package.golden",
"example_with_ts_library_package.golden",
":example_spec_lib",
"//packages/bazel/test/ng_package/example:npm_package",
"//packages/bazel/test/ng_package/example-with-ts-library:npm_package",
"@npm//diff",
],
entry_point = ":example_package.spec.ts",
templated_args = ["--accept"],
)
| {
"end_byte": 2708,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/BUILD.bazel"
} |
angular/packages/bazel/test/ng_package/test_utils.ts_0_921 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
/**
* Jasmine asymmetric matcher that compares a given object ensuring that it matches deep
* with the other while also respecting the order of keys. This is useful when comparing
* the NodeJS `package.json` `exports` field where order matters.
*/
export function matchesObjectWithOrder(expected: any): jasmine.AsymmetricMatcher<any> {
return {
asymmetricMatch(actual: any): boolean {
// Use JSON stringify to compare the object with respect to the order of keys
// in the object, and its nested objects.
return JSON.stringify(actual) === JSON.stringify(expected);
},
jasmineToString(prettyPrint: (value: any) => string): string {
return prettyPrint(expected);
},
};
}
| {
"end_byte": 921,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/test_utils.ts"
} |
angular/packages/bazel/test/ng_package/example/_index.scss_0_60 | /// test file which should ship as part of the NPM package.
| {
"end_byte": 60,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/_index.scss"
} |
angular/packages/bazel/test/ng_package/example/mymodule.ts_0_331 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {NgModule} from '@angular/core';
import {a} from './secondary/secondarymodule';
@NgModule({})
export class MyModule {}
| {
"end_byte": 331,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/mymodule.ts"
} |
angular/packages/bazel/test/ng_package/example/some-file.txt_0_43 | This file is just copied into the package.
| {
"end_byte": 43,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/some-file.txt"
} |
angular/packages/bazel/test/ng_package/example/extra-styles.css_0_33 | .special {
color: goldenrod;
}
| {
"end_byte": 33,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/extra-styles.css"
} |
angular/packages/bazel/test/ng_package/example/arbitrary-npm-package-main.js_0_217 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
const x = 1;
| {
"end_byte": 217,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/arbitrary-npm-package-main.js"
} |
angular/packages/bazel/test/ng_package/example/BUILD.bazel_0_1688 | load("//tools:defaults.bzl", "ng_module", "ng_package", "pkg_npm")
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
ng_module(
name = "example",
srcs = glob(["*.ts"]),
module_name = "example",
deps = [
"//packages/bazel/test/ng_package/example/secondary",
"@npm//@types",
],
)
ng_package(
name = "npm_package",
srcs = [
"_index.scss",
"package.json",
"some-file.txt",
":arbitrary_bin_file",
":arbitrary_genfiles_file",
":extra-styles.css",
":logo.png",
# This file should be just ignored, and not copied into the package.
"//packages/bazel/test/ng_package:outside_package.txt",
],
nested_packages = [
":arbitrary_npm_package",
],
primary_bundle_name = "waffels",
deps = [
":example",
"//packages/bazel/test/ng_package/example/a11y",
"//packages/bazel/test/ng_package/example/imports",
"//packages/bazel/test/ng_package/example/secondary",
],
)
# Use a genrule to create a file in bazel-genfiles to ensure that the genfiles output of
# a rule can be passed through to the `data` of ng_package.
genrule(
name = "arbitrary_genfiles_file",
outs = ["arbitrary_genfiles.txt"],
cmd = "echo Hello > $@",
)
# Use a genrule to create a file in bazel-bin to ensure that the bin output of
# a rule can be passed through to the `data` of ng_package.
genrule(
name = "arbitrary_bin_file",
outs = ["arbitrary_bin.txt"],
cmd = "echo World > $@",
output_to_bindir = True,
)
pkg_npm(
name = "arbitrary_npm_package",
srcs = [":arbitrary-npm-package-main.js"],
)
| {
"end_byte": 1688,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/BUILD.bazel"
} |
angular/packages/bazel/test/ng_package/example/index.ts_0_232 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export * from './mymodule';
| {
"end_byte": 232,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/index.ts"
} |
angular/packages/bazel/test/ng_package/example/imports/public-api.ts_0_406 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Injectable} from '@angular/core';
import {MySecondService} from './second';
@Injectable({providedIn: 'root'})
export class MyService {
constructor(public secondService: MySecondService) {}
}
| {
"end_byte": 406,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/imports/public-api.ts"
} |
angular/packages/bazel/test/ng_package/example/imports/second.ts_0_313 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {Injectable} from '@angular/core';
@Injectable({providedIn: 'root'})
export class MySecondService {}
| {
"end_byte": 313,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/imports/second.ts"
} |
angular/packages/bazel/test/ng_package/example/imports/BUILD.bazel_0_262 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
ng_module(
name = "imports",
srcs = glob(["*.ts"]),
module_name = "example/imports",
deps = [
"//packages/core",
],
)
| {
"end_byte": 262,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/imports/BUILD.bazel"
} |
angular/packages/bazel/test/ng_package/example/imports/index.ts_0_234 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export * from './public-api';
| {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/imports/index.ts"
} |
angular/packages/bazel/test/ng_package/example/a11y/public-api.ts_0_286 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {NgModule} from '@angular/core';
@NgModule({})
export class A11yModule {}
| {
"end_byte": 286,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/a11y/public-api.ts"
} |
angular/packages/bazel/test/ng_package/example/a11y/BUILD.bazel_0_256 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
ng_module(
name = "a11y",
srcs = glob(["*.ts"]),
module_name = "example/a11y",
deps = [
"//packages/core",
],
)
| {
"end_byte": 256,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/a11y/BUILD.bazel"
} |
angular/packages/bazel/test/ng_package/example/a11y/index.ts_0_234 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export * from './public-api';
| {
"end_byte": 234,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/a11y/index.ts"
} |
angular/packages/bazel/test/ng_package/example/secondary/BUILD.bazel_0_290 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
ng_module(
name = "secondary",
srcs = glob(["*.ts"]),
module_name = "example/secondary",
deps = [
"//packages/core",
"@npm//@types",
],
)
| {
"end_byte": 290,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/secondary/BUILD.bazel"
} |
angular/packages/bazel/test/ng_package/example/secondary/index.ts_0_239 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export * from './secondarymodule';
| {
"end_byte": 239,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/secondary/index.ts"
} |
angular/packages/bazel/test/ng_package/example/secondary/secondarymodule.ts_0_312 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {NgModule} from '@angular/core';
@NgModule({})
export class SecondaryModule {}
export const a = 1;
| {
"end_byte": 312,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example/secondary/secondarymodule.ts"
} |
angular/packages/bazel/test/ng_package/example-with-ts-library/BUILD.bazel_0_669 | load("//tools:defaults.bzl", "ng_package", "ts_library")
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
ts_library(
name = "example",
srcs = glob(["*.ts"]),
module_name = "example-with-ts-library",
deps = [],
)
ng_package(
name = "npm_package",
srcs = [
"package.json",
# This file should be just ignored, and not copied into the package.
"//packages/bazel/test/ng_package:outside_package.txt",
],
deps = [
":example",
"//packages/bazel/test/ng_package/example-with-ts-library/portal",
"//packages/bazel/test/ng_package/example-with-ts-library/utils",
],
)
| {
"end_byte": 669,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example-with-ts-library/BUILD.bazel"
} |
angular/packages/bazel/test/ng_package/example-with-ts-library/index.ts_0_236 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export const VERSION = '0.0.0';
| {
"end_byte": 236,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example-with-ts-library/index.ts"
} |
angular/packages/bazel/test/ng_package/example-with-ts-library/portal/portal-module.ts_0_309 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {NgModule} from '@angular/core';
@NgModule({})
export class PortalModule {}
export const a = 1;
| {
"end_byte": 309,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example-with-ts-library/portal/portal-module.ts"
} |
angular/packages/bazel/test/ng_package/example-with-ts-library/portal/BUILD.bazel_0_300 | load("//tools:defaults.bzl", "ng_module")
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
ng_module(
name = "portal",
srcs = glob(["*.ts"]),
module_name = "example-with-ts-library/portal",
deps = [
"//packages/core",
"@npm//@types",
],
)
| {
"end_byte": 300,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example-with-ts-library/portal/BUILD.bazel"
} |
angular/packages/bazel/test/ng_package/example-with-ts-library/portal/index.ts_0_237 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export * from './portal-module';
| {
"end_byte": 237,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example-with-ts-library/portal/index.ts"
} |
angular/packages/bazel/test/ng_package/example-with-ts-library/utils/testing.ts_0_294 | /**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export function dispatchFakeEvent(el: HTMLElement, ev: Event) {
el.dispatchEvent(ev);
}
| {
"end_byte": 294,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example-with-ts-library/utils/testing.ts"
} |
angular/packages/bazel/test/ng_package/example-with-ts-library/utils/BUILD.bazel_0_229 | load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//packages/bazel/test:__subpackages__"])
ts_library(
name = "utils",
srcs = glob(["*.ts"]),
module_name = "example-with-ts-library/utils",
)
| {
"end_byte": 229,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/packages/bazel/test/ng_package/example-with-ts-library/utils/BUILD.bazel"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.