Skip to content

Commit b473e56

Browse files
committed
update to 9.4.0
1 parent 8bcdfd6 commit b473e56

1 file changed

Lines changed: 103 additions & 13 deletions

File tree

src/v9.ts

Lines changed: 103 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,112 @@ import CSInterfaceV8 from "./v8";
1515

1616
export * from './v8'
1717

18-
/** CSInterface - v9.2.0 */
19-
2018
/**
21-
* Retrieves the scale factor of Monitor.
22-
*
23-
* @since 8.5.0
24-
*
25-
* @return value >= 1.0f
26-
* only available for windows machine
19+
* CSInterface - v9.4.0
2720
*/
28-
if (navigator.appVersion.toLowerCase().indexOf("windows") >= 0) {
29-
30-
class CSInterface extends CSInterfaceV8 {
21+
export default class CSInterface extends CSInterfaceV8 {
22+
/**
23+
* Retrieves the scale factor of Monitor.
24+
*
25+
* @since 8.5.0
26+
*
27+
* @return value >= 1.0f
28+
* only available for windows machine
29+
*/
30+
getMonitorScaleFactor(): number {
3131

32-
getMonitorScaleFactor(): number {
32+
if (navigator.appVersion.toLowerCase().indexOf("windows") >= 0) {
3333
return window.__adobe_cep__.getMonitorScaleFactor();
3434
}
35+
36+
return 0;
37+
}
38+
39+
/**
40+
* @since 9.4.0
41+
*
42+
* Loads binary file created which is located at url asynchronously
43+
*
44+
* @param urlName url at which binary file is located. Local files should start with 'file://'
45+
* @param callback Optional. A callback function that returns after binary is loaded
46+
*
47+
* @example
48+
*
49+
* To create JS binary use command ./cep_compiler test.js test.bin
50+
* To load JS binary asyncronously
51+
* var CSLib = new CSInterface();
52+
* CSLib.loadBinAsync(url, function () { });
53+
*/
54+
loadBinAsync(urlName: string, callback: Function): boolean {
55+
try
56+
{
57+
const xhr = new XMLHttpRequest();
58+
xhr.responseType = 'arraybuffer'; // make response as ArrayBuffer
59+
xhr.open('GET', urlName, true);
60+
xhr.onerror = function ()
61+
{
62+
console.log("Unable to load snapshot from given URL");
63+
return false;
64+
};
65+
xhr.send();
66+
xhr.onload = () => {
67+
window.__adobe_cep__.loadSnapshot(xhr.response);
68+
if (typeof callback === "function")
69+
{
70+
callback();
71+
}
72+
else if(typeof callback !== "undefined")
73+
{
74+
console.log("Provided callback is not a function");
75+
}
76+
}
77+
}
78+
catch(err)
79+
{
80+
console.log(err);
81+
return false;
82+
}
83+
84+
return true;
85+
}
86+
87+
/**
88+
* @since 9.4.0
89+
*
90+
* Loads binary file created synchronously
91+
*
92+
* @param pathName the local path at which binary file is located
93+
*
94+
* @example
95+
* To create JS binary use command ./cep_compiler test.js test.bin
96+
* To load JS binary syncronously
97+
* var CSLib = new CSInterface();
98+
* CSLib.loadBinSync(path);
99+
*/
100+
loadBinSync(pathName: string): boolean {
101+
try
102+
{
103+
const OSVersion = this.getOSInformation();
104+
if(pathName.startsWith("file://"))
105+
{
106+
if (OSVersion.indexOf("Windows") >= 0)
107+
{
108+
pathName = pathName.replace("file:///", "");
109+
}
110+
else if (OSVersion.indexOf("Mac") >= 0)
111+
{
112+
pathName = pathName.replace("file://", "");
113+
}
114+
window.__adobe_cep__.loadSnapshot(pathName);
115+
return true;
116+
}
117+
}
118+
catch(err)
119+
{
120+
console.log(err);
121+
return false;
122+
}
123+
//control should not come here
124+
return false;
35125
}
36-
}
126+
}

0 commit comments

Comments
 (0)