<commit_before>import "zone.js/dist/zone";

import { NgModule, Component, VERSION } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { HttpClientModule } from "@angular/common/http";
import { HttpClient } from "@angular/common/http";
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { RouterModule } from "@angular/router";

// simple example

class FooComponent {
    constructor() {
        this.version = VERSION.full;
    }
}

FooComponent.annotations = [
    new Component({
        selector: "my-app",
        template: "<h1>Angular {{ version }} in ES2015</h1>"
    })
];

class AppModule {}

AppModule.annotations = [
    new NgModule({
        imports: [BrowserModule],
        declarations: [FooComponent],
        bootstrap: [FooComponent]
    })
];

// list example

class FriendsService {
    constructor() {
        this.names = ["Aaren", "Martin", "Shannon", "Ariana", "Kai"];
    }

    getNames() {
        return this.names;
    }

    addName(name) {
        this.names.push(name);
    }

    addAsyncName(name) {
        setTimeout(() => {
            this.names.push(name);
        }, 1000);
    }
}

class ListComponent {
    constructor(friendsService) {
        this.friendsService = friendsService;

        this.me = "Alice";
        this.names = this.friendsService.getNames();
    }

    addFriend(name) {
        this.friendsService.addName(name);
    }

    addAsyncFriend(name) {
        this.friendsService.addAsyncName(name);
    }
}

ListComponent.annotations = [
    new Component({
        selector: "my-list",
        viewProviders: [FriendsService],
        template: `
            <p>My name: {{ me }}
            <p>Friends:</p>
            <ul>
            <li *ngFor="let name of names">{{ name }}</li>
            </ul>
            <button (click)="addFriend('Foo')">Add Foo friend</button>
            <button (click)="addAsyncFriend('Bar')">Simulate async update</button>
        `
    })
];

ListComponent.parameters = [FriendsService];

class ListModule {}

ListModule.annotations = [
    new NgModule({
        imports: [BrowserModule],
        declarations: [ListComponent],
        bootstrap: [ListComponent]
    })
];

// hello example

class HelloComponent {
    constructor(http) {
        this.http = http;

        this.greeting = "Hello";
        this.greetingFromJSON = "n.a.";
    }

    ngOnInit() {
        const url = "https://httpbin.org/get?res={%22hello%22:%20%22Hello%20JSON%20world!!!%22}";
        const rx = this.http.get(url);


        rx.subscribe(res => {
            const greetings = JSON.parse(res.args.res);

            this.greetingFromJSON = greetings.hello;
        });
    }
}

HelloComponent.annotations = [
    new Component({
        selector: "my-hello",
        template: "<p>{{ greeting }} world! {{ greetingFromJSON }}</p>"
    })
];

HelloComponent.parameters = [HttpClient];

class HelloModule {}

HelloModule.annotations = [
    new NgModule({
        imports: [BrowserModule, HttpClientModule],
        declarations: [HelloComponent],
        bootstrap: [HelloComponent]
    })
];

// routes

class View1Component {
    constructor() {
        this.viewName = "My View";
    }
}

View1Component.annotations = [
    new Component({
        template: "<p>{{ viewName }} loaded with the router</p>"
    })
];

class MyRoutesComponent {}

MyRoutesComponent.annotations = [
    new Component({
        selector: "my-routes",
        template: "<h2>My routes</h2><router-outlet></router-outlet>"
    })
];

const routing = RouterModule.forRoot([
    { path: "", component: View1Component }
]);

class MyRoutesModule {}

MyRoutesModule.annotations = [
    new NgModule({
        imports: [BrowserModule, routing],
        declarations: [MyRoutesComponent, View1Component],
        bootstrap: [MyRoutesComponent]
    })
];

// boot

platformBrowserDynamic().bootstrapModule(AppModule);
platformBrowserDynamic().bootstrapModule(ListModule);
platformBrowserDynamic().bootstrapModule(HelloModule);
platformBrowserDynamic().bootstrapModule(MyRoutesModule);
<commit_msg>Move metadata to the class as static.<commit_after>import "zone.js/dist/zone";

