Skip to content

feat: make the plugin ready for AoT compilation #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#JavaScript files
# JavaScript files
/**/*.js
/**/*.js.map

# ngc metadata
/**/*.metadata.json

# built application files
*.apk
Expand Down
5 changes: 1 addition & 4 deletions angular/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
/**
* Directives identifying the RadCalendar.
*/
export const NSFRESCO_DIRECTIVES;
export * from "./nativescript-fresco.module";
1 change: 1 addition & 0 deletions angular/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./nativescript-fresco.module";
4 changes: 4 additions & 0 deletions angular/nativescript-fresco-directives.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare class FrescoDraweeDirective {
constructor();
}
export declare const NSFRESCO_DIRECTIVES: typeof FrescoDraweeDirective[];
7 changes: 1 addition & 6 deletions angular/nativescript-fresco-directives.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import * as elementRegistryModule from "nativescript-angular/element-registry";
import { Directive } from '@angular/core';

import { FrescoDrawee } from "nativescript-fresco";

@Directive({
selector: "FrescoDrawee"
})
class FrescoDraweeDirective {
export class FrescoDraweeDirective {
constructor() { }
}
export const NSFRESCO_DIRECTIVES = [ FrescoDraweeDirective ];

elementRegistryModule.registerElement("FrescoDrawee", () => FrescoDrawee);
2 changes: 2 additions & 0 deletions angular/nativescript-fresco.module.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare class TNSFrescoModule {
}
13 changes: 13 additions & 0 deletions angular/nativescript-fresco.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NgModule } from "@angular/core";
import { registerElement } from "nativescript-angular/element-registry";

import { NSFRESCO_DIRECTIVES } from "./nativescript-fresco-directives";
import { FrescoDrawee } from "../";

@NgModule({
declarations: [NSFRESCO_DIRECTIVES],
exports: [NSFRESCO_DIRECTIVES],
})
export class TNSFrescoModule { }

registerElement("FrescoDrawee", () => FrescoDrawee);
6 changes: 3 additions & 3 deletions angular/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "nativescript-fresco-directives",
"main": "nativescript-fresco-directives.js"
}
"name": "nativescript-fresco-module",
"main": "index.js"
}
21 changes: 11 additions & 10 deletions demo/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { NativeScriptModule, platformNativeScriptDynamic } from "nativescript-angular/platform";
import { AppComponent } from "./components/app.component";
import { NSFRESCO_DIRECTIVES } from 'nativescript-fresco/angular';
import { FrescoDrawee } from 'nativescript-fresco';
import { NativeScriptModule } from "nativescript-angular/platform";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
import { NgModule, OnInit } from "@angular/core";
import { NgModule, OnInit, NO_ERRORS_SCHEMA } from "@angular/core";
import { AppComponent } from "./components/app.component";

import { TNSFrescoModule } from "nativescript-fresco/angular";
import * as frescoModule from "nativescript-fresco";
import * as applicationModule from "application";

Expand All @@ -20,19 +20,20 @@ if (applicationModule.android) {
AppComponent
],
declarations: [
NSFRESCO_DIRECTIVES,
AppComponent
],
imports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptRouterModule
NativeScriptRouterModule,
TNSFrescoModule
],
exports: [
NativeScriptModule,
NativeScriptRouterModule
],
schemas: [
NO_ERRORS_SCHEMA
]
})
class AppModule { }

platformNativeScriptDynamic().bootstrapModule(AppModule);
export class AppModule { }
1 change: 0 additions & 1 deletion demo/app/components/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit, ViewChild, ElementRef } from "@angular/core";
import { FrescoDraweeDirective } from "nativescript-fresco/angular";

@Component({
selector: "my-app",
Expand Down
6 changes: 6 additions & 0 deletions demo/app/main.aot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScript } from "nativescript-angular/platform-static";

import { AppModuleNgFactory } from "./app.module.ngfactory";

platformNativeScript().bootstrapModuleFactory(AppModuleNgFactory);
6 changes: 6 additions & 0 deletions demo/app/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScriptDynamic } from "nativescript-angular/platform";

import { AppModule } from "./app.module";

