├── .gitignore
├── README.md
├── app
├── App_Resources
│ ├── Android
│ │ ├── AndroidManifest.xml
│ │ ├── app.gradle
│ │ ├── drawable-hdpi
│ │ │ ├── background.png
│ │ │ ├── icon.png
│ │ │ └── logo.png
│ │ ├── drawable-ldpi
│ │ │ ├── background.png
│ │ │ ├── icon.png
│ │ │ └── logo.png
│ │ ├── drawable-mdpi
│ │ │ ├── background.png
│ │ │ ├── icon.png
│ │ │ └── logo.png
│ │ ├── drawable-nodpi
│ │ │ └── splash_screen.xml
│ │ ├── drawable-xhdpi
│ │ │ ├── background.png
│ │ │ ├── icon.png
│ │ │ └── logo.png
│ │ ├── drawable-xxhdpi
│ │ │ ├── background.png
│ │ │ ├── icon.png
│ │ │ └── logo.png
│ │ ├── drawable-xxxhdpi
│ │ │ ├── background.png
│ │ │ ├── icon.png
│ │ │ └── logo.png
│ │ ├── values-v21
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ └── values
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ └── iOS
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── icon-29.png
│ │ │ ├── icon-29@2x.png
│ │ │ ├── icon-29@3x.png
│ │ │ ├── icon-40.png
│ │ │ ├── icon-40@2x.png
│ │ │ ├── icon-40@3x.png
│ │ │ ├── icon-50.png
│ │ │ ├── icon-50@2x.png
│ │ │ ├── icon-57.png
│ │ │ ├── icon-57@2x.png
│ │ │ ├── icon-60@2x.png
│ │ │ ├── icon-60@3x.png
│ │ │ ├── icon-72.png
│ │ │ ├── icon-72@2x.png
│ │ │ ├── icon-76.png
│ │ │ ├── icon-76@2x.png
│ │ │ └── icon-83.5@2x.png
│ │ ├── Contents.json
│ │ ├── LaunchImage.launchimage
│ │ │ ├── Contents.json
│ │ │ ├── Default-568h@2x.png
│ │ │ ├── Default-667h@2x.png
│ │ │ ├── Default-736h@3x.png
│ │ │ ├── Default-Landscape.png
│ │ │ ├── Default-Landscape@2x.png
│ │ │ ├── Default-Landscape@3x.png
│ │ │ ├── Default-Portrait.png
│ │ │ ├── Default-Portrait@2x.png
│ │ │ ├── Default.png
│ │ │ └── Default@2x.png
│ │ ├── LaunchScreen.AspectFill.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchScreen-AspectFill.png
│ │ │ └── LaunchScreen-AspectFill@2x.png
│ │ └── LaunchScreen.Center.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchScreen-Center.png
│ │ │ └── LaunchScreen-Center@2x.png
│ │ ├── Info.plist
│ │ ├── LaunchScreen.storyboard
│ │ └── build.xcconfig
├── activity_indicator.png
├── app.css
├── app.js
├── grayscale-algo.android.js
├── grayscale-algo.ios.js
├── main-page.js
├── main-page.xml
├── main-view-model.js
├── package.json
├── references.d.ts
├── workers
│ └── grayscaler.js
└── zenyatta.jpg
├── hooks
├── after-prepare
│ └── nativescript-dev-webpack.js
└── before-prepareJSApp
│ └── nativescript-dev-webpack.js
├── package.json
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .vscode
3 | platforms
4 | hooks
5 | lib
6 |
7 | report
8 | package-lock.json
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Workers Sample App
2 |
3 | Sample app demonstrating the Workers API in NativeScript. Press the Animate button to start a never ending animation. Press the Process button to trigger the creation of a new worker that performs relatively heavy image processing operation on a background thread. After the operation finishes its execution the original image on the screen is replaced by the black and white version of the image produced by the worker thread. Meanwhile the animation happening on the main thread should not be affected by the background image processing.
--------------------------------------------------------------------------------
/app/App_Resources/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/App_Resources/Android/app.gradle:
--------------------------------------------------------------------------------
1 | // Add your native dependencies here:
2 |
3 | // Uncomment to add recyclerview-v7 dependency
4 | //dependencies {
5 | // compile 'com.android.support:recyclerview-v7:+'
6 | //}
7 |
8 | android {
9 | defaultConfig {
10 | generatedDensities = []
11 | applicationId = "org.nativescript.grayscale"
12 | }
13 | aaptOptions {
14 | additionalParameters "--no-version-vectors"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-hdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-hdpi/background.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-hdpi/logo.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-ldpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-ldpi/background.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-ldpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-ldpi/logo.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-mdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-mdpi/background.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-mdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-mdpi/logo.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-nodpi/splash_screen.xml:
--------------------------------------------------------------------------------
1 |
2 | -
3 |
4 |
5 | -
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xhdpi/background.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xxhdpi/background.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xxhdpi/logo.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xxxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xxxhdpi/background.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xxxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xxxhdpi/icon.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/drawable-xxxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/Android/drawable-xxxhdpi/logo.png
--------------------------------------------------------------------------------
/app/App_Resources/Android/values-v21/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3d5afe
4 |
--------------------------------------------------------------------------------
/app/App_Resources/Android/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
14 |
15 |
16 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/app/App_Resources/Android/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F5F5F5
4 | #757575
5 | #33B5E5
6 | #272734
7 |
--------------------------------------------------------------------------------
/app/App_Resources/Android/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
18 |
19 |
21 |
22 |
23 |
31 |
32 |
34 |
35 |
36 |
42 |
43 |
45 |
46 |
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "29x29",
5 | "idiom" : "iphone",
6 | "filename" : "icon-29.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "29x29",
11 | "idiom" : "iphone",
12 | "filename" : "icon-29@2x.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "icon-29@3x.png",
19 | "scale" : "3x"
20 | },
21 | {
22 | "size" : "40x40",
23 | "idiom" : "iphone",
24 | "filename" : "icon-40@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "40x40",
29 | "idiom" : "iphone",
30 | "filename" : "icon-40@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "57x57",
35 | "idiom" : "iphone",
36 | "filename" : "icon-57.png",
37 | "scale" : "1x"
38 | },
39 | {
40 | "size" : "57x57",
41 | "idiom" : "iphone",
42 | "filename" : "icon-57@2x.png",
43 | "scale" : "2x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "icon-60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "icon-60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "29x29",
59 | "idiom" : "ipad",
60 | "filename" : "icon-29.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "29x29",
65 | "idiom" : "ipad",
66 | "filename" : "icon-29@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "40x40",
71 | "idiom" : "ipad",
72 | "filename" : "icon-40.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "40x40",
77 | "idiom" : "ipad",
78 | "filename" : "icon-40@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "50x50",
83 | "idiom" : "ipad",
84 | "filename" : "icon-50.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "50x50",
89 | "idiom" : "ipad",
90 | "filename" : "icon-50@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "72x72",
95 | "idiom" : "ipad",
96 | "filename" : "icon-72.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "72x72",
101 | "idiom" : "ipad",
102 | "filename" : "icon-72@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "76x76",
107 | "idiom" : "ipad",
108 | "filename" : "icon-76.png",
109 | "scale" : "1x"
110 | },
111 | {
112 | "size" : "76x76",
113 | "idiom" : "ipad",
114 | "filename" : "icon-76@2x.png",
115 | "scale" : "2x"
116 | },
117 | {
118 | "size" : "83.5x83.5",
119 | "idiom" : "ipad",
120 | "filename" : "icon-83.5@2x.png",
121 | "scale" : "2x"
122 | }
123 | ],
124 | "info" : {
125 | "version" : 1,
126 | "author" : "xcode"
127 | }
128 | }
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "extent" : "full-screen",
5 | "idiom" : "iphone",
6 | "subtype" : "736h",
7 | "filename" : "Default-736h@3x.png",
8 | "minimum-system-version" : "8.0",
9 | "orientation" : "portrait",
10 | "scale" : "3x"
11 | },
12 | {
13 | "extent" : "full-screen",
14 | "idiom" : "iphone",
15 | "subtype" : "736h",
16 | "filename" : "Default-Landscape@3x.png",
17 | "minimum-system-version" : "8.0",
18 | "orientation" : "landscape",
19 | "scale" : "3x"
20 | },
21 | {
22 | "extent" : "full-screen",
23 | "idiom" : "iphone",
24 | "subtype" : "667h",
25 | "filename" : "Default-667h@2x.png",
26 | "minimum-system-version" : "8.0",
27 | "orientation" : "portrait",
28 | "scale" : "2x"
29 | },
30 | {
31 | "orientation" : "portrait",
32 | "idiom" : "iphone",
33 | "filename" : "Default@2x.png",
34 | "extent" : "full-screen",
35 | "minimum-system-version" : "7.0",
36 | "scale" : "2x"
37 | },
38 | {
39 | "extent" : "full-screen",
40 | "idiom" : "iphone",
41 | "subtype" : "retina4",
42 | "filename" : "Default-568h@2x.png",
43 | "minimum-system-version" : "7.0",
44 | "orientation" : "portrait",
45 | "scale" : "2x"
46 | },
47 | {
48 | "orientation" : "portrait",
49 | "idiom" : "ipad",
50 | "filename" : "Default-Portrait.png",
51 | "extent" : "full-screen",
52 | "minimum-system-version" : "7.0",
53 | "scale" : "1x"
54 | },
55 | {
56 | "orientation" : "landscape",
57 | "idiom" : "ipad",
58 | "filename" : "Default-Landscape.png",
59 | "extent" : "full-screen",
60 | "minimum-system-version" : "7.0",
61 | "scale" : "1x"
62 | },
63 | {
64 | "orientation" : "portrait",
65 | "idiom" : "ipad",
66 | "filename" : "Default-Portrait@2x.png",
67 | "extent" : "full-screen",
68 | "minimum-system-version" : "7.0",
69 | "scale" : "2x"
70 | },
71 | {
72 | "orientation" : "landscape",
73 | "idiom" : "ipad",
74 | "filename" : "Default-Landscape@2x.png",
75 | "extent" : "full-screen",
76 | "minimum-system-version" : "7.0",
77 | "scale" : "2x"
78 | },
79 | {
80 | "orientation" : "portrait",
81 | "idiom" : "iphone",
82 | "filename" : "Default.png",
83 | "extent" : "full-screen",
84 | "scale" : "1x"
85 | },
86 | {
87 | "orientation" : "portrait",
88 | "idiom" : "iphone",
89 | "filename" : "Default@2x.png",
90 | "extent" : "full-screen",
91 | "scale" : "2x"
92 | },
93 | {
94 | "orientation" : "portrait",
95 | "idiom" : "iphone",
96 | "filename" : "Default-568h@2x.png",
97 | "extent" : "full-screen",
98 | "subtype" : "retina4",
99 | "scale" : "2x"
100 | },
101 | {
102 | "orientation" : "portrait",
103 | "idiom" : "ipad",
104 | "extent" : "to-status-bar",
105 | "scale" : "1x"
106 | },
107 | {
108 | "orientation" : "portrait",
109 | "idiom" : "ipad",
110 | "filename" : "Default-Portrait.png",
111 | "extent" : "full-screen",
112 | "scale" : "1x"
113 | },
114 | {
115 | "orientation" : "landscape",
116 | "idiom" : "ipad",
117 | "extent" : "to-status-bar",
118 | "scale" : "1x"
119 | },
120 | {
121 | "orientation" : "landscape",
122 | "idiom" : "ipad",
123 | "filename" : "Default-Landscape.png",
124 | "extent" : "full-screen",
125 | "scale" : "1x"
126 | },
127 | {
128 | "orientation" : "portrait",
129 | "idiom" : "ipad",
130 | "extent" : "to-status-bar",
131 | "scale" : "2x"
132 | },
133 | {
134 | "orientation" : "portrait",
135 | "idiom" : "ipad",
136 | "filename" : "Default-Portrait@2x.png",
137 | "extent" : "full-screen",
138 | "scale" : "2x"
139 | },
140 | {
141 | "orientation" : "landscape",
142 | "idiom" : "ipad",
143 | "extent" : "to-status-bar",
144 | "scale" : "2x"
145 | },
146 | {
147 | "orientation" : "landscape",
148 | "idiom" : "ipad",
149 | "filename" : "Default-Landscape@2x.png",
150 | "extent" : "full-screen",
151 | "scale" : "2x"
152 | }
153 | ],
154 | "info" : {
155 | "version" : 1,
156 | "author" : "xcode"
157 | }
158 | }
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchScreen-AspectFill.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchScreen-AspectFill@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchScreen-Center.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchScreen-Center@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png
--------------------------------------------------------------------------------
/app/App_Resources/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiresFullScreen
28 |
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/App_Resources/iOS/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/App_Resources/iOS/build.xcconfig:
--------------------------------------------------------------------------------
1 | // You can add custom settings here
2 | // for example you can uncomment the following line to force distribution code signing
3 | // CODE_SIGN_IDENTITY = iPhone Distribution
4 | // To build for device with XCode 8 you need to specify your development team. More info: https://developer.apple.com/library/prerelease/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
5 | // DEVELOPMENT_TEAM = YOUR_TEAM_ID;
6 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
7 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
8 |
--------------------------------------------------------------------------------
/app/activity_indicator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/activity_indicator.png
--------------------------------------------------------------------------------
/app/app.css:
--------------------------------------------------------------------------------
1 | .title {
2 | font-size: 30;
3 | horizontal-align: center;
4 | margin: 20;
5 | }
6 |
7 | .subtitle {
8 | font-size: 20;
9 | horizontal-align: center;
10 | text-align: center;
11 | vertical-align: center;
12 | margin: -30;
13 | }
14 |
15 | button {
16 | font-size: 20;
17 | horizontal-align: center;
18 | }
19 |
20 | .btn {
21 | border-radius: 10;
22 | color: #fff;
23 | background-color: #284898
24 | }
25 |
26 | .message {
27 | font-size: 20;
28 | color: #284848;
29 | horizontal-align: center;
30 | margin: 0 20;
31 | text-align: center;
32 | }
33 |
--------------------------------------------------------------------------------
/app/app.js:
--------------------------------------------------------------------------------
1 | var application = require("application");
2 | application.start({ moduleName: "main-page" });
3 |
--------------------------------------------------------------------------------
/app/grayscale-algo.android.js:
--------------------------------------------------------------------------------
1 | function grayScaleImage(bitmap, fileName, appDir, progressCallback) {
2 | var Bitmap = android.graphics.Bitmap;
3 | var Color = android.graphics.Color;
4 |
5 | var w = bitmap.getWidth();
6 | var h = bitmap.getHeight();
7 |
8 | var bitmapOut = Bitmap.createBitmap(w, h, bitmap.getConfig());
9 |
10 | var A, R, G, B;
11 | var px;
12 |
13 | var RedFactor = 0.299;
14 | var GreenFactor = 0.587;
15 | var BlueFactor = 0.114;
16 |
17 | var portion = Math.floor(w / 100);
18 | var currPart = 0;
19 |
20 | for (var x = 0; x < w; ++x) {
21 | for (var y = 0; y < h; ++y) {
22 | px = bitmap.getPixel(x, y);
23 | A = Color.alpha(px);
24 |
25 | /*
26 | * Apply filter contrast for every channel (R, G, B);
27 | */
28 | R = Color.red(px);
29 | G = Color.green(px);
30 | B = Color.blue(px);
31 |
32 | var transformedPx = Math.round(RedFactor * R + GreenFactor * G + BlueFactor * B);
33 | bitmapOut.setPixel(x, y, Color.argb(A, transformedPx, transformedPx, transformedPx));
34 | }
35 |
36 | if (x % portion == 0) {
37 | ++currPart;
38 | progressCallback(currPart);
39 | }
40 | }
41 |
42 | return saveToFile(fileName, bitmapOut, appDir);
43 | }
44 |
45 | function saveToFile(fileName, bmp, appDir) {
46 | var CompressFormat = android.graphics.Bitmap.CompressFormat;
47 | var FileOutputStream = java.io.FileOutputStream;
48 | var File = java.io.File;
49 |
50 | var pathOnDevice = appDir;
51 |
52 | var path = pathOnDevice;
53 |
54 | log('Saving file to: ' + path);
55 |
56 | var file = new File(path, fileName);
57 | var resultP = file.getAbsolutePath();
58 |
59 | log('Abs file path: ' + resultP);
60 |
61 | try {
62 | var out = new FileOutputStream(resultP);
63 | bmp.compress(CompressFormat.PNG, 10, out);
64 | out.flush();
65 | out.close();
66 | } catch (e) {
67 | log('Failed to save image to file: ' + e.toString());
68 |
69 | return null;
70 | }
71 |
72 | log('Saved image to file: ' + resultP);
73 |
74 |
75 | return resultP;
76 | }
77 |
78 | function toGrayScale(bitmapSrc, fileName, appDir, progressCallback) {
79 | var File = java.io.File;
80 | var BitmapFactory = android.graphics.BitmapFactory;
81 |
82 | log('bitmapSrc: ' + bitmapSrc);
83 |
84 | var f = new File(bitmapSrc);
85 | if (!f.exists()) { return null; }
86 |
87 | var bitmap = BitmapFactory.decodeFile(bitmapSrc);
88 |
89 | return grayScaleImage(bitmap, fileName, appDir, progressCallback);
90 | }
91 |
92 | function log(message) {
93 | if (!global.TNS_WEBPACK) {
94 | require("globals");
95 | console.log(message);
96 | }
97 | }
98 |
99 | module.exports.ToGrayscale = toGrayScale;
100 |
--------------------------------------------------------------------------------
/app/grayscale-algo.ios.js:
--------------------------------------------------------------------------------
1 | function toGrayScale(bitmapSrc, bitmapDest, appDir, progressCallback) {
2 | var destinationOutputPath = NSString.stringWithString(appDir).stringByAppendingPathComponent(bitmapDest);
3 |
4 | var image = UIImage.imageWithContentsOfFile(bitmapSrc);
5 | var actualWidth = image.size.width;
6 | var actualHeight = image.size.height;
7 | var imageRect = CGRectMake(0, 0, actualWidth, actualHeight);
8 | var colorSpace = CGColorSpaceCreateDeviceGray();
9 |
10 | var context = CGBitmapContextCreate(null, actualWidth, actualHeight, 8, 0, colorSpace, kCGImageAlphaNone);
11 | CGContextDrawImage(context, imageRect, image.CGImage);
12 | var grayImage = CGBitmapContextCreateImage(context);
13 |
14 | var alphaContext = CGBitmapContextCreate(null, actualWidth, actualHeight, 8, 0, null, kCGImageAlphaOnly);
15 | CGContextDrawImage(alphaContext, imageRect, image.CGImage);
16 | var mask = CGBitmapContextCreateImage(alphaContext);
17 |
18 | var grayScaleImage = UIImage.imageWithCGImageScaleOrientation(CGImageCreateWithMask(grayImage, mask), image.scale, image.imageOrientation);
19 | var grayScaleImageBinary = UIImagePNGRepresentation(grayScaleImage);
20 | grayScaleImageBinary.writeToFileAtomically(destinationOutputPath, true);
21 |
22 | //CGColorSpaceRelease(colorSpace);
23 | //CGContextRelease(context);
24 | //CGContextRelease(alphaContext);
25 | //CGImageRelease(grayImage);
26 | //CGImageRelease(mask);
27 |
28 | return destinationOutputPath;
29 | }
30 |
31 | module.exports.ToGrayscale = toGrayScale;
--------------------------------------------------------------------------------
/app/main-page.js:
--------------------------------------------------------------------------------
1 | var createViewModel = require("./main-view-model").createViewModel;
2 |
3 | function onNavigatingTo(args) {
4 | var page = args.object;
5 | page.bindingContext = createViewModel();
6 | }
7 |
8 | exports.onNavigatingTo = onNavigatingTo;
--------------------------------------------------------------------------------
/app/main-page.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/main-view-model.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var Observable = require("data/observable").Observable;
4 | var Image = require("ui/image");
5 | var fs = require("file-system");
6 |
7 | var frame = require("ui/frame");
8 | var page = require("ui/page");
9 | var animation = require("ui/animation");
10 | var enums = require("ui/enums");
11 |
12 | function createViewModel() {
13 | var viewModel = new Observable();
14 | var pathToBW = "";
15 | var appDir = fs.knownFolders.currentApp().path;
16 | var originalImage = appDir + "/zenyatta.jpg"
17 | viewModel.image = originalImage;
18 | viewModel.indicator = appDir + "/activity_indicator.png";
19 |
20 | var anim;
21 | var lbl1Anim;
22 |
23 | viewModel.reset = function () {
24 | viewModel.set("image", originalImage);
25 | }
26 |
27 | viewModel.animateLbl = function () {
28 | if (lbl1Anim && lbl1Anim.isPlaying) {
29 | lbl1Anim.cancel();
30 |
31 | return;
32 | }
33 |
34 | let lbl1 = getViewById("lbl1");
35 | lbl1Anim = new animation.Animation([{
36 | target: lbl1,
37 | rotate: 720,
38 | translate: { x: 100, y: 100 },
39 | opacity: 0.5,
40 | iterations: Number.POSITIVE_INFINITY,
41 | duration: 2000
42 | }, {
43 | target: lbl1,
44 | scale: { x: 3, y: 3 },
45 | duration: 2000,
46 | iterations: Number.POSITIVE_INFINITY
47 | }]);
48 |
49 | lbl1Anim.play().catch(function (e) {
50 | console.log('Animation failed: ' + e);
51 | });
52 | }
53 |
54 | viewModel.percents = 0;
55 |
56 | viewModel.hideLoader = true;
57 | viewModel.grayscaleOnWorker = function () {
58 | var w;
59 | if (global.TNS_WEBPACK) {
60 | var GrayscaleWorker = require("nativescript-worker-loader!./workers/grayscaler.js");
61 | w = new GrayscaleWorker();
62 | } else {
63 | w = new Worker("./workers/grayscaler.js");
64 | }
65 |
66 | anim = new animation.Animation([{
67 | target: getViewById("img2"),
68 | rotate: 360,
69 | iterations: Number.POSITIVE_INFINITY,
70 | duration: 2000
71 | }]);
72 |
73 | anim.play().catch(function (e) {
74 | console.log('Animation failed: ' + e);
75 | });
76 |
77 | viewModel.set("percents", 0);
78 |
79 | w.postMessage({ src: originalImage, fileName: "zenyatta-bw.jpg", appDir: appDir });
80 | viewModel.set("hideLoader", false);
81 |
82 | w.onmessage = function (msg) {
83 | if (msg.data.res == "progress") {
84 | viewModel.set("percents", msg.data.value);
85 | return;
86 | }
87 |
88 | if (msg.data.res == "success") {
89 | pathToBW = msg.data.src;
90 | console.log("Inside success callback of grayscaleOnWorker : " + pathToBW);
91 | // w.postMessage("close");
92 | w.terminate();
93 | viewModel.set("hideLoader", true);
94 | viewModel.set("image", pathToBW);
95 | viewModel.set("percents", 100);
96 |
97 | anim.cancel();
98 | }
99 | }
100 |
101 | w.onerror = function (e) {
102 | console.log('Error from worker: ' + e.message);
103 | console.dir(e);
104 | anim.cancel();
105 | viewModel.set("percents", "Error");
106 | }
107 | }
108 |
109 | return viewModel;
110 | }
111 |
112 | function getViewById(viewId) {
113 | let currentPage;
114 | let topFrame = frame.topmost();
115 | currentPage = topFrame.currentPage;
116 |
117 | let v = currentPage.getViewById(viewId);
118 | return v;
119 | }
120 |
121 | exports.createViewModel = createViewModel;
122 |
--------------------------------------------------------------------------------
/app/package.json:
--------------------------------------------------------------------------------
1 | {"name":"tns-template-hello-world","main":"app.js","version":"2.3.0","author":{"name":"Telerik","email":"support@telerik.com"},"description":"Nativescript hello-world project template","license":"Apache-2.0","keywords":["telerik","mobile","nativescript","{N}","tns","appbuilder","template"],"repository":{"type":"git","url":"git://github.com/NativeScript/template-hello-world.git"},"bugs":{"url":"https://github.com/NativeScript/template-hello-world/issues"},"homepage":"https://github.com/NativeScript/template-hello-world","android":{"v8Flags":"--expose_gc"},"readme":"ERROR: No README data found!","_id":"tns-template-hello-world@2.3.0","_from":"tns-template-hello-world@2.3.0"}
--------------------------------------------------------------------------------
/app/references.d.ts:
--------------------------------------------------------------------------------
1 | /// Enable smart suggestions and completions in Visual Studio Code JavaScript projects.
2 |
--------------------------------------------------------------------------------
/app/workers/grayscaler.js:
--------------------------------------------------------------------------------
1 | // required manually to setup 'console'
2 | var grayscaleAlgo = require("../grayscale-algo");
3 |
4 | onmessage = function (msg) {
5 | if (msg.data == "close") {
6 | close();
7 | return;
8 | }
9 |
10 | var data = msg.data;
11 | var bitmapSrc = data.src;
12 | var fileName = data.fileName;
13 | var appDir = data.appDir;
14 |
15 | var res = grayscaleAlgo.ToGrayscale(bitmapSrc, fileName, appDir, progressCallback);
16 | var jsStr = "" + res;
17 | postMessage({ res: res ? "success" : "fail", src: jsStr });
18 | }
19 |
20 | onerror = function (e) {
21 | // return true to not propagate to main
22 | }
23 |
24 | function progressCallback(value) {
25 | postMessage({ res: "progress", value: value });
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/app/zenyatta.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NativeScript/demo-workers/00eee1408cfba632e279974e47ed3402c1e04584/app/zenyatta.jpg
--------------------------------------------------------------------------------
/hooks/after-prepare/nativescript-dev-webpack.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-dev-webpack/lib/after-prepare.js");
2 |
--------------------------------------------------------------------------------
/hooks/before-prepareJSApp/nativescript-dev-webpack.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-dev-webpack/lib/before-prepareJS.js");
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "NativeScript Application",
3 | "license": "SEE LICENSE IN ",
4 | "readme": "NativeScript Application",
5 | "repository": "",
6 | "nativescript": {
7 | "id": "org.nativescript.grayscale",
8 | "tns-ios": {
9 | "version": "5.1.1"
10 | },
11 | "tns-android": {
12 | "version": "5.1.0"
13 | }
14 | },
15 | "dependencies": {
16 | "tns-core-modules": "~5.1.2"
17 | },
18 | "devDependencies": {
19 | "babel-traverse": "6.26.0",
20 | "babel-types": "6.26.0",
21 | "babylon": "6.18.0",
22 | "extract-text-webpack-plugin": "~3.0.2",
23 | "lazy": "1.0.11",
24 | "nativescript-dev-webpack": "~0.19.1",
25 | "nativescript-worker-loader": "~0.9.2"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { join, relative, resolve, sep } = require("path");
2 |
3 | const webpack = require("webpack");
4 | const nsWebpack = require("nativescript-dev-webpack");
5 | const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
6 | const CleanWebpackPlugin = require("clean-webpack-plugin");
7 | const CopyWebpackPlugin = require("copy-webpack-plugin");
8 | const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
9 | const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
10 | const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
11 |
12 | module.exports = env => {
13 | // Add your custom Activities, Services and other android app components here.
14 | const appComponents = [
15 | "tns-core-modules/ui/frame",
16 | "tns-core-modules/ui/frame/activity",
17 | ];
18 |
19 | const platform = env && (env.android && "android" || env.ios && "ios");
20 | if (!platform) {
21 | throw new Error("You need to provide a target platform!");
22 | }
23 |
24 | const platforms = ["ios", "android"];
25 | const projectRoot = __dirname;
26 |
27 | // Default destination inside platforms//...
28 | const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
29 | const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
30 |
31 | const {
32 | // The 'appPath' and 'appResourcesPath' values are fetched from
33 | // the nsconfig.json configuration file
34 | // when bundling with `tns run android|ios --bundle`.
35 | appPath = "app",
36 | appResourcesPath = "app/App_Resources",
37 |
38 | // You can provide the following flags when running 'tns run android|ios'
39 | snapshot, // --env.snapshot
40 | uglify, // --env.uglify
41 | report, // --env.report
42 | sourceMap, // --env.sourceMap
43 | hmr, // --env.hmr,
44 | } = env;
45 | const externals = (env.externals || []).map((e) => { // --env.externals
46 | return new RegExp(e + ".*");
47 | });
48 |
49 | const appFullPath = resolve(projectRoot, appPath);
50 | const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
51 |
52 | const entryModule = nsWebpack.getEntryModule(appFullPath);
53 | const entryPath = `.${sep}${entryModule}.js`;
54 |
55 | const config = {
56 | mode: uglify ? "production" : "development",
57 | context: appFullPath,
58 | externals,
59 | watchOptions: {
60 | ignored: [
61 | appResourcesFullPath,
62 | // Don't watch hidden files
63 | "**/.*",
64 | ]
65 | },
66 | target: nativescriptTarget,
67 | entry: {
68 | bundle: entryPath,
69 | },
70 | output: {
71 | pathinfo: false,
72 | path: dist,
73 | libraryTarget: "commonjs2",
74 | filename: "[name].js",
75 | globalObject: "global",
76 | },
77 | resolve: {
78 | extensions: [".js", ".scss", ".css"],
79 | // Resolve {N} system modules from tns-core-modules
80 | modules: [
81 | "node_modules/tns-core-modules",
82 | "node_modules",
83 | ],
84 | alias: {
85 | '~': appFullPath
86 | },
87 | // don't resolve symlinks to symlinked modules
88 | symlinks: false
89 | },
90 | resolveLoader: {
91 | // don't resolve symlinks to symlinked loaders
92 | symlinks: false
93 | },
94 | node: {
95 | // Disable node shims that conflict with NativeScript
96 | "http": false,
97 | "timers": false,
98 | "setImmediate": false,
99 | "fs": "empty",
100 | "__dirname": false,
101 | },
102 | devtool: sourceMap ? "inline-source-map" : "none",
103 | optimization: {
104 | splitChunks: {
105 | cacheGroups: {
106 | vendor: {
107 | name: "vendor",
108 | chunks: "all",
109 | test: (module, chunks) => {
110 | const moduleName = module.nameForCondition ? module.nameForCondition() : '';
111 | return /[\\/]node_modules[\\/]/.test(moduleName) ||
112 | appComponents.some(comp => comp === moduleName);
113 |
114 | },
115 | enforce: true,
116 | },
117 | }
118 | },
119 | minimize: !!uglify,
120 | minimizer: [
121 | new UglifyJsPlugin({
122 | parallel: true,
123 | cache: true,
124 | uglifyOptions: {
125 | output: {
126 | comments: false,
127 | },
128 | compress: {
129 | // The Android SBG has problems parsing the output
130 | // when these options are enabled
131 | 'collapse_vars': platform !== "android",
132 | sequences: platform !== "android",
133 | }
134 | }
135 | })
136 | ],
137 | },
138 | module: {
139 | rules: [
140 | {
141 | test: new RegExp(entryPath),
142 | use: [
143 | // Require all Android app components
144 | platform === "android" && {
145 | loader: "nativescript-dev-webpack/android-app-components-loader",
146 | options: { modules: appComponents }
147 | },
148 |
149 | {
150 | loader: "nativescript-dev-webpack/bundle-config-loader",
151 | options: {
152 | loadCss: !snapshot, // load the application css if in debug mode
153 | }
154 | },
155 | ].filter(loader => !!loader)
156 | },
157 |
158 | {
159 | test: /-page\.js$/,
160 | use: "nativescript-dev-webpack/script-hot-loader"
161 | },
162 |
163 | {
164 | test: /\.(css|scss)$/,
165 | use: "nativescript-dev-webpack/style-hot-loader"
166 | },
167 |
168 | {
169 | test: /\.(html|xml)$/,
170 | use: "nativescript-dev-webpack/markup-hot-loader"
171 | },
172 |
173 | { test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader"},
174 |
175 | {
176 | test: /\.css$/,
177 | use: { loader: "css-loader", options: { minimize: false, url: false } }
178 | },
179 |
180 | {
181 | test: /\.scss$/,
182 | use: [
183 | { loader: "css-loader", options: { minimize: false, url: false } },
184 | "sass-loader"
185 | ]
186 | },
187 | ]
188 | },
189 | plugins: [
190 | // Define useful constants like TNS_WEBPACK
191 | new webpack.DefinePlugin({
192 | "global.TNS_WEBPACK": "true",
193 | "process": undefined,
194 | }),
195 | // Remove all files from the out dir.
196 | new CleanWebpackPlugin([ `${dist}/**/*` ]),
197 | // Copy native app resources to out dir.
198 | new CopyWebpackPlugin([
199 | {
200 | from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
201 | to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
202 | context: projectRoot
203 | },
204 | ]),
205 | // Copy assets to out dir. Add your own globs as needed.
206 | new CopyWebpackPlugin([
207 | { from: { glob: "fonts/**" } },
208 | { from: { glob: "**/*.jpg" } },
209 | { from: { glob: "**/*.png" } },
210 | ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
211 | // Generate a bundle starter script and activate it in package.json
212 | new nsWebpack.GenerateBundleStarterPlugin([
213 | "./vendor",
214 | "./bundle",
215 | ]),
216 | // For instructions on how to set up workers with webpack
217 | // check out https://github.com/nativescript/worker-loader
218 | new NativeScriptWorkerPlugin(),
219 | new nsWebpack.PlatformFSPlugin({
220 | platform,
221 | platforms,
222 | }),
223 | // Does IPC communication with the {N} CLI to notify events when running in watch mode.
224 | new nsWebpack.WatchStateLoggerPlugin(),
225 | ],
226 | };
227 |
228 | if (report) {
229 | // Generate report files for bundles content
230 | config.plugins.push(new BundleAnalyzerPlugin({
231 | analyzerMode: "static",
232 | openAnalyzer: false,
233 | generateStatsFile: true,
234 | reportFilename: resolve(projectRoot, "report", `report.html`),
235 | statsFilename: resolve(projectRoot, "report", `stats.json`),
236 | }));
237 | }
238 |
239 | if (snapshot) {
240 | config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
241 | chunk: "vendor",
242 | requireModules: [
243 | "tns-core-modules/bundle-entry-points",
244 | ],
245 | projectRoot,
246 | webpackConfig: config,
247 | }));
248 | }
249 |
250 | if (hmr) {
251 | config.plugins.push(new webpack.HotModuleReplacementPlugin());
252 | }
253 |
254 |
255 | return config;
256 | };
257 |
--------------------------------------------------------------------------------