Merge pull request #26504 from NextFaze/feature/wikitude-cordova-plugin

Add wikitude-cordova-plugin types
This commit is contained in:
Nathan Shively-Sanders
2018-06-20 10:52:44 -07:00
committed by GitHub
4 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
const startupConfiguration: any = { camera_position: 'back' };
// Some code samples from the wikitude ionic starter
WikitudePlugin.loadARchitectWorld(
success => {
console.log('ARchitect World loaded successfully.');
},
fail => {
console.log('Failed to load ARchitect World!');
},
'www/assets/07_3dModels_6_3dModelAtGeoLocation/index.html',
['geo'],
<JSON> startupConfiguration
);
WikitudePlugin.setOnUrlInvokeCallback(url => {
if (url.indexOf('captureScreen') > -1) {
WikitudePlugin.captureScreen(
absoluteFilePath => {
WikitudePlugin.callJavaScript(
`World.testFunction('Screenshot saved at: ${absoluteFilePath}');`
);
},
errorMessage => {
console.log(errorMessage);
},
true,
null
);
} else {
alert(url + 'not handled');
}
});

View File

@@ -0,0 +1,82 @@
// Type definitions for com.wikitude.phonegap.wikitudeplugin 7.2
// Project: https://github.com/Wikitude/wikitude-cordova-plugin
// Definitions by: zbarbuto <https://github.com/zbarbuto>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// The following types are taken directly (unmodified) from the wikitude-ionic-3-starter-app
// https://github.com/pbreuss/wikitude-ionic-3-starter-app
// Latest commit at time of writing was 647cd546f6d1805765c4cee725566e246ca6259d
/**
* Wrapper for the Wikitude SDK Phonegap Plugin - to use with IONIC2
* (c) 2016 Schneeweis.Technology
*/
interface WikitudePlugin {
isDeviceSupported(
successCallback: (success: string) => void,
errorCallback: (message: string) => void,
requiredFeatures: [string]
): void;
loadARchitectWorld(
successCallback: (success: string) => void,
errorCallback: (message: string) => void,
architectWorldPath: string,
requiredFeatures: [string],
startupConfiguration: JSON | object
): void;
close(): void;
hide(): void;
show(): void;
// test type ok?
callJavaScript(js: any): void;
setOnUrlInvokeCallback(onUrlInvokeCallback: (success: string) => void): void;
setLocation(latitude: any, longitude: any, altitude: any, accuracy: any): void;
captureScreen(
successCallback: (success: string) => void,
errorCallback: (message: string) => void,
includeWebView: boolean,
imagePathInBundleOrNullForPhotoLibrary: string | null
): void;
setErrorHandler(errorHandler: (message: string) => void): void;
setDeviceSensorsNeedCalibrationHandler(
startCalibrationHandler: (message: string) => void
): void;
setDeviceSensorsFinishedCalibrationHandler(
finishedCalibrationHandler: (message: string) => void
): void;
setBackButtonCallback(onBackButtonCallback: (message: string) => void): void;
/* Lifecycle updates */
onResume(): void;
onBackButton(): void;
onPause(): void;
onWikitudeOK(): void;
onWikitudeError(): void;
_sdkKey: string;
FeatureGeo: string;
Feature2DTracking: string;
CameraPositionUndefined: number;
CameraPositionFront: number;
CameraPositionBack: number;
CameraFocusRangeNone: number;
CameraFocusRangeNear: number;
CameraFocusRangeFar: number;
}
declare var WikitudePlugin: WikitudePlugin;

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"com.wikitude.phonegap.wikitudeplugin-tests.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}