platformNativeScriptDynamic().bootstrapModule(AppModule);
2 changes: 1 addition & 1 deletion demo/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fresco-sample",
"main": "app.js",
"main": "main",
"version": "1.0.0",
"author": {
"name": "Vladimir Amiorkov",
Expand Down
25 changes: 25 additions & 0 deletions demo/app/vendor-platform.android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//Resolve JavaScript classes that extend a Java class, and need to resolve
//their JavaScript module from a bundled script. For example:
//NativeScriptApplication, NativeScriptActivity, etc.
//
//This module gets bundled together with the rest of the app code and the
//`require` calls get resolved to the correct bundling import call.
//
//At runtime the module gets loaded *before* the rest of the app code, so code
//placed here needs to be careful about its dependencies.

require("application");
require("ui/frame");
require("ui/frame/activity");

if (global.TNS_WEBPACK) {
global.__requireOverride = function (name, dir) {
if (name === "./tns_modules/application/application.js") {
return require("application");
} else if (name === "./tns_modules/ui/frame/frame.js") {
return require("ui/frame");
} else if (name === "./tns_modules/ui/frame/activity.js") {
return require("ui/frame/activity");
}
};
}
Empty file added demo/app/vendor-platform.ios.ts
Empty file.
13 changes: 13 additions & 0 deletions demo/app/vendor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require("./vendor-platform");

require('reflect-metadata');
require('@angular/platform-browser');
require('@angular/core');
require('@angular/common');
require('@angular/forms');
require('@angular/http');
require('@angular/router');

require('nativescript-angular/platform-static');
require('nativescript-angular/forms');
require('nativescript-angular/router');
52 changes: 40 additions & 12 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@
}
},
"dependencies": {
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/core": "2.3.1",
"@angular/forms": "2.3.1",
"@angular/http": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/router": "3.3.1",
"nativescript-angular": "1.3.0",
"nativescript-dev-webpack": "^0.3.1",
"nativescript-fresco": "file:..",
"nativescript-telerik-ui": "1.4.1",
"@angular/common": "2.1.2",
"@angular/compiler": "2.1.2",
"@angular/core": "2.1.2",
"@angular/forms": "2.1.2",
"@angular/http": "2.1.2",
"@angular/platform-browser": "2.1.2",
"@angular/platform-browser-dynamic": "2.1.2",
"@angular/router": "3.1.2",
"nativescript-angular": "1.1.2",
"nativescript-theme-core": "^0.1.3",
"reflect-metadata": "~0.1.8",
"rxjs": "5.0.0-beta.12",
"rxjs": "5.0.0-rc.4",
"tns-core-modules": "2.4.0"
},
"devDependencies": {
Expand All @@ -34,6 +35,33 @@
"babylon": "6.8.4",
"lazy": "1.0.11",
"nativescript-dev-typescript": "^0.3.1",
"typescript": "2.0.3"
"typescript": "~2.0.3",
"zone.js": "~0.7.2",
"webpack": "~2.1.0-beta.27",
"webpack-sources": "~0.1.3",
"copy-webpack-plugin": "~3.0.1",
"raw-loader": "~0.5.1",
"nativescript-css-loader": "~0.26.0",
"resolve-url-loader": "~1.6.0",
"extract-text-webpack-plugin": "~2.0.0-beta.4",
"@angular/compiler-cli": "2.3.1",
"@ngtools/webpack": "1.2.1",
"htmlparser2": "^3.9.2"
},
"scripts": {
"clean-android": "tns clean-app android",
"clean-ios": "tns clean-app ios",
"prewebpack-android": "npm run clean-android",
"prewebpack-ios": "npm run clean-ios",
"webpack-android": "webpack --config=webpack.android.js --progress",
"webpack-ios": "webpack --config=webpack.ios.js --progress",
"prestart-android-bundle": "npm run webpack-android",
"prestart-ios-bundle": "npm run webpack-ios",
"start-android-bundle": "tns run android --bundle --disable-npm-install",
"start-ios-bundle": "tns run ios --bundle --disable-npm-install",
"prebuild-android-bundle": "npm run webpack-android",
"prebuild-ios-bundle": "npm run webpack-ios",
"build-android-bundle": "tns build android --bundle --disable-npm-install",
"build-ios-bundle": "tns build ios --bundle --disable-npm-install"
}
}
}
22 changes: 22 additions & 0 deletions demo/tsconfig.aot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"types": []
},
"exclude": [
"node_modules",
"platforms"
],
"angularCompilerOptions": {
"skipMetadataEmit": true,
"genDir": "./"
}
}
5 changes: 3 additions & 2 deletions demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
],
"exclude": [
"node_modules",
"platforms"
"platforms",
"**/*.aot.ts"
]
}
}
113 changes: 113 additions & 0 deletions nativescript-fresco-common.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/// <reference path="references.d.ts" />
import viewModule = require("ui/core/view");
import observableModule = require("data/observable");
export declare module ScaleType {
var Center: string;
var CenterCrop: string;
var CenterInside: string;
var FitCenter: string;
var FitEnd: string;
var FitStart: string;
var FitXY: string;
var FocusCrop: string;
}
export interface IAnimatedImage {
start(): void;
stop(): void;
isRunning(): boolean;
}
export interface IImageInfo {
getHeight(): number;
getWidth(): number;
}
export interface IError {
getMessage(): string;
getErrorType(): string;
toString(): string;
}
export declare class EventData implements observableModule.EventData {
private _eventName;
private _object;
eventName: string;
object: any;
}
export declare class FrescoDrawee extends viewModule.View {
static finalImageSetEvent: string;
static failureEvent: string;
static intermediateImageFailedEvent: string;
static intermediateImageSetEvent: string;
static releaseEvent: string;
static submitEvent: string;
private static imageUriProperty;
private static placeholderImageUriProperty;
private static failureImageUriProperty;
private static actualImageScaleTypeProperty;
private static fadeDurationProperty;
private static backgroundUriProperty;
private static progressiveRenderingEnabledProperty;
private static showProgressBarProperty;
private static progressBarColorProperty;
private static roundAsCircleProperty;
private static roundTopLeftProperty;
private static roundTopRightProperty;
private static roundBottomLeftroperty;
private static roundBottomRightProperty;
private static roundedCornerRadiusProperty;
private static autoPlayAnimationsProperty;
private static tapToRetryEnabledProperty;
private static aspectRatioProperty;
imageUri: string;
placeholderImageUri: string;
failureImageUri: string;
actualImageScaleType: string;
fadeDuration: number;
backgroundUri: string;
progressiveRenderingEnabled: boolean;
showProgressBar: boolean;
progressBarColor: string;
roundAsCircle: boolean;
roundBottomRight: boolean;
roundTopLeft: boolean;
roundTopRight: boolean;
roundBottomLeft: boolean;
roundedCornerRadius: number;
autoPlayAnimations: boolean;
tapToRetryEnabled: boolean;
aspectRatio: number;
private static onImageUriPropertyChanged(args);
private static onPlaceholderImageUriPropertyChanged(args);
private static onFailureImageUriPropertyChanged(args);
private static onActualImageScaleTypePropertyChanged(args);
private static onFadeDurationPropertyChanged(args);
private static onBackgroundUriPropertyChanged(args);
private static onProgressiveRenderingEnabledPropertyChanged(args);
private static onShowProgressBarPropertyChanged(args);
private static onProgressBarColorPropertyChanged(args);
private static onRoundAsCirclePropertyChanged(args);
private static onRoundTopLeftPropertyChanged(args);
private static onRoundTopRightPropertyChanged(args);
private static onRoundBottomLeftPropertyChanged(args);
private static onRoundBottomRightPropertyChanged(args);
private static onRoundedCornerRadiusPropertyChanged(args);
private static onAutoPlayAnimationsPropertyChanged(args);
private static onTapToRetryEnabledPropertyChanged(args);
private static onAspectRatioPropertyChanged(args);
protected onImageUriChanged(args: any): void;
protected onPlaceholderImageUriChanged(args: any): void;
protected onFailureImageUriChanged(args: any): void;
protected onActualImageScaleTypeChanged(args: any): void;
protected onFadeDurationChanged(args: any): void;
protected onBackgroundUriChanged(args: any): void;
protected onProgressiveRenderingEnabledChanged(args: any): void;
protected onShowProgressBarChanged(args: any): void;
protected onProgressBarColorChanged(args: any): void;
protected onRoundAsCircleChanged(args: any): void;
protected onRoundTopLeftChanged(args: any): void;
protected onRoundTopRightChanged(args: any): void;
protected onRoundBottomLeftChanged(args: any): void;
protected onRoundBottomRightChanged(args: any): void;
protected onRoundedCornerRadiusChanged(args: any): void;
protected onAutoPlayAnimationsPChanged(args: any): void;
protected onTapToRetryEnabledChanged(args: any): void;
protected onAspectRatioChanged(args: any): void;
}
Loading