Skip to content

Commit c615811

Browse files
committed
Merge branch 'release/3.0.0-beta3'
2 parents 7d3bcd1 + 9ec9bc9 commit c615811

File tree

8 files changed

+153
-124
lines changed

8 files changed

+153
-124
lines changed

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ node_modules
3030
www/
3131
config.json
3232
dist/
33+
aot/

‎CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<a name="3.0.0-beta3"></a>
2+
### 3.0.0-beta3 (2017-01-22)
3+
4+
Add AOT support <https://github.com/shprink/wp-api-angular/issues/19>
5+
16
<a name="3.0.0-beta2"></a>
27
### 3.0.0-beta2 (2016-11-14)
38

‎README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
wp-api-angular
1+
<p align="center">
2+
<h1 align="center">wp-api-angular</h1>
3+
<p align="center">Angular >=2 services for WordPress >= 4.7 Rest API</p>
4+
</p>
5+
26
================
37

48
[![Join the chat at https://gitter.im/shprink/wp-api-angular](https://badges.gitter.im/shprink/wp-api-angular.svg)](https://gitter.im/shprink/wp-api-angular?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -12,6 +16,7 @@ If you want to use AngularJS v1, here is the latest version: [v2.0.0-rc3](https:
1216
## Installation
1317

1418
```shell
19+
npm install -g typings
1520
npm install wp-api-angular
1621
```
1722

@@ -216,8 +221,8 @@ cp config.dist.json config.json
216221
# and run watch to build on the lib files changes
217222
npm run watch
218223

219-
# in the other terminal run following to build the test page and the doc
220-
npm run devserver
224+
# in the other terminal run following to build the test page
225+
npm start
221226
```
222227
223228
Open ```http://localhost:8080```

‎package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "wp-api-angular",
3-
"version": "3.0.0-beta2",
3+
"version": "3.0.0-beta3",
44
"description": "WordPress WP-API v2 client for Angular2",
55
"main": "wp-api-angular.js",
66
"typings": "wp-api-angular.d.ts",
77
"scripts": {
88
"start": "webpack-dev-server --port 8080 --json --progress --config webpack.config.js",
99
"prebuild": "rm -rf dist",
10-
"build": "tsc && npm run dumpdev && npm run dumpprod",
10+
"build": "node ./node_modules/@angular/compiler-cli/src/main.js && npm run dumpdev && npm run dumpprod",
1111
"postbuild": "cp package.json README.md dist/",
12-
"watch": "rm -rf dist && tsc -w",
12+
"watch": "rm -rf dist && node ./node_modules/@angular/compiler-cli/src/main.js",
1313
"publish": "npm run build && npm publish dist",
1414
"dumpdev": "ENV=dev webpack --progress --colors --config webpack.config.dist.js -d",
1515
"dumpprod": "ENV=prod webpack --progress --colors --config webpack.config.dist.js -p",
@@ -37,11 +37,12 @@
3737
"dependencies": {
3838
"@angular/common": "^2.0.0",
3939
"@angular/compiler": "^2.0.0",
40+
"@angular/compiler-cli": "^2.4.4",
4041
"@angular/core": "^2.0.0",
4142
"@angular/http": "^2.1.2",
4243
"@angular/platform-browser": "^2.0.0",
4344
"@angular/platform-browser-dynamic": "^2.0.0",
44-
"rxjs": "5.0.0-beta.12"
45+
"rxjs": "^5.0.1"
4546
},
4647
"devDependencies": {
4748
"babel-core": "^6.10.4",
@@ -52,7 +53,7 @@
5253
"path": "^0.4.9",
5354
"reflect-metadata": "^0.1.3",
5455
"ts-loader": "0.8.1",
55-
"typescript": "~1.8.10",
56+
"typescript": "^2.1.5",
5657
"util": "^0.10.3",
5758
"webpack": "~1.13.1",
5859
"webpack-dev-server": "~1.14.1",

‎src/Custom.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Injectable } from '@angular/core';
2+
import { Http } from '@angular/http';
23

34
// Need to import interfaces dependencies
45
// Bug TypeScript https://github.com/Microsoft/TypeScript/issues/5938
@@ -7,6 +8,7 @@ import { RequestOptionsArgs } from '@angular/http/src/interfaces';
78
import { Response } from '@angular/http/src/static_response';
89

910
import { WpApiParent } from './Parent';
11+
import { WpApiAppConfig } from './wp-api-angular';
1012

1113
export interface IWpApiCustom {
1214
getList(options?: RequestOptionsArgs): Observable<Response>;
@@ -16,18 +18,11 @@ export interface IWpApiCustom {
1618
delete(customId: number, options?: RequestOptionsArgs): Observable<Response>;
1719
}
1820

19-
@Injectable()
20-
export class WpApiCustom extends WpApiParent {
21-
getInstance(entityName = null) {
22-
if (!entityName) {
23-
throw new Error(`getInstance needs an entity name`);
24-
}
25-
return new Custom(this.config, this.http, entityName);
26-
}
27-
}
28-
2921
export class Custom extends WpApiParent implements IWpApiCustom {
30-
constructor(config, http, private entityName: string) {
22+
constructor(
23+
public config: WpApiAppConfig,
24+
public http: Http,
25+
public entityName: string) {
3126
super(config, http);
3227
}
3328
getList(options = {}) {
@@ -46,3 +41,14 @@ export class Custom extends WpApiParent implements IWpApiCustom {
4641
return this.httpDelete(`/${this.entityName}/${customId}`, options)
4742
}
4843
}
44+
45+
46+
@Injectable()
47+
export class WpApiCustom extends WpApiParent {
48+
getInstance(entityName = '') {
49+
if (typeof entityName !== 'string') {
50+
throw new Error(`getInstance needs an entity name`);
51+
}
52+
return new Custom(this.config, this.http, entityName);
53+
}
54+
}

‎src/wp-api-angular.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export interface WpApiAppConfig {
3939
@NgModule({
4040
imports: [
4141
HttpModule
42+
],
43+
exports: [
44+
HttpModule
4245
]
4346
})
4447
export class WpApiModule {

‎tsconfig.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
4-
"module": "commonjs",
5-
"emitDecoratorMetadata": true,
63
"experimentalDecorators": true,
4+
"emitDecoratorMetadata": true,
5+
"module": "commonjs",
6+
"target": "es5",
77
"noImplicitAny": false,
8-
"rootDir": "src",
98
"outDir": "dist",
9+
"rootDir": "src",
1010
"sourceMap": true,
1111
"inlineSources": true,
1212
"declaration": true,
13-
"removeComments": true
13+
"removeComments": true,
14+
"skipLibCheck": true,
15+
"moduleResolution": "node"
1416
},
1517
"files": [
16-
"./src/wp-api-angular.ts",
17-
"./typings/overwrite.d.ts",
18-
"./typings/index.d.ts"
19-
],
20-
"exclude": [
21-
"node_modules"
18+
"./src/wp-api-angular.ts"
2219
],
23-
"compileOnSave": false,
24-
"atom": {
25-
"rewriteTsconfig": false
20+
"angularCompilerOptions": {
21+
"skipTemplateCodegen": true,
22+
"strictMetadataEmit": true,
23+
"debug": true
2624
}
2725
}

0 commit comments

Comments
 (0)