Skip to content

Commit a035cce

Browse files
- #6 Support NativeScript (or rather: tns-ios) 3.4
- Webpack update
1 parent 9db77da commit a035cce

11 files changed

Lines changed: 108 additions & 97 deletions

.travis.yml

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,71 @@
1+
android:
2+
components:
3+
- tools
4+
- platform-tools
5+
- build-tools-26.0.1
6+
- android-26
7+
- extra-android-m2repository
8+
- sys-img-armeabi-v7a-android-21
9+
10+
before_cache:
11+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
12+
13+
cache:
14+
directories:
15+
- .nvm
16+
- $HOME/.gradle/caches/
17+
- $HOME/.gradle/wrapper/
18+
19+
install:
20+
- echo no | npm install -g nativescript
21+
- tns usage-reporting disable
22+
- tns error-reporting disable
23+
- npm install
24+
- cd src
25+
- npm run setup
26+
27+
script:
28+
29+
130
matrix:
231
include:
332
- stage: "Lint"
433
language: node_js
534
os: linux
635
node_js: "6"
7-
script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint
36+
script: "npm run ci.tslint"
837
- stage: "WebPack"
938
os: osx
1039
env:
11-
- BuildiOS="11"
12-
- Xcode="9"
40+
- Webpack="iOS"
1341
osx_image: xcode9
14-
language: node_js
42+
language: node_js
1543
node_js: "6"
1644
jdk: oraclejdk8
17-
script: cd demo && npm run build.plugin && npm i && npm run build-ios-bundle
45+
script: cd ../demo && tns build ios --bundle
1846
- language: android
1947
os: linux
2048
env:
21-
- Platform="Android"
49+
- Webpack="Android"
2250
jdk: oraclejdk8
2351
before_install: nvm install 6.10.3
24-
script: cd demo && npm run build.plugin && npm i && npm run build-android-bundle
25-
- stage: "Build and Test"
26-
env:
27-
- BuildAndroid="26"
52+
script: cd ../demo && tns build android --bundle
53+
- stage: "Build"
54+
env:
55+
- BuildAndroid="25"
2856
language: android
2957
os: linux
3058
jdk: oraclejdk8
31-
before_install: nvm install stable
59+
before_install: nvm install 6.10.3
3260
script:
33-
- cd src && npm i && npm run tsc && cd ../demo && tns build android
61+
- cd ../demo && tns build android
3462
- os: osx
3563
env:
3664
- BuildiOS="11"
3765
- Xcode="9"
3866
osx_image: xcode9
39-
language: node_js
40-
node_js: "6"
41-
jdk: oraclejdk8
42-
script:
43-
- cd src && npm i && npm run tsc && cd ../demo && tns build ios
44-
- os: linux
45-
language: android
46-
dist: precise
47-
sudo: required
48-
jdk: oraclejdk8
49-
before_script:
50-
- echo no | android create avd --force -n test -t android-21 -b armeabi-v7a
51-
- emulator -avd test -no-audio -no-window &
52-
- android-wait-for-emulator
53-
before_install:
54-
- nvm install 6
55-
script: cd src && npm run test.android
56-
- os: osx
5767
language: node_js
5868
node_js: "6"
5969
jdk: oraclejdk8
60-
osx_image: xcode9
61-
script: cd src && npm run test.ios
62-
63-
android:
64-
components:
65-
- tools
66-
- platform-tools
67-
- build-tools-26.0.1
68-
- android-26
69-
- extra-android-m2repository
70-
- sys-img-armeabi-v7a-android-21
71-
72-
install:
73-
- echo no | npm install -g nativescript
74-
- tns usage-reporting disable
75-
- tns error-reporting disable
70+
script:
71+
- cd ../demo && tns build ios

demo/app/tests/tests.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
var WebviewUtils = require("nativescript-webview-utils").WebViewUtils;
22

