├── node ├── VERSION ├── .jshintignore ├── framework ├── .gitignore ├── Images │ ├── appbar.back.rest.png │ ├── appbar.next.rest.png │ ├── appbar.save.rest.png │ ├── appbar.stop.rest.png │ ├── appbar.close.rest.png │ └── appbar.feature.video.rest.png ├── resources │ └── notification-beep.wav ├── Properties │ └── AssemblyInfo.cs └── WPCordovaClassLib.sln ├── spec ├── unit │ ├── fixtures │ │ └── EmptyProject │ │ │ └── bin │ │ │ ├── ARM │ │ │ ├── Debug │ │ │ │ └── .gitignore │ │ │ └── Release │ │ │ │ └── CordovaAppProj_Release_ARM.xap │ │ │ └── Debug │ │ │ └── CordovaAppProj_Debug_AnyCPU.xap │ ├── package.spec.js │ ├── run.spec.js │ └── MSBuildTools.spec.js ├── .jshintrc └── e2e │ └── endtoend.spec.js ├── template ├── Background.png ├── __PreviewImage.jpg ├── __TemplateIcon.png ├── www │ ├── img │ │ └── logo.png │ ├── index.html │ ├── js │ │ └── index.js │ └── css │ │ └── index.css ├── ApplicationIcon.png ├── SplashScreenImage.jpg ├── lib │ ├── Newtonsoft.Json.dll │ ├── Newtonsoft.Json.nuspec │ └── LICENSE.md ├── Images │ ├── appbar.back.rest.png │ ├── appbar.close.rest.png │ ├── appbar.next.rest.png │ ├── appbar.save.rest.png │ ├── appbar.stop.rest.png │ └── appbar.feature.video.rest.png ├── Properties │ ├── AppManifest.xml │ ├── AssemblyInfo.cs │ └── WMAppManifest.xml ├── cordova │ ├── log.bat │ ├── defaults.xml │ ├── lib │ │ ├── start-emulator.bat │ │ ├── list-started-emulators.bat │ │ ├── install-device.bat │ │ ├── win_os_version.js │ │ ├── win_sdk_version.js │ │ ├── install-emulator.bat │ │ ├── list-devices.bat │ │ ├── list-emulator-images.bat │ │ ├── clean.js │ │ ├── target-list.js │ │ ├── device.js │ │ ├── package.js │ │ ├── MSBuildTools.js │ │ ├── build.js │ │ ├── run.js │ │ └── utils.js │ ├── build.bat │ ├── clean │ ├── run.bat │ ├── clean.bat │ ├── win_os_version.bat │ ├── win_sdk_version.bat │ ├── version.bat │ ├── run │ └── build ├── cordovalib │ ├── IBrowserDecorator.cs │ ├── ScriptCallback.cs │ ├── CordovaView.xaml │ ├── JSON │ │ └── JsonHelper.cs │ ├── CordovaCommandCall.cs │ ├── PluginResult.cs │ ├── CommandFactory.cs │ ├── OrientationHelper.cs │ ├── ConsoleHelper.cs │ ├── BrowserMouseHelper.cs │ ├── MimeTypeMapper.cs │ ├── Commands │ │ └── BaseCommand.cs │ └── ImageExifHelper.cs ├── App.xaml ├── MainPage.xaml.cs ├── MainPage.xaml ├── CordovaWP8Solution.sln ├── App.xaml.cs └── MyTemplate.vstemplate ├── NOTICE ├── .jshintrc ├── .gitignore ├── LICENSE ├── .github └── PULL_REQUEST_TEMPLATE.md ├── bin ├── createTemplates.bat ├── update.bat ├── check_reqs.bat ├── create.bat ├── update ├── check_reqs ├── create └── lib │ ├── update.js │ ├── check_reqs.js │ └── create.js ├── appveyor.yml ├── cordova-js-src ├── platform.js └── exec.js ├── CONTRIBUTING.md ├── .gitattributes ├── package.json └── README.md /node: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 3.9.0-dev 2 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | template/www/* 2 | -------------------------------------------------------------------------------- /framework/.gitignore: -------------------------------------------------------------------------------- 1 | /_UpgradeReport_Files/ 2 | -------------------------------------------------------------------------------- /spec/unit/fixtures/EmptyProject/bin/ARM/Debug/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/unit/fixtures/EmptyProject/bin/Debug/CordovaAppProj_Debug_AnyCPU.xap: -------------------------------------------------------------------------------- 1 | (dummy package) -------------------------------------------------------------------------------- /spec/unit/fixtures/EmptyProject/bin/ARM/Release/CordovaAppProj_Release_ARM.xap: -------------------------------------------------------------------------------- 1 | (dummy package) -------------------------------------------------------------------------------- /template/Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/Background.png -------------------------------------------------------------------------------- /template/__PreviewImage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/__PreviewImage.jpg -------------------------------------------------------------------------------- /template/__TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/__TemplateIcon.png -------------------------------------------------------------------------------- /template/www/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/www/img/logo.png -------------------------------------------------------------------------------- /template/ApplicationIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/ApplicationIcon.png -------------------------------------------------------------------------------- /template/SplashScreenImage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/SplashScreenImage.jpg -------------------------------------------------------------------------------- /template/lib/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/lib/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /framework/Images/appbar.back.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/framework/Images/appbar.back.rest.png -------------------------------------------------------------------------------- /framework/Images/appbar.next.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/framework/Images/appbar.next.rest.png -------------------------------------------------------------------------------- /framework/Images/appbar.save.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/framework/Images/appbar.save.rest.png -------------------------------------------------------------------------------- /framework/Images/appbar.stop.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/framework/Images/appbar.stop.rest.png -------------------------------------------------------------------------------- /template/Images/appbar.back.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/Images/appbar.back.rest.png -------------------------------------------------------------------------------- /template/Images/appbar.close.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/Images/appbar.close.rest.png -------------------------------------------------------------------------------- /template/Images/appbar.next.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/Images/appbar.next.rest.png -------------------------------------------------------------------------------- /template/Images/appbar.save.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/Images/appbar.save.rest.png -------------------------------------------------------------------------------- /template/Images/appbar.stop.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/Images/appbar.stop.rest.png -------------------------------------------------------------------------------- /framework/Images/appbar.close.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/framework/Images/appbar.close.rest.png -------------------------------------------------------------------------------- /framework/resources/notification-beep.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/framework/resources/notification-beep.wav -------------------------------------------------------------------------------- /framework/Images/appbar.feature.video.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/framework/Images/appbar.feature.video.rest.png -------------------------------------------------------------------------------- /template/Images/appbar.feature.video.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-wp8/HEAD/template/Images/appbar.feature.video.rest.png -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Apache Cordova 2 | Copyright 2012 The Apache Software Foundation 3 | 4 | This product includes software developed by 5 | The Apache Software Foundation (http://www.apache.org) -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true 3 | , "bitwise": true 4 | , "undef": true 5 | , "trailing": true 6 | , "quotmark": true 7 | , "indent": 4 8 | , "unused": "vars" 9 | , "latedef": "nofunc" 10 | } 11 | -------------------------------------------------------------------------------- /spec/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true 3 | , "bitwise": true 4 | , "undef": true 5 | , "trailing": true 6 | , "quotmark": true 7 | , "indent": 4 8 | , "unused": "vars" 9 | , "latedef": "nofunc" 10 | , "jasmine": true 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | obj 3 | *.csproj.user 4 | *.suo 5 | *.cache 6 | Thumbs.db 7 | 8 | /temp/* 9 | 10 | *.dll 11 | !template/lib/* 12 | 13 | # Ignore template zip files 14 | *.zip 15 | 16 | # Other useful stuff 17 | *.bak 18 | *.cache 19 | *.log 20 | *.swp 21 | *.user 22 | 23 | *.DS_Store 24 | 25 | framework/Bin/* 26 | 27 | node_modules/ 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | 14 | This product bundles Newtonsoft.Json, which is available under The MIT License (MIT). 15 | For details, see template/lib/LICENSE.md, http://james.newtonking.com/json 16 | -------------------------------------------------------------------------------- /template/lib/Newtonsoft.Json.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Newtonsoft.Json 5 | 6.0.8 6 | Json.NET 7 | James Newton-King 8 | James Newton-King 9 | https://raw.github.com/JamesNK/Newtonsoft.Json/master/LICENSE.md 10 | http://james.newtonking.com/json 11 | false 12 | Json.NET is a popular high-performance JSON framework for .NET 13 | en-US 14 | json 15 | 16 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 9 | 10 | ### Platforms affected 11 | 12 | 13 | ### What does this PR do? 14 | 15 | 16 | ### What testing has been done on this change? 17 | 18 | 19 | ### Checklist 20 | - [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database 21 | - [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. 22 | - [ ] Added automated test coverage as appropriate for this change. 23 | -------------------------------------------------------------------------------- /template/Properties/AppManifest.xml: -------------------------------------------------------------------------------- 1 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /bin/createTemplates.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | cscript "%~dp0\createTemplates.js" %* //nologo -------------------------------------------------------------------------------- /template/cordova/log.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | @ECHO OFF 24 | ECHO Sorry, logging is not supported for Windows Phone. 1>&2 25 | EXIT /B 1 -------------------------------------------------------------------------------- /template/cordova/defaults.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /template/cordova/lib/start-emulator.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | ECHO Sorry, start-emulator is not availible yet for Windows Phone. 1>&2 24 | EXIT /B 1 -------------------------------------------------------------------------------- /template/cordova/lib/list-started-emulators.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | ECHO Sorry, list-started-emulators is not availible yet for Windows Phone. 1>&2 24 | EXIT /B 1 -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | # appveyor file 21 | # http://www.appveyor.com/docs/appveyor-yml 22 | 23 | install: 24 | - npm install 25 | 26 | build: off 27 | 28 | test_script: 29 | - node --version 30 | - npm --version 31 | - msbuild /version 32 | - npm test -------------------------------------------------------------------------------- /template/cordova/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0build" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'build' in cordova, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /bin/update.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0update" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'update' script in 'bin' folder, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /template/cordova/clean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, 15 | software distributed under the License is distributed on an 16 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | KIND, either express or implied. See the License for the 18 | specific language governing permissions and limitations 19 | under the License. 20 | */ 21 | 22 | var clean = require('./lib/clean'); 23 | 24 | clean.run(process.argv).done(null, function(err) { 25 | console.error('ERROR: ' + err); 26 | process.exit(2); 27 | }); -------------------------------------------------------------------------------- /template/cordova/run.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0run" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'run' in cordova, aborting...>&2 29 | EXIT /B 1 30 | ) 31 | -------------------------------------------------------------------------------- /bin/check_reqs.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0check_reqs" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'check_reqs' in 'bin' folder, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /bin/create.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET full_path=%~dp0 24 | IF EXIST "%full_path%create" ( 25 | node "%full_path%create" %* 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'create' in 'bin' folder, aborting...>&2 29 | EXIT /B 1 30 | ) 31 | -------------------------------------------------------------------------------- /template/cordova/clean.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0clean" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'clean' script in 'cordova' folder, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /template/cordovalib/IBrowserDecorator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using Microsoft.Phone.Controls; 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using System.Text; 20 | using System.Threading.Tasks; 21 | 22 | namespace WPCordovaClassLib.CordovaLib 23 | { 24 | interface IBrowserDecorator 25 | { 26 | WebBrowser Browser { get; set; } 27 | void InjectScript(); 28 | bool HandleCommand(string cmd); 29 | void AttachNativeHandlers(); 30 | void DetachNativeHandlers(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /template/lib/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2007 James Newton-King 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /template/cordova/lib/install-device.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0\..\run" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* --device --nobuild 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'deploy' in cordova, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /template/cordova/lib/win_os_version.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var utils = require('./utils'); 21 | 22 | utils.getOSVersion().then(function (version) { 23 | console.log(version); 24 | }, function (err) { 25 | console.error(err); 26 | process.exit(2); 27 | }); 28 | -------------------------------------------------------------------------------- /template/cordova/lib/win_sdk_version.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var utils = require('./utils'); 21 | 22 | utils.getSDKVersion().then(function (version) { 23 | console.log(version); 24 | }, function (err) { 25 | console.error(err); 26 | process.exit(2); 27 | }); 28 | -------------------------------------------------------------------------------- /template/cordova/lib/install-emulator.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0\..\run" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* --emulator --nobuild 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'run' in cordova, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /template/cordova/lib/list-devices.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0target-list.js" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* --devices 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'target-list.js' in cordova/lib, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /template/cordova/win_os_version.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0lib\win_os_version.js" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'win_os_version.js' in 'bin' folder, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /template/cordova/win_sdk_version.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0lib\win_sdk_version.js" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'win_sdk_version.js' in 'bin' folder, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /template/cordova/version.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | @ECHO OFF 24 | SET script_path="%~dp0..\VERSION" 25 | IF EXIST %script_path% ( 26 | type %script_path% 27 | ) ELSE ( 28 | ECHO. 29 | ECHO ERROR: Could not find file VERSION in project folder, path tried was %script_path% >&2 30 | EXIT /B 1 31 | ) -------------------------------------------------------------------------------- /template/cordova/lib/list-emulator-images.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | goto endheader 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | :endheader 22 | 23 | SET script_path="%~dp0target-list.js" 24 | IF EXIST %script_path% ( 25 | node %script_path% %* --emulators 26 | ) ELSE ( 27 | ECHO. 28 | ECHO ERROR: Could not find 'target-list.js' in cordova/lib, aborting...>&2 29 | EXIT /B 1 30 | ) -------------------------------------------------------------------------------- /template/cordova/lib/clean.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var Q = require('q'), 21 | path = require('path'), 22 | shell = require('shelljs'); 23 | 24 | var ROOT = path.join(__dirname, '..', '..'); 25 | 26 | module.exports.run = function (argv) { 27 | var projectPath = ROOT; 28 | ['obj', 'Bin'].forEach(function(dir) { 29 | shell.rm('-rf', path.join(projectPath, dir)); 30 | }); 31 | return Q.resolve(); 32 | }; -------------------------------------------------------------------------------- /template/cordova/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, 15 | software distributed under the License is distributed on an 16 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | KIND, either express or implied. See the License for the 18 | specific language governing permissions and limitations 19 | under the License. 20 | */ 21 | 22 | var args = process.argv, 23 | run = require('./lib/run'); 24 | 25 | // Handle help flag 26 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) > -1) { 27 | run.help(); 28 | } else { 29 | run.run(args).done(null, function (err) { 30 | var errorMessage = (err && err.stack) ? err.stack : err; 31 | console.error('ERROR: ' + errorMessage); 32 | process.exit(2); 33 | }); 34 | } -------------------------------------------------------------------------------- /template/cordova/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, 15 | software distributed under the License is distributed on an 16 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | KIND, either express or implied. See the License for the 18 | specific language governing permissions and limitations 19 | under the License. 20 | */ 21 | 22 | var build = require('./lib/build'), 23 | args = process.argv; 24 | 25 | // Handle help flag 26 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) > -1) { 27 | build.help(); 28 | } else { 29 | build.run(args).done(null, function(err) { 30 | var errorMessage = (err && err.stack) ? err.stack : err; 31 | console.error('ERROR: ' + errorMessage); 32 | process.exit(2); 33 | }); 34 | } -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, 15 | software distributed under the License is distributed on an 16 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | KIND, either express or implied. See the License for the 18 | specific language governing permissions and limitations 19 | under the License. 20 | */ 21 | 22 | var update = require('./lib/update'); 23 | 24 | // check for help flag 25 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) { 26 | update.help(); 27 | } else { 28 | update.run(process.argv).done(function () { 29 | console.log('Successfully updated windows project.'); 30 | }, function (err) { 31 | console.error('Failed to check requirements due to', err); 32 | process.exit(2); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /bin/check_reqs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, 15 | software distributed under the License is distributed on an 16 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | KIND, either express or implied. See the License for the 18 | specific language governing permissions and limitations 19 | under the License. 20 | */ 21 | 22 | var check_reqs = require('./lib/check_reqs'); 23 | 24 | // check for help flag 25 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) { 26 | check_reqs.help(); 27 | } else { 28 | check_reqs.run().done(function success(msbuild) { 29 | console.log('Environment is supported; found MSBuild Tools version ' + msbuild.version + ' at ' + msbuild.path); 30 | }, function (err) { 31 | console.error('Failed to check requirements due to', err); 32 | process.exit(2); 33 | }); 34 | } -------------------------------------------------------------------------------- /bin/create: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | Licensed to the Apache Software Foundation (ASF) under one 5 | or more contributor license agreements. See the NOTICE file 6 | distributed with this work for additional information 7 | regarding copyright ownership. The ASF licenses this file 8 | to you under the Apache License, Version 2.0 (the 9 | "License"); you may not use this file except in compliance 10 | with the License. You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, 15 | software distributed under the License is distributed on an 16 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | KIND, either express or implied. See the License for the 18 | specific language governing permissions and limitations 19 | under the License. 20 | */ 21 | 22 | /* 23 | * create a cordova/windows8 project 24 | * USAGE 25 | * ./create [path package activity] 26 | * ./bin/create.bat C:\Users\Me\MyTestProj "test.proj" "TestProject" 27 | */ 28 | 29 | var create = require('./lib/create'); 30 | 31 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) { 32 | create.help(); 33 | } else { 34 | create.run(process.argv).done(null, function (err) { 35 | console.error('Failed to create project due to', err); 36 | process.exit(2); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /cordova-js-src/platform.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | module.exports = { 23 | id: 'windowsphone', 24 | bootstrap: function() { 25 | var cordova = require('cordova'), 26 | exec = require('cordova/exec'); 27 | 28 | // Inject a listener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners 29 | var backButtonChannel = cordova.addDocumentEventHandler('backbutton'); 30 | backButtonChannel.onHasSubscribersChange = function() { 31 | exec(null, null, "CoreEvents", "overridebackbutton", [this.numHandlers == 1]); 32 | }; 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | # Contributing to Apache Cordova 23 | 24 | Anyone can contribute to Cordova. And we need your contributions. 25 | 26 | There are multiple ways to contribute: report bugs, improve the docs, and 27 | contribute code. 28 | 29 | For instructions on this, start with the 30 | [contribution overview](http://cordova.apache.org/contribute/). 31 | 32 | The details are explained there, but the important items are: 33 | - Sign and submit an Apache ICLA (Contributor License Agreement). 34 | - Have a Jira issue open that corresponds to your contribution. 35 | - Run the tests so your patch doesn't break existing functionality. 36 | 37 | We look forward to your contributions! 38 | 39 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | 3 | # source code 4 | *.php text 5 | *.css text 6 | *.sass text 7 | *.scss text 8 | *.less text 9 | *.styl text 10 | *.js text 11 | *.coffee text 12 | *.json text 13 | *.htm text 14 | *.html text 15 | *.xml text 16 | *.svg text 17 | *.txt text 18 | *.ini text 19 | *.inc text 20 | *.pl text 21 | *.rb text 22 | *.py text 23 | *.scm text 24 | *.sql text 25 | *.sh text 26 | *.bat text 27 | 28 | # templates 29 | *.ejs text 30 | *.hbt text 31 | *.jade text 32 | *.haml text 33 | *.hbs text 34 | *.dot text 35 | *.tmpl text 36 | *.phtml text 37 | 38 | # server config 39 | .htaccess text 40 | 41 | # git config 42 | .gitattributes text 43 | .gitignore text 44 | .gitconfig text 45 | 46 | # code analysis config 47 | .jshintrc text 48 | .jscsrc text 49 | .jshintignore text 50 | .csslintrc text 51 | 52 | # misc config 53 | *.yaml text 54 | *.yml text 55 | .editorconfig text 56 | 57 | # build config 58 | *.npmignore text 59 | *.bowerrc text 60 | 61 | # Heroku 62 | Procfile text 63 | .slugignore text 64 | 65 | # Documentation 66 | *.md text 67 | LICENSE text 68 | AUTHORS text 69 | 70 | 71 | # 72 | ## These files are binary and should be left untouched 73 | # 74 | 75 | # (binary is a macro for -text -diff) 76 | *.png binary 77 | *.jpg binary 78 | *.jpeg binary 79 | *.gif binary 80 | *.ico binary 81 | *.mov binary 82 | *.mp4 binary 83 | *.mp3 binary 84 | *.flv binary 85 | *.fla binary 86 | *.swf binary 87 | *.gz binary 88 | *.zip binary 89 | *.7z binary 90 | *.ttf binary 91 | *.eot binary 92 | *.woff binary 93 | *.pyc binary 94 | *.pdf binary 95 | *.dll binary 96 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-wp8", 3 | "version": "3.9.0-dev", 4 | "description": "cordova-wp8 release", 5 | "main": "bin/create", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/apache/cordova-wp8" 9 | }, 10 | "keywords": [ 11 | "wp8", 12 | "windowsphone", 13 | "cordova", 14 | "apache" 15 | ], 16 | "dependencies": { 17 | "nopt": "~3", 18 | "shelljs": "~0.3", 19 | "node-uuid": "~1.4", 20 | "q": "~1" 21 | }, 22 | "bundledDependencies": [ 23 | "nopt", 24 | "shelljs", 25 | "node-uuid", 26 | "q" 27 | ], 28 | "devDependencies": { 29 | "jasmine-node": "~1", 30 | "jshint": "^2.6.0", 31 | "rewire": ">=2.1.3", 32 | "istanbul": "^0.3.4" 33 | }, 34 | "scripts": { 35 | "test": "npm run jshint && npm run test-unit && npm run test-e2e", 36 | "test-unit": "node node_modules/jasmine-node/lib/jasmine-node/cli.js --captureExceptions spec/unit", 37 | "test-e2e": "node node_modules/jasmine-node/lib/jasmine-node/cli.js --captureExceptions spec/e2e", 38 | "cover": "node node_modules/istanbul/lib/cli.js cover --root template --print detail node_modules/jasmine-node/bin/jasmine-node -- spec/unit", 39 | "jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint template && node node_modules/jshint/bin/jshint spec" 40 | }, 41 | "author": "Apache Software Foundation", 42 | "license": "Apache Version 2.0" 43 | } 44 | -------------------------------------------------------------------------------- /template/App.xaml: -------------------------------------------------------------------------------- 1 | 19 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /template/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Linq; 23 | using System.Net; 24 | using System.Windows; 25 | using System.Windows.Controls; 26 | using System.Windows.Documents; 27 | using System.Windows.Input; 28 | using System.Windows.Media; 29 | using System.Windows.Media.Animation; 30 | using System.Windows.Shapes; 31 | using Microsoft.Phone.Controls; 32 | using System.IO; 33 | using System.Windows.Media.Imaging; 34 | using System.Windows.Resources; 35 | 36 | 37 | namespace $safeprojectname$ 38 | { 39 | public partial class MainPage : PhoneApplicationPage 40 | { 41 | // Constructor 42 | public MainPage() 43 | { 44 | InitializeComponent(); 45 | this.CordovaView.Loaded += CordovaView_Loaded; 46 | } 47 | 48 | private void CordovaView_Loaded(object sender, RoutedEventArgs e) 49 | { 50 | this.CordovaView.Loaded -= CordovaView_Loaded; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /template/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Hello World 28 | 29 | 30 |
31 |

