x4js 1.4.21 → 1.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/settings.js +2 -3
- package/package.json +1 -1
- package/src/settings.ts +2 -4
- package/tsconfig.json +0 -2
- package/src/hosts/electron.ts +0 -164
- package/src/hosts/host.ts +0 -100
- package/src/hosts/nwjs.ts +0 -141
- package/src/hosts/nwjs_types.ts +0 -339
package/README.md
CHANGED
package/lib/settings.js
CHANGED
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
**/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.Settings = void 0;
|
|
32
|
-
const host_1 = require("./hosts/host");
|
|
33
32
|
class Settings {
|
|
34
33
|
m_data;
|
|
35
34
|
m_name;
|
|
@@ -48,14 +47,14 @@ class Settings {
|
|
|
48
47
|
}
|
|
49
48
|
_save() {
|
|
50
49
|
let data = JSON.stringify(this.m_data);
|
|
51
|
-
|
|
50
|
+
localStorage.write(this.m_name, data);
|
|
52
51
|
}
|
|
53
52
|
_load() {
|
|
54
53
|
if (this.m_data) {
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
57
56
|
this.m_data = {};
|
|
58
|
-
let data =
|
|
57
|
+
let data = localStorage.read(this.m_name);
|
|
59
58
|
if (data !== null) {
|
|
60
59
|
data = JSON.parse(data);
|
|
61
60
|
if (data) {
|
package/package.json
CHANGED
package/src/settings.ts
CHANGED
|
@@ -27,8 +27,6 @@
|
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
29
|
|
|
30
|
-
import { host } from './hosts/host';
|
|
31
|
-
|
|
32
30
|
export class Settings {
|
|
33
31
|
|
|
34
32
|
private m_data: any;
|
|
@@ -52,7 +50,7 @@ export class Settings {
|
|
|
52
50
|
|
|
53
51
|
private _save( ) {
|
|
54
52
|
let data = JSON.stringify(this.m_data);
|
|
55
|
-
|
|
53
|
+
localStorage.write( this.m_name, data );
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
private _load( ) {
|
|
@@ -62,7 +60,7 @@ export class Settings {
|
|
|
62
60
|
|
|
63
61
|
this.m_data = {};
|
|
64
62
|
|
|
65
|
-
let data =
|
|
63
|
+
let data = localStorage.read( this.m_name );
|
|
66
64
|
if( data!==null ) {
|
|
67
65
|
data = JSON.parse( data );
|
|
68
66
|
if( data ) {
|
package/tsconfig.json
CHANGED
package/src/hosts/electron.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file host/electron.ts
|
|
3
|
-
* @author Etienne Cochard
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
6
|
-
*
|
|
7
|
-
* This program is free software; you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU General Public License as published by
|
|
9
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
-
**/
|
|
19
|
-
|
|
20
|
-
import { x4document } from '../dom-gen'
|
|
21
|
-
import { FileStat, PathType, PartType, Host } from './host'
|
|
22
|
-
|
|
23
|
-
export * from './host';
|
|
24
|
-
|
|
25
|
-
declare const require;
|
|
26
|
-
declare const host_require;
|
|
27
|
-
|
|
28
|
-
if( !globalThis.host_require ) {
|
|
29
|
-
globalThis.host_require = require;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const fs = host_require( 'fs' );
|
|
33
|
-
export const process = host_require( 'process' );
|
|
34
|
-
export const electron = host_require( 'electron' );
|
|
35
|
-
export const path = host_require( 'path' );
|
|
36
|
-
|
|
37
|
-
//import * as path from 'node:path';
|
|
38
|
-
|
|
39
|
-
export class ElectronHost extends Host {
|
|
40
|
-
|
|
41
|
-
makePath( ...els: string[] ) {
|
|
42
|
-
return path.join( ...els );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
readBinary( path: string ): Promise<Uint8Array> {
|
|
46
|
-
return new Promise( ( resolve, reject ) => {
|
|
47
|
-
fs.readFile( path, ( err, buff ) => {
|
|
48
|
-
if( err ) { reject( err ); }
|
|
49
|
-
else { resolve( buff ); }
|
|
50
|
-
} );
|
|
51
|
-
} );
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
writeBinary( path: string, data: Uint8Array ): Promise<boolean> {
|
|
55
|
-
return new Promise( ( resolve, reject ) => {
|
|
56
|
-
fs.writeFile( path, data, ( err ) => {
|
|
57
|
-
if( err ) { reject(err); }
|
|
58
|
-
else { resolve( true ); }
|
|
59
|
-
} );
|
|
60
|
-
} );
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
readUtf8( path: string ): Promise<string> {
|
|
64
|
-
return new Promise( ( resolve, reject ) => {
|
|
65
|
-
fs.readFile( path, { encoding: 'utf8' }, ( err, buff ) => {
|
|
66
|
-
if( err ) { reject( err ); }
|
|
67
|
-
else { resolve( buff.toString() ); }
|
|
68
|
-
} );
|
|
69
|
-
} );
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
writeUtf8( path: string, data: string ): Promise<boolean> {
|
|
73
|
-
return new Promise( ( resolve, reject ) => {
|
|
74
|
-
fs.writeFile( path, data, {encoding: 'utf8'}, ( err ) => {
|
|
75
|
-
if( err ) { reject(err); }
|
|
76
|
-
else { resolve( true ); }
|
|
77
|
-
} );
|
|
78
|
-
} );
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
compress( data: Uint8Array ): Promise<Uint8Array> {
|
|
82
|
-
return new Promise( (resolve, reject ) => {
|
|
83
|
-
let zlib = this.require('zlib');
|
|
84
|
-
zlib.gzip( data, ( err, Uint8Array ) => {
|
|
85
|
-
if( err ) { reject( err); }
|
|
86
|
-
else { resolve( Uint8Array); }
|
|
87
|
-
} );
|
|
88
|
-
} );
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
decompress( data: Uint8Array ): Promise<Uint8Array> {
|
|
92
|
-
return new Promise( (resolve, reject ) => {
|
|
93
|
-
let zlib = this.require('zlib');
|
|
94
|
-
zlib.gunzip( data, ( err, Uint8Array ) => {
|
|
95
|
-
if( err ) { reject( err); }
|
|
96
|
-
else { resolve( Uint8Array); }
|
|
97
|
-
} );
|
|
98
|
-
} );
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
readLocalStorage( name: string ): string {
|
|
102
|
-
return localStorage.getItem( name );
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
writeLocalStorage( name: string, data: string ): void {
|
|
106
|
-
localStorage.setItem( name, data );
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
stat( name: string ): FileStat {
|
|
110
|
-
let stat = fs.statSync( name );
|
|
111
|
-
if( !stat ) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
atime: stat.atimeMs,
|
|
117
|
-
isDir: stat.isDirectory()
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
readDir( path: string ): Promise<string[]> {
|
|
122
|
-
return new Promise( ( resolve, reject ) => {
|
|
123
|
-
fs.readdir( path, ( err, files ) => {
|
|
124
|
-
if( err ) { reject(err); }
|
|
125
|
-
else { resolve(files); }
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
require( name: string ): any {
|
|
131
|
-
return host_require( name );
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
cwd( ): string {
|
|
135
|
-
return process.cwd( );
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
get ipc( ) {
|
|
139
|
-
return electron.ipcRenderer;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
getPath( type: PathType ) : string {
|
|
143
|
-
return this.ipc.sendSync( 'getPath', type );
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
getPathPart( pth: string, type: PartType ) : string {
|
|
147
|
-
|
|
148
|
-
let els = path.parse( pth );
|
|
149
|
-
switch ( type ) {
|
|
150
|
-
case 'dirname': return els.dir;
|
|
151
|
-
case 'basename': return els.base;
|
|
152
|
-
case 'filename': return els.name;
|
|
153
|
-
case 'extname': return els.ext;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return '';
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
createCanvas = ( ) => {
|
|
160
|
-
return x4document.createElement('canvas');
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
new ElectronHost( );
|
package/src/hosts/host.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file host.ts
|
|
3
|
-
* @author Etienne Cochard
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
6
|
-
*
|
|
7
|
-
* This program is free software; you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU General Public License as published by
|
|
9
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
-
**/
|
|
19
|
-
|
|
20
|
-
export interface FileStat {
|
|
21
|
-
atime: number;
|
|
22
|
-
isDir: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type PathType = 'home' | 'appData' | 'userData' | 'cache' | 'temp' | 'exe' | 'desktop' | 'documents' | 'downloads' | 'music'
|
|
26
|
-
| 'pictures'| 'videos' | 'recent' | 'logs' | 'crashDumps';
|
|
27
|
-
|
|
28
|
-
export type PartType = 'filename' | 'extname' | 'basename' | 'dirname';
|
|
29
|
-
|
|
30
|
-
export abstract class Host {
|
|
31
|
-
|
|
32
|
-
constructor( ) {
|
|
33
|
-
host = this;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
makePath( ...els: string[] ) {
|
|
37
|
-
return els.join( '/' );
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
readBinary( path: string ): Promise<Uint8Array> {
|
|
41
|
-
return Promise.reject( 'not imp' );
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
writeBinary( path: string, data: Uint8Array ): Promise<boolean> {
|
|
45
|
-
return Promise.reject( 'not imp' );
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
readUtf8( path: string ): Promise<string> {
|
|
49
|
-
return Promise.reject( 'not imp' );
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
writeUtf8( path: string, data: string ): Promise<boolean> {
|
|
53
|
-
return Promise.reject( 'not imp' );
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
compress( data: Uint8Array ): Promise<Uint8Array> {
|
|
57
|
-
return Promise.reject( 'not imp' );
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
decompress( data: Uint8Array ): Promise<Uint8Array> {
|
|
61
|
-
return Promise.reject( 'not imp' );
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
readLocalStorage( name: string ): string {
|
|
65
|
-
return localStorage.getItem( name );
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
writeLocalStorage( name: string, data: string ): void {
|
|
69
|
-
localStorage.setItem( name, data );
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
stat( name: string ): FileStat {
|
|
73
|
-
throw 'not imp';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
readDir( path: string ): Promise<string[]> {
|
|
77
|
-
throw 'not imp';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
require( name: string ): any {
|
|
81
|
-
throw 'not imp';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
cwd( ): string {
|
|
85
|
-
throw 'not imp';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
getPath( type: PathType ) : string {
|
|
89
|
-
throw 'not imp';
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getPathPart( path: string, type: PartType ) : string {
|
|
93
|
-
throw 'not imp';
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
abstract createCanvas( );
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
export let host: Host = null;
|
package/src/hosts/nwjs.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file host/nwjs.ts
|
|
3
|
-
* @author Etienne Cochard
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
6
|
-
*
|
|
7
|
-
* This program is free software; you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU General Public License as published by
|
|
9
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
-
**/
|
|
19
|
-
|
|
20
|
-
import { FileStat, PathType, Host } from './host'
|
|
21
|
-
|
|
22
|
-
export * from './host';
|
|
23
|
-
|
|
24
|
-
// to deal with amd modules (that are not comletely compatible with nodejs)
|
|
25
|
-
// globalThis.node_require must be set to require BEFORE polyfill code of amd module.
|
|
26
|
-
// ie. globalThis.node_require = require;
|
|
27
|
-
|
|
28
|
-
declare const host_require;
|
|
29
|
-
if( !globalThis.host_require ) {
|
|
30
|
-
globalThis.host_require = require;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const fs = host_require( 'fs' );
|
|
34
|
-
const process = host_require( 'process' );
|
|
35
|
-
const path = host_require( 'path' );
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export class NWJSHost implements Host {
|
|
40
|
-
|
|
41
|
-
makePath( ...els: string[] ) {
|
|
42
|
-
return path.join( ...els );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
readBinary( path: string ): Promise<Uint8Array> {
|
|
46
|
-
return new Promise( ( resolve, reject ) => {
|
|
47
|
-
fs.readFile( path, ( err, buff ) => {
|
|
48
|
-
if( err ) { reject( err ); }
|
|
49
|
-
else { resolve( buff ); }
|
|
50
|
-
} );
|
|
51
|
-
} );
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
writeBinary( path: string, data: Uint8Array ): Promise<boolean> {
|
|
55
|
-
return new Promise( ( resolve, reject ) => {
|
|
56
|
-
fs.writeFile( path, data, ( err ) => {
|
|
57
|
-
if( err ) { reject(err); }
|
|
58
|
-
else { resolve( true ); }
|
|
59
|
-
} );
|
|
60
|
-
} );
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
readUtf8( path: string ): Promise<string> {
|
|
64
|
-
return new Promise( ( resolve, reject ) => {
|
|
65
|
-
fs.readFile( path, { encoding: 'utf8' }, ( err, buff ) => {
|
|
66
|
-
if( err ) { reject( err ); }
|
|
67
|
-
else { resolve( buff.toString() ); }
|
|
68
|
-
} );
|
|
69
|
-
} );
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
writeUtf8( path: string, data: string ): Promise<boolean> {
|
|
73
|
-
return new Promise( ( resolve, reject ) => {
|
|
74
|
-
fs.writeFile( path, data, {encoding: 'utf8'}, ( err ) => {
|
|
75
|
-
if( err ) { reject(err); }
|
|
76
|
-
else { resolve( true ); }
|
|
77
|
-
} );
|
|
78
|
-
} );
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
compress( data: Uint8Array ): Promise<Uint8Array> {
|
|
82
|
-
return new Promise( (resolve, reject ) => {
|
|
83
|
-
let zlib = host_require('zlib');
|
|
84
|
-
zlib.gzip( data, ( err, Uint8Array ) => {
|
|
85
|
-
if( err ) { reject( err); }
|
|
86
|
-
else { resolve( Uint8Array); }
|
|
87
|
-
} );
|
|
88
|
-
} );
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
decompress( data: Uint8Array ): Promise<Uint8Array> {
|
|
92
|
-
return new Promise( (resolve, reject ) => {
|
|
93
|
-
let zlib = host_require('zlib');
|
|
94
|
-
zlib.gunzip( data, ( err, Uint8Array ) => {
|
|
95
|
-
if( err ) { reject( err); }
|
|
96
|
-
else { resolve( Uint8Array); }
|
|
97
|
-
} );
|
|
98
|
-
} );
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
readLocalStorage( name: string ): string {
|
|
102
|
-
return localStorage.getItem( name );
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
writeLocalStorage( name: string, data: string ): void {
|
|
106
|
-
localStorage.setItem( name, data );
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
stat( name: string ): FileStat {
|
|
110
|
-
let stat = fs.statSync( name );
|
|
111
|
-
if( !stat ) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
atime: stat.atimeMs
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
readDir( path: string ): Promise<string[]> {
|
|
121
|
-
return new Promise( ( resolve, reject ) => {
|
|
122
|
-
fs.readdir( path, ( err, files ) => {
|
|
123
|
-
if( err ) { reject(err); }
|
|
124
|
-
else { resolve(files); }
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
require( name: string ): any {
|
|
130
|
-
// your amd module must define window.node_require = require;
|
|
131
|
-
return host_require( name );
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
cwd( ): string {
|
|
135
|
-
return process.cwd( );
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
getPath( type: PathType ) : string {
|
|
139
|
-
throw 'not imp';
|
|
140
|
-
}
|
|
141
|
-
}
|
package/src/hosts/nwjs_types.ts
DELETED
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file nwjs.ts
|
|
3
|
-
* @author Etienne Cochard
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
6
|
-
*
|
|
7
|
-
* This program is free software; you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU General Public License as published by
|
|
9
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
-
**/
|
|
19
|
-
|
|
20
|
-
declare namespace nw {
|
|
21
|
-
|
|
22
|
-
const App: NWApp;
|
|
23
|
-
|
|
24
|
-
class NWApp {
|
|
25
|
-
public readonly argv: string[];
|
|
26
|
-
public readonly fullArgv: string[];
|
|
27
|
-
public readonly filteredArgv: string[];
|
|
28
|
-
public readonly startPath: string;
|
|
29
|
-
public readonly manifest: object;
|
|
30
|
-
public readonly dataPath: string;
|
|
31
|
-
|
|
32
|
-
clearCache(): void;
|
|
33
|
-
clearAppCache(manifest_url: string): void;
|
|
34
|
-
closeAllWindows(): void;
|
|
35
|
-
crashBrowser(): void;
|
|
36
|
-
crashRenderer(): void;
|
|
37
|
-
getProxyForURL(url: string): void;
|
|
38
|
-
setProxyConfig(config: string, pac_url: string): void;
|
|
39
|
-
quit(): void;
|
|
40
|
-
setCrashDumpDir(dir: string): void;
|
|
41
|
-
addOriginAccessWhitelistEntry(sourceOrigin: string, destinationProtocol: string, destinationHost: string, allowDestinationSubdomain: boolean): void;
|
|
42
|
-
removeOriginAccessWhitelistEntry(sourceOrigin: string, destinationProtocol: string, destinationHost: string, allowDestinationSubdomain: boolean): void;
|
|
43
|
-
registerGlobalHotKey(shortcut: Shortcut): void;
|
|
44
|
-
unregisterGlobalHotKey(shortcut: Shortcut): void;
|
|
45
|
-
on(event: "open", listener: (args: string) => void): this;
|
|
46
|
-
on(event: "reopen", listener: () => void): this;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
namespace Shortcut {
|
|
50
|
-
interface IShortcutOptions {
|
|
51
|
-
key: string;
|
|
52
|
-
active?: Function;
|
|
53
|
-
failed?: Function;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
class Shortcut {
|
|
58
|
-
public active?: Function;
|
|
59
|
-
public failed?: Function;
|
|
60
|
-
public key: string;
|
|
61
|
-
constructor(option: {
|
|
62
|
-
key: string;
|
|
63
|
-
active?: Function;
|
|
64
|
-
failed?: Function;
|
|
65
|
-
});
|
|
66
|
-
on(name: "active", ...args: any[]): this;
|
|
67
|
-
on(name: "failed", ...args: any[]): this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
namespace Clipboard {
|
|
71
|
-
function get(): Clipboard;
|
|
72
|
-
interface IClipboardData {
|
|
73
|
-
data: string;
|
|
74
|
-
type?: "text" | "png" | "jpeg" | "html" | "rtf";
|
|
75
|
-
raw?: boolean;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
class Clipboard {
|
|
80
|
-
set(data: string, type?: "text" | "png" | "jpeg" | "html" | "rtf", raw?: boolean): this;
|
|
81
|
-
set(clipboardData: Clipboard.IClipboardData): this;
|
|
82
|
-
set(clipboardDataList: Clipboard.IClipboardData[]): this;
|
|
83
|
-
get(type?: string, raw?: boolean): string;
|
|
84
|
-
get(clipboardData: Clipboard.IClipboardData): string;
|
|
85
|
-
get(clipboardDataList: Clipboard.IClipboardData[]): Clipboard.IClipboardData[];
|
|
86
|
-
readAvailableTypes(): "text" | "png" | "jpeg" | "html" | "rtf"[];
|
|
87
|
-
clear(): this;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
class MenuItem {
|
|
91
|
-
public readonly type: "normal" | "checkbox" | "separator";
|
|
92
|
-
public label: string;
|
|
93
|
-
public icon: string;
|
|
94
|
-
public iconIsTemplate: boolean;
|
|
95
|
-
public tooltip: string;
|
|
96
|
-
public checked: boolean;
|
|
97
|
-
public enabled: boolean;
|
|
98
|
-
public readonly submenu: Menu;
|
|
99
|
-
public click: Function;
|
|
100
|
-
public key: string;
|
|
101
|
-
public modifiers: string;
|
|
102
|
-
constructor(option?: {
|
|
103
|
-
label?: string;
|
|
104
|
-
icon?: string;
|
|
105
|
-
tooltip?: string;
|
|
106
|
-
type?: "normal" | "checkbox" | "separator";
|
|
107
|
-
click?: Function;
|
|
108
|
-
enabled?: boolean;
|
|
109
|
-
checked?: boolean;
|
|
110
|
-
submenu?: Menu;
|
|
111
|
-
key?: string;
|
|
112
|
-
modifiers?: string;
|
|
113
|
-
});
|
|
114
|
-
on(event: "click", listener: (...args: any[]) => void): this;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class Menu {
|
|
118
|
-
public items: MenuItem[];
|
|
119
|
-
constructor(option?: {
|
|
120
|
-
type?: string;
|
|
121
|
-
});
|
|
122
|
-
append(item: MenuItem): this;
|
|
123
|
-
insert(item: MenuItem, i: number): this;
|
|
124
|
-
remove(item: MenuItem): this;
|
|
125
|
-
removeAt(i: number): this;
|
|
126
|
-
popup(x: number, y: number): this;
|
|
127
|
-
createMacBuiltin(appname: string, options?: {
|
|
128
|
-
hideEdit?: boolean;
|
|
129
|
-
hideWindow?: boolean;
|
|
130
|
-
}): this;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
interface IScreenData {
|
|
134
|
-
id: number;
|
|
135
|
-
bounds: {
|
|
136
|
-
x: number;
|
|
137
|
-
y: number;
|
|
138
|
-
width: number;
|
|
139
|
-
height: number;
|
|
140
|
-
};
|
|
141
|
-
work_area: {
|
|
142
|
-
x: number;
|
|
143
|
-
y: number;
|
|
144
|
-
width: number;
|
|
145
|
-
height: number;
|
|
146
|
-
};
|
|
147
|
-
scaleFactor: number;
|
|
148
|
-
isBuiltIn: boolean;
|
|
149
|
-
rotation: number;
|
|
150
|
-
touchSupport: number;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
class NWDesktopCaptureMonitor {
|
|
154
|
-
public started: boolean;
|
|
155
|
-
constructor();
|
|
156
|
-
start(should_include_screens: boolean, should_include_windows: boolean): this;
|
|
157
|
-
stop(): this;
|
|
158
|
-
registerStream(id: string): this;
|
|
159
|
-
on(event: "added", listener: (id: string, name: string, order: number, type: "screen" | "window" | "other" | "unknown", primary: boolean) => void): this;
|
|
160
|
-
on(event: "removed", listener: (order: number) => void): this;
|
|
161
|
-
on(event: "orderchanged", listener: (id: string, new_order: number, old_order: number) => void): this;
|
|
162
|
-
on(event: "namechanged", listener: (id: string, name: string) => void): this;
|
|
163
|
-
on(event: "thumbnailchanged", listener: (id: string, thumbnail: string) => void): this;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const Screen: NWScreen;
|
|
167
|
-
class NWScreen {
|
|
168
|
-
public readonly screens: IScreenData[];
|
|
169
|
-
public readonly DesktopCaptureMonitor: NWDesktopCaptureMonitor;
|
|
170
|
-
constructor();
|
|
171
|
-
Init(): void;
|
|
172
|
-
chooseDesktopMedia(sources: "window" | "screen" [], callback: (streamId: number | false) => void): this;
|
|
173
|
-
on(event: "displayBoundsChanged", listener: (screen: IScreenData) => void): this;
|
|
174
|
-
on(event: "displayAdded", listener: (screen: IScreenData) => void): this;
|
|
175
|
-
on(event: "displayRemoved", listener: (screen: IScreenData) => void): this;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
interface IWindowSubfields {
|
|
179
|
-
id?: string;
|
|
180
|
-
title?: string;
|
|
181
|
-
width?: number;
|
|
182
|
-
height?: number;
|
|
183
|
-
icon?: string;
|
|
184
|
-
position?: "null" | "center" | "mouse";
|
|
185
|
-
min_width?: number;
|
|
186
|
-
min_height?: number;
|
|
187
|
-
max_width?: number;
|
|
188
|
-
max_height?: number;
|
|
189
|
-
as_desktop?: boolean;
|
|
190
|
-
resizable?: boolean;
|
|
191
|
-
always_on_top?: boolean;
|
|
192
|
-
visible_on_all_workspaces?: boolean;
|
|
193
|
-
fullscreen?: boolean;
|
|
194
|
-
show_in_taskbar?: boolean;
|
|
195
|
-
frame?: boolean;
|
|
196
|
-
show?: boolean;
|
|
197
|
-
kiosk?: boolean;
|
|
198
|
-
transparent?: boolean;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
interface IWindowOptions extends IWindowSubfields {
|
|
202
|
-
new_instance?: boolean;
|
|
203
|
-
inject_js_start?: string;
|
|
204
|
-
inject_js_end?: string;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
class Window {
|
|
208
|
-
public readonly window: any;
|
|
209
|
-
public x: number;
|
|
210
|
-
public y: number;
|
|
211
|
-
public width: number;
|
|
212
|
-
public height: number;
|
|
213
|
-
public title: string;
|
|
214
|
-
public menu: Menu;
|
|
215
|
-
public readonly isAlwaysOnTop: boolean;
|
|
216
|
-
public readonly isFullscreen: boolean;
|
|
217
|
-
public readonly isTransparent: boolean;
|
|
218
|
-
public readonly isKioskMode: boolean;
|
|
219
|
-
public zoomLevel: number;
|
|
220
|
-
public cookies: {
|
|
221
|
-
[key: string]: Function;
|
|
222
|
-
}
|
|
223
|
-
constructor();
|
|
224
|
-
static get(window_object: any): Window;
|
|
225
|
-
static open(url: string, options?: IWindowOptions, callback?: (win: Window) => void): Window;
|
|
226
|
-
moveTo(x: number, y: number): this;
|
|
227
|
-
moveBy(x: number, y: number): this;
|
|
228
|
-
resizeTo(width: number, height: number): this;
|
|
229
|
-
resizeBy(width: number, height: number): this;
|
|
230
|
-
focus(): this;
|
|
231
|
-
blur(): this;
|
|
232
|
-
show(is_show?: boolean): this;
|
|
233
|
-
hide(): this;
|
|
234
|
-
close(force?: boolean): this;
|
|
235
|
-
reload(): this;
|
|
236
|
-
reloadDev(): this;
|
|
237
|
-
reloadIgnoringCache(): this;
|
|
238
|
-
maximize(): this;
|
|
239
|
-
minimize(): this;
|
|
240
|
-
restore(): this;
|
|
241
|
-
enterFullscreen(): this;
|
|
242
|
-
leaveFullscreen(): this;
|
|
243
|
-
toggleFullscreen(): this;
|
|
244
|
-
enterKioskMode(): this;
|
|
245
|
-
leaveKioskMode(): this;
|
|
246
|
-
toggleKioskMode(): this;
|
|
247
|
-
setShadow(shadow: boolean): this;
|
|
248
|
-
showDevTools(iframe?: string | HTMLFrameElement, callback?: (dev_win: Window) => void): this;
|
|
249
|
-
closeDevTools(): this;
|
|
250
|
-
getPrinters(callback: object[]): this;
|
|
251
|
-
isDevToolsOpen(): boolean;
|
|
252
|
-
print(options: {
|
|
253
|
-
autoprint: boolean;
|
|
254
|
-
printer: string;
|
|
255
|
-
pdf_path: string;
|
|
256
|
-
headerFooterEnabled: boolean;
|
|
257
|
-
landscape: boolean;
|
|
258
|
-
mediaSize: object;
|
|
259
|
-
shouldPrintBackgrounds: boolean;
|
|
260
|
-
marginsType: 0 | 1 | 2| 3;
|
|
261
|
-
marginsCustom: object;
|
|
262
|
-
copies: number;
|
|
263
|
-
scaleFactor: number;
|
|
264
|
-
headerString: string;
|
|
265
|
-
footerString: string;
|
|
266
|
-
} | {}): this;
|
|
267
|
-
setMaximumSize(width: number, height: number): this;
|
|
268
|
-
setMinimumSize(width: number, height: number): this;
|
|
269
|
-
setResizable(resizable: boolean): this;
|
|
270
|
-
setAlwaysOnTop(top: boolean): this;
|
|
271
|
-
setVisibleOnAllWorkspaces(visible: boolean): this;
|
|
272
|
-
canSetVisibleOnAllWorkspaces(): boolean;
|
|
273
|
-
setPosition(position: "null" | "center" | "mouse"): this;
|
|
274
|
-
setShowInTaskbar(show: boolean): this;
|
|
275
|
-
requestAttention(attention: boolean | number): this;
|
|
276
|
-
capturePage(callback: Function, config?: "png" | "jpeg" | {
|
|
277
|
-
format?: "png" | "jpeg";
|
|
278
|
-
datatype?: "raw" | "buffer" | "datauri";
|
|
279
|
-
}): this;
|
|
280
|
-
setProgressBar(progress: number): this;
|
|
281
|
-
setBadgeLabel(label: string): this;
|
|
282
|
-
eval(frame: HTMLFrameElement | null, script: string): this;
|
|
283
|
-
evalNWBin(frame: HTMLFrameElement | null, path: string | ArrayBuffer | Buffer): this;
|
|
284
|
-
evalNWBinModule(frame: HTMLFrameElement | null, path: string | ArrayBuffer | Buffer, module_path: string): this;
|
|
285
|
-
on(event: "close", listener: () => void): this;
|
|
286
|
-
on(event: "closed", listener: () => void): this;
|
|
287
|
-
on(event: "loading", listener: () => void): this;
|
|
288
|
-
on(event: "loaded", listener: () => void): this;
|
|
289
|
-
on(event: "document-start", listener: (frame: HTMLFrameElement | null) => void): this;
|
|
290
|
-
on(event: "document-end", listener: (frame: HTMLFrameElement | null) => void): this;
|
|
291
|
-
on(event: "focus", listener: () => void): this;
|
|
292
|
-
on(event: "blur", listener: () => void): this;
|
|
293
|
-
on(event: "minimize", listener: () => void): this;
|
|
294
|
-
on(event: "restore", listener: () => void): this;
|
|
295
|
-
on(event: "maximize", listener: () => void): this;
|
|
296
|
-
on(event: "move", listener: (x: number, y: number) => void): this;
|
|
297
|
-
on(event: "resize", listener: (width: number, height: number) => void): this;
|
|
298
|
-
on(event: "enter-fullscreen", listener: () => void): this;
|
|
299
|
-
on(event: "zoom", listener: () => void): this;
|
|
300
|
-
on(event: "devtools-closed", listener: () => void): this;
|
|
301
|
-
on(event: "new-win-policy", listener: (frame: HTMLFrameElement | null, url: string, policy: {
|
|
302
|
-
ignore(): void;
|
|
303
|
-
forceCurrent(): void;
|
|
304
|
-
forceDownload(): void;
|
|
305
|
-
forceNewWindow(): void;
|
|
306
|
-
forceNewPopup(): void;
|
|
307
|
-
setNewWindowManifest(m: IWindowSubfields): void;
|
|
308
|
-
}) => void): this;
|
|
309
|
-
on(event: "navigation", listener: (frame: HTMLFrameElement | null, url: string, policy: {
|
|
310
|
-
ignore(): void;
|
|
311
|
-
}) => void): this;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
namespace Shell {
|
|
315
|
-
function openExternal(uri: string): void;
|
|
316
|
-
function openItem(file_path: string): void;
|
|
317
|
-
function showItemInFolder(file_path: string): void;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
class Tray {
|
|
321
|
-
public title: string;
|
|
322
|
-
public tooltip: string;
|
|
323
|
-
public icon: string;
|
|
324
|
-
public alticon: string;
|
|
325
|
-
public menu: Menu;
|
|
326
|
-
constructor(option: {
|
|
327
|
-
title: string;
|
|
328
|
-
tooltip: string;
|
|
329
|
-
icon: string;
|
|
330
|
-
alticon: string;
|
|
331
|
-
iconsAreTemplates: boolean;
|
|
332
|
-
menu: Menu;
|
|
333
|
-
});
|
|
334
|
-
remove(): void;
|
|
335
|
-
on(event: "click", listener: (...args: any[]) => void): this;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
|