3-
describe("greet function", function () {
3+
describe("addHeaders", function () {
44
it("exists", function () {
55
expect(WebviewUtils.addHeaders).toBeDefined();
66
});
7-
});
7+
});
8+
9+
describe("setUserAgent", function () {
10+
it("exists", function () {
11+
expect(WebviewUtils.setUserAgent).toBeDefined();
12+
});
13+
});
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require("application");
22
if (!global["__snapshot"]) {
3-
/*
4-
In case snapshot generation is enabled these modules will get into the bundle but will not be required/evaluated.
5-
The snapshot webpack plugin will add them to the tns-java-classes.js bundle file. This way, they will be evaluated on app start as early as possible.
6-
*/
3+
// In case snapshot generation is enabled these modules will get into the bundle
4+
// but will not be required/evaluated.
5+
// The snapshot webpack plugin will add them to the tns-java-classes.js bundle file.
6+
// This way, they will be evaluated on app start as early as possible.
77
require("ui/frame");
88
require("ui/frame/activity");
99
}

demo/app/vendor-platform.ios.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// There is a bug in angular: https://github.com/angular/angular-cli/pull/8589/files
2+
// Legendary stuff, its webpack plugin pretty much doesn't work with empty TypeScript files in v1.8.3
3+
void 0;

demo/app/vendor.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// Snapshot the ~/app.css and the theme
2+
const application = require("application");
3+
require("ui/styling/style-scope");
4+
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
5+
global.registerWebpackModules(appCssContext);
6+
application.loadAppCss();
7+
18
require("./vendor-platform");
29

310
require("bundle-entry-points");

demo/package.json

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,23 @@
2222
"copy-webpack-plugin": "~4.0.1",
2323
"extract-text-webpack-plugin": "~3.0.0",
2424
"filewalker": "0.1.2",
25-
"jasmine-core": "^2.5.2",
26-
"karma": "^1.3.0",
27-
"karma-jasmine": "^1.0.2",
25+
"jasmine-core": "^2.8.0",
26+
"karma": "^1.7.1",
27+
"karma-jasmine": "^1.1.0",
2828
"karma-nativescript-launcher": "^0.4.0",
2929
"lazy": "1.0.11",
3030
"nativescript-css-loader": "~0.26.0",
3131
"nativescript-dev-typescript": "libs",
32-
"nativescript-dev-webpack": "^0.7.3",
32+
"nativescript-dev-webpack": "~0.9.0",
3333
"raw-loader": "~0.5.1",
3434
"resolve-url-loader": "~2.1.0",
3535
"tns-platform-declarations": "~3.4.0",
36-
"tslint": "~5.4.3",
3736
"typescript": "~2.6.0",
38-
"webpack": "~3.2.0",
37+
"webpack": "~3.8.1",
3938
"webpack-bundle-analyzer": "^2.8.2",
40-
"webpack-sources": "~1.0.1"
41-
},
42-
"scripts": {
43-
"build.plugin": "cd ../src && npm run build",
44-
"ci.tslint": "npm i && tslint --config '../tslint.json' 'app/**/*.ts' --exclude '**/node_modules/**'",
45-
"ns-bundle": "ns-bundle",
46-
"publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
47-
"generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
48-
"start-android-bundle": "npm run ns-bundle --android --run-app",
49-
"start-ios-bundle": "npm run ns-bundle --ios --run-app",
50-
"build-android-bundle": "npm run ns-bundle --android --build-app",
51-
"build-ios-bundle": "npm run ns-bundle --ios --build-app"
39+
"webpack-sources": "~1.0.1",
40+
"css-loader": "~0.28.7",
41+
"nativescript-worker-loader": "~0.8.1",
42+
"uglifyjs-webpack-plugin": "~1.1.6"
5243
}
5344
}

demo/references.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
2-
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
1+
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" /> Needed for autocompletion and compilation.

