├── CordovaLib ├── VERSION ├── .gitignore ├── CordovaLib │ ├── Classes │ │ ├── CDVMainWindow.h │ │ ├── Utils │ │ │ ├── NSScreen+Utils.h │ │ │ ├── NSData+Base64.h │ │ │ ├── NSWindow+Utils.h │ │ │ ├── NSWindow+Utils.m │ │ │ └── NSScreen+Utils.m │ │ ├── CDVMainWindow.m │ │ ├── Localizable.strings │ │ ├── Commands │ │ │ ├── CDV.h │ │ │ ├── CDVConsole.h │ │ │ ├── CDVWindowSizeCommand.h │ │ │ ├── CDVCursorMonitorService.h │ │ │ ├── CDVJSON.h │ │ │ ├── CDVDebug.h │ │ │ ├── CDVCommandDelegateImpl.h │ │ │ ├── CDVConfigParser.h │ │ │ ├── CDVCommandQueue.h │ │ │ ├── CDVAvailability.h │ │ │ ├── CDVPlugin.h │ │ │ ├── CDVInvokedUrlCommand.h │ │ │ ├── CDVCommandDelegate.h │ │ │ ├── CDVWindowSizeCommand.m │ │ │ ├── CDVJSON.m │ │ │ ├── CDVConsole.m │ │ │ ├── CDVPluginResult.h │ │ │ └── CDVInvokedUrlCommand.m │ │ ├── CookieJar.h │ │ ├── CDVBridge.h │ │ └── CDVWebViewDelegate.h │ └── CordovaLib-Prefix.pch └── CordovaLib-Info.plist ├── cordova-js-src ├── plugin │ └── osx │ │ └── .gitignore ├── platform.js └── exec.js ├── bin ├── templates │ ├── project │ │ ├── gitignore │ │ ├── __PROJECT_NAME__ │ │ │ ├── gitignore │ │ │ ├── Images.xcassets │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ ├── icon-16x16.png │ │ │ │ │ ├── icon-32x32.png │ │ │ │ │ ├── icon-64x64.png │ │ │ │ │ ├── icon-128x128.png │ │ │ │ │ ├── icon-256x256.png │ │ │ │ │ ├── icon-512x512.png │ │ │ │ │ └── Contents.json │ │ │ ├── en.lproj │ │ │ │ └── InfoPlist.strings │ │ │ ├── Plugins │ │ │ │ └── README │ │ │ ├── main.m │ │ │ ├── __PROJECT_NAME__-Prefix.pch │ │ │ ├── __PROJECT_NAME__-Info.plist │ │ │ ├── Classes │ │ │ │ ├── MainViewController.h │ │ │ │ ├── AppDelegate.h │ │ │ │ ├── AppDelegate.m │ │ │ │ └── MainViewController.m │ │ │ └── config.xml │ │ └── www │ │ │ ├── img │ │ │ └── logo.png │ │ │ ├── spec │ │ │ ├── helper.js │ │ │ └── index.js │ │ │ ├── index.html │ │ │ ├── js │ │ │ └── index.js │ │ │ └── spec.html │ └── scripts │ │ └── cordova │ │ ├── build-extras.xcconfig │ │ ├── build-release.xcconfig │ │ ├── lib │ │ ├── start-emulator │ │ ├── configMunger.js │ │ ├── clean.js │ │ ├── spawn.js │ │ ├── run.js │ │ ├── copy-www-build-step.js │ │ └── ConsoleLogger.js │ │ ├── build-debug.xcconfig │ │ ├── version │ │ ├── clean │ │ ├── build.xcconfig │ │ ├── defaults.xml │ │ ├── build │ │ └── run ├── apple_osx_version ├── apple_xcode_version ├── update_cordova_subproject ├── check_reqs ├── update ├── test └── create ├── tests ├── cdv-test-project │ ├── .gitignore │ ├── www │ │ ├── img │ │ │ └── logo.png │ │ ├── js │ │ │ └── index.js │ │ └── index.html │ ├── res │ │ └── test-64x64.png │ ├── plugins │ │ ├── cordova-plugin-whitelist │ │ │ ├── NOTICE │ │ │ ├── package.json │ │ │ ├── whitelist.js │ │ │ ├── CONTRIBUTING.md │ │ │ ├── plugin.xml │ │ │ └── RELEASENOTES.md │ │ ├── fetch.json │ │ └── osx.json │ ├── hooks │ │ └── README.md │ └── config.xml ├── spec │ ├── objc.json │ ├── component.json │ ├── coverage.json │ ├── helper.js │ ├── objc │ │ └── cordovalib.spec.js │ └── component │ │ ├── create.spec.js │ │ └── platform.spec.js └── CordovaLibTests │ ├── CordovaLibTests-Info.plist │ ├── en.lproj │ └── InfoPlist.strings │ ├── CordovaLibApp │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── CordovaLibApp-Prefix.pch │ ├── CordovaLibApp-Info.plist │ ├── MainViewController.h │ ├── main.m │ ├── AppDelegate.h │ ├── www │ │ ├── cordova_plugins.js │ │ ├── plugins │ │ │ └── test-plugin.js │ │ ├── index.html │ │ └── tests.js │ ├── AppDelegate.m │ ├── config.xml │ └── MainViewController.m │ ├── TestPlugin.h │ ├── CordovaLibTests-Prefix.pch │ ├── TestPlugin.m │ ├── CDVStartPageTests.m │ ├── CDVWebViewTest.h │ ├── CDVPluginsTests.m │ ├── CDVBase64Tests.m │ ├── CDVInvokedUrlCommandTests.m │ └── CDVWebViewTest.m ├── NOTICE ├── .eslintignore ├── .gitignore ├── .ratignore ├── component.json ├── .travis.yml ├── .github ├── ISSUE_TEMPLATE │ ├── FEATURE_REQUEST.md │ ├── SUPPORT_QUESTION.md │ └── BUG_REPORT.md ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── .eslintrc.yml ├── .asf.yaml ├── CONTRIBUTING.md └── package.json /CordovaLib/VERSION: -------------------------------------------------------------------------------- 1 | 7.1.0-dev 2 | -------------------------------------------------------------------------------- /cordova-js-src/plugin/osx/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/templates/project/gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.perspectivev3 3 | *.pbxuser 4 | .DS_Store 5 | build/ 6 | -------------------------------------------------------------------------------- /tests/cdv-test-project/.gitignore: -------------------------------------------------------------------------------- 1 | platforms 2 | /node_modules 3 | package.json 4 | package-lock.json 5 | -------------------------------------------------------------------------------- /CordovaLib/.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | *.pbxuser 3 | *.perspectivev3 4 | *.mode1v3 5 | javascripts/cordova-*.js 6 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.perspectivev3 3 | *.pbxuser 4 | .DS_Store 5 | build/ 6 | -------------------------------------------------------------------------------- /bin/templates/project/www/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/bin/templates/project/www/img/logo.png -------------------------------------------------------------------------------- /tests/cdv-test-project/www/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/tests/cdv-test-project/www/img/logo.png -------------------------------------------------------------------------------- /tests/cdv-test-project/res/test-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/tests/cdv-test-project/res/test-64x64.png -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Apache Cordova 2 | Copyright 2012 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | bin/node_modules/* 2 | bin/templates/project/* 3 | bin/templates/scripts/cordova/lib/start-emulator 4 | bin/test 5 | tests/cdv-test-project/* 6 | tests/CordovaLibTests/* 7 | CordovaLib/cordova.js 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .*.sw? 3 | .vscode 4 | *.cso 5 | tmp 6 | *.mode1v3 7 | *.pbxuser 8 | xcuserdata 9 | *.xcworkspace 10 | console.log 11 | node_modules 12 | coverage/ 13 | npm-debug.log 14 | .nyc_output/ 15 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-16x16.png -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-32x32.png -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-64x64.png -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-128x128.png -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-256x256.png -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/cordova-osx/HEAD/bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/icon-512x512.png -------------------------------------------------------------------------------- /.ratignore: -------------------------------------------------------------------------------- 1 | # yes, not .gitignore 2 | gitignore 3 | 4 | # licenses for both below are in the cordova-osx LICENSE file 5 | NSData+Base64.h 6 | NSData+Base64.m 7 | 8 | # AppIcon.appiconset 9 | Contents.json 10 | 11 | cdv-test-project 12 | -------------------------------------------------------------------------------- /tests/cdv-test-project/plugins/cordova-plugin-whitelist/NOTICE: -------------------------------------------------------------------------------- 1 | Apache Cordova 2 | Copyright 2012 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /tests/spec/objc.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "tests/spec", 3 | "spec_files": [ 4 | "objc/**/*[sS]pec.js" 5 | ], 6 | "helpers": [ 7 | "helper.js" 8 | ], 9 | "stopSpecOnExpectationFailure": false, 10 | "random": false 11 | } 12 | -------------------------------------------------------------------------------- /tests/spec/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "tests/spec", 3 | "spec_files": [ 4 | "component/**/*[sS]pec.js" 5 | ], 6 | "helpers": [ 7 | "helper.js" 8 | ], 9 | "stopSpecOnExpectationFailure": false, 10 | "random": false 11 | } 12 | -------------------------------------------------------------------------------- /component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-osx", 3 | "version": "4.0.0-dev", 4 | "repository": "apache/cordova-osx", 5 | "main": "CordovaLib/cordova.js", 6 | "scripts": [ 7 | "CordovaLib/cordova.js" 8 | ], 9 | "license": "Apache Version 2.0" 10 | } 11 | -------------------------------------------------------------------------------- /tests/cdv-test-project/plugins/fetch.json: -------------------------------------------------------------------------------- 1 | { 2 | "cordova-plugin-whitelist": { 3 | "source": { 4 | "type": "registry", 5 | "id": "cordova-plugin-whitelist@1" 6 | }, 7 | "is_top_level": true, 8 | "variables": {} 9 | } 10 | } -------------------------------------------------------------------------------- /tests/spec/coverage.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "tests/spec", 3 | "spec_files": [ 4 | "component/**/*[sS]pec.js", 5 | "objc/**/*[sS]pec.js" 6 | ], 7 | "helpers": [ 8 | "helper.js" 9 | ], 10 | "stopSpecOnExpectationFailure": false, 11 | "random": false 12 | } 13 | -------------------------------------------------------------------------------- /tests/cdv-test-project/plugins/osx.json: -------------------------------------------------------------------------------- 1 | { 2 | "prepare_queue": { 3 | "installed": [], 4 | "uninstalled": [] 5 | }, 6 | "config_munge": { 7 | "files": {} 8 | }, 9 | "installed_plugins": { 10 | "cordova-plugin-whitelist": { 11 | "PACKAGE_NAME": "org.apache.cordova.test" 12 | } 13 | }, 14 | "dependent_plugins": {} 15 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode11.5 3 | sudo: false 4 | 5 | env: 6 | matrix: 7 | - TRAVIS_NODE_VERSION: 12 8 | - TRAVIS_NODE_VERSION: 14 9 | 10 | before_install: 11 | - nvm install $TRAVIS_NODE_VERSION 12 | 13 | install: 14 | - npm install -g cordova@latest 15 | - npm install 16 | - npm install -g codecov 17 | 18 | script: 19 | - node --version 20 | - npm --version 21 | - npm test 22 | 23 | after_script: 24 | - codecov 25 | -------------------------------------------------------------------------------- /tests/cdv-test-project/plugins/cordova-plugin-whitelist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-plugin-whitelist", 3 | "version": "1.2.1", 4 | "description": "Cordova Whitelist Plugin", 5 | "cordova": { 6 | "platforms": [ 7 | "android" 8 | ] 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/apache/cordova-plugin-whitelist" 13 | }, 14 | "keywords": [ 15 | "cordova", 16 | "whitelist", 17 | "ecosystem:cordova", 18 | "cordova-android" 19 | ], 20 | "engines": [ 21 | { 22 | "name": "cordova-android", 23 | "version": ">=4.0.0" 24 | } 25 | ], 26 | "author": "Apache Software Foundation", 27 | "license": "Apache 2.0" 28 | } 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🚀 Feature Request 3 | about: A suggestion for a new functionality 4 | 5 | --- 6 | 7 | # Feature Request 8 | 9 | ## Motivation Behind Feature 10 | 11 | 12 | 13 | 14 | ## Feature Description 15 | 20 | 21 | 22 | 23 | ## Alternatives or Workarounds 24 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.apache.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 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 | /* Localized versions of Info.plist keys */ 21 | 22 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 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 | /* Localized versions of Info.plist keys */ 21 | 22 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 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 | /* Localized versions of Info.plist keys */ 21 | 22 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/CDVMainWindow.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | @interface CDVMainWindow : NSWindow 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Utils/NSScreen+Utils.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | @interface NSScreen (Utils) 23 | 24 | + (NSRect) fullScreenRect; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Plugins/README: -------------------------------------------------------------------------------- 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 | Put the .h and .m files of your plugin here. The .js files of your plugin belong in the www folder. 21 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/main.m: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | int main(int argc, const char * argv[]) 23 | { 24 | return NSApplicationMain(argc, argv); 25 | } 26 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/build-extras.xcconfig: -------------------------------------------------------------------------------- 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 | // 21 | // Auto-generated config file to override configuration files (build-release/build-debug). 22 | // 23 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/CDVMainWindow.m: -------------------------------------------------------------------------------- 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 | #import "CDVMainWindow.h" 21 | 22 | @implementation CDVMainWindow 23 | 24 | - (BOOL) canBecomeKeyWindow { 25 | return YES; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/CordovaLib-Prefix.pch: -------------------------------------------------------------------------------- 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 | // The contents of this file are implicitly included at the beginning of every source file. 21 | 22 | #ifdef __OBJC__ 23 | #import 24 | #endif 25 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Localizable.strings: -------------------------------------------------------------------------------- 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 | /****************************************************************************/ 21 | /* Localization file */ 22 | 23 | 24 | "OK" = "OK"; 25 | 26 | "Cancel" = "Cancel"; 27 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDV.h: -------------------------------------------------------------------------------- 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 | #import "CDVAvailability.h" 21 | 22 | #import "CDVJSON.h" 23 | #import "CDVDebug.h" 24 | #import "CDVPluginResult.h" 25 | #import "CDVInvokedUrlCommand.h" 26 | #import "CDVPlugin.h" 27 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/CordovaLibApp-Prefix.pch: -------------------------------------------------------------------------------- 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 | // The contents of this file are implicitly included at the beginning of every source file. 21 | 22 | #ifdef __OBJC__ 23 | #import 24 | #endif 25 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Prefix.pch: -------------------------------------------------------------------------------- 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 | // The contents of this file are implicitly included at the beginning of every source file. 21 | 22 | #ifdef __OBJC__ 23 | #import 24 | #endif 25 | -------------------------------------------------------------------------------- /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: 'osx', 24 | bootstrap: function () { 25 | require('cordova/channel').onNativeReady.fire(); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/TestPlugin.h: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | 23 | @interface TestPlugin : CDVPlugin 24 | 25 | - (void) echo:(CDVInvokedUrlCommand*)command __unused; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Utils/NSData+Base64.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Base64.h 3 | // base64 4 | // 5 | // Created by Matt Gallagher on 2009/06/03. 6 | // Copyright 2009 Matt Gallagher. All rights reserved. 7 | // 8 | // Permission is given to use this source code file, free of charge, in any 9 | // project, commercial or otherwise, entirely at your risk, with the condition 10 | // that any redistribution (in part or whole) of source code must retain 11 | // this copyright and permission notice. Attribution in compiled projects is 12 | // appreciated but not required. 13 | // 14 | 15 | #import 16 | 17 | void *CDVNewBase64Decode( 18 | const char* inputBuffer, 19 | size_t length, 20 | size_t * outputLength); 21 | 22 | char *CDVNewBase64Encode( 23 | const void* inputBuffer, 24 | size_t length, 25 | bool separateLines, 26 | size_t * outputLength); 27 | 28 | @interface NSData (CDVBase64) 29 | 30 | + (NSData*)dataFromBase64String:(NSString*)aString; 31 | - (NSString*)base64EncodedString; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 💬 Support Question 3 | about: If you have a question, please check out our Slack or StackOverflow! 4 | 5 | --- 6 | 7 | 8 | 9 | Apache Cordova uses GitHub Issues as a feature request and bug tracker _only_. 10 | For usage and support questions, please check out the resources below. Thanks! 11 | 12 | --- 13 | 14 | You can get answers to your usage and support questions about **Apache Cordova** on: 15 | 16 | * Slack Community Chat: https://cordova.slack.com (you can sign-up at http://slack.cordova.io/) 17 | * StackOverflow: https://stackoverflow.com/questions/tagged/cordova using the tag `cordova` 18 | 19 | --- 20 | 21 | If you are using a tool that uses Cordova internally, like e.g. Ionic, check their support channels: 22 | 23 | * **Ionic Framework** 24 | * [Ionic Community Forum](https://forum.ionicframework.com/) 25 | * [Ionic Worldwide Slack](https://ionicworldwide.herokuapp.com/) 26 | * **PhoneGap** 27 | * [PhoneGap Developer Community](https://forums.adobe.com/community/phonegap) 28 | -------------------------------------------------------------------------------- /bin/apple_osx_version: -------------------------------------------------------------------------------- 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 | const versions = require('./lib/versions.js'); 23 | 24 | versions.get_apple_osx_version().catch(function (err) { 25 | console.log(err); 26 | process.exit(2); 27 | }); 28 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | org.apache.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | NSHumanReadableCopyright 26 | Copyright © 2013 Apache Foundation. All rights reserved. 27 | NSPrincipalClass 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/build-release.xcconfig: -------------------------------------------------------------------------------- 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 | // 21 | // XCode Build settings for "Release" Build Configuration. 22 | // 23 | 24 | #include "build.xcconfig" 25 | 26 | CODE_SIGN_IDENTITY = Mac Distribution 27 | 28 | #include "build-extras.xcconfig" 29 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | --ID-- 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSMainNibFile 28 | MainViewController 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /bin/apple_xcode_version: -------------------------------------------------------------------------------- 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 | const versions = require('./lib/versions.js'); 23 | 24 | versions.get_apple_xcode_version().then(function (version) { 25 | console.log(version); 26 | }, function (err) { 27 | console.error(err); 28 | process.exit(2); 29 | }); 30 | -------------------------------------------------------------------------------- /bin/update_cordova_subproject: -------------------------------------------------------------------------------- 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 | const create = require('./lib/create'); 23 | let args; 24 | 25 | if (process.argv.length < 3) { 26 | create.updateSubprojectHelp(); 27 | } else { 28 | args = process.argv.slice(2); 29 | create.update_cordova_subproject(args); 30 | } 31 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/lib/start-emulator: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 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 | # Run the below to get the device targets: 21 | # xcrun instruments -s 22 | 23 | set -e 24 | 25 | 26 | DEFAULT_TARGET="iPhone 5s" 27 | TARGET=${1:-$DEFAULT_TARGET} 28 | LIB_PATH=$( cd "$( dirname "$0" )" && pwd -P) 29 | 30 | xcrun instruments -w "$TARGET" &> /dev/null -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | extends: '@cordova/eslint-config/node' 19 | 20 | # FIXME avoid rule exceptions 21 | rules: 22 | prefer-promise-reject-errors: off 23 | 24 | overrides: 25 | - files: [tests/spec/**/*.js] 26 | extends: '@cordova/eslint-config/node-tests' 27 | 28 | - files: [cordova-js-src/**/*.js] 29 | extends: '@cordova/eslint-config/browser' 30 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/build-debug.xcconfig: -------------------------------------------------------------------------------- 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 | // 21 | // XCode Build settings for "Debug" Build Configuration. 22 | // 23 | 24 | #include "build.xcconfig" 25 | 26 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 27 | 28 | // disable code signing for debug builds 29 | CODE_SIGNING_ALLOWED = NO 30 | 31 | #include "build-extras.xcconfig" 32 | -------------------------------------------------------------------------------- /tests/cdv-test-project/hooks/README.md: -------------------------------------------------------------------------------- 1 | 21 | # Cordova Hooks 22 | 23 | Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. See Hooks Guide for more details: http://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html#Hooks%20Guide. 24 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVConsole.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | 23 | @interface CDVConsole : NSObject { 24 | 25 | } 26 | 27 | - (void) log:(NSString*)message; 28 | - (void) trace:(NSString*)message; 29 | - (void) debug:(NSString*)message; 30 | - (void) info:(NSString*)message; 31 | - (void) warn:(NSString*)message; 32 | - (void) error:(NSString*)message; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/CordovaLibApp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | org.apache.cordova.osx.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2014 ca.ca.ca. All rights reserved. 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/MainViewController.h: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | #import 23 | 24 | @interface MainViewController : CDVViewController 25 | 26 | @end 27 | 28 | @interface MainCommandDelegate : CDVCommandDelegateImpl 29 | @end 30 | 31 | @interface MainCommandQueue : CDVCommandQueue 32 | @end -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug Report 3 | about: If something isn't working as expected. 4 | 5 | --- 6 | 7 | # Bug Report 8 | 9 | ## Problem 10 | 11 | ### What is expected to happen? 12 | 13 | 14 | 15 | ### What does actually happen? 16 | 17 | 18 | 19 | ## Information 20 | 21 | 22 | 23 | 24 | ### Command or Code 25 | 26 | 27 | 28 | 29 | ### Environment, Platform, Device 30 | 31 | 32 | 33 | 34 | ### Version information 35 | 42 | 43 | 44 | 45 | ## Checklist 46 | 47 | 48 | - [ ] I searched for existing GitHub issues 49 | - [ ] I updated all Cordova tooling to most recent version 50 | - [ ] I included all the necessary information above 51 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVWindowSizeCommand.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | 23 | @interface CDVWindowSizeCommand : NSObject 24 | 25 | + (void) makeFullScreen:(NSWindow*) window; 26 | 27 | + (void) removeFullScreen:(NSWindow*) window; 28 | 29 | + (void) toggleFullScreen:(NSWindow*) window; 30 | 31 | + (void) setSizeOfWindow:(NSWindow*) window size: (NSSize) size; 32 | @end 33 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Classes/MainViewController.h: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | #import 23 | 24 | @interface MainViewController : CDVViewController 25 | 26 | @end 27 | 28 | @interface MainCommandDelegate : CDVCommandDelegateImpl 29 | @end 30 | 31 | @interface MainCommandQueue : CDVCommandQueue 32 | @end -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibTests-Prefix.pch: -------------------------------------------------------------------------------- 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 | #ifndef CordovaLibTests_CordovaLibTests_Prefix_pch 21 | #define CordovaLibTests_CordovaLibTests_Prefix_pch 22 | 23 | // Include any system framework and library headers here that should be included in all compilation units. 24 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.h: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | 23 | @interface AppDelegate : NSObject { 24 | 25 | IBOutlet NSWindow* window; 26 | } 27 | 28 | @property (nonatomic, strong) IBOutlet NSWindow* window; 29 | @property (nonatomic, strong) IBOutlet CDVViewController* viewController; 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /tests/cdv-test-project/plugins/cordova-plugin-whitelist/whitelist.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 | 21 | if (!document.querySelector('meta[http-equiv=Content-Security-Policy]')) { 22 | var msg = 'No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.'; 23 | console.error(msg); 24 | setInterval(function() { 25 | console.warn(msg); 26 | }, 10000); 27 | } 28 | -------------------------------------------------------------------------------- /tests/spec/helper.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 | const SpecReporter = require('jasmine-spec-reporter').SpecReporter; 20 | 21 | jasmine.getEnv().clearReporters(); 22 | jasmine.getEnv().addReporter(new SpecReporter({ 23 | spec: { 24 | displayPending: true, 25 | displayDuration: true 26 | }, 27 | summary: { 28 | displayDuration: true, 29 | displayStacktrace: true 30 | } 31 | })); 32 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ### Platforms affected 10 | 11 | 12 | 13 | ### Motivation and Context 14 | 15 | 16 | 17 | 18 | 19 | ### Description 20 | 21 | 22 | 23 | 24 | ### Testing 25 | 26 | 27 | 28 | 29 | ### Checklist 30 | 31 | - [ ] I've run the tests to see all new and existing tests pass 32 | - [ ] I added automated test coverage as appropriate for this change 33 | - [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`) 34 | - [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/)) 35 | - [ ] I've updated the documentation if necessary 36 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/version: -------------------------------------------------------------------------------- 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 | 24 | Returns the VERSION of CordovaLib used. 25 | Note: it does not work if the --shared option was used to create the project. 26 | */ 27 | 28 | // Coho updates this line 29 | const VERSION = '7.1.0-dev'; 30 | 31 | module.exports.version = VERSION; 32 | 33 | if (!module.parent) { 34 | console.log(VERSION); 35 | } 36 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVCursorMonitorService.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | #pragma clang diagnostic push 23 | #pragma ide diagnostic ignored "OCUnusedMethodInspection" 24 | 25 | @interface CDVCursorMonitorService : NSObject 26 | 27 | + (CDVCursorMonitorService*) service; 28 | 29 | - (void) startWithTimeout: (CFTimeInterval) timeout; 30 | 31 | - (void) stop; 32 | 33 | @end 34 | 35 | #pragma clang diagnostic pop 36 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVJSON.h: -------------------------------------------------------------------------------- 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 | #pragma clang diagnostic push 21 | #pragma ide diagnostic ignored "OCUnusedMethodInspection" 22 | 23 | @interface NSArray (CDVJSONSerializing) 24 | - (NSString*) JSONString; 25 | @end 26 | 27 | @interface NSDictionary (CDVJSONSerializing) 28 | - (NSString*) JSONString; 29 | @end 30 | 31 | @interface NSString (CDVJSONSerializing) 32 | - (id) JSONObject; 33 | @end 34 | 35 | #pragma clang diagnostic pop 36 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/main.m: -------------------------------------------------------------------------------- 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 | #import 21 | #import "AppDelegate.h" 22 | 23 | static AppDelegate* _appDelegate; 24 | 25 | int main(int argc, const char * argv[]) { 26 | @autoreleasepool { 27 | _appDelegate = [[AppDelegate alloc] init]; 28 | [NSApplication sharedApplication]; 29 | [NSApp setDelegate: _appDelegate]; 30 | [NSApp finishLaunching]; 31 | [NSApp run]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVDebug.h: -------------------------------------------------------------------------------- 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 | #pragma clang diagnostic push 21 | #pragma ide diagnostic ignored "OCUnusedMacroInspection" 22 | 23 | #ifdef DEBUG 24 | #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) 25 | #else 26 | #define DLog(...) 27 | #endif 28 | #define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) 29 | 30 | #pragma clang diagnostic pop 31 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/AppDelegate.h: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | 23 | @interface AppDelegate : NSObject { 24 | IBOutlet NSWindow* window; 25 | } 26 | 27 | @property (nonatomic, strong) IBOutlet CDVViewController* viewController; 28 | @property (nonatomic, strong) IBOutlet NSWindow* window; 29 | 30 | - (void)createViewController: (NSString*) startPage; 31 | - (void)destroyViewController; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/CookieJar.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | @interface CookieJar : NSObject 23 | 24 | - (void) putCookie:(NSHTTPCookie*) cookie; 25 | 26 | - (void) putCookies:(NSArray*) cookies; 27 | 28 | - (NSArray*) cookies; 29 | 30 | - (NSDictionary*) cookiesForURL:(NSURL*) url; 31 | 32 | - (void) handleCookiesInRequest:(NSMutableURLRequest*) request; 33 | 34 | - (void) handleCookiesInResponse:(NSHTTPURLResponse*) response; 35 | 36 | - (void) clear; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVCommandDelegateImpl.h: -------------------------------------------------------------------------------- 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 | #import "CDVCommandDelegate.h" 21 | 22 | @class CDVViewController; 23 | @class CDVCommandQueue; 24 | 25 | @interface CDVCommandDelegateImpl : NSObject { 26 | // @private 27 | #ifdef __MAC_10_8 28 | __weak 29 | #endif 30 | CDVViewController* _viewController; 31 | @protected 32 | __weak CDVCommandQueue* _commandQueue; 33 | } 34 | - (id)initWithViewController:(CDVViewController*)viewController; 35 | @end 36 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Utils/NSWindow+Utils.h: -------------------------------------------------------------------------------- 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 | 21 | #import 22 | 23 | @interface NSWindow (Utils) 24 | 25 | - (float) titleBarHeight; 26 | 27 | /** 28 | * Sets the internal 'lock' flag that prevents setting the window level. this is 29 | * mainly used to make the modal alert boxes work with our fullscreen mode. 30 | */ 31 | - (void) setIsLevelLocked:(bool) lock; 32 | 33 | /** 34 | * see {@link #setIsLevelLocked} 35 | */ 36 | - (bool) getIsLevelLocked; 37 | 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /.asf.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | github: 19 | description: "[DEPRECATED] Apache Cordova OSX" 20 | homepage: https://cordova.apache.org/ 21 | 22 | labels: 23 | - cordova 24 | - cordova-platform 25 | - osx 26 | - objective-c 27 | - javascript 28 | - nodejs 29 | - hacktoberfest 30 | 31 | notifications: 32 | commits: commits@cordova.apache.org 33 | issues: issues@cordova.apache.org 34 | pullrequests_status: issues@cordova.apache.org 35 | pullrequests_comment: issues@cordova.apache.org 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | ### Issue Type 7 | 8 | 9 | - [ ] Bug Report 10 | - [ ] Feature Request 11 | - [ ] Support Question 12 | 13 | ## Description 14 | 15 | ## Information 16 | 17 | 18 | ### Command or Code 19 | 20 | 21 | ### Environment, Platform, Device 22 | 23 | 24 | 25 | 26 | ### Version information 27 | 34 | 35 | 36 | 37 | ## Checklist 38 | 39 | 40 | - [ ] I searched for already existing GitHub issues about this 41 | - [ ] I updated all Cordova tooling to their most recent version 42 | - [ ] I included all the necessary information above 43 | -------------------------------------------------------------------------------- /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 | const 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 | console.log('Usage: check_reqs or node check_reqs'); 27 | } else { 28 | check_reqs.run().catch(function (err) { 29 | console.error('Failed to check requirements due to ' + err); 30 | process.exit(2); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVConfigParser.h: -------------------------------------------------------------------------------- 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 | @interface CDVConfigParser : NSObject { 21 | NSString* featureName; 22 | } 23 | 24 | @property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict; 25 | @property (nonatomic, readonly, strong) NSMutableDictionary* settings; 26 | @property (nonatomic, readonly, strong) NSMutableArray* whitelistHosts; 27 | @property (nonatomic, readonly, strong) NSMutableArray* startupPluginNames; 28 | @property (nonatomic, readonly, strong) NSString* startPage; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/CDVBridge.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | @class WebView; 23 | @class CDVViewController; 24 | 25 | @interface CDVBridge : NSObject { 26 | } 27 | 28 | @property(nonatomic, weak) WebView* webView; 29 | @property(nonatomic,assign) CDVViewController* viewController; 30 | 31 | - (id) initWithWebView:(WebView*) webView andViewController:(CDVViewController*) viewController; 32 | 33 | - (void) exec:(NSString*) callbackId withService:(NSString*) service andAction:(NSString*) action andArguments:(WebScriptObject*) arguments; 34 | 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /bin/templates/scripts/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 | const Api = require('./Api'); 23 | 24 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) { 25 | console.log('Cleans the project directory.'); 26 | process.exit(0); 27 | } 28 | 29 | new Api().clean({ argv: process.argv.slice(2) }).then(function () { 30 | console.log('** CLEAN SUCCEEDED **'); 31 | }, function (err) { 32 | console.error(err); 33 | process.exit(2); 34 | }); 35 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/www/cordova_plugins.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 | cordova.define('cordova/plugin_list', function (require, exports, module) { 22 | module.exports = [{ 23 | 'file': 'plugins/test-plugin.js', 24 | 'id': 'cordova-plugin-osx-test.specs', 25 | 'pluginId': 'cordova-plugin-osx-test', 26 | 'clobbers': [ 27 | 'plugins.Test' 28 | ] 29 | } 30 | ]; 31 | module.exports.metadata = { 32 | 'cordova-plugin-osx-test': '1.0.0' 33 | } 34 | }); 35 | -------------------------------------------------------------------------------- /bin/templates/project/www/spec/helper.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 | afterEach(function () { 20 | document.getElementById('stage').innerHTML = ''; 21 | }); 22 | 23 | var helper = { 24 | trigger: function (obj, name) { 25 | var e = document.createEvent('Event'); 26 | e.initEvent(name, true, true); 27 | obj.dispatchEvent(e); 28 | }, 29 | getComputedStyle: function (querySelector, property) { 30 | var element = document.querySelector(querySelector); 31 | return window.getComputedStyle(element).getPropertyValue(property); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/TestPlugin.m: -------------------------------------------------------------------------------- 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 | #import "TestPlugin.h" 21 | 22 | @implementation TestPlugin { 23 | 24 | } 25 | 26 | - (void) pluginInitialize { 27 | [super pluginInitialize]; 28 | NSLog(@"test plugin initialized."); 29 | return; 30 | } 31 | 32 | - (void) echo:(CDVInvokedUrlCommand*) command { 33 | id arg0 = [command argumentAtIndex:0]; 34 | NSLog(@"TestPlugin.echo(%@)", arg0); 35 | 36 | CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:arg0]; 37 | [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 38 | } 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /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 | - Check for Github issues that corresponds to your contribution and link or create them if necessary. 34 | - Run the tests so your patch doesn't break existing functionality. 35 | 36 | We look forward to your contributions! 37 | 38 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/CDVWebViewDelegate.h: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | 23 | #define CDV_JS_KEY_CONSOLE @"console" 24 | #define CDV_JS_KEY_CORDOVABRIDGE @"cordovabridge" 25 | 26 | @class CDVConsole; 27 | @class CDVBridge; 28 | @class CDVViewController; 29 | 30 | @interface CDVWebViewDelegate : NSObject { 31 | } 32 | 33 | @property (nonatomic) BOOL allowWebViewNavigation; 34 | @property (nonatomic, strong) CDVConsole* console; 35 | @property (nonatomic, strong) CDVBridge* bridge; 36 | @property (nonatomic, 37 | #ifdef __MAC_10_8 38 | weak 39 | #else 40 | strong 41 | #endif 42 | ) IBOutlet CDVViewController* viewController; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /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 | const path = require('path'); 23 | const Api = require('./templates/scripts/cordova/Api'); 24 | const args = require('nopt')({ 25 | link: Boolean, 26 | shared: Boolean, // alias for --link 27 | help: Boolean 28 | }); 29 | 30 | if (args.help || args.argv.remain.length === 0) { 31 | console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'update')) + ' [--link]'); 32 | process.exit(0); 33 | } 34 | 35 | Api.updatePlatform(args.argv.remain[0], { link: (args.link || args.shared) }).catch(err => { 36 | console.log(err); 37 | process.exit(2); 38 | }); 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-osx", 3 | "version": "7.1.0-dev", 4 | "description": "cordova-osx release", 5 | "main": "bin/templates/scripts/cordova/Api.js", 6 | "repository": "github:apache/cordova-osx", 7 | "bugs": "https://github.com/apache/cordova-osx/issues", 8 | "keywords": [ 9 | "osx", 10 | "cordova", 11 | "apache", 12 | "ecosystem:cordova", 13 | "cordova:platform" 14 | ], 15 | "scripts": { 16 | "test": "npm run lint && npm run test:coverage", 17 | "test:objc": "jasmine --config=tests/spec/objc.json", 18 | "test:component": "jasmine --config=tests/spec/component.json", 19 | "test:coverage": "nyc jasmine --config=tests/spec/coverage.json", 20 | "lint": "eslint . \"bin/**/!(*.*)\"" 21 | }, 22 | "author": "Apache Software Foundation", 23 | "license": "Apache-2.0", 24 | "dependencies": { 25 | "cordova-common": "^4.0.2", 26 | "nopt": "^5.0.0", 27 | "plist": "^3.0.4", 28 | "shelljs": "^0.8.5", 29 | "underscore": "^1.13.2", 30 | "unorm": "^1.4.1", 31 | "xcode": "^3.0.1" 32 | }, 33 | "devDependencies": { 34 | "@cordova/eslint-config": "^4.0.0", 35 | "jasmine": "^4.0.2", 36 | "jasmine-spec-reporter": "^7.0.0", 37 | "nyc": "^15.1.0", 38 | "tmp": "0.2.1" 39 | }, 40 | "engines": { 41 | "node": ">=10.0.0" 42 | }, 43 | "nyc": { 44 | "include": [ 45 | "bin/lib/**", 46 | "bin/templates/scripts/**" 47 | ], 48 | "reporter": [ 49 | "lcov", 50 | "text" 51 | ] 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CDVStartPageTests.m: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | 23 | #import "CDVWebViewTest.h" 24 | 25 | @interface CDVStartPageTest : CDVWebViewTest 26 | @end 27 | 28 | @implementation CDVStartPageTest 29 | 30 | - (void) setUp { 31 | [super setUp]; 32 | } 33 | 34 | - (void) tearDown { 35 | [super tearDown]; 36 | } 37 | 38 | - (void) testDefaultStartPage { 39 | [self viewController]; 40 | NSString* geHREF = @"window.location.href"; 41 | NSString* href = [self.webView stringByEvaluatingJavaScriptFromString:geHREF]; 42 | XCTAssertTrue([href hasSuffix:@"index.html"], @"href should point to index.html"); 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/www/plugins/test-plugin.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 | cordova.define('cordova-plugin-osx-test.specs', function(require, exports, module) { 22 | 23 | var argscheck = require('cordova/argscheck'), 24 | channel = require('cordova/channel'), 25 | utils = require('cordova/utils'), 26 | exec = require('cordova/exec'), 27 | cordova = require('cordova'); 28 | 29 | function Specs() { 30 | 31 | console.log('hello test'); 32 | } 33 | 34 | Specs.prototype.echo = function(successCallback, errorCallback, obj) { 35 | exec(successCallback, errorCallback, 'TestPlugin', 'echo', [obj]); 36 | }; 37 | 38 | module.exports = new Specs(); 39 | 40 | }); 41 | 42 | -------------------------------------------------------------------------------- /tests/cdv-test-project/plugins/cordova-plugin-whitelist/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 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/lib/configMunger.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 node: true */ 21 | 22 | const PlatformJson = require('cordova-common').PlatformJson; 23 | const PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger; 24 | const PluginInfoProvider = require('cordova-common').PluginInfoProvider; 25 | 26 | // shared PlatformMunger instance 27 | let _instance = null; 28 | 29 | module.exports = { 30 | 31 | get: function (platformRoot) { 32 | if (!_instance) { 33 | _instance = new PlatformMunger('osx', platformRoot, PlatformJson.load(platformRoot, 'osx'), 34 | new PluginInfoProvider()); 35 | } 36 | 37 | return _instance; 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVCommandQueue.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | #pragma clang diagnostic push 23 | #pragma ide diagnostic ignored "OCUnusedMethodInspection" 24 | 25 | @class CDVInvokedUrlCommand; 26 | @class CDVViewController; 27 | 28 | @interface CDVCommandQueue : NSObject 29 | 30 | @property (nonatomic, readonly) BOOL currentlyExecuting; 31 | 32 | - (id)initWithViewController:(CDVViewController*)viewController; 33 | - (void)dispose; 34 | 35 | - (void)resetRequestId; 36 | - (void)enqueCommandBatch:(NSString*)batchJSON; 37 | 38 | - (void)maybeFetchCommandsFromJs:(NSNumber*)requestId; 39 | - (void)fetchCommandsFromJs; 40 | - (void)executePending; 41 | - (BOOL)execute:(CDVInvokedUrlCommand*)command; 42 | 43 | @end 44 | 45 | #pragma clang diagnostic pop 46 | -------------------------------------------------------------------------------- /tests/spec/objc/cordovalib.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 | 20 | const shell = require('shelljs'); 21 | const path = require('path'); 22 | const util = require('util'); 23 | const tmp = require('tmp'); 24 | 25 | const tests_dir = path.join(__dirname, '..', '..'); 26 | 27 | describe('cordova-lib', () => { 28 | it('objective-c unit tests', () => { 29 | const artifacts_dir = tmp.dirSync().name; 30 | 31 | // run the tests 32 | const command = util.format('xcodebuild test ' + 33 | '-project %s/CordovaLibTests/CordovaLibTests.xcodeproj ' + 34 | '-scheme CordovaLibApp ' + 35 | 'CONFIGURATION_BUILD_DIR="%s"', tests_dir, artifacts_dir); 36 | shell.echo(command); 37 | 38 | const return_code = shell.exec(command).code; 39 | expect(return_code).toBe(0); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m: -------------------------------------------------------------------------------- 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 | #import "AppDelegate.h" 21 | #import "MainViewController.h" 22 | 23 | @implementation AppDelegate 24 | 25 | 26 | @synthesize window; 27 | 28 | - (id)init 29 | { 30 | self = [super init]; 31 | return self; 32 | } 33 | 34 | - (void) applicationDidStartLaunching:(NSNotification*) aNotification 35 | { 36 | } 37 | 38 | - (void) applicationWillFinishLaunching:(NSNotification*)aNotification 39 | { 40 | } 41 | 42 | - (void) applicationDidFinishLaunching:(NSNotification*)aNotification 43 | { 44 | 45 | } 46 | 47 | - (BOOL)applicationShouldHandleReopen:(NSApplication *)app hasVisibleWindows:(BOOL)visibleWindows 48 | { 49 | if (visibleWindows) { 50 | [self.window orderFront:self]; 51 | } else { 52 | [self.window makeKeyAndOrderFront:self]; 53 | } 54 | return YES; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/build.xcconfig: -------------------------------------------------------------------------------- 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 | // 21 | // XCode build settings shared by all Build Configurations. 22 | // Settings are overridden by configuration-level .xcconfig file (build-release/build-debug). 23 | // 24 | 25 | HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)" 26 | OSX_DEPLOYMENT_TARGET = 10.9 27 | OTHER_LDFLAGS = -ObjC 28 | TARGETED_DEVICE_FAMILY = 1,2 29 | 30 | // Type of signing identity used for codesigning, resolves to first match of given type. 31 | // "Mac Developer": Development builds (default, local only; Mac Development certificate) or "Mac Distribution": Distribution builds (Adhoc/In-House/AppStore; Mac Distribution certificate) 32 | CODE_SIGN_IDENTITY = Mac Developer 33 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/defaults.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CDVWebViewTest.h: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | 23 | @class AppDelegate; 24 | @class CDVViewController; 25 | 26 | @interface CDVWebViewTest : XCTestCase 27 | 28 | @property (nonatomic, strong) NSString* startPage; 29 | 30 | - (AppDelegate*)appDelegate; 31 | - (CDVViewController*)viewController; 32 | - (WebView*)webView; 33 | 34 | // Returns the already registered plugin object for the given class. 35 | - (id)pluginInstance:(NSString*)pluginName; 36 | // Destroys the existing webview and creates a new one. 37 | - (void)reloadWebView; 38 | // Runs the run loop until the given block returns true, or until a timeout 39 | // occurs. 40 | - (void)waitForConditionName:(NSString*)conditionName block:(BOOL (^)())block; 41 | - (void) waitForPageLoad; 42 | 43 | // Convenience function for stringByEvaluatingJavaScriptFromString. 44 | - (NSString*)evalJs:(NSString*)code; 45 | @end 46 | -------------------------------------------------------------------------------- /tests/cdv-test-project/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelloCordova 4 | 5 | A sample Apache Cordova application that responds to the deviceready event. 6 | This project is used for testing adding the OSX platform. 7 | 8 | 9 | Apache Cordova Team 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bin/test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 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 | 24 | # the two lines below are to get the current folder, and resolve symlinks 25 | SCRIPT="$0" 26 | # need this for relative symlinks 27 | while [ -h "$SCRIPT" ] ; do 28 | SCRIPT=`readlink "$SCRIPT"` 29 | done 30 | 31 | BINDIR=$( cd "$( dirname "$SCRIPT" )" && pwd ) 32 | TESTDIR=$BINDIR/mobile-spec-test 33 | 34 | echo "TESTDIR" $SCRIPT 35 | 36 | # get the latest mobile-spec 37 | git clone git://github.com/apache/cordova-mobile-spec.git $BINDIR/mobile-spec 38 | 39 | # clobber test if it exists 40 | if [ -e $TESTDIR ] 41 | then 42 | rm -rf $TESTDIR 43 | fi 44 | 45 | # generate a working proj 46 | $BINDIR/create $TESTDIR org.apache.cordova.test CordovaTest 47 | 48 | # kill the default app and replace it w/ mobile-spec 49 | rm -rf $TESTDIR/www 50 | mv $BINDIR/mobile-spec $TESTDIR/www 51 | 52 | # build it, launch it and start logging on stdout 53 | $TESTDIR/cordova/debug && $TESTDIR/cordova/log 54 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CDVPluginsTests.m: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | 23 | #import "CDVWebViewTest.h" 24 | 25 | @interface CDVPluginsTest : CDVWebViewTest 26 | @end 27 | 28 | @implementation CDVPluginsTest 29 | 30 | - (void) setUp { 31 | [super setUp]; 32 | } 33 | 34 | - (void) tearDown { 35 | [super tearDown]; 36 | } 37 | 38 | - (void) testEcho { 39 | [self viewController]; 40 | 41 | NSString* testId = [self.webView stringByEvaluatingJavaScriptFromString:@"runTests()"]; 42 | 43 | NSLog(@"waiting for test %@", testId); 44 | NSString *jsString = [NSString stringWithFormat:@"window.jsTests['%@'].result", testId]; 45 | 46 | __block NSString *result; 47 | [self waitForConditionName:testId block:^{ 48 | result = [self evalJs:jsString]; 49 | return (BOOL) (result.length > 0); 50 | }]; 51 | XCTAssertTrue([result isEqualToString:@"true"], @"test should succeed"); 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /bin/templates/scripts/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 | const path = require('path'); 21 | const shell = require('shelljs'); 22 | const spawn = require('./spawn'); 23 | 24 | const projectPath = path.join(__dirname, '..', '..'); 25 | 26 | module.exports.run = function () { 27 | const projectName = shell.ls(projectPath).filter(function (name) { 28 | return path.extname(name) === '.xcodeproj'; 29 | })[0]; 30 | 31 | if (!projectName) { 32 | return Promise.reject('No Xcode project found in ' + projectPath); 33 | } 34 | 35 | return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Debug', '-alltargets', 'clean'], projectPath) 36 | .then(function () { 37 | return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Release', '-alltargets', 'clean'], projectPath); 38 | }).then(function () { 39 | return shell.rm('-rf', path.join(projectPath, 'build')); 40 | }); 41 | }; 42 | -------------------------------------------------------------------------------- /bin/templates/project/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | Hello World 28 | 29 | 30 |
31 |

