Skip to content

Commit

Permalink
Add version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HasanMhdAmin committed Sep 8, 2020
1 parent 08f9267 commit fe89865
Show file tree
Hide file tree
Showing 162 changed files with 21,744 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## [1.0.0]
* [iOS] Initial release of the Cordova plugin for VideoEditor SDK.
* [Android] Initial release of the Cordova plugin for VideoEditor SDK.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 img.ly

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
# vesdk-cordova
<p align="center">
<a href="https://www.photoeditorsdk.com/?utm_campaign=Projects&utm_source=Github&utm_medium=VESDK&utm_content=Cordova"><img src="https://video.photoeditorsdk.com/assets/img/vesdk-logo-s.svg" alt="VideoEditor SDK Logo"/></a>
</p>
<p align="center">
<a href="https://npmjs.org/package/cordova-plugin-videoeditorsdk">
<img src="https://img.shields.io/npm/v/cordova-plugin-videoeditorsdk.svg" alt="NPM version">
</a>
<img src="https://img.shields.io/badge/platforms-android%20|%20ios-lightgrey.svg" alt="Platform support">
<a href="http://twitter.com/VideoEditorSDK">
<img src="https://img.shields.io/badge/twitter-@VideoEditorSDK-blue.svg?style=flat" alt="Twitter">
</a>
</p>

# Cordova & Ionic plugin for VideoEditor SDK
## Getting started

Add VideoEditor SDK plugin to your project as follows:

```sh
cordova plugin add cordova-plugin-videoeditorsdk
```

### Android