demo/tsconfig.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"experimentalDecorators": true,
1010
"lib": [
1111
"es6",
12-
"dom"
12+
"dom",
13+
"es2015.iterable"
1314
],
1415
"pretty": true,
1516
"allowUnreachableCode": false,
@@ -20,12 +21,11 @@
2021
"noImplicitReturns": true,
2122
"noImplicitUseStrict": false,
2223
"noFallthroughCasesInSwitch": true,
23-
"baseUrl": ".",
24-
"paths": {
25-
"*": [
26-
"./node_modules/*"
27-
]
28-
}
24+
"typeRoots": [
25+
"./node_modules/@types",
26+
"./node_modules"
27+
],
28+
"types": []
2929
},
3030
"exclude": [
3131
"node_modules",

src/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-webview-utils",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Add custom headers to a NativeScript WebView. Perhaps more utils later.",
55
"main": "webview-utils",
66
"typings": "index.d.ts",
@@ -11,20 +11,22 @@
1111
}
1212
},
1313
"scripts": {
14-
"tsc": "tsc -skipLibCheck",
1514
"build": "npm i && tsc",
16-
"postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src && npm run plugin.link",
17-
"test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch",
18-
"test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch",
19-
"tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"",
20-
"plugin.link": "npm link && cd ../demo && npm link nativescript-webview-utils && cd ../src",
21-
"plugin.tscwatch": "npm run tsc -- -w",
22-
"demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles",
23-
"demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles",
24-
"demo.reset": "cd ../demo && rimraf platforms",
25-
"plugin.prepare": "npm run tsc && cd ../demo && tns plugin remove nativescript-webview-utils && tns plugin add ../src",
26-
"clean": "cd ../demo && rimraf hooks node_modules platforms && cd ../src && rimraf node_modules && npm run plugin.link",
27-
"ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**'"
15+
"demo.ios": "npm run preparedemo && cd ../demo && tns run ios --emulator",
16+
"demo.ios.device": "npm run preparedemo && cd ../demo && tns platform remove ios && tns run ios",
17+
"demo.android": "npm run preparedemo && cd ../demo && tns platform remove android && tns run android --justlaunch",
18+
"test": "npm run tslint && npm run tslint.demo && cd ../demo && tns build ios && tns build android",
19+
"test.ios": "cd ../demo && tns platform remove ios && tns test ios --emulator",
20+
"test.ios.device": "cd ../demo && tns platform remove ios && tns test ios",
21+
"test.android": "cd ../demo && tns platform remove android && tns test android --justlaunch",
22+
"preparedemo": "npm run build && cd ../demo && tns plugin remove nativescript-webview-utils && tns plugin add ../src && tns install",
23+
"setup": "npm run build && cd ../demo && npm i",
24+
"setupandinstall": "npm i && cd ../demo && npm i && cd ../src && npm run build && cd ../demo && tns plugin add ../src && cd ../src",
25+
"tslint": "tslint --config '../tslint.json' '*.ts' --exclude '**/node_modules/**'",
26+
"tslint.demo": "tslint --config '../tslint.json' '../demo/app/*.ts' --exclude '**/node_modules/**'",
27+
"ci.tslint": "npm run tslint && npm run tslint.demo",
28+
"prepublishOnly": "npm run build",
29+
"development.setup": "npm run setup && npm link && cd ../demo && npm link nativescript-webview-utils && cd ../src"
2830
},
2931
"keywords": [
3032
"ecosystem:NativeScript",
@@ -50,8 +52,6 @@
5052
"tns-core-modules": "~3.4.0",
5153
"tns-platform-declarations": "~3.4.0",
5254
"typescript": "~2.6.0",
53-
"prompt": "^1.0.0",
54-
"rimraf": "^2.5.0",
5555
"tslint": "^5.0.0"
5656
},
5757
"dependencies": {},

src/tsconfig.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@
2020
"noImplicitAny": false,
2121
"noImplicitReturns": true,
2222
"noImplicitUseStrict": false,
23-
"noFallthroughCasesInSwitch": true
23+
"noFallthroughCasesInSwitch": true,
24+
"typeRoots": [
25+
"./node_modules/@types",
26+
"./node_modules"
27+
],
28+
"types": [
29+
]
2430
},
2531
"exclude": [
32+
"demo",
2633
"node_modules"
2734
],
2835
"compileOnSave": false

0 commit comments

Comments
 (0)