Apache Cordova

32 | 33 | 38 |
39 | 40 | 41 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "size": "16x16", 5 | "idiom": "mac", 6 | "filename": "icon-16x16.png", 7 | "scale": "1x" 8 | }, 9 | { 10 | "size": "16x16", 11 | "idiom": "mac", 12 | "filename": "icon-32x32.png", 13 | "scale": "2x" 14 | }, 15 | { 16 | "size": "32x32", 17 | "idiom": "mac", 18 | "filename": "icon-32x32.png", 19 | "scale": "1x" 20 | }, 21 | { 22 | "size": "32x32", 23 | "idiom": "mac", 24 | "filename": "icon-64x64.png", 25 | "scale": "2x" 26 | }, 27 | { 28 | "size": "128x128", 29 | "idiom": "mac", 30 | "filename": "icon-128x128.png", 31 | "scale": "1x" 32 | }, 33 | { 34 | "size": "128x128", 35 | "idiom": "mac", 36 | "filename": "icon-256x256.png", 37 | "scale": "2x" 38 | }, 39 | { 40 | "size": "256x256", 41 | "idiom": "mac", 42 | "filename": "icon-256x256.png", 43 | "scale": "1x" 44 | }, 45 | { 46 | "size": "256x256", 47 | "idiom": "mac", 48 | "filename": "icon-512x512.png", 49 | "scale": "2x" 50 | }, 51 | { 52 | "size": "512x512", 53 | "idiom": "mac", 54 | "filename": "icon-512x512.png", 55 | "scale": "1x" 56 | }, 57 | { 58 | "idiom": "mac", 59 | "size": "512x512", 60 | "filename": "icon-1024x1024.png", 61 | "scale": "2x" 62 | } 63 | ], 64 | "info": { 65 | "version": 1, 66 | "author": "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /bin/templates/scripts/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 | const args = process.argv; 23 | const Api = require('./Api'); 24 | const nopt = require('nopt'); 25 | 26 | // Support basic help commands 27 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) { 28 | require('./lib/build').help(); 29 | process.exit(0); 30 | } 31 | 32 | // Parse arguments 33 | const buildOpts = nopt({ 34 | verbose: Boolean, 35 | silent: Boolean, 36 | debug: Boolean, 37 | release: Boolean, 38 | codeSignIdentity: String, 39 | codeSignResourceRules: String, 40 | provisioningProfile: String, 41 | buildConfig: String, 42 | noSign: Boolean 43 | }, { '-r': '--release' }, args); 44 | 45 | // Make buildOptions compatible with PlatformApi build method spec 46 | buildOpts.argv = buildOpts.argv.remain; 47 | 48 | new Api().build(buildOpts).then(function () { 49 | console.log('** BUILD SUCCEEDED **'); 50 | }, function (err) { 51 | const errorMessage = (err && err.stack) ? err.stack : err; 52 | console.error(errorMessage); 53 | process.exit(2); 54 | }); 55 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/lib/spawn.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 | const proc = require('child_process'); 21 | 22 | /** 23 | * Run specified command with arguments 24 | * @param {String} cmd Command 25 | * @param {Array} args Array of arguments that should be passed to command 26 | * @param {String} opt_cwd Working directory for command 27 | * @param {String} opt_verbosity Verbosity level for command stdout output, "verbose" by default 28 | * @return {Promise} Promise either fullfilled or rejected with error code 29 | */ 30 | module.exports = function (cmd, args, opt_cwd) { 31 | return new Promise((resolve, reject) => { 32 | try { 33 | const child = proc.spawn(cmd, args, { cwd: opt_cwd, stdio: 'inherit' }); 34 | 35 | child.on('exit', function (code) { 36 | if (code) { 37 | reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' + args); 38 | } else { 39 | resolve(); 40 | } 41 | }); 42 | } catch (e) { 43 | console.error('error caught: ' + e); 44 | reject(e); 45 | } 46 | }); 47 | }; 48 | -------------------------------------------------------------------------------- /bin/templates/project/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 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 46 | 47 | 48 |

Hey, it's Cordova!

49 |
    50 |
  1. Check your console log for any white-list rejection errors.
  2. 51 |
  3. Add your allowed hosts in config.xml as access tags and set the origin attribute. (wildcards 52 | OK, don't enter the URL scheme) 53 |
  4. 54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /bin/templates/scripts/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 | const args = process.argv; 23 | const Api = require('./Api'); 24 | const nopt = require('nopt'); 25 | 26 | // Handle help flag 27 | if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) { 28 | require('./lib/run').help(); 29 | process.exit(0); 30 | } 31 | 32 | // Parse arguments (includes build params as well) 33 | const opts = nopt({ 34 | verbose: Boolean, 35 | silent: Boolean, 36 | debug: Boolean, 37 | release: Boolean, 38 | nobuild: Boolean, 39 | archs: String, 40 | list: Boolean, 41 | device: Boolean, 42 | emulator: Boolean, 43 | target: String, 44 | codeSignIdentity: String, 45 | codeSignResourceRules: String, 46 | provisioningProfile: String, 47 | buildConfig: String, 48 | noSign: Boolean 49 | }, {}, args); 50 | 51 | // Make options compatible with PlatformApi build method spec 52 | opts.argv = opts.argv.remain; 53 | 54 | new Api().run(opts).then(function () { 55 | console.log('** RUN SUCCEEDED **'); 56 | }, function (err) { 57 | const errorMessage = (err && err.stack) ? err.stack : err; 58 | console.error(errorMessage); 59 | process.exit(2); 60 | }); 61 | -------------------------------------------------------------------------------- /tests/cdv-test-project/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 explicitly 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 | 51 | app.initialize(); -------------------------------------------------------------------------------- /tests/CordovaLibTests/CDVBase64Tests.m: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | #import 23 | 24 | @interface CDVBase64Tests : XCTestCase 25 | @end 26 | 27 | @implementation CDVBase64Tests 28 | 29 | - (void) setUp { 30 | [super setUp]; 31 | 32 | // setup code here 33 | } 34 | 35 | - (void) tearDown { 36 | // Tear-down code here. 37 | 38 | [super tearDown]; 39 | } 40 | 41 | - (void) testBase64Encode { 42 | NSString* decodedString = @"abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&"; 43 | NSData* decodedData = [decodedString dataUsingEncoding:NSUTF8StringEncoding]; 44 | 45 | NSString* expectedEncodedString = @"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwIUAjJCVeJg=="; 46 | NSString* actualEncodedString = [decodedData base64EncodedString]; 47 | 48 | XCTAssertTrue([expectedEncodedString isEqualToString:actualEncodedString]); 49 | } 50 | 51 | - (void) testBase64Decode { 52 | NSString* encodedString = @"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwIUAjJCVeJg=="; 53 | NSString* decodedString = @"abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&"; 54 | NSData* encodedData = [decodedString dataUsingEncoding:NSUTF8StringEncoding]; 55 | NSData* decodedData = [NSData dataFromBase64String:encodedString]; 56 | 57 | XCTAssertTrue([encodedData isEqualToData:decodedData]); 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVAvailability.h: -------------------------------------------------------------------------------- 1 | /* 2 | #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_7_0_0 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 | #define __CORDOVA_OSX__ 21 | 22 | #define __CORDOVA_4_0_0 40000 23 | #define __CORDOVA_NA 99999 /* not available */ 24 | 25 | /* 26 | #if CORDOVA_VERSION_MIN_REQUIRED >= __CORDOVA_4_0_0 27 | // do something when its at least 4.0.0 28 | #else 29 | // do something else (non 4.0.0) 30 | #endif 31 | */ 32 | #ifndef CORDOVA_VERSION_MIN_REQUIRED 33 | #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_4_0_0 34 | #endif 35 | 36 | 37 | /* Return the string version of the decimal version */ 38 | #define CDV_VERSION [NSString stringWithFormat:@"%d.%d.%d", \ 39 | (CORDOVA_VERSION_MIN_REQUIRED / 10000), \ 40 | (CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \ 41 | (CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100] 42 | 43 | #ifdef __clang__ 44 | #define CDV_DEPRECATED(version, msg) __attribute__((deprecated("Deprecated in Cordova " #version ". " msg))) 45 | #else 46 | #define CDV_DEPRECATED(version, msg) __attribute__((deprecated())) 47 | #endif 48 | 49 | // Enable this to log all exec() calls. 50 | #define CDV_ENABLE_EXEC_LOGGING 0 51 | #if CDV_ENABLE_EXEC_LOGGING 52 | #define CDV_EXEC_LOG NSLog 53 | #else 54 | #define CDV_EXEC_LOG(...) do {} while (NO) 55 | #endif 56 | #define __CORDOVA_5_0_0 50000 57 | #define __CORDOVA_6_0_0 60000 58 | #define __CORDOVA_7_0_0 70000 59 | -------------------------------------------------------------------------------- /tests/cdv-test-project/plugins/cordova-plugin-whitelist/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 24 | Whitelist 25 | Cordova Network Whitelist Plugin 26 | Apache 2.0 27 | cordova,whitelist,policy 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in. 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/AppDelegate.m: -------------------------------------------------------------------------------- 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 | #import "AppDelegate.h" 21 | #import "MainViewController.h" 22 | 23 | @implementation AppDelegate 24 | 25 | 26 | @synthesize viewController; 27 | @synthesize window; 28 | 29 | - (id)init{ 30 | self = [super init]; 31 | return self; 32 | } 33 | 34 | - (void)createViewController: (NSString*) startPage { 35 | NSAssert(!self.viewController, @"ViewController already created."); 36 | if (startPage == nil) { 37 | startPage = @"index.html"; 38 | } 39 | self.viewController = [[MainViewController alloc] initWithWindowNibName:@"MainViewController"]; 40 | self.viewController.wwwFolderName = @"www"; 41 | self.viewController.startPage = startPage; 42 | [[self.viewController window] makeKeyAndOrderFront:self]; 43 | } 44 | 45 | - (void)destroyViewController 46 | { 47 | [self.viewController close]; 48 | self.viewController = nil; 49 | } 50 | 51 | - (void) applicationDidStartLaunching:(NSNotification*) aNotification { 52 | } 53 | 54 | - (void) applicationWillFinishLaunching:(NSNotification*)aNotification{ 55 | } 56 | 57 | - (void) applicationDidFinishLaunching:(NSNotification*)aNotification { 58 | // Create the main view on start-up only when not running unit tests. 59 | Class testProbeClass = NSClassFromString(@"XCTestProbe"); 60 | if (!testProbeClass) { 61 | testProbeClass = NSClassFromString(@"SenTestProbe"); 62 | } 63 | if (!testProbeClass) { 64 | [self createViewController: nil]; 65 | } 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CDVInvokedUrlCommandTests.m: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | 23 | #import 24 | 25 | @interface CDVInvokedUrlCommandTests : XCTestCase 26 | @end 27 | 28 | @implementation CDVInvokedUrlCommandTests 29 | 30 | - (void) testInitWithNoArgs { 31 | NSArray* jsonArr = @[@"callbackId", @"className", @"methodName", [NSArray array]]; 32 | CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand commandFromJson:jsonArr]; 33 | 34 | XCTAssertEqual(@"callbackId", command.callbackId); 35 | XCTAssertEqual(@"className", command.cmdClassName); 36 | XCTAssertEqual(@"methodName", command.methodName); 37 | XCTAssertEqual([NSArray array], command.arguments); 38 | } 39 | 40 | - (void) testArgumentAtIndex { 41 | NSArray* arguments = @[[NSNull null], [WebUndefined undefined]]; 42 | NSArray* jsonArr = @[[NSNull null], @"className", @"methodName", arguments]; 43 | CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand commandFromJson:jsonArr]; 44 | 45 | XCTAssertNil([command argumentAtIndex:0], @"NSNull to nil"); 46 | XCTAssertNil([command argumentAtIndex:1], @"WebUndefined to nil"); 47 | XCTAssertNil([command argumentAtIndex:100], @"Invalid index to nil"); 48 | XCTAssertEqual(@"default", [command argumentAtIndex:0 withDefault:@"default"], @"NSNull to default"); 49 | XCTAssertEqual(@"default", [command argumentAtIndex:1 withDefault:@"default"], @"WebUndefined to default"); 50 | XCTAssertEqual(@"default", [command argumentAtIndex:100 withDefault:@"default"], @"Invalid index to default"); 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVPlugin.h: -------------------------------------------------------------------------------- 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 | #import 21 | #import 22 | #import "CDVPluginResult.h" 23 | #import "CDVCommandDelegate.h" 24 | #import "CDVViewController.h" 25 | 26 | #pragma clang diagnostic push 27 | #pragma ide diagnostic ignored "OCUnusedPropertyInspection" 28 | #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" 29 | #pragma ide diagnostic ignored "OCUnusedMethodInspection" 30 | 31 | extern NSString* const CDVPageDidLoadNotification; 32 | extern NSString* const CDVPluginHandleOpenURLNotification; 33 | extern NSString* const CDVPluginResetNotification; 34 | extern NSString* const CDVLocalNotification; 35 | 36 | @interface CDVPlugin : NSObject {} 37 | 38 | @property (nonatomic, weak) WebView* webView; 39 | @property (nonatomic, unsafe_unretained) CDVViewController* viewController; 40 | @property (nonatomic, unsafe_unretained) id commandDelegate; 41 | 42 | @property (readonly, assign) BOOL hasPendingOperation; 43 | 44 | - (CDVPlugin*)initWithWebView:(WebView*)theWebView; 45 | - (void)pluginInitialize; 46 | 47 | - (void)handleOpenURL:(NSNotification*)notification; 48 | - (void)onAppTerminate; 49 | - (void)onMemoryWarning; 50 | - (void)onReset; 51 | - (void)dispose; 52 | 53 | /* 54 | // see initWithWebView implementation 55 | - (void) onPause {} 56 | - (void) onResume {} 57 | - (void) onOrientationWillChange {} 58 | - (void) onOrientationDidChange {} 59 | - (void)didReceiveLocalNotification:(NSNotification *)notification; 60 | */ 61 | 62 | - (id)appDelegate; 63 | 64 | @end 65 | 66 | #pragma clang diagnostic pop 67 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | #pragma clang diagnostic push 23 | #pragma ide diagnostic ignored "OCUnusedPropertyInspection" 24 | 25 | @interface CDVInvokedUrlCommand : NSObject { 26 | NSString* _callbackId; 27 | NSString* _cmdClassName; 28 | NSString* _methodName; 29 | NSArray* _arguments; 30 | } 31 | 32 | @property(nonatomic, readonly) NSArray* arguments; 33 | @property(nonatomic, readonly) NSString* callbackId; 34 | @property(nonatomic, readonly) NSString* cmdClassName; 35 | @property(nonatomic, readonly) NSString* methodName; 36 | 37 | + (CDVInvokedUrlCommand*) commandFromJson:(NSArray*) jsonEntry; 38 | 39 | - (id) initWithArguments:(NSArray*) arguments 40 | callbackId:(NSString*) callbackId 41 | className:(NSString*) className 42 | methodName:(NSString*) methodName; 43 | 44 | - (id) initFromJson:(NSArray*) jsonEntry; 45 | 46 | /** 47 | * Returns the argument at the given index. 48 | * If index >= the number of arguments, returns nil. 49 | * If the argument at the given index is NSNull, returns nil. 50 | */ 51 | - (id) argumentAtIndex:(NSUInteger) index; 52 | 53 | /** 54 | * Same as above, but returns defaultValue instead of nil. 55 | */ 56 | - (id) argumentAtIndex:(NSUInteger) index withDefault:(id) defaultValue; 57 | 58 | /** 59 | * Same as above, but returns defaultValue instead of nil, and if the argument is not of the expected class, returns defaultValue 60 | */ 61 | - (id) argumentAtIndex:(NSUInteger) index withDefault:(id) defaultValue andClass:(Class) aClass; 62 | 63 | @end 64 | 65 | #pragma clang diagnostic pop 66 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | TestApp 40 | 41 | A sample Apache Cordova application that responds to the deviceready event. 42 | 43 | 44 | Apache Cordova Team 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /tests/spec/component/create.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 | 20 | const shell = require('shelljs'); 21 | const path = require('path'); 22 | const util = require('util'); 23 | const fs = require('fs'); 24 | const tmp = require('tmp').dirSync().name; 25 | 26 | const cordova_bin = path.join(__dirname, '../../..', 'bin'); 27 | 28 | function initProjectPath (projectname) { 29 | // remove existing folder 30 | const pPath = path.join(tmp, projectname); 31 | shell.rm('-rf', pPath); 32 | return pPath; 33 | } 34 | 35 | function createProject (projectname, projectid) { 36 | const projectPath = initProjectPath(projectname); 37 | 38 | // create the project 39 | const command = util.format('"%s/create" "%s/%s" %s "%s"', cordova_bin, tmp, projectname, projectid, projectname); 40 | shell.echo(command); 41 | 42 | const return_code = shell.exec(command).code; 43 | expect(return_code).toBe(0); 44 | expect(fs.existsSync(projectPath)).toBe(true); 45 | 46 | console.log('created project at %s', projectPath); 47 | return projectPath; 48 | } 49 | 50 | function createAndBuild (projectname, projectid) { 51 | const projectPath = createProject(projectname, projectid); 52 | 53 | // build the project 54 | const command = util.format('"%s/cordova/build"', path.join(tmp, projectname)); 55 | shell.echo(command); 56 | 57 | const return_code = shell.exec(command, { silent: true }).code; 58 | expect(return_code).toBe(0); 59 | 60 | // clean-up 61 | shell.rm('-rf', projectPath); 62 | } 63 | 64 | describe('create', () => { 65 | it('create project with ascii+unicode name, and spaces', () => { 66 | const projectname = '応応応応 hello 用用用用'; 67 | const projectid = 'com.test.app6'; 68 | 69 | createAndBuild(projectname, projectid); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /bin/templates/project/www/spec.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | Jasmine Spec Runner 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /tests/cdv-test-project/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 31 | 32 | 33 | 34 | 35 | 36 | Hello World 37 | 38 | 39 |
40 |

Apache Cordova

41 | 45 |
46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /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/OSX project 24 | * 25 | * USAGE 26 | * ./create 27 | * 28 | * EXAMPLE 29 | * ./create ~/Desktop/radness org.apache.cordova.radness Radness 30 | */ 31 | 32 | const path = require('path'); 33 | const ConfigParser = require('cordova-common').ConfigParser; 34 | const Api = require('./templates/scripts/cordova/Api'); 35 | 36 | const argv = require('nopt')({ 37 | help: Boolean, 38 | link: Boolean 39 | }); 40 | 41 | const projectPath = argv.argv.remain[0]; 42 | 43 | if (argv.help || !projectPath) { 44 | console.log('Usage: $0 [--link] []'); 45 | console.log(' --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it.'); 46 | console.log(' : Path to your new Cordova OSX project'); 47 | console.log(' : Package name, following reverse-domain style convention'); 48 | console.log(' : Project name'); 49 | console.log(' : Path to project template (override).'); 50 | process.exit(0); 51 | } 52 | 53 | // use default configuration file from project template 54 | const config = new ConfigParser(path.resolve(__dirname, 'templates/project/__PROJECT_NAME__/config.xml')); 55 | 56 | // apply overrides (package and project names 57 | if (argv.argv.remain[1]) config.setPackageName(argv.argv.remain[1]); 58 | if (argv.argv.remain[2]) config.setName(argv.argv.remain[2]); 59 | 60 | const options = { 61 | link: argv.link, 62 | customTemplate: argv.argv.remain[3] 63 | }; 64 | 65 | Api.createPlatform(projectPath, config, options).catch(err => { 66 | console.error(err); 67 | process.exit(2); 68 | }); 69 | -------------------------------------------------------------------------------- /bin/templates/scripts/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 | /* jshint node: true */ 21 | 22 | const path = require('path'); 23 | const build = require('./build'); 24 | const spawn = require('./spawn'); 25 | const events = require('cordova-common').events; 26 | 27 | const projectPath = path.join(__dirname, '..', '..'); 28 | 29 | module.exports.run = function (runOptions) { 30 | return Promise.resolve().then(function () { 31 | if (!runOptions.nobuild) { 32 | return build.run(runOptions); 33 | } 34 | }).then(function () { 35 | return build.findXCodeProjectIn(projectPath); 36 | }).then(function (projectName) { 37 | const appPath = path.join(projectPath, 'build', projectName + '.app'); 38 | return runApp(appPath, projectName); 39 | }); 40 | }; 41 | 42 | /** 43 | * runs the app 44 | * @return {Promise} Resolves when run succeeds otherwise rejects 45 | */ 46 | function runApp (appDir, appName) { 47 | const binPath = path.join(appDir, 'Contents', 'MacOS', appName); 48 | events.emit('log', 'Starting: ' + binPath); 49 | return spawn(binPath); 50 | } 51 | 52 | module.exports.help = function () { 53 | console.log('\nUsage: run [ --debug | --release | --nobuild ]'); 54 | console.log(' --debug : Builds project in debug mode. (Passed down to build command, if necessary)'); 55 | console.log(' --release : Builds project in release mode. (Passed down to build command, if necessary)'); 56 | console.log(' --nobuild : Uses pre-built package, or errors if project is not built.'); 57 | console.log(''); 58 | console.log('Examples:'); 59 | console.log(' run'); 60 | console.log(' run --release'); 61 | console.log(' run --debug'); 62 | console.log(''); 63 | process.exit(0); 64 | }; 65 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVCommandDelegate.h: -------------------------------------------------------------------------------- 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 | #import "CDVAvailability.h" 21 | #import "CDVInvokedUrlCommand.h" 22 | 23 | #pragma clang diagnostic push 24 | #pragma ide diagnostic ignored "OCUnusedPropertyInspection" 25 | #pragma ide diagnostic ignored "OCUnusedMethodInspection" 26 | 27 | @class CDVPlugin; 28 | @class CDVPluginResult; 29 | 30 | @protocol CDVCommandDelegate 31 | 32 | @property (nonatomic, readonly) NSDictionary* settings; 33 | 34 | /** 35 | * Resolves the path for a given resource. 36 | */ 37 | - (NSString*) pathForResource:(NSString*) resourcepath; 38 | 39 | /** 40 | * Returns the command instance for the given plugin name 41 | */ 42 | - (id) getCommandInstance:(NSString*) pluginName; 43 | 44 | /** 45 | * Sends a plugin result to the JS. This is thread-safe. 46 | */ 47 | - (void) sendPluginResult:(CDVPluginResult*) result callbackId:(NSString*) callbackId; 48 | 49 | /** 50 | * Evaluates the given JS. This is thread-safe. 51 | */ 52 | - (void) evalJs:(NSString*) js; 53 | 54 | /** 55 | * Can be used to evaluate JS right away instead of scheduling it on the run-loop. 56 | * This is required for dispatch resign and pause events, but should not be used 57 | * without reason. Without the run-loop delay, alerts used in JS callbacks may result 58 | * in dead-lock. This method must be called from the UI thread. 59 | */ 60 | - (void) evalJs:(NSString*) js scheduledOnRunLoop:(BOOL) scheduledOnRunLoop; 61 | 62 | /** 63 | * Runs the given block on a background thread using a shared thread-pool. 64 | */ 65 | - (void) runInBackground:(void (^)()) block; 66 | 67 | /** 68 | * Returns the User-Agent of the associated UIWebView. 69 | */ 70 | - (NSString*) userAgent; 71 | 72 | /** 73 | * Returns whether the given URL passes the white-list. 74 | */ 75 | - (BOOL) URLIsWhitelisted:(NSURL*) url; 76 | 77 | @end 78 | 79 | #pragma clang diagnostic pop 80 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVWindowSizeCommand.m: -------------------------------------------------------------------------------- 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 | #import "CDVWindowSizeCommand.h" 21 | #import "NSScreen+Utils.h" 22 | 23 | @implementation CDVWindowSizeCommand { 24 | } 25 | 26 | static NSRect savedFrameRect; 27 | 28 | /** 29 | * Makes the window fullscreen by resizing it to the size of all attached displays. This is different from just entering 30 | * normal OSX fullscreen mode which only covers the main display. 31 | */ 32 | + (void) makeFullScreen:(NSWindow*) window { 33 | NSRect fullScreenRect = [NSScreen fullScreenRect]; 34 | NSLog(@"Full screen resolution: %.f x %.f", fullScreenRect.size.width, fullScreenRect.size.height); 35 | [window setStyleMask:window.styleMask & ~NSTitledWindowMask]; 36 | [window setHidesOnDeactivate:YES]; 37 | [window setLevel:NSMainMenuWindowLevel + 1]; 38 | savedFrameRect = window.frame; 39 | [window setFrame:fullScreenRect display:YES]; 40 | } 41 | 42 | /** 43 | * Takes the window off fullscreen mode. 44 | */ 45 | + (void) removeFullScreen:(NSWindow*) window { 46 | [window setStyleMask:window.styleMask | NSTitledWindowMask]; 47 | [window setHidesOnDeactivate:NO]; 48 | [window setLevel:NSNormalWindowLevel]; 49 | [window setFrame:savedFrameRect display:YES]; 50 | } 51 | 52 | /** 53 | * Toggles fullscreen mode of the window. 54 | */ 55 | + (void) toggleFullScreen:(NSWindow*) window { 56 | if ((window.styleMask & NSTitledWindowMask) == NSTitledWindowMask) { 57 | [CDVWindowSizeCommand makeFullScreen:window]; 58 | } else { 59 | [CDVWindowSizeCommand removeFullScreen:window]; 60 | } 61 | } 62 | 63 | + (void) setSizeOfWindow:(NSWindow*) window size:(NSSize) size { 64 | NSLog(@"Set window size to %.f x %.f", size.width, size.height); 65 | NSRect frameRect = window.frame; 66 | frameRect.size = size; 67 | [window setFrame:frameRect display:YES]; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVJSON.m: -------------------------------------------------------------------------------- 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 | #import "CDVJSON.h" 21 | 22 | @implementation NSArray (CDVJSONSerializing) 23 | 24 | - (NSString*) JSONString { 25 | NSError* error = nil; 26 | NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self 27 | options:NSJSONWritingPrettyPrinted 28 | error:&error]; 29 | 30 | if (error != nil) { 31 | NSLog(@"NSArray JSONString error: %@", [error localizedDescription]); 32 | return nil; 33 | } else { 34 | return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 35 | } 36 | } 37 | 38 | @end 39 | 40 | @implementation NSDictionary (CDVJSONSerializing) 41 | 42 | - (NSString*) JSONString { 43 | NSError* error = nil; 44 | NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self 45 | options:NSJSONWritingPrettyPrinted 46 | error:&error]; 47 | 48 | if (error != nil) { 49 | NSLog(@"NSDictionary JSONString error: %@", [error localizedDescription]); 50 | return nil; 51 | } else { 52 | return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 53 | } 54 | } 55 | 56 | @end 57 | 58 | @implementation NSString (CDVJSONSerializing) 59 | 60 | - (id) JSONObject { 61 | NSError* error = nil; 62 | id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding] 63 | options:kNilOptions 64 | error:&error]; 65 | 66 | if (error != nil) { 67 | NSLog(@"NSString JSONObject error: %@", [error localizedDescription]); 68 | } 69 | 70 | return object; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVConsole.m: -------------------------------------------------------------------------------- 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 | #import "CDVConsole.h" 21 | 22 | 23 | @implementation CDVConsole 24 | 25 | 26 | - (void) log:(NSString*) message { 27 | NSLog(@"%@", message); 28 | } 29 | 30 | - (void) trace:(NSString*) message { 31 | NSLog(@"trace: %@", message); 32 | } 33 | 34 | - (void) debug:(NSString*) message { 35 | NSLog(@"debug: %@", message); 36 | } 37 | 38 | - (void) info:(NSString*) message { 39 | NSLog(@"info: %@", message); 40 | } 41 | 42 | - (void) warn:(NSString*) message { 43 | NSLog(@"warn: %@", message); 44 | } 45 | 46 | - (void) error:(NSString*) message { 47 | NSLog(@"error: %@", message); 48 | } 49 | 50 | #pragma mark WebScripting Protocol 51 | 52 | /* checks whether a selector is acceptable to be called from JavaScript */ 53 | + (BOOL) isSelectorExcludedFromWebScript:(SEL) sel { 54 | return sel != @selector(log:) && 55 | sel != @selector(trace:) && 56 | sel != @selector(debug:) && 57 | sel != @selector(info:) && 58 | sel != @selector(warn:) && 59 | sel != @selector(error:); 60 | } 61 | 62 | /* helper function so we don't have to have underscores and stuff in js to refer to the right method */ 63 | + (NSString*) webScriptNameForSelector:(SEL) sel { 64 | if (sel == @selector(log:)) { 65 | return @"log"; 66 | } else if (sel == @selector(trace:)) { 67 | return @"trace"; 68 | } else if (sel == @selector(debug:)) { 69 | return @"debug"; 70 | } else if (sel == @selector(info:)) { 71 | return @"info"; 72 | } else if (sel == @selector(warn:)) { 73 | return @"warn"; 74 | } else if (sel == @selector(error:)) { 75 | return @"error"; 76 | } else { 77 | return nil; 78 | } 79 | } 80 | 81 | // right now exclude all properties (eg keys) 82 | + (BOOL) isKeyExcludedFromWebScript:(const char*) name { 83 | return YES; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Utils/NSWindow+Utils.m: -------------------------------------------------------------------------------- 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 | 21 | #import 22 | #import "NSWindow+Utils.h" 23 | 24 | #define KEY_LEVEL_LOCKED @"level_lock" 25 | 26 | @implementation NSWindow (Utils) 27 | 28 | 29 | + (NSWindow*) instance { 30 | static NSWindow* _instance = nil; 31 | 32 | @synchronized (self) { 33 | if (_instance == nil) { 34 | _instance = [[self alloc] init]; 35 | } 36 | } 37 | 38 | return _instance; 39 | } 40 | 41 | - (float) titleBarHeight { 42 | NSRect frame = [self frame]; 43 | NSRect contentRect = [NSWindow contentRectForFrameRect: frame 44 | styleMask: NSTitledWindowMask]; 45 | 46 | return (float) (frame.size.height - contentRect.size.height); 47 | } 48 | 49 | - (NSMutableDictionary*) props { 50 | NSMutableDictionary* p = objc_getAssociatedObject(self, @selector(props)); 51 | if (p == nil) { 52 | p = [NSMutableDictionary dictionary]; 53 | p[KEY_LEVEL_LOCKED] = @NO; 54 | objc_setAssociatedObject(self, @selector(props), p, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 55 | } 56 | return p; 57 | } 58 | 59 | - (bool) getIsLevelLocked { 60 | NSMutableDictionary* p = [self props]; 61 | return [@YES isEqualTo:p[KEY_LEVEL_LOCKED]]; 62 | } 63 | 64 | - (void) setIsLevelLocked:(bool) lock { 65 | NSMutableDictionary* p = [self props]; 66 | p[KEY_LEVEL_LOCKED] = lock ? @YES : @NO; 67 | } 68 | 69 | - (void) swizzled_setLevel: (NSInteger) level { 70 | if ([self getIsLevelLocked]) { 71 | return; 72 | } 73 | 74 | #pragma clang diagnostic push 75 | #pragma ide diagnostic ignored "InfiniteRecursion" 76 | [self swizzled_setLevel:level]; 77 | #pragma clang diagnostic pop 78 | } 79 | 80 | + (void)load { 81 | Method original, swizzled; 82 | 83 | original = class_getInstanceMethod(self, @selector(setLevel:)); 84 | swizzled = class_getInstanceMethod(self, @selector(swizzled_setLevel:)); 85 | method_exchangeImplementations(original, swizzled); 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /bin/templates/project/www/spec/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 | describe('app', function () { 20 | describe('initialize', function () { 21 | it('should bind deviceready', function () { 22 | runs(function () { 23 | spyOn(app, 'onDeviceReady'); 24 | app.initialize(); 25 | helper.trigger(window.document, 'deviceready'); 26 | }); 27 | 28 | waitsFor(function () { 29 | return (app.onDeviceReady.calls.length > 0); 30 | }, 'onDeviceReady should be called once', 500); 31 | 32 | runs(function () { 33 | expect(app.onDeviceReady).toHaveBeenCalled(); 34 | }); 35 | }); 36 | }); 37 | 38 | describe('onDeviceReady', function () { 39 | it('should report that it fired', function () { 40 | spyOn(app, 'receivedEvent'); 41 | app.onDeviceReady(); 42 | expect(app.receivedEvent).toHaveBeenCalledWith('deviceready'); 43 | }); 44 | }); 45 | 46 | describe('receivedEvent', function () { 47 | beforeEach(function () { 48 | var el = document.getElementById('stage'); 49 | el.innerHTML = ['
', 50 | '

Listening

', 51 | '

Received

', 52 | '
'].join('\n'); 53 | }); 54 | 55 | it('should hide the listening element', function () { 56 | app.receivedEvent('deviceready'); 57 | var displayStyle = helper.getComputedStyle('#deviceready .listening', 'display'); 58 | expect(displayStyle).toEqual('none'); 59 | }); 60 | 61 | it('should show the received element', function () { 62 | app.receivedEvent('deviceready'); 63 | var displayStyle = helper.getComputedStyle('#deviceready .received', 'display'); 64 | expect(displayStyle).toEqual('block'); 65 | }); 66 | }); 67 | }); 68 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/lib/copy-www-build-step.js: -------------------------------------------------------------------------------- 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 | // This script copies the www directory into the Xcode project. 23 | 24 | // This script should not be called directly. 25 | // It is called as a build step from Xcode. 26 | 27 | const BUILT_PRODUCTS_DIR = process.env.BUILT_PRODUCTS_DIR; 28 | const FULL_PRODUCT_NAME = process.env.FULL_PRODUCT_NAME; 29 | const COPY_HIDDEN = process.env.COPY_HIDDEN; 30 | const PROJECT_FILE_PATH = process.env.PROJECT_FILE_PATH; 31 | 32 | const path = require('path'); 33 | const fs = require('fs'); 34 | const shell = require('shelljs'); 35 | const srcDir = 'www'; 36 | const dstDir = path.join(BUILT_PRODUCTS_DIR, FULL_PRODUCT_NAME, 'Contents', 'Resources'); 37 | const dstWwwDir = path.join(dstDir, 'www'); 38 | 39 | if (!BUILT_PRODUCTS_DIR) { 40 | console.error('The script is meant to be run as an Xcode build step and relies on env variables set by Xcode.'); 41 | process.exit(1); 42 | } 43 | 44 | try { 45 | fs.statSync(srcDir); 46 | } catch (e) { 47 | console.error('Path does not exist: ' + srcDir); 48 | process.exit(2); 49 | } 50 | 51 | // Code signing files must be removed or else there are 52 | // resource signing errors. 53 | shell.rm('-rf', dstWwwDir); 54 | shell.rm('-rf', path.join(dstDir, '_CodeSignature')); 55 | shell.rm('-rf', path.join(dstDir, 'PkgInfo')); 56 | shell.rm('-rf', path.join(dstDir, 'embedded.mobileprovision')); 57 | 58 | // Copy www dir recursively 59 | let code; 60 | if (COPY_HIDDEN) { 61 | code = shell.exec('rsync -Lra "' + srcDir + '" "' + dstDir + '"').code; 62 | } else { 63 | code = shell.exec('rsync -Lra --exclude="- .*" "' + srcDir + '" "' + dstDir + '"').code; 64 | } 65 | 66 | if (code !== 0) { 67 | console.error('Error occurred on copying www. Code: ' + code); 68 | process.exit(3); 69 | } 70 | 71 | // Copy the config.xml file. 72 | shell.cp('-f', path.join(path.dirname(PROJECT_FILE_PATH), path.basename(PROJECT_FILE_PATH, '.xcodeproj'), 'config.xml'), 73 | dstDir); 74 | -------------------------------------------------------------------------------- /bin/templates/scripts/cordova/lib/ConsoleLogger.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 | let loggerInstance; 21 | const util = require('util'); 22 | const EventEmitter = require('events').EventEmitter; 23 | const CordovaError = require('cordova-common').CordovaError; 24 | 25 | /** 26 | * @class ConsoleLogger 27 | * @extends EventEmitter 28 | * 29 | * Implementing basic logging for platform. Inherits regular NodeJS 30 | * EventEmitter. All events, emitted on this class instance are immediately 31 | * logged to console. 32 | * 33 | * Also attaches handler to process' uncaught exceptions, so these exceptions 34 | * logged to console similar to regular error events. 35 | */ 36 | function ConsoleLogger () { 37 | EventEmitter.call(this); 38 | 39 | const isVerbose = process.argv.indexOf('-d') >= 0 || process.argv.indexOf('--verbose') >= 0; 40 | // For CordovaError print only the message without stack trace unless we 41 | // are in a verbose mode. 42 | process.on('uncaughtException', function (err) { 43 | if ((err instanceof CordovaError) && isVerbose) { 44 | console.error(err.stack); 45 | } else { 46 | console.error(err.message); 47 | } 48 | process.exit(1); 49 | }); 50 | 51 | this.on('results', console.log); 52 | this.on('verbose', function () { 53 | if (isVerbose) { console.log.apply(console, arguments); } 54 | }); 55 | this.on('info', console.log); 56 | this.on('log', console.log); 57 | this.on('warn', console.warn); 58 | } 59 | util.inherits(ConsoleLogger, EventEmitter); 60 | 61 | /** 62 | * Returns already instantiated/newly created instance of ConsoleLogger class. 63 | * This method should be used instead of creating ConsoleLogger directly, 64 | * otherwise we'll get multiple handlers attached to process' 65 | * uncaughtException 66 | * 67 | * @return {ConsoleLogger} New or already created instance of ConsoleLogger 68 | */ 69 | ConsoleLogger.get = function () { 70 | loggerInstance = loggerInstance || new ConsoleLogger(); 71 | return loggerInstance; 72 | }; 73 | 74 | module.exports = ConsoleLogger; 75 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 
 44 | 45 | 46 | __PROJECT_NAME__ 47 | __CDV_ORGANIZATION_NAME__ 48 | 49 | A sample Apache Cordova application that responds to the deviceready event. 50 | 51 | 52 | Apache Cordova Team 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /tests/cdv-test-project/plugins/cordova-plugin-whitelist/RELEASENOTES.md: -------------------------------------------------------------------------------- 1 | 21 | # Release Notes 22 | 23 | ### 1.2.1 (Jan 15, 2016) 24 | * CB-10194 info tag prints for ios when not applicable 25 | 26 | ### 1.2.0 (Nov 18, 2015) 27 | * removed **iOS** engine check from `plugin.xml` 28 | * [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest 29 | * [CB-9972](https://issues.apache.org/jira/browse/CB-9972) - Remove **iOS** whitelist 30 | * Updated the text, it should read 4.0.x and greater, since this plugin will be required for `cordova-android 5.0` 31 | * Fixing contribute link. 32 | * Updated `plugin.xml ` tag to remove warning about not needing this plugin if you are using the **iOS 9 SDK** 33 | * [CB-9738](https://issues.apache.org/jira/browse/CB-9738) - Disable whitelist use when runtime environment is **iOS 9** 34 | * [CB-9740](https://issues.apache.org/jira/browse/CB-9740) - Add `` tag describing whitelist plugin not needed on `cordova-ios` and cordova-android 3.x` 35 | * [CB-9568](https://issues.apache.org/jira/browse/CB-9568) - Update whitelist plugin to allow all network access by default 36 | * [CB-9337](https://issues.apache.org/jira/browse/CB-9337) - enable use of `` tags for native code network requests 37 | 38 | ### 1.1.0 (Jun 17, 2015) 39 | * [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-whitelist documentation translation: cordova-plugin-whitelist 40 | * fix npm md issue 41 | * Usage of CDVURLRequestFilter protocol. 42 | * [CB-9089](https://issues.apache.org/jira/browse/CB-9089) - iOS whitelist plugin does not compile 43 | * [CB-9090](https://issues.apache.org/jira/browse/CB-9090) - Enable whitelist plugin for cordova-ios 4.0.0 44 | * Fixed error in Content-Security-Policy example 45 | 46 | ### 1.0.0 (Mar 25, 2015) 47 | * [CB-8739](https://issues.apache.org/jira/browse/CB-8739) added missing license headers 48 | * Add @Override to CustomConfigXmlParser methods 49 | * Change ID to cordova-plugin-whitelist rather than reverse-DNS-style 50 | * Tweak CSP examples in README 51 | * [CB-8660](https://issues.apache.org/jira/browse/CB-8660) remove extra commas from package.json 52 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/www/tests.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 | 21 | function echoTests() { 22 | var payloads = { 23 | 'string': "Hello, World", 24 | 'empty-string': "", 25 | 'one': 1, 26 | 'zero': 0, 27 | 'true': true, 28 | 'false': false, 29 | 'double': 3.141, 30 | 'array': ['a','b','c'], 31 | 'nested-array': ['a','b','c', [1,2,3]], 32 | 'object': {a:'a', b:'b'}, 33 | 'nested-object': {a:'a', b:'b', c:{d:'d'}} 34 | }; 35 | 36 | var tests = []; 37 | var numCompleted = 0; 38 | var numFailed = 0; 39 | function completed() { 40 | numCompleted++; 41 | if (numCompleted === tests.length) { 42 | window.jsTests.echo.result = numFailed === 0; 43 | } 44 | } 45 | 46 | var Test = function(name, payload) { 47 | this.payload = payload; 48 | this.name = name; 49 | this.result = ''; 50 | }; 51 | var _success = function(ret) { 52 | var result = JSON.stringify(ret); 53 | var expected = JSON.stringify(this.payload); 54 | if (result === expected) { 55 | console.log('success of ' + this.name); 56 | this.result = true; 57 | } else { 58 | console.log(this.name + ' failed. Expected ' + expected +' but got ' + result); 59 | this.result = false; 60 | numFailed++; 61 | } 62 | completed(); 63 | }; 64 | 65 | var _failure = function(e) { 66 | console.log('failure of ' + this.name); 67 | this.result = false; 68 | numFailed++; 69 | completed(); 70 | }; 71 | 72 | Test.prototype.run = function() { 73 | plugins.Test.echo(_success.bind(this), _failure.bind(this), this.payload); 74 | }; 75 | 76 | 77 | for (var name in payloads) { 78 | var test = new Test(name, payloads[name]); 79 | tests.push(test); 80 | test.run(); 81 | } 82 | } 83 | 84 | function runTests() { 85 | 86 | console.log('running tests...'); 87 | echoTests(); 88 | return 'echo'; 89 | 90 | } 91 | 92 | window.jsTests = { 93 | 94 | echo: { 95 | result: '' 96 | } 97 | }; 98 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Utils/NSScreen+Utils.m: -------------------------------------------------------------------------------- 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 | #import "NSScreen+Utils.h" 21 | #import 22 | 23 | NSString* screenNameForDisplay(CGDirectDisplayID displayID) { 24 | NSString *screenName = nil; 25 | 26 | NSDictionary *deviceInfo = (__bridge NSDictionary *) IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName); 27 | NSDictionary *localizedNames = deviceInfo[[NSString stringWithUTF8String:kDisplayProductName]]; 28 | 29 | if ([localizedNames count] > 0) { 30 | screenName = localizedNames[[localizedNames allKeys][0]]; 31 | } 32 | 33 | return screenName; 34 | } 35 | 36 | @implementation NSScreen (Utils) 37 | 38 | + (NSRect) fullScreenRect { 39 | CGFloat x0 = 0.0f; 40 | CGFloat y0 = 0.0f; 41 | CGFloat x1 = 0.0f; 42 | CGFloat y1 = 0.0f; 43 | 44 | NSArray* screens = [NSScreen screens]; 45 | NSLog(@"Detected %lu display%s:", screens.count, screens.count > 1 ? "s" : ""); 46 | for (NSScreen* screen in [NSScreen screens]) { 47 | NSNumber* screenID = [screen.deviceDescription objectForKey:@"NSScreenNumber"]; 48 | CGDirectDisplayID aID = [screenID unsignedIntValue]; 49 | NSLog(@"- %@ at: %.lf,%.lf size: %.lf x %.lf", screenNameForDisplay(aID), 50 | screen.frame.origin.x, screen.frame.origin.y, 51 | screen.frame.size.width, screen.frame.size.height); 52 | 53 | if (NSMinX(screen.frame) < x0) { 54 | x0 = NSMinX(screen.frame); 55 | }; 56 | if (NSMinY(screen.frame) < y0) { 57 | y0 = NSMinY(screen.frame); 58 | }; 59 | if (NSMaxX(screen.frame) > x1) { 60 | x1 = NSMaxX(screen.frame); 61 | }; 62 | if (NSMaxY(screen.frame) > y1) { 63 | y1 = NSMaxY(screen.frame); 64 | }; 65 | } 66 | if ([NSScreen screensHaveSeparateSpaces] && screens.count > 1) { 67 | NSLog(@"Fullscreen only possible to cover main screen. Disable 'Displays have separate Spaces' in 'System Preferences -> Mission Control' to span all displays."); 68 | return [NSScreen mainScreen].frame; 69 | } 70 | 71 | return NSMakeRect(x0, y0, x1-x0, y1-y0); 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CordovaLibApp/MainViewController.m: -------------------------------------------------------------------------------- 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 | #import "MainViewController.h" 21 | 22 | @interface MainViewController () 23 | 24 | @end 25 | 26 | @implementation MainViewController 27 | 28 | - (id) initWithWindow:(NSWindow*) window { 29 | self = [super initWithWindow:window]; 30 | if (self) { 31 | // Initialization code here. 32 | } 33 | 34 | return self; 35 | } 36 | 37 | - (id) initWithWindowNibName:(NSString*) nibNameOrNil { 38 | self = [super initWithWindowNibName:nibNameOrNil]; 39 | if (self) { 40 | // Uncomment to override the CDVCommandDelegateImpl used 41 | // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self]; 42 | // Uncomment to override the CDVCommandQueue used 43 | // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self]; 44 | } 45 | return self; 46 | } 47 | 48 | 49 | - (id) init { 50 | self = [super init]; 51 | if (self) { 52 | // Uncomment to override the CDVCommandDelegateImpl used 53 | // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self]; 54 | // Uncomment to override the CDVCommandQueue used 55 | // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self]; 56 | } 57 | return self; 58 | } 59 | 60 | 61 | - (void) awakeFromNib { 62 | [super awakeFromNib]; 63 | 64 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 65 | } 66 | 67 | @end 68 | 69 | @implementation MainCommandDelegate 70 | 71 | /* To override the methods, uncomment the line in the init function(s) 72 | in MainViewController.m 73 | */ 74 | 75 | #pragma mark CDVCommandDelegate implementation 76 | 77 | - (id) getCommandInstance:(NSString*) className { 78 | return [super getCommandInstance:className]; 79 | } 80 | 81 | - (NSString*) pathForResource:(NSString*) resourcepath; { 82 | return [super pathForResource:resourcepath]; 83 | } 84 | 85 | @end 86 | 87 | @implementation MainCommandQueue 88 | 89 | /* To override, uncomment the line in the init function(s) 90 | in MainViewController.m 91 | */ 92 | - (BOOL) execute:(CDVInvokedUrlCommand*) command { 93 | return [super execute:command]; 94 | } 95 | 96 | @end 97 | 98 | -------------------------------------------------------------------------------- /bin/templates/project/__PROJECT_NAME__/Classes/MainViewController.m: -------------------------------------------------------------------------------- 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 | #import "MainViewController.h" 21 | 22 | @interface MainViewController () 23 | 24 | @end 25 | 26 | @implementation MainViewController 27 | 28 | - (id)initWithWindow:(NSWindow *)window 29 | { 30 | self = [super initWithWindow:window]; 31 | if (self) { 32 | // Initialization code here. 33 | } 34 | 35 | return self; 36 | } 37 | 38 | - (id)initWithWindowNibName:(NSString*)nibNameOrNil 39 | { 40 | self = [super initWithWindowNibName:nibNameOrNil]; 41 | if (self) { 42 | // Uncomment to override the CDVCommandDelegateImpl used 43 | // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self]; 44 | // Uncomment to override the CDVCommandQueue used 45 | // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self]; 46 | } 47 | return self; 48 | } 49 | 50 | 51 | - (id)init 52 | { 53 | self = [super init]; 54 | if (self) { 55 | // Uncomment to override the CDVCommandDelegateImpl used 56 | // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self]; 57 | // Uncomment to override the CDVCommandQueue used 58 | // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self]; 59 | } 60 | return self; 61 | } 62 | 63 | 64 | - (void)awakeFromNib 65 | { 66 | [super awakeFromNib]; 67 | 68 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 69 | } 70 | 71 | @end 72 | 73 | @implementation MainCommandDelegate 74 | 75 | /* To override the methods, uncomment the line in the init function(s) 76 | in MainViewController.m 77 | */ 78 | 79 | #pragma mark CDVCommandDelegate implementation 80 | 81 | - (id)getCommandInstance:(NSString*)className 82 | { 83 | return [super getCommandInstance:className]; 84 | } 85 | 86 | - (NSString*)pathForResource:(NSString*)resourcepath; 87 | { 88 | return [super pathForResource:resourcepath]; 89 | } 90 | 91 | @end 92 | 93 | @implementation MainCommandQueue 94 | 95 | /* To override, uncomment the line in the init function(s) 96 | in MainViewController.m 97 | */ 98 | - (BOOL)execute:(CDVInvokedUrlCommand*)command 99 | { 100 | return [super execute:command]; 101 | } 102 | 103 | @end 104 | 105 | -------------------------------------------------------------------------------- /tests/spec/component/platform.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 | 20 | const shell = require('shelljs'); 21 | const path = require('path'); 22 | const util = require('util'); 23 | const fs = require('fs'); 24 | 25 | const test_projectPath = path.join(__dirname, '../../', 'cdv-test-project'); 26 | const test_platformPath = path.join(test_projectPath, 'platforms', 'osx'); 27 | 28 | function initProject () { 29 | // remove existing folder 30 | const pPath = path.join(test_projectPath, 'platforms'); 31 | shell.rm('-rf', pPath); 32 | } 33 | 34 | describe('platform add', () => { 35 | beforeEach(() => { 36 | initProject(); 37 | 38 | shell.cd(test_projectPath); 39 | 40 | const command = 'cordova platform add ../../'; 41 | console.log('executing "%s" in "%s"', command, shell.pwd()); 42 | 43 | const return_code = shell.exec(command, { silent: false }).code; 44 | expect(return_code).toBe(0); 45 | }); 46 | 47 | it('should have a config.xml', () => { 48 | const configXmlPath = path.join(test_platformPath, 'HelloCordova', 'config.xml'); 49 | expect(fs.existsSync(configXmlPath)).toBe(true); 50 | }); 51 | 52 | it('should have the correct icons', () => { 53 | const platformIcons = [ 54 | { name: 'icon-16x16.png', width: 16, height: 16 }, 55 | { name: 'icon-32x32.png', width: 32, height: 32 }, 56 | { name: 'icon-64x64.png', width: 64, height: 64 }, 57 | { name: 'icon-128x128.png', width: 128, height: 128 }, 58 | { name: 'icon-256x256.png', width: 256, height: 256 }, 59 | { name: 'icon-512x512.png', width: 512, height: 512 }, 60 | { name: 'icon-1024x1024.png', width: 1024, height: 1024 } 61 | ]; 62 | 63 | const appIconsPath = path.join(test_platformPath, 'HelloCordova', 'Images.xcassets', 'AppIcon.appiconset'); 64 | const srcIcon = path.join(test_projectPath, 'res', 'test-64x64.png'); 65 | 66 | platformIcons.forEach(function (iconDef) { 67 | const iconPath = path.join(appIconsPath, iconDef.name); 68 | expect(fs.existsSync(iconPath)).toBe(true); 69 | 70 | // check if the icons are the same as the one specified in the config.xml 71 | const cmd = util.format('cmp "%s" "%s"', srcIcon, iconPath); 72 | const return_code = shell.exec(cmd, { silent: false }).code; 73 | 74 | expect(return_code).toBe(0); 75 | }); 76 | }); 77 | }); 78 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVPluginResult.h: -------------------------------------------------------------------------------- 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 | #import 21 | 22 | #pragma clang diagnostic push 23 | #pragma ide diagnostic ignored "OCUnusedPropertyInspection" 24 | #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" 25 | #pragma ide diagnostic ignored "OCUnusedMethodInspection" 26 | typedef enum { 27 | CDVCommandStatus_NO_RESULT = 0, 28 | CDVCommandStatus_OK, 29 | CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION, 30 | CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION, 31 | CDVCommandStatus_INSTANTIATION_EXCEPTION, 32 | CDVCommandStatus_MALFORMED_URL_EXCEPTION, 33 | CDVCommandStatus_IO_EXCEPTION, 34 | CDVCommandStatus_INVALID_ACTION, 35 | CDVCommandStatus_JSON_EXCEPTION, 36 | CDVCommandStatus_ERROR 37 | } CDVCommandStatus; 38 | 39 | @interface CDVPluginResult : NSObject {} 40 | 41 | @property (nonatomic, strong, readonly) NSNumber* status; 42 | @property (nonatomic, strong, readonly) id message; 43 | @property (nonatomic, strong) NSNumber* keepCallback; 44 | 45 | /** 46 | * This property can be used to scope the lifetime of another object. For example, 47 | * Use it to store the associated NSData when `message` is created using initWithBytesNoCopy. 48 | */ 49 | @property (nonatomic, strong) id associatedObject; 50 | 51 | - (CDVPluginResult*)init; 52 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal; 53 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage; 54 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage; 55 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage; 56 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage; 57 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage; 58 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage; 59 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage; 60 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages; 61 | + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode; 62 | 63 | + (void)setVerbose:(BOOL)verbose; 64 | + (BOOL)isVerbose; 65 | 66 | - (void)setKeepCallbackAsBool:(BOOL)bKeepCallback; 67 | 68 | - (NSString*)argumentsAsJSON; 69 | 70 | @end 71 | 72 | #pragma clang diagnostic pop 73 | -------------------------------------------------------------------------------- /tests/CordovaLibTests/CDVWebViewTest.m: -------------------------------------------------------------------------------- 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 | #import "CDVWebViewTest.h" 21 | 22 | #import "AppDelegate.h" 23 | 24 | @interface CDVWebViewTest () 25 | // Runs the run loop until the webview has finished loading. 26 | - (void) waitForPageLoad; 27 | @end 28 | 29 | @implementation CDVWebViewTest 30 | 31 | @synthesize startPage; 32 | 33 | - (void) setUp { 34 | [super setUp]; 35 | } 36 | 37 | - (void) tearDown { 38 | // Enforce that the view controller is released between tests to ensure 39 | // tests don't affect each other. 40 | // [self.appDelegate destroyViewController]; 41 | [super tearDown]; 42 | } 43 | 44 | - (AppDelegate*) appDelegate { 45 | return [[NSApplication sharedApplication] delegate]; 46 | } 47 | 48 | - (CDVViewController*) viewController { 49 | // Lazily create the view controller so that tests that do not require it 50 | // are not slowed down by it. 51 | if (self.appDelegate.viewController == nil) { 52 | 53 | [self.appDelegate createViewController:self.startPage]; 54 | 55 | // Things break if tearDown is called before the page has finished 56 | // loading (a JS error happens and an alert pops up), so enforce a wait here 57 | [self waitForPageLoad]; 58 | } 59 | 60 | XCTAssertNotNil(self.appDelegate.viewController, @"createViewController failed"); 61 | return self.appDelegate.viewController; 62 | } 63 | 64 | - (WebView*) webView { 65 | return self.viewController.webView; 66 | } 67 | 68 | - (id) pluginInstance:(NSString*) pluginName { 69 | id ret = [self.viewController getCommandInstance:pluginName]; 70 | 71 | XCTAssertNotNil(ret, @"Missing plugin %@", pluginName); 72 | return ret; 73 | } 74 | 75 | - (void) reloadWebView { 76 | [self.appDelegate destroyViewController]; 77 | [self viewController]; 78 | } 79 | 80 | - (void) waitForConditionName:(NSString*) conditionName block:(BOOL (^)()) block { 81 | // Number of seconds to wait for a condition to become true before giving up. 82 | const NSTimeInterval kConditionTimeout = 5.0; 83 | // Useful when debugging so that it does not timeout after one loop. 84 | const int kMinIterations = 4; 85 | 86 | NSDate* startTime = [NSDate date]; 87 | int i = 0; 88 | 89 | while (!block()) { 90 | [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 91 | NSTimeInterval elapsed = -[startTime timeIntervalSinceNow]; 92 | if (i > kMinIterations && elapsed > kConditionTimeout) { 93 | XCTFail(@"Timed out waiting for condition %@", conditionName); 94 | break; 95 | } 96 | ++i; 97 | } 98 | } 99 | 100 | - (void) waitForPageLoad { 101 | [self waitForConditionName:@"PageLoad" block:^{ 102 | return [@"true" isEqualToString:[self evalJs:@"window.pageIsLoaded"]]; 103 | }]; 104 | } 105 | 106 | - (NSString*) evalJs:(NSString*) code { 107 | return [self.webView stringByEvaluatingJavaScriptFromString:code]; 108 | } 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /CordovaLib/CordovaLib/Classes/Commands/CDVInvokedUrlCommand.m: -------------------------------------------------------------------------------- 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 | #import 21 | #import "CDVInvokedUrlCommand.h" 22 | 23 | @implementation CDVInvokedUrlCommand 24 | 25 | @synthesize arguments = _arguments; 26 | @synthesize callbackId = _callbackId; 27 | @synthesize cmdClassName = _cmdClassName; 28 | @synthesize methodName = _methodName; 29 | 30 | + (CDVInvokedUrlCommand*) commandFromJson:(NSArray*) jsonEntry { 31 | return [[CDVInvokedUrlCommand alloc] initFromJson:jsonEntry]; 32 | } 33 | 34 | - (id) initFromJson:(NSArray*) jsonEntry { 35 | id tmp = jsonEntry[0]; 36 | NSString* callbackId = tmp == [NSNull null] ? nil : tmp; 37 | NSString* className = jsonEntry[1]; 38 | NSString* methodName = jsonEntry[2]; 39 | NSMutableArray* arguments = jsonEntry[3]; 40 | 41 | return [self initWithArguments:arguments 42 | callbackId:callbackId 43 | className:className 44 | methodName:methodName]; 45 | } 46 | 47 | - (id) initWithArguments:(NSArray*) arguments 48 | callbackId:(NSString*) callbackId 49 | className:(NSString*) className 50 | methodName:(NSString*) methodName { 51 | self = [super init]; 52 | if (self != nil) { 53 | _arguments = arguments; 54 | _callbackId = callbackId; 55 | _cmdClassName = className; 56 | _methodName = methodName; 57 | } 58 | [self massageArguments]; 59 | return self; 60 | } 61 | 62 | - (void) massageArguments { 63 | NSMutableArray* newArgs = nil; 64 | 65 | for (NSUInteger i = 0, count = [_arguments count]; i < count; ++i) { 66 | id arg = _arguments[i]; 67 | if (![arg isKindOfClass:[NSDictionary class]]) { 68 | continue; 69 | } 70 | NSDictionary* dict = arg; 71 | NSString* type = dict[@"CDVType"]; 72 | if (!type || ![type isEqualToString:@"ArrayBuffer"]) { 73 | continue; 74 | } 75 | NSString* data = dict[@"data"]; 76 | if (!data) { 77 | continue; 78 | } 79 | if (newArgs == nil) { 80 | newArgs = [NSMutableArray arrayWithArray:_arguments]; 81 | _arguments = newArgs; 82 | } 83 | newArgs[i] = [[NSData alloc] initWithBase64EncodedString:data options:0]; 84 | } 85 | } 86 | 87 | - (id) argumentAtIndex:(NSUInteger) index { 88 | return [self argumentAtIndex:index withDefault:nil]; 89 | } 90 | 91 | - (id) argumentAtIndex:(NSUInteger) index withDefault:(id) defaultValue { 92 | return [self argumentAtIndex:index withDefault:defaultValue andClass:nil]; 93 | } 94 | 95 | - (id) argumentAtIndex:(NSUInteger) index withDefault:(id) defaultValue andClass:(Class) aClass { 96 | if (index >= [_arguments count]) { 97 | return defaultValue; 98 | } 99 | id ret = _arguments[index]; 100 | if (ret == [NSNull null] || ret == [WebUndefined undefined]) { 101 | ret = defaultValue; 102 | } 103 | if ((aClass != nil) && ![ret isKindOfClass:aClass]) { 104 | ret = defaultValue; 105 | } 106 | return ret; 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /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 | /** 23 | * Creates a gap bridge used to notify the native code about commands. 24 | 25 | * @private 26 | */ 27 | const cordova = require('cordova'); 28 | const utils = require('cordova/utils'); 29 | const base64 = require('cordova/base64'); 30 | 31 | function massageMessageNativeToJs (message) { 32 | if (message.CDVType === 'ArrayBuffer') { 33 | const stringToArrayBuffer = function (str) { 34 | const ret = new Uint8Array(str.length); 35 | for (let i = 0; i < str.length; i++) { 36 | ret[i] = str.charCodeAt(i); 37 | } 38 | return ret.buffer; 39 | }; 40 | const base64ToArrayBuffer = function (b64) { 41 | return stringToArrayBuffer(atob(b64)); 42 | }; 43 | message = base64ToArrayBuffer(message.data); 44 | } 45 | return message; 46 | } 47 | 48 | function convertMessageToArgsNativeToJs (message) { 49 | const args = []; 50 | if (!message || !Object.prototype.hasOwnProperty.call(message, 'CDVType')) { 51 | args.push(message); 52 | } else if (message.CDVType === 'MultiPart') { 53 | message.messages.forEach(function (e) { 54 | args.push(massageMessageNativeToJs(e)); 55 | }); 56 | } else { 57 | args.push(massageMessageNativeToJs(message)); 58 | } 59 | return args; 60 | } 61 | 62 | function massageArgsJsToNative (args) { 63 | if (!args || utils.typeName(args) !== 'Array') { 64 | return args; 65 | } 66 | const ret = []; 67 | args.forEach(function (arg, i) { 68 | if (utils.typeName(arg) === 'ArrayBuffer') { 69 | ret.push({ 70 | CDVType: 'ArrayBuffer', 71 | data: base64.fromArrayBuffer(arg) 72 | }); 73 | } else { 74 | ret.push(arg); 75 | } 76 | }); 77 | return ret; 78 | } 79 | 80 | function OSXExec () { 81 | let callbackId = 'INVALID'; 82 | 83 | const successCallback = arguments[0]; 84 | const failCallback = arguments[1]; 85 | const service = arguments[2]; 86 | const action = arguments[3]; 87 | let actionArgs = arguments[4]; 88 | 89 | // Register the callbacks and add the callbackId to the positional 90 | // arguments if given. 91 | if (successCallback || failCallback) { 92 | callbackId = service + cordova.callbackId++; 93 | cordova.callbacks[callbackId] = 94 | { success: successCallback, fail: failCallback }; 95 | } 96 | 97 | actionArgs = massageArgsJsToNative(actionArgs); 98 | 99 | if (window.cordovabridge && window.cordovabridge.exec) { 100 | window.cordovabridge.exec(callbackId, service, action, actionArgs); 101 | } else { 102 | alert('window.cordovabridge binding is missing.'); 103 | } 104 | } 105 | 106 | OSXExec.nativeCallback = function (callbackId, status, message, keepCallback) { 107 | const success = status === 0 || status === 1; 108 | const args = convertMessageToArgsNativeToJs(message); 109 | cordova.callbackFromNative(callbackId, success, status, args, keepCallback); 110 | }; 111 | 112 | module.exports = OSXExec; 113 | --------------------------------------------------------------------------------