Apache Cordova

32 | 36 |
37 | 38 | 39 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /template/www/js/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | var app = { 20 | // Application Constructor 21 | initialize: function() { 22 | this.bindEvents(); 23 | }, 24 | // Bind Event Listeners 25 | // 26 | // Bind any events that are required on startup. Common events are: 27 | // `load`, `deviceready`, `offline`, and `online`. 28 | bindEvents: function() { 29 | document.addEventListener('deviceready', this.onDeviceReady, false); 30 | }, 31 | // deviceready Event Handler 32 | // 33 | // The scope of `this` is the event. In order to call the `receivedEvent` 34 | // function, we must explicity call `app.receivedEvent(...);` 35 | onDeviceReady: function() { 36 | app.receivedEvent('deviceready'); 37 | }, 38 | // Update DOM on a Received Event 39 | receivedEvent: function(id) { 40 | var parentElement = document.getElementById(id); 41 | var listeningElement = parentElement.querySelector('.listening'); 42 | var receivedElement = parentElement.querySelector('.received'); 43 | 44 | listeningElement.setAttribute('style', 'display:none;'); 45 | receivedElement.setAttribute('style', 'display:block;'); 46 | 47 | console.log('Received Event: ' + id); 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /framework/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | using System.Reflection; 15 | using System.Runtime.CompilerServices; 16 | using System.Runtime.InteropServices; 17 | 18 | // General Information about an assembly is controlled through the following 19 | // set of attributes. Change these attribute values to modify the information 20 | // associated with an assembly. 21 | [assembly: AssemblyTitle("WPCordovaClassLib")] 22 | [assembly: AssemblyDescription("0.0.0")] 23 | [assembly: AssemblyConfiguration("")] 24 | [assembly: AssemblyCompany("Apache Cordova")] 25 | [assembly: AssemblyProduct("WPCordovaClassLib")] 26 | [assembly: AssemblyCopyright("")] 27 | [assembly: AssemblyTrademark("")] 28 | [assembly: AssemblyCulture("")] 29 | 30 | // Setting ComVisible to false makes the types in this assembly not visible 31 | // to COM components. If you need to access a type in this assembly from 32 | // COM, set the ComVisible attribute to true on that type. 33 | [assembly: ComVisible(false)] 34 | 35 | // The following GUID is for the ID of the typelib if this project is exposed to COM 36 | [assembly: Guid("633ee7ad-9a75-4b68-96e9-281528c50275")] 37 | 38 | // Version information for an assembly consists of the following four values: 39 | // 40 | // Major Version 41 | // Minor Version 42 | // Build Number 43 | // Revision 44 | // 45 | // You can specify all the values or you can default the Revision and Build Numbers 46 | // by using the '*' as shown below: 47 | [assembly: AssemblyVersion("0.0.0.0")] 48 | [assembly: AssemblyFileVersion("0.0.0.0")] 49 | -------------------------------------------------------------------------------- /template/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 19 | 34 | 35 | 36 | 37 | 38 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /template/cordova/lib/target-list.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var devices = require('./device'), 21 | args = process.argv.slice(2); 22 | 23 | // help/usage function 24 | function help() { 25 | console.log(''); 26 | console.log('Usage: node target-list.js [ --emulators | --devices | --started_emulators | --all ]'); 27 | console.log(' --emulators : List the possible target emulators availible.'); 28 | console.log(' --devices : List the possible target devices availible. *NOT IMPLEMENTED YET*'); 29 | console.log(' --started_emulators : List any started emulators availible. *NOT IMPLEMENTED YET*'); 30 | console.log(' --all : List all devices returned by CordovaDeploy.exe -devices '); 31 | console.log('examples:'); 32 | console.log(' node target-list.js --emulators'); 33 | console.log(' node target-list.js --devices'); 34 | console.log(' node target-list.js --started_emulators'); 35 | console.log(' node target-list.js --all'); 36 | console.log(''); 37 | } 38 | 39 | // Handle help flag 40 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[0]) > -1) { 41 | help(); 42 | } else { 43 | devices.listDevices() 44 | .then(function (deviceList) { 45 | deviceList.forEach(function (device) { 46 | console.log(device); 47 | }); 48 | }); 49 | } -------------------------------------------------------------------------------- /template/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | using System.Reflection; 15 | using System.Runtime.CompilerServices; 16 | using System.Runtime.InteropServices; 17 | using System.Resources; 18 | 19 | // General Information about an assembly is controlled through the following 20 | // set of attributes. Change these attribute values to modify the information 21 | // associated with an assembly. 22 | [assembly: AssemblyTitle("CordovaAppProj")] 23 | [assembly: AssemblyDescription("2.0.0.0")] 24 | [assembly: AssemblyConfiguration("")] 25 | [assembly: AssemblyCompany("Apache Cordova")] 26 | [assembly: AssemblyProduct("CordovaAppProj")] 27 | [assembly: AssemblyCopyright("Copyright © Apache Cordova 2013")] 28 | [assembly: AssemblyTrademark("Apache Cordova")] 29 | [assembly: AssemblyCulture("")] 30 | 31 | 32 | [assembly: NeutralResourcesLanguageAttribute("en-US")] 33 | 34 | // Setting ComVisible to false makes the types in this assembly not visible 35 | // to COM components. If you need to access a type in this assembly from 36 | // COM, set the ComVisible attribute to true on that type. 37 | [assembly: ComVisible(false)] 38 | 39 | // The following GUID is for the ID of the typelib if this project is exposed to COM 40 | [assembly: Guid("9e27b972-0825-4386-ba17-63c695262c3d")] 41 | 42 | // Version information for an assembly consists of the following four values: 43 | // 44 | // Major Version 45 | // Minor Version 46 | // Build Number 47 | // Revision 48 | // 49 | // You can specify all the values or you can default the Revision and Build Numbers 50 | // by using the '*' as shown below: 51 | [assembly: AssemblyVersion("1.0.0.0")] 52 | [assembly: AssemblyFileVersion("1.0.0.0")] 53 | -------------------------------------------------------------------------------- /template/cordova/lib/device.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var Q = require('q'), 21 | utils = require('./utils'); 22 | 23 | // returns one of available devices which name match with parovided string 24 | // return rejected promise if device with name specified not found 25 | module.exports.findDevice = function (target) { 26 | target = target.toLowerCase(); 27 | return module.exports.listDevices().then(function(deviceList) { 28 | // CB-7616 since we use partial match shorter names should go first, 29 | // example case is ['Emulator WVGA 512MB', 'Emulator WVGA'] 30 | var sortedList = deviceList.concat().sort(function (l, r) { return l.length > r.length; }); 31 | for (var idx in sortedList) { 32 | if (sortedList[idx].toLowerCase().indexOf(target) > -1) { 33 | // we should return index based on original list 34 | return Q.resolve(deviceList.indexOf(sortedList[idx])); 35 | } 36 | } 37 | return Q.reject('Specified device not found'); 38 | }); 39 | }; 40 | 41 | // returns array of available devices names 42 | module.exports.listDevices = function () { 43 | return utils.getXapDeploy() 44 | .then(function(xapDeploy) { 45 | return utils.exec('"' + xapDeploy + '" /enumeratedevices') 46 | .then(function(output) { 47 | return Q.resolve(output.split('\n').map(function(line) { 48 | var match = /\s*(\d)+\s+(.*)/.exec(line); 49 | return match && match[2]; 50 | }).filter(function (line) { 51 | return line; 52 | })); 53 | }); 54 | }); 55 | }; -------------------------------------------------------------------------------- /framework/WPCordovaClassLib.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Express 2012 for Windows Phone 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | # 21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPCordovaClassLib", "WPCordovaClassLib.csproj", "{FC6A1A70-892D-46AD-9E4A-9793F72AF780}" 22 | EndProject 23 | Global 24 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 25 | Debug|ARM = Debug|ARM 26 | Debug|Any CPU = Debug|Any CPU 27 | Debug|x86 = Debug|x86 28 | Release|ARM = Release|ARM 29 | Release|Any CPU = Release|Any CPU 30 | Release|x86 = Release|x86 31 | EndGlobalSection 32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 33 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Debug|ARM.ActiveCfg = Debug|ARM 34 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Debug|ARM.Build.0 = Debug|ARM 35 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Debug|x86.ActiveCfg = Debug|x86 38 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Debug|x86.Build.0 = Debug|x86 39 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Release|ARM.ActiveCfg = Release|ARM 40 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Release|ARM.Build.0 = Release|ARM 41 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Release|x86.ActiveCfg = Release|x86 44 | {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Release|x86.Build.0 = Release|x86 45 | EndGlobalSection 46 | GlobalSection(SolutionProperties) = preSolution 47 | HideSolutionNode = FALSE 48 | EndGlobalSection 49 | EndGlobal 50 | 51 | 52 | -------------------------------------------------------------------------------- /template/Properties/WMAppManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | 20 | 21 | ApplicationIcon.png 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Background.png 33 | 0 34 | Background.png 35 | $safeprojectname$ 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | false 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /template/cordova/lib/package.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var Q = require('q'), 21 | fs = require('fs'), 22 | path = require('path'), 23 | shell = require('shelljs'), 24 | device = require ('./device'), 25 | utils = require('./utils'); 26 | 27 | function Package (packagepath) { 28 | this.packagePath = packagepath; 29 | } 30 | 31 | Package.prototype.deployTo = function (deployTarget) { 32 | var pkg = this; 33 | return utils.getXapDeploy() 34 | .then(function (xapDeploy) { 35 | var getTarget = deployTarget == 'device' ? Q('de') : 36 | deployTarget == 'emulator' ? Q('xd') : device.findDevice(deployTarget); 37 | 38 | return getTarget.then(function (target) { 39 | return utils.spawn(xapDeploy, ['/installlaunch', pkg.packagePath, '/targetdevice:' + target]); 40 | }); 41 | }); 42 | }; 43 | 44 | // returns full path to package with chip architecture, build and project types specified 45 | module.exports.getPackage = function (buildtype, buildarch) { 46 | var projectPath = path.resolve(path.join(__dirname, '..', '..')); 47 | var buildFolder = buildarch.toLowerCase() == 'anycpu' ? 48 | path.join(projectPath, 'Bin', buildtype) : 49 | path.join(projectPath, 'Bin', buildarch, buildtype); 50 | 51 | // reject promise if buildFolder folder doesn't exists 52 | if (!fs.existsSync(buildFolder)) { 53 | return Q.reject('Directory with build artefacts doesn\'t exists'); 54 | } 55 | 56 | // search for first .appx file in specified folder 57 | var appxFiles = shell.ls(path.join(buildFolder, '*.xap')); 58 | if (appxFiles && appxFiles[0]) { 59 | // resolve with full path to file if found 60 | return Q.resolve(new Package(appxFiles[0])); 61 | } 62 | // else reject with error 63 | return Q.reject('Can\'t find package with ' + buildtype + ' build type and ' + buildarch + ' chip architecture'); 64 | }; 65 | -------------------------------------------------------------------------------- /template/cordovalib/ScriptCallback.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using System; 16 | using System.Net; 17 | using System.Windows; 18 | using System.Windows.Controls; 19 | using System.Windows.Documents; 20 | using System.Windows.Ink; 21 | using System.Windows.Input; 22 | using System.Windows.Media; 23 | using System.Windows.Media.Animation; 24 | using System.Windows.Shapes; 25 | using WPCordovaClassLib.Cordova.JSON; 26 | using System.Diagnostics; 27 | 28 | namespace WPCordovaClassLib.Cordova 29 | { 30 | /// 31 | /// Represents client script function to execute 32 | /// 33 | public class ScriptCallback : EventArgs 34 | { 35 | /// 36 | /// The scripting function to execute. 37 | /// 38 | public string ScriptName { get; private set; } 39 | 40 | /// 41 | /// A variable number of strings to pass to the function as parameters. 42 | /// 43 | public string[] Args { get; private set; } 44 | 45 | /// 46 | /// Creates new instance of a ScriptCallback class. 47 | /// 48 | /// The scripting function to execute 49 | /// A variable number of strings to pass to the function as parameters 50 | public ScriptCallback(string function, string[] args) 51 | { 52 | this.ScriptName = function; 53 | this.Args = args; 54 | } 55 | 56 | /// 57 | /// Creates new instance of a ScriptCallback class. 58 | /// 59 | /// The scripting function to execute 60 | /// The id argument 61 | /// The message argument 62 | /// The value argument 63 | public ScriptCallback(string function, string id, object msg, object value) 64 | { 65 | this.ScriptName = function; 66 | 67 | String arg = String.Format("{{\"id\": {0}, \"msg\": {1}, \"value\": {2}}}", 68 | JsonHelper.Serialize(id), JsonHelper.Serialize(msg), JsonHelper.Serialize(value)); 69 | 70 | this.Args = new string[] { arg }; 71 | } 72 | 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /bin/lib/update.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var Q = require('q'), 21 | fs = require('fs'), 22 | path = require('path'), 23 | shell = require('shelljs'), 24 | create = require('./create'); 25 | 26 | // returns package metadata from config.xml with fields 'namespace' and 'name' 27 | function extractMetadata(projectPath) { 28 | if (!fs.existsSync(path.join(projectPath, 'config.xml'))){ 29 | return Q.reject('config.xml does not exist'); 30 | } 31 | 32 | var meta = { // default values 33 | namespace: 'io.cordova.hellocordova', 34 | name: 'HelloCordova' 35 | }; 36 | 37 | // TODO: read real values from config.xml 38 | // in case of Cordova CLI all values will be automatically updated by cli for you 39 | // but the script could be used w/o CLI so we should correctly populate meta 40 | 41 | return Q.resolve(meta); 42 | } 43 | 44 | module.exports.help = function () { 45 | console.log('WARNING : Make sure to back up your project before updating!'); 46 | console.log('Usage: update PathToProject '); 47 | console.log(' PathToProject : The path the project you would like to update.'); 48 | console.log('examples:'); 49 | console.log(' update C:\\Users\\anonymous\\Desktop\\MyProject'); 50 | }; 51 | 52 | // updates the cordova.js in project along with the cordova tooling. 53 | module.exports.run = function (argv) { 54 | var projectPath = argv[2]; 55 | if (!fs.existsSync(projectPath)){ 56 | // if specified project path is not valid then reject promise 57 | Q.reject('The given path to the project does not exist.' + 58 | ' Please provide a path to the project you would like to update.'); 59 | } 60 | 61 | return extractMetadata(projectPath).then(function (metadata) { 62 | shell.rm('-rf', projectPath); 63 | 64 | // setup args for create.run which requires process.argv-like array 65 | var createArgs = argv.concat([metadata.namespace, metadata.name]); 66 | return create.run(createArgs); 67 | }); 68 | }; -------------------------------------------------------------------------------- /template/cordovalib/CordovaView.xaml: -------------------------------------------------------------------------------- 1 | 19 | 30 | 31 | 32 | 33 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /cordova-js-src/exec.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var cordova = require('cordova'), 23 | base64 = require('cordova/base64'); 24 | 25 | /** 26 | * Execute a cordova command. It is up to the native side whether this action 27 | * is synchronous or asynchronous. The native side can return: 28 | * Synchronous: PluginResult object as a JSON string 29 | * Asynchronous: Empty string "" 30 | * If async, the native side will cordova.callbackSuccess or cordova.callbackError, 31 | * depending upon the result of the action. 32 | * 33 | * @param {Function} success The success callback 34 | * @param {Function} fail The fail callback 35 | * @param {String} service The name of the service to use 36 | * @param {String} action Action to be run in cordova 37 | * @param {String[]} [args] Zero or more arguments to pass to the method 38 | 39 | */ 40 | 41 | module.exports = function(success, fail, service, action, args) { 42 | 43 | var callbackId = service + cordova.callbackId++; 44 | if (typeof success == "function" || typeof fail == "function") { 45 | cordova.callbacks[callbackId] = {success:success, fail:fail}; 46 | } 47 | args = args || []; 48 | // generate a new command string, ex. DebugConsole/log/DebugConsole23/["wtf dude?"] 49 | for(var n = 0; n < args.length; n++) 50 | { 51 | // special case for ArrayBuffer which could not be stringified out of the box 52 | if(typeof ArrayBuffer !== "undefined" && args[n] instanceof ArrayBuffer) 53 | { 54 | args[n] = base64.fromArrayBuffer(args[n]); 55 | } 56 | 57 | if(typeof args[n] !== "string") 58 | { 59 | args[n] = JSON.stringify(args[n]); 60 | } 61 | } 62 | var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args); 63 | // pass it on to Notify 64 | try { 65 | if(window.external) { 66 | window.external.Notify(command); 67 | } 68 | else { 69 | console.log("window.external not available :: command=" + command); 70 | } 71 | } 72 | catch(e) { 73 | console.log("Exception calling native with command :: " + command + " :: exception=" + e); 74 | } 75 | }; 76 | 77 | -------------------------------------------------------------------------------- /template/cordova/lib/MSBuildTools.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var Q = require('q'), 21 | path = require('path'), 22 | utils = require('./utils'); 23 | 24 | function MSBuildTools (version, path) { 25 | this.version = version; 26 | this.path = path; 27 | } 28 | 29 | MSBuildTools.prototype.buildProject = function(projFile, buildType, buildarch) { 30 | console.log('\nBuilding project: ' + projFile); 31 | console.log('\tConfiguration : ' + buildType); 32 | console.log('\tPlatform : ' + buildarch); 33 | 34 | var args = ['/clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal', '/nologo', 35 | '/p:Configuration=' + buildType, 36 | '/p:Platform=' + buildarch]; 37 | 38 | return utils.spawn(path.join(this.path, 'msbuild'), [projFile].concat(args)); 39 | }; 40 | 41 | // returns full path to msbuild tools required to build the project and tools version 42 | module.exports.findAvailableVersion = function (searchFor32Bit) { 43 | var versions = ['14.0', '12.0', '4.0']; 44 | 45 | return Q.all(versions.map(function (version) { 46 | return checkMSBuildVersion(version, searchFor32Bit); 47 | })) 48 | .then(function (versions) { 49 | // select first msbuild version available, and resolve promise with it 50 | var msbuildTools = versions[0] || versions[1] || versions[2]; 51 | return msbuildTools ? Q.resolve(msbuildTools) : Q.reject('MSBuild tools not found'); 52 | }); 53 | }; 54 | 55 | function checkMSBuildVersion(version, searchFor32Bit) { 56 | var deferred = Q.defer(); 57 | 58 | var regRoot = searchFor32Bit ? 'HKLM\\SOFTWARE\\Wow6432Node' : 'HKLM\\SOFTWARE'; 59 | 60 | utils.exec('reg query ' + regRoot + '\\Microsoft\\MSBuild\\ToolsVersions\\' + version + ' /v MSBuildToolsPath') 61 | .then(function(output) { 62 | // fetch msbuild path from 'reg' output 63 | var path = /MSBuildToolsPath\s+REG_SZ\s+(.*)/i.exec(output); 64 | if (path) { 65 | deferred.resolve(new MSBuildTools(version, path[1])); 66 | return; 67 | } 68 | deferred.resolve(null); // not found 69 | }, function () { 70 | deferred.resolve(null); 71 | }); 72 | return deferred.promise; 73 | } -------------------------------------------------------------------------------- /spec/unit/package.spec.js: -------------------------------------------------------------------------------- 1 | /** 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | 'License'); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | var path = require('path'), 20 | rewire = require('rewire'), 21 | shell = require('shelljs'), 22 | platformRoot = '../../template', 23 | pkgRoot = './template/', 24 | pkgPath = path.join(pkgRoot, 'Bin'), 25 | testPkgPath = './spec/unit/fixtures/EmptyProject/Bin', 26 | pkg = rewire(platformRoot + '/cordova/lib/package.js'); 27 | 28 | function isXapPackage(pack) { 29 | return pack.packagePath.indexOf('.xap') >= 0; 30 | } 31 | 32 | describe('getPackage method', function() { 33 | it('start', function () { 34 | shell.rm('-rf', pkgPath); 35 | shell.cp('-R', testPkgPath, pkgRoot); 36 | }); 37 | 38 | it('spec.1 should find arm release package', function(done) { 39 | var rejected = jasmine.createSpy(); 40 | 41 | pkg.getPackage('release', 'arm') 42 | .then(function(pack) { 43 | expect(isXapPackage(pack)).toBe(true); 44 | }, rejected) 45 | .finally(function() { 46 | expect(rejected).not.toHaveBeenCalled(); 47 | done(); 48 | }); 49 | }); 50 | 51 | it('spec.2 should find anycpu debug package', function(done) { 52 | var rejected = jasmine.createSpy(); 53 | 54 | pkg.getPackage('debug', 'anycpu') 55 | .then(function(pack) { 56 | expect(isXapPackage(pack)).toBe(true); 57 | }, rejected) 58 | .finally(function() { 59 | expect(rejected).not.toHaveBeenCalled(); 60 | done(); 61 | }); 62 | }); 63 | 64 | it('spec.3 should not find x86 release package and reject', function(done) { 65 | var resolved = jasmine.createSpy(); 66 | 67 | pkg.getPackage('release', 'x86') 68 | .then(resolved) 69 | .finally(function() { 70 | expect(resolved).not.toHaveBeenCalled(); 71 | done(); 72 | }); 73 | }); 74 | 75 | it('spec.4 should not find arm debug package and reject', function(done) { 76 | var resolved = jasmine.createSpy(); 77 | 78 | pkg.getPackage('debug', 'arm') 79 | .then(resolved) 80 | .finally(function() { 81 | expect(resolved).not.toHaveBeenCalled(); 82 | done(); 83 | }); 84 | }); 85 | 86 | it('end', function() { 87 | shell.rm('-rf', pkgPath); 88 | }); 89 | }); 90 | -------------------------------------------------------------------------------- /spec/e2e/endtoend.spec.js: -------------------------------------------------------------------------------- 1 | /** 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | var shell = require('shelljs'), 20 | fs = require('fs'), 21 | path = require('path'); 22 | 23 | describe('Cordova create and build', function(){ 24 | 25 | var projectFolder = 'testcreate 応用', 26 | buildDirectory = path.join(__dirname, '../..'), 27 | anycpuPackageFolder = path.join(buildDirectory, projectFolder, 'Bin', 'Debug'), 28 | x86PackageFolder = path.join(buildDirectory, projectFolder, 'Bin', 'x86', 'Debug'), 29 | armPackageFolder = path.join(buildDirectory, projectFolder, 'Bin', 'ARM', 'Debug'), 30 | buildScriptPath = '"' + path.join(buildDirectory, projectFolder, 'cordova', 'build') + '"', 31 | originalTimeout; 32 | 33 | beforeEach(function(){ 34 | shell.exec(path.join('bin', 'create') + ' "' + projectFolder + '" com.test.app 応用', {silent : true}); 35 | originalTimeout = jasmine.getEnv().defaultTimeoutInterval; 36 | jasmine.getEnv().defaultTimeoutInterval = 30000; 37 | }); 38 | 39 | afterEach(function() { 40 | shell.cd(buildDirectory); 41 | shell.rm('-rf', projectFolder); 42 | jasmine.getEnv().defaultTimeoutInterval = originalTimeout; 43 | }); 44 | 45 | it('spec.1 should create new project', function(){ 46 | expect(fs.existsSync(projectFolder)).toBe(true); 47 | }); 48 | 49 | it('spec.2 should build project', function(){ 50 | shell.exec(buildScriptPath, {silent:true}); 51 | var packages = shell.ls(anycpuPackageFolder); 52 | expect(packages.filter(function(file) { return file.match(/.*AnyCPU\.xap$/); }).length).toBe(1); 53 | }); 54 | 55 | it('spec.3 should build project for particular CPU', function(){ 56 | shell.exec(buildScriptPath + ' --archs=\"x86\"', {silent : true}); 57 | var x86Package = shell.ls(x86PackageFolder); 58 | expect(x86Package.filter(function(file) { return file.match(/.*x86\.xap$/); }).length).toBe(1); 59 | }); 60 | 61 | it('spec.4 should build project for CPUs separated by whitespaces', function(){ 62 | shell.exec(buildScriptPath + ' --archs=\"x86 arm anycpu\"', {silent : true}); 63 | var anycpuPackage = shell.ls(anycpuPackageFolder); 64 | expect(anycpuPackage.filter(function(file) { return file.match(/.*AnyCPU\.xap$/); }).length).toBe(1); 65 | var x86Package = shell.ls(x86PackageFolder); 66 | expect(x86Package.filter(function(file) { return file.match(/.*x86\.xap$/); }).length).toBe(1); 67 | var armPackage = shell.ls(armPackageFolder); 68 | expect(armPackage.filter(function(file) { return file.match(/.*ARM\.xap$/); }).length).toBe(1); 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /template/CordovaWP8Solution.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | # 5 | # Licensed to the Apache Software Foundation (ASF) under one 6 | # or more contributor license agreements. See the NOTICE file 7 | # distributed with this work for additional information 8 | # regarding copyright ownership. The ASF licenses this file 9 | # to you under the Apache License, Version 2.0 (the 10 | # "License"); you may not use this file except in compliance 11 | # with the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, 16 | # software distributed under the License is distributed on an 17 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 | # KIND, either express or implied. See the License for the 19 | # specific language governing permissions and limitations 20 | # under the License. 21 | # 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CordovaWP8AppProj", "CordovaWP8AppProj.csproj", "{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Any CPU = Debug|Any CPU 27 | Debug|ARM = Debug|ARM 28 | Debug|x64 = Debug|x64 29 | Debug|x86 = Debug|x86 30 | Release|Any CPU = Release|Any CPU 31 | Release|ARM = Release|ARM 32 | Release|x64 = Release|x64 33 | Release|x86 = Release|x86 34 | EndGlobalSection 35 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 36 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 39 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|ARM.ActiveCfg = Debug|ARM 40 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|ARM.Build.0 = Debug|ARM 41 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|ARM.Deploy.0 = Debug|ARM 42 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x64.ActiveCfg = Debug|x64 43 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x64.Build.0 = Debug|x64 44 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x64.Deploy.0 = Debug|x64 45 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x86.ActiveCfg = Debug|x86 46 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x86.Build.0 = Debug|x86 47 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Debug|x86.Deploy.0 = Debug|x86 48 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.Deploy.0 = Release|Any CPU 51 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|ARM.ActiveCfg = Release|ARM 52 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|ARM.Build.0 = Release|ARM 53 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|ARM.Deploy.0 = Release|ARM 54 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x64.ActiveCfg = Release|x64 55 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x64.Build.0 = Release|x64 56 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x64.Deploy.0 = Release|x64 57 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x86.ActiveCfg = Release|x86 58 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x86.Build.0 = Release|x86 59 | {3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|x86.Deploy.0 = Release|x86 60 | EndGlobalSection 61 | GlobalSection(SolutionProperties) = preSolution 62 | HideSolutionNode = FALSE 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 21 | 22 | 23 | Apache Cordova for Windows Phone 8 24 | === 25 | 26 | --- 27 | 📌 **Deprecation Notice** 28 | 29 | This repository is deprecated and no more work will be done on this by Apache Cordova. You can continue to use this and it should work as-is but any future issues will not be fixed by the Cordova community. 30 | 31 | Feel free to fork this repository and improve your fork. Existing forks are listed in [Network](../../network) and [Forks](../../network/members). 32 | 33 | - Learn more: https://github.com/apache/cordova/blob/master/deprecated.md#deprecated-platforms 34 | --- 35 | 36 | [![Build status](https://ci.appveyor.com/api/projects/status/apoby7i5j5xnmhy2/branch/master)](https://ci.appveyor.com/project/Humbedooh/cordova-wp8/branch/master) 37 | 38 | 39 | This repo includes code to build Apache Cordova applications that target Windows Phone 8 SDK. 40 | 41 | An Apache Cordova based applications is, at the core, an application written with web technology: HTML, CSS and JavaScript. 42 | 43 | [Apache Cordova][] is a project at The Apache Software Foundation (ASF). 44 | 45 | Requires 46 | --- 47 | 48 | - [Windows Phone SDK 8][] 49 | -- Windows Phone 8 development requires Windows 8 Professional, and Visual Studio 2012 ( express works ) 50 | 51 | 52 | Getting Started 53 | --- 54 | 55 | 56 | ## Create a new project 57 | 58 | Getting Started from the command line 59 | --- 60 | 61 | >.\wp8\bin\create PathToNewProject [ PackageName ] [ AppName ] 62 | 63 | >PathToNewProject : The path to where you wish to create the project 64 | >PackageName : The namespace for the project (default is Cordova.Example) 65 | >AppName : The name of the application (default is CordovaWP8AppProj) 66 | 67 | >example: 68 | >.\wp8\bin\create C:\Users\anonymous\Desktop\MyWP8Proj io.cordova.example CordovaWP8App 69 | 70 | From here you can open it in Visual Studio: 71 | - Launch Visual Studio and open Solution file (.sln) in (C:\Users\anonymous\Desktop\MyWP8Proj) 72 | - Built and Run it 73 | 74 | Or, you can continue with the command line: 75 | - >cd C:\Users\anonymous\Desktop\MyWP8Proj 76 | >cordova\run 77 | 78 | 79 | BUGS? 80 | ----- 81 | 82 | - File them at the [Apache Cordova Issue Tracker][] 83 | 84 | 85 | Further Reading 86 | --- 87 | 88 | - [Apache Cordova Documentation][] 89 | - [Apache Cordova Wiki][] 90 | 91 | [Windows Phone SDK 8]: http://www.microsoft.com/en-us/download/details.aspx?id=35471 "Download Windows Phone SDK 8" 92 | 93 | [Apache Cordova]: http://cordova.io "Apache Cordova" 94 | [Apache Cordova Issue Tracker]: https://issues.apache.org/jira/browse/CB "Apache Cordova Issue Tracker" 95 | [Apache Cordova Documentation]: http://cordova.io/docs "Apache Cordova Documentation" 96 | [Apache Cordova Wiki]: http://wiki.apache.org/cordova "Apache Cordova Wiki" 97 | 98 | -------------------------------------------------------------------------------- /template/cordovalib/JSON/JsonHelper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using System; 16 | using System.Runtime.Serialization.Json; 17 | using System.IO; 18 | using System.Text; 19 | using System.Diagnostics; 20 | using Newtonsoft.Json; 21 | 22 | namespace WPCordovaClassLib.Cordova.JSON 23 | { 24 | /// 25 | /// Provides JSON serialization/deserialization functionality. 26 | /// 27 | public static class JsonHelper 28 | { 29 | /// 30 | /// Serializes object to JSON string representation 31 | /// 32 | /// object to serialize 33 | /// JSON representation of the object. Returns 'null' string for null passed as argument 34 | public static string Serialize(object obj, bool bUseJsonDotNet = false) 35 | { 36 | if (bUseJsonDotNet) 37 | { 38 | return JsonConvert.SerializeObject(obj); 39 | } 40 | else if (obj == null) 41 | { 42 | return "null"; 43 | } 44 | else 45 | { 46 | 47 | DataContractJsonSerializer ser = new DataContractJsonSerializer(obj.GetType()); 48 | 49 | MemoryStream ms = new MemoryStream(); 50 | ser.WriteObject(ms, obj); 51 | 52 | ms.Position = 0; 53 | 54 | string json = String.Empty; 55 | 56 | using (StreamReader sr = new StreamReader(ms)) 57 | { 58 | json = sr.ReadToEnd(); 59 | } 60 | 61 | ms.Close(); 62 | 63 | return json; 64 | } 65 | 66 | } 67 | 68 | /// 69 | /// Parses json string to object instance 70 | /// 71 | /// type of the object 72 | /// json string representation of the object 73 | /// Deserialized object instance 74 | public static T Deserialize(string json, bool bUseJsonDotNet = false) 75 | { 76 | 77 | if (bUseJsonDotNet) 78 | { 79 | return JsonConvert.DeserializeObject(json); 80 | } 81 | else 82 | { 83 | DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(T)); 84 | object result = null; 85 | try 86 | { 87 | using (MemoryStream mem = new MemoryStream(Encoding.UTF8.GetBytes(json))) 88 | { 89 | result = deserializer.ReadObject(mem); 90 | } 91 | } 92 | catch (Exception ex) 93 | { 94 | Debug.WriteLine(ex.Message); 95 | Debug.WriteLine("Failed to deserialize " + typeof(T) + " with JSON value :: " + json); 96 | } 97 | 98 | return (T)result; 99 | } 100 | 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /template/cordovalib/CordovaCommandCall.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using System; 16 | using System.Net; 17 | using System.Windows; 18 | using System.Windows.Controls; 19 | using System.Windows.Documents; 20 | using System.Windows.Ink; 21 | using System.Windows.Input; 22 | using System.Windows.Media; 23 | using System.Windows.Media.Animation; 24 | using System.Windows.Shapes; 25 | using System.Linq; 26 | using System.Collections.Generic; 27 | 28 | namespace WPCordovaClassLib.Cordova 29 | { 30 | /// 31 | /// Represents Cordova native command call: action callback, etc 32 | /// 33 | public class CordovaCommandCall 34 | { 35 | public String Service { get; private set; } 36 | public String Action { get; private set; } 37 | public String CallbackId { get; private set; } 38 | public String Args { get; private set; } 39 | public String Namespace { get; set; } 40 | 41 | /// 42 | /// Retrieves command call parameters and creates wrapper for them 43 | /// 44 | /// Command string in the form 'service/action/callback/args' 45 | /// New class instance or null of string does not represent Cordova command 46 | public static CordovaCommandCall Parse(string commandStr) 47 | { 48 | //System.Diagnostics.Debug.WriteLine("CommandString : " + commandStr); 49 | if (string.IsNullOrEmpty(commandStr)) 50 | { 51 | return null; 52 | } 53 | 54 | string[] split = commandStr.Split('/'); 55 | if (split.Length < 3) 56 | { 57 | return null; 58 | } 59 | 60 | CordovaCommandCall commandCallParameters = new CordovaCommandCall(); 61 | commandCallParameters.Service = split[0]; 62 | commandCallParameters.Action = split[1]; 63 | commandCallParameters.CallbackId = split[2]; 64 | commandCallParameters.Namespace = String.Empty; 65 | 66 | try 67 | { 68 | string arg = split.Length <= 3 ? "[]" : String.Join("/", split.Skip(3)); 69 | if (!arg.StartsWith("[")) // save the exception 70 | { 71 | arg = string.Format("[{0}]", arg); 72 | } 73 | List args = JSON.JsonHelper.Deserialize>(arg); 74 | args.Add(commandCallParameters.CallbackId); 75 | commandCallParameters.Args = JSON.JsonHelper.Serialize(args.ToArray()); 76 | } 77 | catch (Exception) 78 | { 79 | return null; 80 | } 81 | // sanity check for illegal names 82 | // was failing with :: 83 | // CordovaCommandResult :: 1, Device1, {"status":1,"message":"{\"name\":\"XD..... 84 | if (commandCallParameters.Service.IndexOfAny(new char[] { '@', ':', ',', '!', ' ' }) > -1) 85 | { 86 | return null; 87 | } 88 | 89 | return commandCallParameters; 90 | } 91 | 92 | 93 | /// 94 | /// Private ctr to disable class creation. 95 | /// New class instance must be initialized via CordovaCommandCall.Parse static method. 96 | /// 97 | private CordovaCommandCall() { } 98 | 99 | 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /template/www/css/index.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | * { 20 | -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */ 21 | -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */ 22 | -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ 23 | -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ 24 | } 25 | 26 | body { 27 | background-color:#E4E4E4; 28 | background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); 29 | background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); 30 | background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); 31 | background-image:-webkit-gradient( 32 | linear, 33 | left top, 34 | left bottom, 35 | color-stop(0, #A7A7A7), 36 | color-stop(0.51, #E4E4E4) 37 | ); 38 | background-attachment:fixed; 39 | font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif; 40 | font-size:12px; 41 | height:100%; 42 | margin:0px; 43 | padding:0px; 44 | text-transform:uppercase; 45 | width:100%; 46 | } 47 | 48 | /* Portrait layout (default) */ 49 | .app { 50 | background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */ 51 | position:absolute; /* position in the center of the screen */ 52 | left:50%; 53 | top:50%; 54 | height:50px; /* text area height */ 55 | width:225px; /* text area width */ 56 | text-align:center; 57 | padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */ 58 | margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */ 59 | /* offset horizontal: half of text area width */ 60 | } 61 | 62 | /* Landscape layout (with min-width) */ 63 | @media screen and (min-aspect-ratio: 1/1) and (min-width:400px) { 64 | .app { 65 | background-position:left center; 66 | padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */ 67 | margin:-90px 0px 0px -198px; /* offset vertical: half of image height */ 68 | /* offset horizontal: half of image width and text area width */ 69 | } 70 | } 71 | 72 | h1 { 73 | font-size:24px; 74 | font-weight:normal; 75 | margin:0px; 76 | overflow:visible; 77 | padding:0px; 78 | text-align:center; 79 | } 80 | 81 | .event { 82 | border-radius:4px; 83 | -webkit-border-radius:4px; 84 | color:#FFFFFF; 85 | font-size:12px; 86 | margin:0px 30px; 87 | padding:2px 0px; 88 | } 89 | 90 | .event.listening { 91 | background-color:#333333; 92 | display:block; 93 | } 94 | 95 | .event.received { 96 | background-color:#4B946A; 97 | display:none; 98 | } 99 | 100 | @keyframes fade { 101 | from { opacity: 1.0; } 102 | 50% { opacity: 0.4; } 103 | to { opacity: 1.0; } 104 | } 105 | 106 | @-webkit-keyframes fade { 107 | from { opacity: 1.0; } 108 | 50% { opacity: 0.4; } 109 | to { opacity: 1.0; } 110 | } 111 | 112 | .blink { 113 | animation:fade 3000ms infinite; 114 | -webkit-animation:fade 3000ms infinite; 115 | } 116 | -------------------------------------------------------------------------------- /template/cordova/lib/build.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | /* jshint sub:true */ 21 | 22 | var Q = require('q'), 23 | path = require('path'), 24 | nopt = require('nopt'), 25 | utils = require('./utils'), 26 | shell = require('shelljs'), 27 | MSBuildTools = require('./MSBuildTools'); 28 | 29 | // Platform project root folder 30 | var ROOT = path.join(__dirname, '..', '..'); 31 | 32 | function parseAndValidateArgs(argv) { 33 | // parse and validate args 34 | var args = nopt({'debug': Boolean, 'release': Boolean, 'archs': [String]}, {'-r': '--release'}, argv); 35 | // Validate args 36 | if (args.debug && args.release) { 37 | return Q.reject('Only one of "debug"/"release" options should be specified'); 38 | } 39 | // get build options/defaults and resolvew with buildopts object 40 | return Q.resolve({ 41 | buildType: args.release ? 'release' : 'debug', 42 | buildArchs: args.archs ? args.archs.split(' ') : ['anycpu'], 43 | }); 44 | } 45 | 46 | // help/usage function 47 | module.exports.help = function () { 48 | console.log(''); 49 | console.log('Usage: build [ --debug | --release ] [--archs=""]'); 50 | console.log(' --help : Displays this dialog.'); 51 | console.log(' --debug : Cleans and builds project in debug mode.'); 52 | console.log(' --release : Cleans and builds project in release mode.'); 53 | console.log(' --release : Cleans and builds project in release mode.'); 54 | console.log(' --archs : Builds project binaries for specific chip architectures. `arm` and `x86` are supported for wp8'); 55 | console.log('examples:'); 56 | console.log(' build '); 57 | console.log(' build --debug'); 58 | console.log(' build --release'); 59 | console.log(' build --release --archs="arm x86"'); 60 | console.log(''); 61 | }; 62 | 63 | // builds cordova-windows application with parameters provided. 64 | // See 'help' function for args list 65 | module.exports.run = function (argv) { 66 | if (!utils.isCordovaProject(ROOT)){ 67 | return Q.reject('Could not find project at ' + ROOT); 68 | } 69 | 70 | return parseAndValidateArgs(argv) 71 | .then(function (buildopts) { 72 | // WP8 requires x86 version of MSBuild, CB-6732 73 | var is64bitSystem = process.env['PROCESSOR_ARCHITECTURE'] != 'x86'; 74 | 75 | // Get available msbuild tools 76 | return MSBuildTools.findAvailableVersion(is64bitSystem) 77 | .then(function (msbuildTools) { 78 | // then build all architectures specified 79 | // chain promises each after previous with reduce function 80 | return buildopts.buildArchs.reduce(function (promise, buildarch) { 81 | return promise.then(function () { 82 | buildarch = buildarch == 'anycpu' ? 'any cpu' : buildarch; 83 | // search for first solution file found 84 | // this is performed due to solution file can be renamed in create 85 | var solutionFiles = shell.ls(path.join(ROOT, '*.sln')); 86 | if (solutionFiles && solutionFiles[0]) { 87 | return msbuildTools.buildProject(solutionFiles[0], buildopts.buildType, buildarch); 88 | } 89 | return Q.reject('No solution files found in project directory'); 90 | }); 91 | }, Q()); 92 | }); 93 | }); 94 | }; -------------------------------------------------------------------------------- /template/cordovalib/PluginResult.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using System; 16 | using System.Net; 17 | using System.Windows; 18 | using System.Windows.Controls; 19 | using System.Windows.Documents; 20 | using System.Windows.Ink; 21 | using System.Windows.Input; 22 | using System.Windows.Media; 23 | using System.Windows.Media.Animation; 24 | using System.Windows.Shapes; 25 | using System.Text; 26 | using System.Diagnostics; 27 | 28 | namespace WPCordovaClassLib.Cordova 29 | { 30 | /// 31 | /// Represents command execution result 32 | /// 33 | public class PluginResult : EventArgs 34 | { 35 | /// 36 | /// Predefined resultant messages 37 | /// 38 | public static string[] StatusMessages = new string[] 39 | { 40 | "No result", 41 | "OK", 42 | "Class not found", 43 | "Illegal access", 44 | "Instantiation error", 45 | "Malformed url", 46 | "IO error", 47 | "Invalid action", 48 | "JSON error", 49 | "Error" 50 | }; 51 | 52 | /// 53 | /// Possible command results status codes 54 | /// 55 | public enum Status : int 56 | { 57 | NO_RESULT = 0, 58 | OK, 59 | CLASS_NOT_FOUND_EXCEPTION, 60 | ILLEGAL_ACCESS_EXCEPTION, 61 | INSTANTIATION_EXCEPTION, 62 | MALFORMED_URL_EXCEPTION, 63 | IO_EXCEPTION, 64 | INVALID_ACTION, 65 | JSON_EXCEPTION, 66 | ERROR 67 | }; 68 | 69 | public Status Result { get; private set; } 70 | public string Message { get; set; } 71 | public bool KeepCallback { get; set; } 72 | public string CallbackId { get; set; } 73 | 74 | /// 75 | /// Whether command succeded or not 76 | /// 77 | public bool IsSuccess 78 | { 79 | get 80 | { 81 | return this.Result == Status.OK || this.Result == Status.NO_RESULT; 82 | } 83 | } 84 | 85 | /// 86 | /// Creates new instance of the PluginResult class. 87 | /// 88 | /// Execution result 89 | public PluginResult(Status status) 90 | : this(status, PluginResult.StatusMessages[(int)status]) 91 | { 92 | } 93 | 94 | /// 95 | /// Creates new instance of the PluginResult class. 96 | /// 97 | /// Execution result 98 | /// The message 99 | public PluginResult(Status status, object message) 100 | { 101 | this.Result = status; 102 | this.Message = JSON.JsonHelper.Serialize(message); 103 | } 104 | 105 | public string ToJSONString() 106 | { 107 | string res = String.Format("\"status\":{0},\"message\":{1},\"keepCallback\":{2}", 108 | (int)this.Result, 109 | this.Message, 110 | this.KeepCallback.ToString().ToLower()); 111 | 112 | res = "{" + res + "}"; 113 | return res; 114 | 115 | } 116 | 117 | [Obsolete] 118 | public string ToCallbackString(string callbackId, string successCallback, string errorCallback) 119 | { 120 | if (this.IsSuccess) 121 | { 122 | StringBuilder buf = new StringBuilder(""); 123 | buf.Append(String.Format("{0}('{1}',{2});", successCallback, callbackId, this.ToJSONString())); 124 | return buf.ToString(); 125 | } 126 | else 127 | { 128 | return String.Format("{0}('{1}',{2});", errorCallback, callbackId, this.ToJSONString()); 129 | } 130 | } 131 | 132 | public override String ToString() 133 | { 134 | return this.ToJSONString(); 135 | } 136 | 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /template/cordova/lib/run.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var Q = require('q'), 21 | nopt = require('nopt'), 22 | path = require('path'), 23 | build = require('./build'), 24 | utils = require('./utils'), 25 | packages = require('./package'); 26 | 27 | var ROOT = path.join(__dirname, '..', '..'); 28 | 29 | module.exports.run = function (argv) { 30 | if (!utils.isCordovaProject(ROOT)) { 31 | return Q.reject('Could not find project at ' + ROOT); 32 | } 33 | 34 | // parse args 35 | var args = nopt({'debug': Boolean, 'release': Boolean, 'nobuild': Boolean, 36 | 'device': Boolean, 'emulator': Boolean, 'target': String, 'archs': String}, 37 | {'r' : '--release'}, argv); 38 | 39 | // Validate args 40 | if (args.debug && args.release) { 41 | return Q.reject('Only one of "debug"/"release" options should be specified'); 42 | } 43 | if ((args.device && args.emulator) || ((args.device || args.emulator) && args.target)) { 44 | return Q.reject('Only one of "device"/"emulator"/"target" options should be specified'); 45 | } 46 | 47 | // Get build/deploy options 48 | var buildType = args.release ? 'release' : 'debug', 49 | buildArchs = args.archs ? args.archs.split(' ') : ['anycpu']; 50 | 51 | // if --nobuild isn't specified then build app first 52 | var buildPackages = args.nobuild ? Q() : build.run(argv); 53 | 54 | return buildPackages 55 | .then(function () { 56 | return packages.getPackage(buildType, buildArchs[0]); 57 | }) 58 | .then(function (builtPackage) { 59 | // Get deploy options 60 | var deployTarget = args.target ? args.target : args.device ? 'device' : 61 | args.emulator ? 'emulator' : null; 62 | 63 | if (deployTarget) { 64 | console.log('\nDeploying package to ' + deployTarget); 65 | return builtPackage.deployTo(deployTarget); 66 | } 67 | // no deploy target specified - try device first & then emulator 68 | console.log('\nTrying to deploy to device'); 69 | return builtPackage.deployTo('device').catch(function (error) { 70 | console.log(error); 71 | console.log('\nFalling back to deploy to emulator instead'); 72 | return builtPackage.deployTo('emulator'); 73 | }); 74 | }); 75 | }; 76 | 77 | module.exports.help = function () { 78 | console.log(''); 79 | console.log('Usage:'); 80 | console.log(' run [ --device || --emulator || --target= ] '); 81 | console.log(' [ --debug || --release || --nobuild ]'); 82 | console.log(' [--archs=\"\"]'); 83 | console.log(' --device : Deploys and runs the project on the connected device.'); 84 | console.log(' --emulator : [DEFAULT] Deploys and runs the project on an emulator.'); 85 | console.log(' --target= : Deploys and runs the project on the specified target.'); 86 | console.log(' --debug : [DEFAULT] Builds project in debug mode.'); 87 | console.log(' --release : Builds project in release mode.'); 88 | console.log(' --nobuild : Ueses pre-built xap, or errors if project is not built.'); 89 | console.log(' --archs : Builds project binaries for specific chip architectures.'); 90 | console.log(' Deploys and runs package with first architecture specified.'); 91 | console.log(' arm` and `x86` are supported for wp8'); 92 | console.log('Examples:'); 93 | console.log(' run'); 94 | console.log(' run --emulator'); 95 | console.log(' run --device'); 96 | console.log(' run --target=7988B8C3-3ADE-488d-BA3E-D052AC9DC710'); 97 | console.log(' run --device --release'); 98 | console.log(' run --emulator --debug'); 99 | console.log(''); 100 | }; -------------------------------------------------------------------------------- /template/cordovalib/CommandFactory.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using System; 16 | using System.Net; 17 | using System.Windows; 18 | using System.Windows.Controls; 19 | using System.Windows.Documents; 20 | using System.Windows.Ink; 21 | using System.Windows.Input; 22 | using System.Windows.Media; 23 | using System.Windows.Media.Animation; 24 | using System.Windows.Shapes; 25 | using System.Collections.Generic; 26 | using WPCordovaClassLib.Cordova.Commands; 27 | using System.Reflection; 28 | using System.Diagnostics; 29 | 30 | namespace WPCordovaClassLib.Cordova 31 | { 32 | /// 33 | /// Provides functionality to create Cordova command by name. 34 | /// 35 | public static class CommandFactory 36 | { 37 | /// 38 | /// Represents predefined namespace name for custom plugins 39 | /// 40 | private static readonly string CustomPluginNamespacePrefix = "Cordova.Extension.Commands."; 41 | 42 | private static readonly string BaseCommandNamespacePrefix = "WPCordovaClassLib.Cordova.Commands."; 43 | 44 | /// 45 | /// Cache instantiated commands in a map. 46 | /// 47 | 48 | private static Dictionary commandMap = new Dictionary(); 49 | 50 | /// 51 | /// Creates command using command class name. Returns null for unknown commands. 52 | /// 53 | /// Command class name, for example Device or Notification 54 | /// Command class instance or null 55 | /// alias can be used as a namespace which is resolved + service 56 | /// or it can be the fully qualified classname 57 | /// or the classname in the current assembly 58 | public static BaseCommand CreateByServiceName(string service, string alias="") 59 | { 60 | 61 | if (string.IsNullOrEmpty(service)) 62 | { 63 | throw new ArgumentNullException("service", "service to create can't be null"); 64 | } 65 | 66 | if (!commandMap.ContainsKey(service)) 67 | { 68 | Type t = Type.GetType(BaseCommandNamespacePrefix + service); 69 | 70 | if (t == null && !string.IsNullOrEmpty(alias)) 71 | { 72 | t = Type.GetType(alias); 73 | 74 | if (t == null) 75 | { 76 | t = Type.GetType(BaseCommandNamespacePrefix + alias); 77 | } 78 | 79 | if (t == null) 80 | { 81 | t = Type.GetType(alias + "." + service); 82 | } 83 | } 84 | 85 | // custom plugin could be defined in own namespace and assembly 86 | if (t == null) 87 | { 88 | string serviceFullName = service.Contains(".") ? service : CustomPluginNamespacePrefix + service; 89 | 90 | foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) 91 | { 92 | // in this case service name represents full type name including namespace 93 | t = a.GetType(serviceFullName); 94 | 95 | if (t == null) // try the Commands Namespace 96 | { 97 | t = a.GetType(BaseCommandNamespacePrefix + service); 98 | } 99 | 100 | if (t != null) 101 | { 102 | break; 103 | } 104 | } 105 | } 106 | 107 | // unknown command, still didn't find it 108 | if (t == null) 109 | { 110 | Debug.WriteLine("Unable to locate command :: " + service); 111 | return null; 112 | } 113 | 114 | commandMap[service] = Activator.CreateInstance(t) as BaseCommand; 115 | } 116 | 117 | return commandMap[service]; 118 | } 119 | 120 | public static void ResetAllCommands() 121 | { 122 | foreach (BaseCommand bc in commandMap.Values) 123 | { 124 | bc.OnReset(); 125 | } 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /template/cordovalib/OrientationHelper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using System; 16 | using System.Net; 17 | using System.Windows; 18 | using System.Windows.Controls; 19 | using System.Windows.Documents; 20 | using System.Windows.Ink; 21 | using System.Windows.Input; 22 | using System.Windows.Media; 23 | using System.Windows.Media.Animation; 24 | using System.Windows.Shapes; 25 | using Microsoft.Phone.Controls; 26 | using WPCordovaClassLib.CordovaLib; 27 | 28 | namespace WPCordovaClassLib.Cordova 29 | { 30 | public class OrientationHelper : IBrowserDecorator 31 | { 32 | public WebBrowser Browser { get; set; } 33 | 34 | public PhoneApplicationPage Page 35 | { 36 | get 37 | { 38 | PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; 39 | if (frame != null) 40 | { 41 | return frame.Content as PhoneApplicationPage; 42 | } 43 | return null; 44 | } 45 | } 46 | 47 | // private PageOrientation CurrentOrientation = PageOrientation.PortraitUp; 48 | //private PageOrientation[] SupportedOrientations; // TODO: 49 | 50 | public void InjectScript() 51 | { 52 | int i = 0; 53 | 54 | switch (Page.Orientation) 55 | { 56 | case PageOrientation.Portrait: // intentional fall through 57 | case PageOrientation.PortraitUp: 58 | i = 0; 59 | break; 60 | case PageOrientation.PortraitDown: 61 | i = 180; 62 | break; 63 | case PageOrientation.Landscape: // intentional fall through 64 | case PageOrientation.LandscapeLeft: 65 | i = -90; 66 | break; 67 | case PageOrientation.LandscapeRight: 68 | i = 90; 69 | break; 70 | } 71 | string jsCallback = String.Format("window.orientation = {0};", i); 72 | 73 | try 74 | { 75 | Browser.InvokeScript("eval", new string[] { jsCallback }); 76 | } 77 | catch (Exception) 78 | { 79 | } 80 | } 81 | 82 | void page_OrientationChanged(object sender, OrientationChangedEventArgs e) 83 | { 84 | int i = 0; 85 | 86 | switch (e.Orientation) 87 | { 88 | case PageOrientation.Portrait: // intentional fall through 89 | case PageOrientation.PortraitUp: 90 | i = 0; 91 | break; 92 | case PageOrientation.PortraitDown: 93 | i = 180; 94 | break; 95 | case PageOrientation.Landscape: // intentional fall through 96 | case PageOrientation.LandscapeLeft: 97 | i = -90; 98 | break; 99 | case PageOrientation.LandscapeRight: 100 | i = 90; 101 | break; 102 | } 103 | // Cordova.fireEvent('orientationchange', window); 104 | string jsCallback = String.Format("window.orientation = {0};", i); 105 | 106 | try 107 | { 108 | 109 | Browser.InvokeScript("eval", new string[] { jsCallback }); 110 | 111 | jsCallback = "var evt = document.createEvent('HTMLEvents');"; 112 | jsCallback += "evt.initEvent( 'orientationchange', true, false );"; 113 | jsCallback += "window.dispatchEvent(evt);"; 114 | jsCallback += "if(window.onorientationchange){window.onorientationchange(evt);}"; 115 | 116 | Browser.InvokeScript("eval", new string[] {jsCallback}); 117 | } 118 | catch (Exception) 119 | { 120 | } 121 | } 122 | 123 | public bool HandleCommand(string commandStr) 124 | { 125 | // No commands are currently accepted. 126 | return true; 127 | } 128 | 129 | public void AttachNativeHandlers() 130 | { 131 | // nothing todo 132 | } 133 | 134 | public void DetachNativeHandlers() 135 | { 136 | // nothing to do 137 | } 138 | } 139 | 140 | 141 | } 142 | -------------------------------------------------------------------------------- /bin/lib/check_reqs.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var Q = require('q'); 21 | 22 | var MSBuildTools; 23 | try { 24 | MSBuildTools = require('../../template/cordova/lib/MSBuildTools'); 25 | } catch (ex) { 26 | // If previous import fails, we're probably running this script 27 | // from installed platform and the module location is different. 28 | MSBuildTools = require('./MSBuildTools'); 29 | } 30 | 31 | /** 32 | * Check if current OS is supports building windows platform 33 | * @return {Promise} Promise either fullfilled or rejected with error message. 34 | */ 35 | var checkOS = function () { 36 | var platform = process.platform; 37 | return (platform === 'win32') ? 38 | Q.resolve(platform): 39 | // Build Universal windows apps available for windows platform only, so we reject on others platforms 40 | Q.reject('Cordova tooling for Windows requires Windows OS to build project'); 41 | }; 42 | 43 | /** 44 | * Checks if MSBuild tools is available. 45 | * @return {Promise} Promise either fullfilled with MSBuild version 46 | * or rejected with error message. 47 | */ 48 | var checkMSBuild = function () { 49 | return MSBuildTools.findAvailableVersion() 50 | .then(function (msbuildTools) { 51 | return Q.resolve(msbuildTools.version); 52 | }, function () { 53 | return Q.reject('MSBuild tools not found. Please install MSBuild tools or VS 2013 from ' + 54 | 'https://www.visualstudio.com/downloads/download-visual-studio-vs'); 55 | }); 56 | }; 57 | 58 | module.exports.run = function () { 59 | return checkOS().then(function () { 60 | // Check whether MSBuild Tools are available 61 | return MSBuildTools.findAvailableVersion(); 62 | }); 63 | }; 64 | 65 | /** 66 | * Object that represents one of requirements for current platform. 67 | * @param {String} id The unique identifier for this requirements. 68 | * @param {String} name The name of requirements. Human-readable field. 69 | * @param {Boolean} isFatal Marks the requirement as fatal. If such requirement will fail 70 | * next requirements' checks will be skipped. 71 | */ 72 | var Requirement = function (id, name, isFatal) { 73 | this.id = id; 74 | this.name = name; 75 | this.installed = false; 76 | this.metadata = {}; 77 | this.isFatal = isFatal || false; 78 | }; 79 | 80 | /** 81 | * Methods that runs all checks one by one and returns a result of checks 82 | * as an array of Requirement objects. This method intended to be used by cordova-lib check_reqs method 83 | * 84 | * @return Promise Array of requirements. Due to implementation, promise is always fulfilled. 85 | */ 86 | module.exports.check_all = function() { 87 | 88 | var requirements = [ 89 | new Requirement('os', 'Windows OS', true), 90 | new Requirement('msbuild', 'MSBuild Tools') 91 | ]; 92 | 93 | var result = []; 94 | var fatalIsHit = false; 95 | 96 | // Define list of checks needs to be performed 97 | var checkFns = [checkOS, checkMSBuild]; 98 | // Then execute requirement checks one-by-one 99 | return checkFns.reduce(function (promise, checkFn, idx) { 100 | return promise.then(function () { 101 | // If fatal requirement is failed, 102 | // we don't need to check others 103 | if (fatalIsHit) return Q(); 104 | 105 | var requirement = requirements[idx]; 106 | return checkFn() 107 | .then(function (version) { 108 | requirement.installed = true; 109 | requirement.metadata.version = version; 110 | result.push(requirement); 111 | }, function (err) { 112 | if (requirement.isFatal) fatalIsHit = true; 113 | requirement.metadata.reason = err; 114 | result.push(requirement); 115 | }); 116 | }); 117 | }, Q()) 118 | .then(function () { 119 | // When chain is completed, return requirements array to upstream API 120 | return result; 121 | }); 122 | }; 123 | 124 | module.exports.help = function () { 125 | console.log('Usage: check_reqs or node check_reqs'); 126 | }; 127 | -------------------------------------------------------------------------------- /template/cordova/lib/utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | /* jshint sub:true */ 21 | 22 | var Q = require('q'), 23 | fs = require('fs'), 24 | path = require('path'), 25 | proc = require('child_process'), 26 | msbuildTools = require('./MSBuildTools'); 27 | 28 | // returns path to app deployment util from Windows Phone 8.x SDK 29 | module.exports.getXapDeploy = function () { 30 | var toolsLookupLocations = [ 31 | // Windows Phone 8.0 32 | path.join((process.env['ProgramFiles(x86)'] || process.env['ProgramFiles']), 33 | 'Microsoft SDKs', 'Windows Phone', 'v8.0', 'Tools', 'Xap Deployment', 'XapDeployCmd.exe'), 34 | // Windows Phone 8.1 35 | path.join((process.env['ProgramFiles(x86)'] || process.env['ProgramFiles']), 36 | 'Microsoft SDKs', 'Windows Phone', 'v8.1', 'Tools', 'AppDeploy', 'AppDeployCmd.exe') 37 | ]; 38 | 39 | for (var idx in toolsLookupLocations) { 40 | if (fs.existsSync(toolsLookupLocations[idx])) { 41 | return Q.resolve(toolsLookupLocations[idx]); 42 | } 43 | } 44 | 45 | console.warn('WARNING: XapDeploy tool (XapDeployCmd.exe) didn\'t found. Assume that it\'s in %PATH%'); 46 | return Q.resolve('XapDeployCmd'); 47 | }; 48 | 49 | module.exports.getOSVersion = function () { 50 | return module.exports.exec('reg query "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion" /v CurrentVersion') 51 | .then(function(output) { 52 | // fetch msbuild path from 'reg' output 53 | var version = /CurrentVersion\s+REG_SZ\s+(.*)/i.exec(output); 54 | if (version) { 55 | return Q.resolve(version[1]); 56 | } 57 | return Q.reject('Can\'t fetch version number from reg output'); 58 | }, function (err) { 59 | return Q.reject('Failed to query OS version ' + err); 60 | }); 61 | }; 62 | 63 | module.exports.getSDKVersion = function () { 64 | var is64bitSystem = process.env['PROCESSOR_ARCHITECTURE'] != 'x86'; 65 | return msbuildTools.findAvailableVersion(is64bitSystem) 66 | .then(function (msbuild) { 67 | return module.exports.exec(module.exports.quote(path.join(msbuild.path, 'msbuild')) + ' -version') 68 | .then(function (output) { 69 | var version = /\.NET\sFramework\,\s[a-z]+\s(\d+\.\d+\.\d+)/gi.exec(output); 70 | if (version) { 71 | return Q.resolve(version[1]); 72 | } 73 | return Q.reject('Unable to get the .NET Framework version'); 74 | }, function (err) { 75 | return Q.reject('Unable to get the .NET Framework version: ' + err); 76 | }); 77 | }); 78 | }; 79 | 80 | // checks to see if a .jsproj file exists in the project root 81 | module.exports.isCordovaProject = function (platformpath) { 82 | if (fs.existsSync(platformpath)) { 83 | var files = fs.readdirSync(platformpath); 84 | for (var i in files){ 85 | if (path.extname(files[i]) == '.csproj'){ 86 | return true; 87 | } 88 | } 89 | } 90 | return false; 91 | }; 92 | 93 | // Takes a command and optional current working directory. 94 | // Returns a promise that either resolves with the stdout, or 95 | // rejects with an error message and the stderr. 96 | module.exports.exec = function(cmd, opt_cwd) { 97 | var d = Q.defer(); 98 | try { 99 | proc.exec(cmd, {cwd: opt_cwd, maxBuffer: 1024000}, function(err, stdout, stderr) { 100 | if (err) d.reject('Error executing "' + cmd + '": ' + stderr); 101 | else d.resolve(stdout); 102 | }); 103 | } catch(e) { 104 | console.error('error caught: ' + e); 105 | d.reject(e); 106 | } 107 | return d.promise; 108 | }; 109 | 110 | // Takes a command and optional current working directory. 111 | module.exports.spawn = function(cmd, args, opt_cwd) { 112 | var d = Q.defer(); 113 | try { 114 | var child = proc.spawn(cmd, args, {cwd: opt_cwd, stdio: 'inherit'}); 115 | child.on('exit', function(code) { 116 | if (code) { 117 | d.reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' + args); 118 | } else { 119 | d.resolve(); 120 | } 121 | }); 122 | } catch(e) { 123 | console.error('error caught: ' + e); 124 | d.reject(e); 125 | } 126 | return d.promise; 127 | }; 128 | 129 | module.exports.quote = function(str) { 130 | return '"' + str + '"'; 131 | }; 132 | -------------------------------------------------------------------------------- /template/cordovalib/ConsoleHelper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | /************************************************************************ 16 | This class is intended to supply the minimum expected browser behavior 17 | for console.log|warn|info ... 18 | js code that is loaded in a minimal cordova application running on a device 19 | or emulator will output console.log calls to Visual Studio's output window 20 | when run from Visual Studio. 21 | 22 | For more advanced/complete console logging functions, 23 | look at cordova-plugin-console. 24 | ************************************************************************/ 25 | 26 | using Microsoft.Phone.Controls; 27 | using Microsoft.Phone.Shell; 28 | using System; 29 | using System.Collections.Generic; 30 | using System.Diagnostics; 31 | using System.IO; 32 | using System.IO.IsolatedStorage; 33 | using System.Linq; 34 | using System.Text; 35 | 36 | namespace WPCordovaClassLib.CordovaLib 37 | { 38 | class ConsoleHelper : IBrowserDecorator 39 | { 40 | 41 | public WebBrowser Browser { get; set; } 42 | 43 | protected bool hasListener = false; 44 | 45 | 46 | 47 | public void InjectScript() 48 | { 49 | using(IsolatedStorageFileStream file = new IsolatedStorageFileStream("debugOutput.txt", FileMode.Create, FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication())) 50 | { 51 | } 52 | 53 | string script = 54 | @"(function(win) { 55 | function stringify() { 56 | // Convert arguments to strings and concat them with comma. 57 | return Array.prototype.map.call( arguments, function argumentToString( argument ) { 58 | // Return primitives as string. 59 | if( typeof argument === 'string' || typeof argument === 'number' ) { 60 | return argument; 61 | } 62 | if( typeof argument === 'function' ) { 63 | return argument.toString(); 64 | } 65 | // Convert complex arguments to JSON. 66 | try { 67 | return JSON.stringify( argument ); 68 | } catch( ignored ) { 69 | return argument.toString(); 70 | } 71 | } ) 72 | .join( ',' ); 73 | } 74 | function exec() { window.external.Notify( 'ConsoleLog/' + stringify.apply( null, arguments ) ); } 75 | var cons = win.console = win.console || {}; 76 | cons.log = exec; 77 | cons.debug = cons.debug || cons.log; 78 | cons.info = cons.info || function() { exec( 'INFO:' + stringify.apply( null, arguments ) ); }; 79 | cons.warn = cons.warn || function() { exec( 'WARN:' + stringify.apply( null, arguments ) ); }; 80 | cons.error = cons.error || function() { exec( 'ERROR:' + stringify.apply( null, arguments ) ); }; 81 | })(window);"; 82 | 83 | Browser.InvokeScript("eval", new string[] { script }); 84 | } 85 | 86 | void OnServiceClosing(object sender, ClosingEventArgs e) 87 | { 88 | using (IsolatedStorageFileStream file = new IsolatedStorageFileStream("debugOutput.txt", FileMode.Append, FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication())) 89 | { 90 | using (StreamWriter writeFile = new StreamWriter(file)) 91 | { 92 | writeFile.WriteLine("EXIT"); 93 | writeFile.Close(); 94 | } 95 | file.Close(); 96 | } 97 | } 98 | 99 | public bool HandleCommand(string commandStr) 100 | { 101 | string output = commandStr.Substring("ConsoleLog/".Length); 102 | Debug.WriteLine(output); 103 | using (IsolatedStorageFileStream file = new IsolatedStorageFileStream("debugOutput.txt", FileMode.Append, FileAccess.Write, IsolatedStorageFile.GetUserStoreForApplication())) 104 | { 105 | using (StreamWriter writeFile = new StreamWriter(file)) 106 | { 107 | writeFile.WriteLine(output); 108 | writeFile.Close(); 109 | } 110 | file.Close(); 111 | } 112 | return true; 113 | } 114 | 115 | public void AttachNativeHandlers() 116 | { 117 | PhoneApplicationService.Current.Closing += OnServiceClosing; 118 | } 119 | 120 | public void DetachNativeHandlers() 121 | { 122 | PhoneApplicationService.Current.Closing -= OnServiceClosing; 123 | } 124 | 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /template/cordovalib/BrowserMouseHelper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | using System.Linq; 20 | using System.Windows; 21 | using System.Windows.Controls; 22 | using Microsoft.Phone.Controls; 23 | using System.Windows.Input; 24 | using System.Diagnostics; 25 | using System.Windows.Media; 26 | using System; 27 | using System.Collections.Generic; 28 | 29 | namespace WPCordovaClassLib 30 | { 31 | 32 | /// 33 | /// Suppresses pinch zoom and optionally scrolling of the WebBrowser control 34 | /// 35 | public class BrowserMouseHelper 36 | { 37 | private WebBrowser _browser; 38 | 39 | /// 40 | /// Gets or sets whether to suppress the scrolling of 41 | /// the WebBrowser control; 42 | /// 43 | public bool ScrollDisabled { 44 | get; 45 | set; 46 | } 47 | 48 | private bool userScalable = true; 49 | private double maxScale = 2.0; 50 | private double minScale = 0.5; 51 | protected Border border; 52 | 53 | /// 54 | /// Represent min delta value to consider event as a mouse move. Experimental calculated. 55 | /// 56 | private const int MouseMoveDeltaThreshold = 10; 57 | 58 | public BrowserMouseHelper(ref WebBrowser browser) 59 | { 60 | _browser = browser; 61 | browser.Loaded += new RoutedEventHandler(browser_Loaded); 62 | } 63 | 64 | private void browser_Loaded(object sender, RoutedEventArgs e) 65 | { 66 | var border0 = VisualTreeHelper.GetChild(_browser, 0); 67 | var border1 = VisualTreeHelper.GetChild(border0, 0); 68 | var panZoom = VisualTreeHelper.GetChild(border1, 0); 69 | var grid = VisualTreeHelper.GetChild(panZoom, 0); 70 | var grid2 = VisualTreeHelper.GetChild(grid, 0); 71 | border = VisualTreeHelper.GetChild(grid2, 0) as Border; 72 | 73 | if (border != null) 74 | { 75 | border.ManipulationDelta += Border_ManipulationDelta; 76 | border.ManipulationCompleted += Border_ManipulationCompleted; 77 | } 78 | 79 | _browser.LoadCompleted += Browser_LoadCompleted; 80 | 81 | } 82 | 83 | void ParseViewportMeta() 84 | { 85 | string metaScript = "(function() { return document.querySelector('meta[name=viewport]').content; })()"; 86 | 87 | try 88 | { 89 | string metaContent = _browser.InvokeScript("eval", new string[] { metaScript }) as string; 90 | string[] arr = metaContent.Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries); 91 | Dictionary metaDictionary = new Dictionary(); 92 | foreach (string val in arr) 93 | { 94 | string[] keyVal = val.Split('='); 95 | metaDictionary.Add(keyVal[0], keyVal[1]); 96 | } 97 | 98 | this.userScalable = false; // reset to default 99 | if (metaDictionary.ContainsKey("user-scalable")) 100 | { 101 | this.userScalable = metaDictionary["user-scalable"] == "yes"; 102 | } 103 | 104 | this.maxScale = 2.0;// reset to default 105 | if (metaDictionary.ContainsKey("maximum-scale")) 106 | { 107 | this.maxScale = double.Parse(metaDictionary["maximum-scale"]); 108 | } 109 | 110 | this.minScale = 0.5;// reset to default 111 | if (metaDictionary.ContainsKey("minimum-scale")) 112 | { 113 | this.minScale = double.Parse(metaDictionary["minimum-scale"]); 114 | } 115 | } 116 | catch (Exception) 117 | { 118 | 119 | } 120 | } 121 | 122 | void Browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) 123 | { 124 | ParseViewportMeta(); 125 | } 126 | 127 | #region ManipulationEvents 128 | 129 | private void Border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) 130 | { 131 | //Debug.WriteLine("Border_ManipulationDelta"); 132 | // optionally suppress zoom 133 | if ((ScrollDisabled || !userScalable) && (e.DeltaManipulation.Scale.X != 0.0 || e.DeltaManipulation.Scale.Y != 0.0)) 134 | { 135 | e.Handled = true; 136 | } 137 | // optionally suppress scrolling 138 | if (ScrollDisabled && (e.DeltaManipulation.Translation.X != 0.0 || e.DeltaManipulation.Translation.Y != 0.0)) 139 | { 140 | e.Handled = true; 141 | } 142 | } 143 | 144 | private void Border_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) 145 | { 146 | //Debug.WriteLine("Border_ManipulationCompleted"); 147 | // suppress zoom 148 | if (ScrollDisabled || ( !userScalable && e.FinalVelocities != null) ) 149 | { 150 | if (e.FinalVelocities.ExpansionVelocity.X != 0.0 || 151 | e.FinalVelocities.ExpansionVelocity.Y != 0.0) 152 | { 153 | e.Handled = true; 154 | } 155 | } 156 | } 157 | 158 | 159 | #endregion 160 | 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /spec/unit/run.spec.js: -------------------------------------------------------------------------------- 1 | /** 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | var Q = require('q'), 20 | path = require('path'), 21 | rewire = require('rewire'), 22 | platformRoot = '../../template', 23 | buildPath = path.join(platformRoot, 'cordova', 'build'), 24 | run = rewire(platformRoot + '/cordova/lib/run.js'); 25 | 26 | describe('run method', function() { 27 | var consoleLogOriginal, 28 | isCordovaProjectOriginal, 29 | buildRunOriginal, 30 | getPackageOriginal; 31 | 32 | var isCordovaProjectFalse = function () { 33 | return false; 34 | }; 35 | 36 | var isCordovaProjectTrue = function () { 37 | return true; 38 | }; 39 | 40 | beforeEach(function () { 41 | // console output suppression 42 | consoleLogOriginal = run.__get__('console.log'); 43 | run.__set__('console.log', function () {} ); 44 | 45 | isCordovaProjectOriginal = run.__get__('utils.isCordovaProject'); 46 | buildRunOriginal = run.__get__('build.run'); 47 | getPackageOriginal = run.__get__('packages.getPackage'); 48 | }); 49 | 50 | afterEach(function() { 51 | run.__set__('utils.isCordovaProject', isCordovaProjectOriginal); 52 | run.__set__('build.run', buildRunOriginal); 53 | run.__set__('packages.getPackage', getPackageOriginal); 54 | }); 55 | 56 | it('spec.1 should not run if not launched from project directory', function(done) { 57 | var buildRun = jasmine.createSpy(); 58 | 59 | run.__set__('utils.isCordovaProject', isCordovaProjectFalse); 60 | run.__set__('build.run', function () { 61 | buildRun(); 62 | return Q.reject(); // rejecting to break run chain 63 | }); 64 | 65 | run.run([ 'node', buildPath ]) 66 | .finally(function() { 67 | expect(buildRun).not.toHaveBeenCalled(); 68 | done(); 69 | }); 70 | }); 71 | 72 | it('spec.2 should not run if both debug and release args are specified', function(done) { 73 | var buildRun = jasmine.createSpy(); 74 | 75 | run.__set__('utils.isCordovaProject', isCordovaProjectTrue); 76 | run.__set__('build.run', function () { 77 | buildRun(); 78 | return Q.reject(); // rejecting to break run chain 79 | }); 80 | 81 | run.run([ 'node', buildPath, '--release', '--debug' ]) 82 | .finally(function() { 83 | expect(buildRun).not.toHaveBeenCalled(); 84 | done(); 85 | }); 86 | }); 87 | 88 | it('spec.3 should not run if device and emulator args are combined', function(done) { 89 | var buildRun = jasmine.createSpy(); 90 | 91 | run.__set__('utils.isCordovaProject', isCordovaProjectTrue); 92 | run.__set__('build.run', function () { 93 | buildRun(); 94 | return Q.reject(); // rejecting to break run chain 95 | }); 96 | run.run([ 'node', buildPath, '--device', '--emulator' ]) 97 | .finally(function() { 98 | expect(buildRun).not.toHaveBeenCalled(); 99 | done(); 100 | }); 101 | }); 102 | 103 | it('spec.4 should not run if device and target args are combined', function(done) { 104 | var buildRun = jasmine.createSpy(); 105 | 106 | run.__set__('utils.isCordovaProject', isCordovaProjectTrue); 107 | run.__set__('build.run', function () { 108 | buildRun(); 109 | return Q.reject(); // rejecting to break run chain 110 | }); 111 | run.run([ 'node', buildPath, '--device', '--target=sometargethere' ]) 112 | .finally(function() { 113 | expect(buildRun).not.toHaveBeenCalled(); 114 | done(); 115 | }); 116 | }); 117 | 118 | it('spec.5 should build and run if all args are ok', function(done) { 119 | var build = jasmine.createSpy(), 120 | deploy = jasmine.createSpy(); 121 | 122 | run.__set__('utils.isCordovaProject', isCordovaProjectTrue); 123 | run.__set__('build.run', function () { 124 | build(); 125 | return Q(); 126 | }); 127 | run.__set__('packages.getPackage', function () { 128 | return Q({ 129 | deployTo: function () { 130 | deploy(); 131 | return Q(); 132 | } 133 | }); 134 | }); 135 | 136 | run.run([ 'node', buildPath, '--emulator' ]) 137 | .finally(function() { 138 | expect(build).toHaveBeenCalled(); 139 | expect(deploy).toHaveBeenCalled(); 140 | done(); 141 | }); 142 | }); 143 | 144 | it('spec.6 should not call build if --nobuild specified', function(done) { 145 | var build = jasmine.createSpy(), 146 | deploy = jasmine.createSpy(); 147 | 148 | run.__set__('utils.isCordovaProject', isCordovaProjectTrue); 149 | run.__set__('build.run', function () { 150 | build(); 151 | return Q(); 152 | }); 153 | run.__set__('packages.getPackage', function () { 154 | return Q({ 155 | deployTo: function () { 156 | deploy(); 157 | return Q(); 158 | } 159 | }); 160 | }); 161 | 162 | run.run([ 'node', buildPath, '--nobuild' ]) 163 | .finally(function() { 164 | expect(build).not.toHaveBeenCalled(); 165 | expect(deploy).toHaveBeenCalled(); 166 | done(); 167 | }); 168 | }); 169 | }); 170 | -------------------------------------------------------------------------------- /spec/unit/MSBuildTools.spec.js: -------------------------------------------------------------------------------- 1 | /** 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | var Q = require('q'), 20 | rewire = require('rewire'), 21 | platformRoot = '../../template', 22 | buildTools = rewire(platformRoot + '/cordova/lib/MSBuildTools.js'); 23 | 24 | var fakeToolsPath = function (version) { 25 | return 'C:\\Program Files (x86)\\MSBuild\\' + version; 26 | }; 27 | 28 | describe('findAvailableVersion method', function(){ 29 | var checkMSBuildVersionOriginal; 30 | 31 | var checkMSBuildVersionFake = function (availableVersions, version) { 32 | var MSBuildTools = buildTools.__get__('MSBuildTools'); 33 | return (availableVersions.indexOf(version) >= 0) ? Q.resolve(new MSBuildTools(version, fakeToolsPath(version))) : Q.resolve(null); 34 | }; 35 | 36 | var versionTest = function (availableVersions, version, done) { 37 | buildTools.__set__('checkMSBuildVersion', checkMSBuildVersionFake.bind(null, availableVersions)); 38 | buildTools.findAvailableVersion().then(function (msbuildTools) { 39 | expect(msbuildTools).not.toBeNull(); 40 | expect(msbuildTools.version).toBeDefined(); 41 | expect(msbuildTools.path).toBeDefined(); 42 | expect(msbuildTools.version).toBe(version); 43 | expect(msbuildTools.path).toBe(fakeToolsPath(version)); 44 | if (typeof done === 'function') { 45 | done(); 46 | } 47 | }); 48 | }; 49 | 50 | beforeEach(function () { 51 | checkMSBuildVersionOriginal = buildTools.__get__('checkMSBuildVersion'); 52 | }); 53 | 54 | afterEach(function () { 55 | buildTools.__set__('checkMSBuildVersion', checkMSBuildVersionOriginal); 56 | }); 57 | 58 | it('spec.1 should find 14.0 available version if 12.0 is unavailable', function(done){ 59 | versionTest(['14.0'], '14.0', done); 60 | }); 61 | 62 | it('spec.2 should select 14.0 available version even if 12.0 is also available', function(done){ 63 | versionTest(['14.0', '12.0', '4.0'], '14.0', done); 64 | }); 65 | 66 | it('spec.3 should find 12.0 available version if 14.0 is unavailable', function(done){ 67 | versionTest(['12.0', '4.0'], '12.0', done); 68 | }); 69 | 70 | it('spec.4 should find 4.0 available version if neither 12.0 nor 14.0 are available', function(done){ 71 | versionTest(['4.0'], '4.0', done); 72 | }); 73 | 74 | it('spec.5 should produce an error if there is no available versions', function(done){ 75 | var resolveSpy = jasmine.createSpy(); 76 | 77 | buildTools.__set__('checkMSBuildVersion', checkMSBuildVersionFake.bind(null, [])); 78 | buildTools.findAvailableVersion() 79 | .then(resolveSpy, function(error){ 80 | expect(error).toBeDefined(); 81 | }) 82 | .finally(function() { 83 | expect(resolveSpy).not.toHaveBeenCalled(); 84 | done(); 85 | }); 86 | }); 87 | }); 88 | 89 | describe('checkMSBuildVersion method', function(){ 90 | var checkMSBuildVersion = buildTools.__get__('checkMSBuildVersion'), 91 | execOriginal; 92 | 93 | beforeEach(function () { 94 | execOriginal = buildTools.__get__('utils.exec'); 95 | }); 96 | 97 | afterEach(function () { 98 | buildTools.__set__('utils.exec', execOriginal); 99 | }); 100 | 101 | it('spec.6 should return valid version and path', function(){ 102 | var version = '14.0'; 103 | 104 | buildTools.__set__('utils.exec', function(cmd) { 105 | return Q.resolve('\r\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\12.0\r\n\tMSBuildToolsPath\tREG_SZ\t' + fakeToolsPath(version) + '\r\n\r\n'); 106 | }); 107 | 108 | checkMSBuildVersion(version).then(function (actual) { 109 | expect(actual.version).toBe(version); 110 | expect(actual.path).toBe(fakeToolsPath(version)); 111 | }); 112 | }); 113 | 114 | it('spec.7 should return null if no tools found for version', function(){ 115 | buildTools.__set__('utils.exec', function(cmd) { 116 | return Q.resolve('ERROR: The system was unable to find the specified registry key or value.'); 117 | }); 118 | 119 | checkMSBuildVersion('14.0').then(function (actual) { 120 | expect(actual).toBeNull(); 121 | }); 122 | }); 123 | 124 | it('spec.8 should return null on internal error', function(){ 125 | buildTools.__set__('utils.exec', function(cmd) { 126 | return Q.reject(); 127 | }); 128 | 129 | checkMSBuildVersion('14.0').then(function (actual) { 130 | expect(actual).toBeNull(); 131 | }); 132 | }); 133 | }); 134 | 135 | describe('MSBuildTools object', function(){ 136 | var MSBuildTools = buildTools.__get__('MSBuildTools'), 137 | spawnOriginal; 138 | 139 | beforeEach(function () { 140 | spawnOriginal = buildTools.__get__('utils.spawn'); 141 | }); 142 | 143 | afterEach(function () { 144 | buildTools.__set__('utils.spawn', spawnOriginal); 145 | }); 146 | 147 | it('spec.9 should have fields and methods defined', function() { 148 | var version = '14.0', 149 | toolsPath = fakeToolsPath(version), 150 | actual = new MSBuildTools(version, toolsPath); 151 | 152 | expect(actual.path).toBeDefined(); 153 | expect(actual.path).toBe(toolsPath); 154 | expect(actual.version).toBeDefined(); 155 | expect(actual.version).toBe(version); 156 | expect(actual.buildProject).toBeDefined(); 157 | }); 158 | }); 159 | -------------------------------------------------------------------------------- /bin/lib/create.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | var Q = require('q'), 21 | fs = require('fs'), 22 | path = require('path'), 23 | shell = require('shelljs'), 24 | uuid = require('node-uuid'); 25 | 26 | var defaultAppName = 'CordovaWP8AppProj'; 27 | var defaultSlnName = 'CordovaWP8Solution'; 28 | 29 | // Creates cordova-windows project at specified path with specified namespace, app name and GUID 30 | module.exports.run = function (argv) { 31 | 32 | // Get script args 33 | var args = argv.slice(2); 34 | 35 | // Set and validate parameters/defaults for create 36 | 37 | var projectPath = args[0]; 38 | if (fs.existsSync(projectPath)){ 39 | return Q.reject('Project directory already exists:\n\t' + projectPath); 40 | } 41 | 42 | // Package name can't contain dashes, so replace it with underscores 43 | // if replacing the - with a _ does not work, give up 44 | var packageName = args[1] ? args[1].replace('-', '_') : 'Cordova.Example'; 45 | if(!/^[a-zA-Z0-9._$]+$/g.test(packageName)) { 46 | return Q.reject('Invalid identifier. PackageName may only include letters, numbers, _ and $'); 47 | } 48 | 49 | var appName = args[2] || defaultAppName, 50 | safeAppName = appName.replace(/(\.\s|\s\.|\s+|\.+)/g, '_'), 51 | platformRoot = path.join(__dirname, '..', '..'), 52 | templatePath = path.join(platformRoot, 'template'), 53 | customTemplate = args[3]; 54 | 55 | console.log('Creating Cordova Windows Project:'); 56 | console.log('\tApp Name : ' + appName); 57 | console.log('\tNamespace : ' + packageName); 58 | console.log('\tPath : ' + projectPath); 59 | if (customTemplate) { 60 | console.log('Custom template path: ' + customTemplate); 61 | } 62 | 63 | console.log('Copying necessary files to ' + projectPath); 64 | // Copy the template source files to the new destination 65 | shell.cp('-rf', path.join(templatePath, '*'), projectPath); 66 | // Copy cordova-js-src directory 67 | shell.cp('-rf', path.join(platformRoot, 'cordova-js-src'), path.join(projectPath, 'platform_www')); 68 | // Copy our unique VERSION file, so peeps can tell what version this project was created from. 69 | shell.cp('-rf', path.join(platformRoot, 'VERSION'), projectPath); 70 | // copy the defaults.xml into config.xml so this project can be built when create is called minus the cordova-cli 71 | shell.cp(path.join(projectPath, 'cordova', 'defaults.xml'), path.join(projectPath, 'config.xml')); 72 | // CB-7618 node_modules must be copied to project folder 73 | shell.cp('-r', path.join(platformRoot, 'node_modules'), path.join(projectPath, 'cordova')); 74 | 75 | // CB-8954 Copy check_reqs module, since it will be required by 'requirements' command 76 | shell.cp('-r', path.join(platformRoot, 'bin', 'check_reqs*'), path.join(projectPath, 'cordova')); 77 | shell.cp('-r', path.join(platformRoot, 'bin', 'lib', 'check_reqs*'), path.join(projectPath, 'cordova', 'lib')); 78 | 79 | // if any custom template is provided, just copy it over created project 80 | if (customTemplate && fs.existsSync(customTemplate)) { 81 | console.log('Copying template overrides from ' + customTemplate + ' to ' + projectPath); 82 | shell.cp('-rf', customTemplate, projectPath); 83 | } 84 | 85 | console.log('Updating project files'); 86 | // replace values in the AppManifest 87 | var wmAppManifest = path.join(projectPath, 'Properties', 'WMAppManifest.xml'), 88 | guid = uuid.v1(); 89 | 90 | shell.sed('-i', /\$guid1\$/g, guid, wmAppManifest); 91 | shell.sed('-i', /\$safeprojectname\$/g, appName, wmAppManifest); 92 | 93 | //replace projectname in project files 94 | ['App.xaml', 'App.xaml.cs', 'MainPage.xaml', 'MainPage.xaml.cs', defaultAppName + '.csproj'].forEach(function (file) { 95 | shell.sed('-i', /\$safeprojectname\$/g, packageName, path.join(projectPath, file)); 96 | }); 97 | 98 | if (appName != defaultAppName) { 99 | var slnFile = path.join(projectPath, defaultSlnName + '.sln'), 100 | csprojFile = path.join(projectPath, defaultAppName + '.csproj'); 101 | 102 | shell.sed('-i', new RegExp(defaultAppName, 'g'), safeAppName, slnFile); 103 | // rename project and solution 104 | shell.mv('-f', slnFile, path.join(projectPath, safeAppName + '.sln')); 105 | shell.mv('-f', csprojFile, path.join(projectPath, safeAppName + '.csproj')); 106 | } 107 | 108 | // remove template cruft 109 | ['__PreviewImage.jpg', '__TemplateIcon.png', 'MyTemplate.vstemplate'].forEach(function (file) { 110 | shell.rm(path.join(projectPath, file)); 111 | }); 112 | 113 | // Delete bld forder and bin folder 114 | ['bld', 'bin', '*.user', '*.suo'].forEach(function (file) { 115 | shell.rm('-rf', path.join(projectPath, file)); 116 | }); 117 | 118 | return Q.resolve(); 119 | }; 120 | 121 | module.exports.help = function () { 122 | console.log('Usage: create PathToNewProject [ PackageName [ AppName [ CustomTemplate ] ] ]'); 123 | console.log(' PathToNewProject : The path to where you wish to create the project'); 124 | console.log(' PackageName : The namespace for the project (default is Cordova.Example)'); 125 | console.log(' AppName : The name of the application (default is CordovaAppProj)'); 126 | console.log(' CustomTemplate : The path to project template overrides'); 127 | console.log(' (will be copied over default platform template files)'); 128 | console.log('examples:'); 129 | console.log(' create C:\\Users\\anonymous\\Desktop\\MyProject'); 130 | console.log(' create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp'); 131 | }; 132 | -------------------------------------------------------------------------------- /template/App.xaml.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Linq; 23 | using System.Net; 24 | using System.Windows; 25 | using System.Windows.Controls; 26 | using System.Windows.Documents; 27 | using System.Windows.Input; 28 | using System.Windows.Media; 29 | using System.Windows.Media.Animation; 30 | using System.Windows.Navigation; 31 | using System.Windows.Shapes; 32 | using Microsoft.Phone.Controls; 33 | using Microsoft.Phone.Shell; 34 | 35 | namespace $safeprojectname$ 36 | { 37 | public partial class App : Application 38 | { 39 | /// 40 | /// Provides easy access to the root frame of the Phone Application. 41 | /// 42 | /// The root frame of the Phone Application. 43 | public PhoneApplicationFrame RootFrame { get; private set; } 44 | 45 | /// 46 | /// Constructor for the Application object. 47 | /// 48 | public App() 49 | { 50 | // Global handler for uncaught exceptions. 51 | UnhandledException += Application_UnhandledException; 52 | 53 | // Show graphics profiling information while debugging. 54 | if (System.Diagnostics.Debugger.IsAttached) 55 | { 56 | // Display the current frame rate counters. 57 | //Application.Current.Host.Settings.EnableFrameRateCounter = true; 58 | 59 | // Show the areas of the app that are being redrawn in each frame. 60 | //Application.Current.Host.Settings.EnableRedrawRegions = true; 61 | 62 | // Enable non-production analysis visualization mode, 63 | // which shows areas of a page that are being GPU accelerated with a colored overlay. 64 | //Application.Current.Host.Settings.EnableCacheVisualization = true; 65 | } 66 | 67 | // Standard Silverlight initialization 68 | InitializeComponent(); 69 | 70 | // Phone-specific initialization 71 | InitializePhoneApplication(); 72 | } 73 | 74 | // Code to execute when the application is launching (eg, from Start) 75 | // This code will not execute when the application is reactivated 76 | private void Application_Launching(object sender, LaunchingEventArgs e) 77 | { 78 | if (System.Diagnostics.Debugger.IsAttached) 79 | { 80 | // Avoid screen locks while debugging. 81 | PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; 82 | } 83 | } 84 | 85 | // Code to execute when the application is activated (brought to foreground) 86 | // This code will not execute when the application is first launched 87 | private void Application_Activated(object sender, ActivatedEventArgs e) 88 | { 89 | } 90 | 91 | // Code to execute when the application is deactivated (sent to background) 92 | // This code will not execute when the application is closing 93 | private void Application_Deactivated(object sender, DeactivatedEventArgs e) 94 | { 95 | } 96 | 97 | // Code to execute when the application is closing (eg, user hit Back) 98 | // This code will not execute when the application is deactivated 99 | private void Application_Closing(object sender, ClosingEventArgs e) 100 | { 101 | } 102 | 103 | // Code to execute if a navigation fails 104 | private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) 105 | { 106 | if (System.Diagnostics.Debugger.IsAttached) 107 | { 108 | // A navigation has failed; break into the debugger 109 | System.Diagnostics.Debugger.Break(); 110 | } 111 | } 112 | 113 | // Code to execute on Unhandled Exceptions 114 | private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) 115 | { 116 | if (System.Diagnostics.Debugger.IsAttached) 117 | { 118 | // An unhandled exception has occurred; break into the debugger 119 | System.Diagnostics.Debugger.Break(); 120 | } 121 | } 122 | 123 | #region Phone application initialization 124 | 125 | // Avoid double-initialization 126 | private bool phoneApplicationInitialized = false; 127 | 128 | // Do not add any additional code to this method 129 | private void InitializePhoneApplication() 130 | { 131 | if (phoneApplicationInitialized) 132 | return; 133 | 134 | // Create the frame but don't set it as RootVisual yet; this allows the splash 135 | // screen to remain active until the application is ready to render. 136 | RootFrame = new PhoneApplicationFrame(); 137 | RootFrame.Navigated += CompleteInitializePhoneApplication; 138 | 139 | // Handle navigation failures 140 | RootFrame.NavigationFailed += RootFrame_NavigationFailed; 141 | 142 | // Ensure we don't initialize again 143 | phoneApplicationInitialized = true; 144 | } 145 | 146 | // Do not add any additional code to this method 147 | private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) 148 | { 149 | // Set the root visual to allow the application to render 150 | if (RootVisual != RootFrame) 151 | RootVisual = RootFrame; 152 | 153 | // Remove this handler since it is no longer needed 154 | RootFrame.Navigated -= CompleteInitializePhoneApplication; 155 | } 156 | 157 | #endregion 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /template/cordovalib/MimeTypeMapper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using System.Collections.Generic; 16 | using System.IO; 17 | 18 | namespace WPCordovaClassLib.Cordova.Commands 19 | { 20 | /// 21 | /// Represents file extension to mime type mapper. 22 | /// 23 | public static class MimeTypeMapper 24 | { 25 | /// 26 | /// For unknown type it is recommended to use 'application/octet-stream' 27 | /// http://stackoverflow.com/questions/1176022/unknown-file-type-mime 28 | /// 29 | private static string DefaultMimeType = "application/octet-stream"; 30 | 31 | /// 32 | /// Stores mime type for all necessary extension 33 | /// 34 | private static readonly Dictionary MIMETypesDictionary = new Dictionary 35 | { 36 | {"avi", "video/x-msvideo"}, 37 | {"bmp", "image/bmp"}, 38 | {"gif", "image/gif"}, 39 | {"html","text/html"}, 40 | {"jpe", "image/jpeg"}, 41 | {"jpeg", "image/jpeg"}, 42 | {"jpg", "image/jpeg"}, 43 | {"js","text/javascript"}, 44 | {"mov", "video/quicktime"}, 45 | {"mp2", "audio/mpeg"}, 46 | {"mp3", "audio/mpeg"}, 47 | {"mp4", "video/mp4"}, 48 | {"mpe", "video/mpeg"}, 49 | {"mpeg", "video/mpeg"}, 50 | {"mpg", "video/mpeg"}, 51 | {"mpga", "audio/mpeg"}, 52 | {"pbm", "image/x-portable-bitmap"}, 53 | {"pcm", "audio/x-pcm"}, 54 | {"pct", "image/pict"}, 55 | {"pgm", "image/x-portable-graymap"}, 56 | {"pic", "image/pict"}, 57 | {"pict", "image/pict"}, 58 | {"png", "image/png"}, 59 | {"pnm", "image/x-portable-anymap"}, 60 | {"pnt", "image/x-macpaint"}, 61 | {"pntg", "image/x-macpaint"}, 62 | {"ppm", "image/x-portable-pixmap"}, 63 | {"qt", "video/quicktime"}, 64 | {"ra", "audio/x-pn-realaudio"}, 65 | {"ram", "audio/x-pn-realaudio"}, 66 | {"ras", "image/x-cmu-raster"}, 67 | {"rgb", "image/x-rgb"}, 68 | {"snd", "audio/basic"}, 69 | {"txt", "text/plain"}, 70 | {"tif", "image/tiff"}, 71 | {"tiff", "image/tiff"}, 72 | {"wav", "audio/x-wav"}, 73 | {"wbmp", "image/vnd.wap.wbmp"}, 74 | 75 | }; 76 | /// 77 | /// Gets mime type by file extension 78 | /// 79 | /// file name to extract extension 80 | /// mime type 81 | public static string GetMimeType(string fileName) 82 | { 83 | string ext = Path.GetExtension(fileName); 84 | 85 | // invalid extension 86 | if (string.IsNullOrEmpty(ext) || !ext.StartsWith(".")) 87 | { 88 | return DefaultMimeType; 89 | } 90 | 91 | ext = ext.Remove(0, 1); 92 | 93 | if (MIMETypesDictionary.ContainsKey(ext)) 94 | { 95 | return MIMETypesDictionary[ext]; 96 | } 97 | 98 | return DefaultMimeType; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /template/cordovalib/Commands/BaseCommand.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | using System; 16 | using System.Reflection; 17 | using Microsoft.Phone.Shell; 18 | using System.Diagnostics; 19 | using System.Collections; 20 | using System.Collections.Generic; 21 | 22 | namespace WPCordovaClassLib.Cordova.Commands 23 | { 24 | public abstract class BaseCommand : IDisposable 25 | { 26 | /* 27 | * All commands + plugins must extend BaseCommand, because they are dealt with as BaseCommands in CordovaView.xaml.cs 28 | * 29 | **/ 30 | 31 | public event EventHandler OnCommandResult; 32 | 33 | public event EventHandler OnCustomScript; 34 | 35 | public string CurrentCommandCallbackId { get; set; } 36 | 37 | public BaseCommand() 38 | { 39 | ResultHandlers = new Dictionary>(); 40 | PhoneApplicationService service = PhoneApplicationService.Current; 41 | service.Activated += this.OnResume; 42 | service.Deactivated += this.OnPause; 43 | } 44 | 45 | protected Dictionary> ResultHandlers; 46 | public void AddResultHandler(string callbackId, EventHandler handler) 47 | { 48 | ResultHandlers.Add(callbackId, handler); 49 | } 50 | public bool RemoveResultHandler(string callbackId) 51 | { 52 | return ResultHandlers.Remove(callbackId); 53 | } 54 | 55 | /* 56 | * InvokeMethodNamed will call the named method of a BaseCommand subclass if it exists and pass the variable arguments list along. 57 | **/ 58 | 59 | public object InvokeMethodNamed(string callbackId, string methodName, params object[] args) 60 | { 61 | //Debug.WriteLine(string.Format("InvokeMethodNamed:{0} callbackId:{1}",methodName,callbackId)); 62 | this.CurrentCommandCallbackId = callbackId; 63 | return InvokeMethodNamed(methodName, args); 64 | } 65 | 66 | public object InvokeMethodNamed(string methodName, params object[] args) 67 | { 68 | MethodInfo mInfo = this.GetType().GetMethod(methodName); 69 | 70 | if (mInfo != null) 71 | { 72 | // every function handles DispatchCommandResult by itself 73 | return mInfo.Invoke(this, args); 74 | } 75 | 76 | // actually methodName could refer to a property 77 | if (args == null || args.Length == 0 || 78 | (args.Length == 1 && "undefined".Equals(args[0]))) 79 | { 80 | PropertyInfo pInfo = this.GetType().GetProperty(methodName); 81 | if (pInfo != null) 82 | { 83 | object res = pInfo.GetValue(this, null); 84 | 85 | DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res)); 86 | 87 | return res; 88 | } 89 | } 90 | 91 | throw new MissingMethodException(methodName); 92 | 93 | } 94 | 95 | [Obsolete] 96 | public void InvokeCustomScript(ScriptCallback script, bool removeHandler) 97 | { 98 | if (this.OnCustomScript != null) 99 | { 100 | this.OnCustomScript(this, script); 101 | if (removeHandler) 102 | { 103 | this.OnCustomScript = null; 104 | } 105 | } 106 | } 107 | 108 | public void DispatchCommandResult() 109 | { 110 | this.DispatchCommandResult(new PluginResult(PluginResult.Status.NO_RESULT)); 111 | } 112 | 113 | public void DispatchCommandResult(PluginResult result,string callbackId="") 114 | { 115 | if (!string.IsNullOrEmpty(callbackId)) 116 | { 117 | result.CallbackId = callbackId; 118 | } 119 | else 120 | { 121 | result.CallbackId = this.CurrentCommandCallbackId; 122 | } 123 | 124 | if (ResultHandlers.ContainsKey(result.CallbackId)) 125 | { 126 | ResultHandlers[result.CallbackId](this, result); 127 | } 128 | else if (this.OnCommandResult != null) 129 | { 130 | OnCommandResult(this, result); 131 | } 132 | else 133 | { 134 | Debug.WriteLine("Failed to locate callback for id : " + result.CallbackId); 135 | } 136 | 137 | if (!result.KeepCallback) 138 | { 139 | this.Dispose(); 140 | } 141 | 142 | } 143 | 144 | 145 | /// 146 | /// Occurs when the application is being deactivated. 147 | /// 148 | public virtual void OnReset() {} 149 | 150 | /// 151 | /// Occurs when the application is being loaded, and the config.xml has an autoload entry 152 | /// 153 | public virtual void OnInit() {} 154 | 155 | 156 | /// 157 | /// Occurs when the application is being deactivated. 158 | /// 159 | public virtual void OnPause(object sender, DeactivatedEventArgs e) {} 160 | 161 | /// 162 | /// Occurs when the application is being made active after previously being put 163 | /// into a dormant state or tombstoned. 164 | /// 165 | public virtual void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e) {} 166 | 167 | public void Dispose() 168 | { 169 | PhoneApplicationService service = PhoneApplicationService.Current; 170 | service.Activated -= this.OnResume; 171 | service.Deactivated -= this.OnPause; 172 | this.OnCommandResult = null; 173 | } 174 | 175 | public void DetachHandlers() 176 | { 177 | this.OnCommandResult = null; 178 | this.OnCustomScript = null; 179 | foreach (string callbackId in new List(ResultHandlers.Keys)) 180 | { 181 | RemoveResultHandler(callbackId); 182 | } 183 | } 184 | 185 | public static string GetBaseURL() 186 | { 187 | #if CORDOVA_CLASSLIB 188 | return "/WPCordovaClassLib;component/"; 189 | #else 190 | return "./"; 191 | #endif 192 | } 193 | } 194 | 195 | 196 | 197 | } 198 | -------------------------------------------------------------------------------- /template/MyTemplate.vstemplate: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | CordovaWP8_3_6_1 17 | Starter project for building a Cordova app for Windows Phone 8 version: 3.6.1 18 | CSharp 19 | 20 | 21 | 1000 22 | true 23 | CordovaWP8_3.6.1 24 | true 25 | Enabled 26 | true 27 | __TemplateIcon.png 28 | __PreviewImage.jpg 29 | 30 | 31 | 32 | App.xaml 33 | App.xaml.cs 34 | ApplicationIcon.png 35 | Background.png 36 | config.xml 37 | 38 | build.bat 39 | clean.bat 40 | 41 | build.js 42 | clean.js 43 | install-device.bat 44 | install-emulator.bat 45 | list-devices.bat 46 | list-emulator-images.bat 47 | list-started-emulators.bat 48 | start-emulator.bat 49 | target-list.js 50 | 51 | log.bat 52 | run.bat 53 | version.bat 54 | 55 | 56 | 57 | BaseCommand.cs 58 | 59 | 60 | JsonHelper.cs 61 | 62 | BrowserMouseHelper.cs 63 | CommandFactory.cs 64 | ConfigHandler.cs 65 | ConsoleHelper.cs 66 | CordovaCommandCall.cs 67 | CordovaView.xaml 68 | CordovaView.xaml.cs 69 | IBrowserDecorator.cs 70 | ImageExifHelper.cs 71 | MimeTypeMapper.cs 72 | NativeExecution.cs 73 | OrientationHelper.cs 74 | PluginResult.cs 75 | ScriptCallback.cs 76 | XHRHelper.cs 77 | 78 | 79 | appbar.back.rest.png 80 | appbar.close.rest.png 81 | appbar.feature.video.rest.png 82 | appbar.next.rest.png 83 | appbar.save.rest.png 84 | appbar.stop.rest.png 85 | 86 | MainPage.xaml 87 | MainPage.xaml.cs 88 | 89 | AppManifest.xml 90 | AssemblyInfo.cs 91 | WMAppManifest.xml 92 | 93 | 94 | SplashScreenImage.jpg 95 | VERSION 96 | 97 | cordova.js 98 | 99 | index.css 100 | 101 | 102 | logo.png 103 | 104 | index.html 105 | 106 | index.js 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /template/cordovalib/ImageExifHelper.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | 14 | */ 15 | 16 | using System; 17 | using System.Diagnostics; 18 | using System.IO; 19 | using System.Windows.Media.Imaging; 20 | 21 | namespace WPCordovaClassLib.Cordova.Commands 22 | { 23 | public class ImageExifOrientation 24 | { 25 | public const int Portrait = 1; 26 | public const int PortraitUpsideDown = 3; 27 | public const int LandscapeLeft = 6; 28 | public const int LandscapeRight = 8; 29 | } 30 | 31 | public class ImageExifHelper 32 | { 33 | 34 | public static Stream RotateStream(Stream stream, int angle) 35 | { 36 | stream.Position = 0; 37 | if (angle % 90 != 0 || angle < 0) 38 | { 39 | throw new ArgumentException(); 40 | } 41 | if (angle % 360 == 0) 42 | { 43 | return stream; 44 | } 45 | 46 | angle = angle % 360; 47 | 48 | BitmapImage bitmap = new BitmapImage(); 49 | bitmap.SetSource(stream); 50 | WriteableBitmap wbSource = new WriteableBitmap(bitmap); 51 | 52 | WriteableBitmap wbTarget = null; 53 | 54 | int srcPixelWidth = wbSource.PixelWidth; 55 | int srcPixelHeight = wbSource.PixelHeight; 56 | 57 | if (angle % 180 == 0) 58 | { 59 | wbTarget = new WriteableBitmap(srcPixelWidth, srcPixelHeight); 60 | } 61 | else 62 | { 63 | wbTarget = new WriteableBitmap(srcPixelHeight, srcPixelWidth); 64 | } 65 | 66 | int destPixelWidth = wbTarget.PixelWidth; 67 | int[] srcPxls = wbSource.Pixels; 68 | int[] destPxls = wbTarget.Pixels; 69 | 70 | // this ugly if/else is to avoid a conditional check for every pixel 71 | if (angle == 90) 72 | { 73 | for (int x = 0; x < srcPixelWidth; x++) 74 | { 75 | for (int y = 0; y < srcPixelHeight; y++) 76 | { 77 | destPxls[(srcPixelHeight - y - 1) + (x * destPixelWidth)] = srcPxls[x + y * srcPixelWidth]; 78 | } 79 | } 80 | } 81 | else if (angle == 180) 82 | { 83 | for (int x = 0; x < srcPixelWidth; x++) 84 | { 85 | for (int y = 0; y < srcPixelHeight; y++) 86 | { 87 | destPxls[(srcPixelWidth - x - 1) + (srcPixelHeight - y - 1) * srcPixelWidth] = srcPxls[x + y * srcPixelWidth]; 88 | } 89 | } 90 | } 91 | else if (angle == 270) 92 | { 93 | for (int x = 0; x < srcPixelWidth; x++) 94 | { 95 | for (int y = 0; y < srcPixelHeight; y++) 96 | { 97 | destPxls[y + (srcPixelWidth - x - 1) * destPixelWidth] = srcPxls[x + y * srcPixelWidth]; 98 | } 99 | } 100 | } 101 | 102 | MemoryStream targetStream = new MemoryStream(); 103 | wbTarget.SaveJpeg(targetStream, destPixelWidth, wbTarget.PixelHeight, 0, 100); 104 | return targetStream; 105 | } 106 | 107 | public static int getImageOrientationFromStream(Stream imgStream) 108 | { 109 | 110 | // 0xFFD8 : jpgHeader 111 | // 0xFFE1 : 112 | // 0x???? : length of exif data 113 | // 0x????, 0x???? : Chars 'E','x','i','f' 114 | // 0x0000 : 2 empty bytes 115 | // <== mark beginning of tags SIZE:ID:VALUE 116 | // 0x???? : 'II' or 'MM' for Intel or Motorola ( always getting II on my WP7 devices ), determines littleEndian-ness 117 | // 0x002A : marker value 118 | // 0x???? : offset to the Image File Data 119 | 120 | // XXXX possible space before actual tag data ... we skip to mark + offset 121 | 122 | // 0x???? number of exif tags present 123 | 124 | // make sure we are at the beginning 125 | imgStream.Seek(0, SeekOrigin.Begin); 126 | BinaryReader reader = new BinaryReader(imgStream); 127 | 128 | byte[] jpgHdr = reader.ReadBytes(2); // always (0xFFD8) 129 | 130 | byte start = reader.ReadByte(); // 0xFF 131 | byte index = reader.ReadByte(); // 0xE1 132 | 133 | while (start == 0xFF && index != 0xE1) // This never seems to happen, todo: optimize 134 | { 135 | // Get the data length 136 | ushort dLen = BitConverter.ToUInt16(reader.ReadBytes(2), 0); 137 | // skip along 138 | reader.ReadBytes(dLen - 2); 139 | start = reader.ReadByte(); 140 | index = reader.ReadByte(); 141 | } 142 | 143 | // It's only success if we found the 0xFFE1 marker 144 | if (start != 0xFF || index != 0xE1) 145 | { 146 | // throw new Exception("Could not find Exif data block"); 147 | Debug.WriteLine("Did not find EXIF data"); 148 | return 0; 149 | } 150 | 151 | // read 2 byte length of EXIF data 152 | ushort exifLen = BitConverter.ToUInt16(reader.ReadBytes(2), 0); 153 | String exif = ""; // build the string 154 | for (var n = 0; n < 4; n++) 155 | { 156 | exif += reader.ReadChar(); 157 | } 158 | if (exif != "Exif") 159 | { 160 | // did not find exif data ... 161 | Debug.WriteLine("Did not find EXIF data"); 162 | return 0; 163 | } 164 | 165 | // read 2 empty bytes 166 | //ushort emptyBytes = BitConverter.ToUInt16(reader.ReadBytes(2), 0); 167 | reader.ReadBytes(2); 168 | 169 | long headerMark = reader.BaseStream.Position; // where are we now <== 170 | 171 | //bool isLEndian = (reader.ReadChar() + "" + reader.ReadChar()) == "II"; 172 | reader.ReadBytes(2); // 'II' or 'MM', but we don't care 173 | 174 | if (0x002A != BitConverter.ToUInt16(reader.ReadBytes(2), 0)) 175 | { 176 | Debug.WriteLine("Error in data != 0x002A"); 177 | return 0; 178 | } 179 | 180 | // Get the offset to the IFD (image file directory) 181 | ushort imgOffset = BitConverter.ToUInt16(reader.ReadBytes(2), 0); 182 | 183 | imgStream.Position = headerMark + imgOffset; 184 | ushort tagCount = BitConverter.ToUInt16(reader.ReadBytes(2), 0); 185 | for (ushort x = 0; x < tagCount; x++) 186 | { 187 | // Orientation = 0x112, aka 274 188 | if (0x112 == BitConverter.ToUInt16(reader.ReadBytes(2), 0)) 189 | { 190 | ushort dType = BitConverter.ToUInt16(reader.ReadBytes(2), 0); 191 | // don't care .. 192 | uint comps = reader.ReadUInt32(); 193 | byte[] tagData = reader.ReadBytes(4); 194 | int orientation = (int)tagData[0]; 195 | Debug.WriteLine("orientation = " + orientation.ToString()); 196 | return orientation; 197 | // 6 means rotate clockwise 90 deg 198 | // 8 means rotate counter-clockwise 90 deg 199 | // 1 means all is good 200 | // 3 means flip vertical 201 | } 202 | // skip to the next item, 12 bytes each 203 | reader.BaseStream.Seek(10, SeekOrigin.Current); 204 | } 205 | return 0; 206 | } 207 | 208 | } 209 | } 210 | --------------------------------------------------------------------------------