Because VideoEditor SDK for Android is quite large, there is a high chance that you will need to enable [Multidex](https://developer.android.com/studio/build/multidex) for your project as follows:

```sh
cordova plugin add cordova-plugin-enable-multidex
```

### Usage

Each platform requires a separate license file. Unlock VideoEditor SDK with a single line of code for both platforms via platform-specific file extensions.

Rename your license files:
- Android license: `ANY_NAME.android`
- iOS license: `ANY_NAME.ios`

Pass the file path without the extension to the `unlockWithLicense` function to unlock both iOS and Android:
```js
VESDK.unlockWithLicense('www/assets/ANY_NAME');
```

Open the editor with a video:
```js
VESDK.openEditor(
successCallback,
failureCallback,
VESDK.loadResource('www/assets/video.mp4')
);
```

Please see the [code documentation](./types/index.d.ts) for more details and additional [customization and configuration options](./types/configuration.ts).

#### Notes for Ionic framework

- Add this line above your class to be able to use `VESDK`.
```js
declare var VESDK;
```
- Ionic will generate a `www` folder that will contain your compiled code and your assets. In order to pass resources to VideoEditor SDK you need to use this folder.

## Example

Please see our [example project](https://github.com/imgly/vesdk-cordova-demo) which demonstrates how to use the Cordova plugin for VideoEditor SDK.

## License Terms

Make sure you have a [commercial license](https://account.photoeditorsdk.com/pricing?product=vesdk&?utm_campaign=Projects&utm_source=Github&utm_medium=VESDK&utm_content=Cordova) for VideoEditor SDK before releasing your app.
A commercial license is required for any app or service that has any form of monetization: This includes free apps with in-app purchases or ad supported applications. Please contact us if you want to purchase the commercial license.

## Support and License

Use our [service desk](http://support.videoeditorsdk.com) for bug reports or support requests. To request a commercial license, please use the [license request form](https://account.photoeditorsdk.com/pricing?product=vesdk&?utm_campaign=Projects&utm_source=Github&utm_medium=VESDK&utm_content=Cordova) on our website.
66 changes: 66 additions & 0 deletions hooks/copy-imglyConfig-gradle-hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const fs = require("fs");
const path = require("path");
const async = require("async");

module.exports = (context) => {
"use strict";

return new Promise((resolve, reject) => {
const BLOCK_START = `// imglyConfig ADDED BY IMGLY - BLOCK START`;
const BLOCK_END = `// imglyConfig ADDED BY IMGLY - BLOCK END`;
const imglyConfigHeader = `
apply plugin: 'ly.img.android.sdk'
apply plugin: 'kotlin-android'
`;

// The content of the gradle file in the cordova app root
const projectRoot = path.join(context.opts.projectRoot);
var gradleConfigFile = path.join(projectRoot, "imglyConfig.gradle");
var imglyConfig = "";
try {
imglyConfig = fs.readFileSync(gradleConfigFile, "utf8");
} catch (err) {
console.log(err);
reject();
}

// The content of the android app gradle file
const platformRoot = path.join(
context.opts.projectRoot,
"platforms/android/app"
);
var gradleFiles = [path.join(platformRoot, "build.gradle")];

async.each(
gradleFiles,
function (file, callback) {
let fileContents = fs.readFileSync(file, "utf8");

let whereToAdd = fileContents.indexOf(
"// PLUGIN GRADLE EXTENSIONS START"
);

fileContents =
fileContents.substr(0, whereToAdd) +
BLOCK_START +
imglyConfigHeader +
imglyConfig +
BLOCK_END +
"\n" +
fileContents.substr(whereToAdd);
fs.writeFileSync(file, fileContents, "utf8");
console.log("updated " + file + " to include imglyConfig");

callback();
},
function (err) {
if (err) {
console.error("unable to update gradle files", err);
reject();
} else {
resolve();
}
}
);
});
};
75 changes: 75 additions & 0 deletions hooks/dependencies-gradle-hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const fs = require("fs");
const path = require("path");
const async = require("async");

module.exports = (context) => {
"use strict";

const BLOCK_START = ` // DEPENDENCIES ADDED BY IMGLY - BLOCK START`;
const BLOCK_END = ` // DEPENDENCIES ADDED BY IMGLY - BLOCK END`;

const imglyDependencies =
"\n" +
BLOCK_START +
`
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath "ly.img.android.sdk:plugin:7.6.0"` +
"\n" +
BLOCK_END +
"\n";
return new Promise((resolve, reject) => {
const platformRoot = path.join(
context.opts.projectRoot,
"platforms/android"
);

// const gradleFiles = findGradleFiles(platformRoot);
var gradleFiles = [path.join(platformRoot, "build.gradle")];

async.each(
gradleFiles,
function (file, callback) {
let fileContents = fs.readFileSync(file, "utf8");

let found = fileContents.indexOf("ly.img.android.sdk:plugin");

if (found === -1) {
// not found
let insertLocations = [];
const myRegexp = /\bdependencies\s*{(.*)$/gm;
let match = myRegexp.exec(fileContents);
while (match != null) {
insertLocations.push(match.index + match[0].length);
match = null; // just modify the first `repositories` tag
}

if (insertLocations.length > 0) {
insertLocations.reverse(); // process locations end -> beginning
// to preserve indices
insertLocations.forEach((location) => {
fileContents =
fileContents.substr(0, location) +
imglyDependencies +
fileContents.substr(location);
});

fs.writeFileSync(file, fileContents, "utf8");
console.log("updated " + file + " to include imgly dependencies ");
}

callback();
} else {
callback();
}
},
function (err) {
if (err) {
console.error("unable to update gradle files", err);
reject();
} else {
resolve();
}
}
);
});
};
54 changes: 54 additions & 0 deletions hooks/imglyConfig-gradle-hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const fs = require("fs");
const path = require("path");
const async = require("async");

module.exports = (context) => {
"use strict";

const imglyConfig = `
// Comment out the modules you don't need, to save size.
imglyConfig {
modules {
include 'ui:text'
include 'ui:focus'
include 'ui:frame'
include 'ui:brush'
include 'ui:filter'
include 'ui:sticker'
include 'ui:overlay'
include 'ui:transform'
include 'ui:adjustment'
include 'ui:text-design'
include 'ui:video-trim' // for VideoEditor
// This module is big, remove the serializer if you don't need that feature.
include 'backend:serializer'
// Remove the asset packs you don't need, these are also big in size.
include 'assets:font-basic'
include 'assets:frame-basic'
include 'assets:filter-basic'
include 'assets:overlay-basic'
include 'assets:sticker-shapes'
include 'assets:sticker-emoticons'
include 'assets:sticker-animated' // for VideoEditor
include 'backend:sticker-animated' // for VideoEditor
include 'backend:sticker-smart'
}
}
`;
return new Promise((resolve, reject) => {
const projectRoot = path.join(context.opts.projectRoot);
var gradleConfigFile = path.join(projectRoot, "imglyConfig.gradle");

try {
fs.writeFileSync(gradleConfigFile, imglyConfig);
console.log("Add imglyConfig.gradle to the root directory.");
resolve();
} catch (err) {
console.error(err);
reject();
}
});
};
51 changes: 51 additions & 0 deletions hooks/remove-copy-imglyConfig-gradle-hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const fs = require("fs");
const path = require("path");
const async = require("async");

module.exports = (context) => {
"use strict";
const BLOCK_START = `// imglyConfig ADDED BY IMGLY - BLOCK START`;
const BLOCK_END = `// imglyConfig ADDED BY IMGLY - BLOCK END`;

return new Promise((resolve, reject) => {
const platformRoot = path.join(
context.opts.projectRoot,
"platforms/android/app"
);

var gradleFiles = [path.join(platformRoot, "build.gradle")];

async.each(
gradleFiles,
function (file, callback) {
let fileContents = fs.readFileSync(file, "utf8");

let found = fileContents.indexOf("imglyConfig");

if (found !== -1) {
// found
var toRemove = fileContents.substring(
fileContents.indexOf(BLOCK_START),
fileContents.lastIndexOf(BLOCK_END) + BLOCK_END.length
);
fileContents = fileContents.replace(toRemove, "");

fs.writeFileSync(file, fileContents, "utf8");
console.log("remove imglyConfig from " + file);

callback();
} else {
callback();
}
},
function (err) {
if (err) {
console.error("unable to update gradle files", err);
reject();
} else {
resolve();
}
}
);
});
};
Loading

0 comments on commit fe89865

Please sign in to comment.