import { NgModule, Component, VERSION } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { HttpClientModule } from "@angular/common/http";
import { HttpClient } from "@angular/common/http";
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { RouterModule } from "@angular/router";

// simple example

class FooComponent {
    static annotations = [
        new Component({
            selector: "my-app",
            template: "<h1>Angular {{ version }} in ES2015</h1>"
        })
    ];

    constructor() {
        this.version = VERSION.full;
    }
}

class AppModule {
    static annotations = [
        new NgModule({
            imports: [BrowserModule],
            declarations: [FooComponent],
            bootstrap: [FooComponent]
        })
    ];
}

// list example

class FriendsService {
    constructor() {
        this.names = ["Aaren", "Martin", "Shannon", "Ariana", "Kai"];
    }

    getNames() {
        return this.names;
    }

    addName(name) {
        this.names.push(name);
    }

    addAsyncName(name) {
        setTimeout(() => {
            this.names.push(name);
        }, 1000);
    }
}

class ListComponent {
    static annotations = [
        new Component({
            selector: "my-list",
            viewProviders: [FriendsService],
            template: `
                <p>My name: {{ me }}
                <p>Friends:</p>
                <ul>
                <li *ngFor="let name of names">{{ name }}</li>
                </ul>
                <button (click)="addFriend('Foo')">Add Foo friend</button>
                <button (click)="addAsyncFriend('Bar')">Simulate async update</button>
            `
        })
    ];

    static parameters = [FriendsService];

    constructor(friendsService) {
        this.friendsService = friendsService;

        this.me = "Alice";
        this.names = this.friendsService.getNames();
    }

    addFriend(name) {
        this.friendsService.addName(name);
    }

    addAsyncFriend(name) {
        this.friendsService.addAsyncName(name);
    }
}

class ListModule {
    static annotations = [
        new NgModule({
            imports: [BrowserModule],
            declarations: [ListComponent],
            bootstrap: [ListComponent]
        })
    ];
}

// hello example

class HelloComponent {
    static annotations = [
        new Component({
            selector: "my-hello",
            template: "<p>{{ greeting }} world! {{ greetingFromJSON }}</p>"
        })
    ];

    static parameters = [HttpClient];

    constructor(http) {
        this.http = http;

        this.greeting = "Hello";
        this.greetingFromJSON = "n.a.";
    }

    ngOnInit() {
        const url = "https://httpbin.org/get?res={%22hello%22:%20%22Hello%20JSON%20world!!!%22}";
        const rx = this.http.get(url);


        rx.subscribe(res => {
            const greetings = JSON.parse(res.args.res);

            this.greetingFromJSON = greetings.hello;
        });
    }
}

class HelloModule {
    static annotations = [
        new NgModule({
            imports: [BrowserModule, HttpClientModule],
            declarations: [HelloComponent],
            bootstrap: [HelloComponent]
        })
    ];
}

// routes

class View1Component {
    static annotations = [
        new Component({
            template: "<p>{{ viewName }} loaded with the router</p>"
        })
    ];

    constructor() {
        this.viewName = "My View";
    }
}

class MyRoutesComponent {
    static annotations = [
        new Component({
            selector: "my-routes",
            template: "<h2>My routes</h2><router-outlet></router-outlet>"
        })
    ];
}

const routing = RouterModule.forRoot([
    { path: "", component: View1Component }
]);

class MyRoutesModule {
    static annotations = [
        new NgModule({
            imports: [BrowserModule, routing],
            declarations: [MyRoutesComponent, View1Component],
            bootstrap: [MyRoutesComponent]
        })
    ];
}

// boot

platformBrowserDynamic().bootstrapModule(AppModule);
platformBrowserDynamic().bootstrapModule(ListModule);
platformBrowserDynamic().bootstrapModule(HelloModule);
platformBrowserDynamic().bootstrapModule(MyRoutesModule);

{'fraction_non_alphanumeric': 0.1379799173065564, 'fraction_numerical': 0.006969875959834613, 'mean_word_length': 2.3945469125902163, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 49, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '541825', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2418, 'n_words': 479}