@raydiant/playlist-window-manager 0.24.1 → 0.25.1-canary.0
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/build/BrowserViewRenderer.d.ts +2 -3
- package/build/BrowserViewRenderer.js +23 -48
- package/build/BrowserWindowRenderer.d.ts +2 -3
- package/build/BrowserWindowRenderer.js +42 -69
- package/build/IFrameRenderer.d.ts +2 -4
- package/build/IFrameRenderer.js +44 -63
- package/build/PlaylistWindowManager.d.ts +1 -10
- package/build/PlaylistWindowManager.js +18 -87
- package/build/PlaylistWindowManagerState.js +3 -3
- package/build/PresentationWindow.d.ts +5 -32
- package/build/PresentationWindow.js +93 -506
- package/build/WindowLoadError.js +1 -3
- package/build/WindowTimeoutError.js +1 -3
- package/build/WindowUnresponsiveError.js +1 -3
- package/build/embeddedApps.d.ts +2 -2
- package/build/embeddedApps.js +15 -36
- package/build/embeddedApps.test.js +36 -89
- package/build/index.js +6 -19
- package/build/preload.js +14 -14
- package/build/types.d.ts +2 -44
- package/package.json +1 -1
- package/src/BrowserViewRenderer.ts +6 -5
- package/src/BrowserWindowRenderer.ts +16 -14
- package/src/PresentationWindow.test.ts +95 -0
- package/src/PresentationWindow.ts +224 -8
- package/src/types.ts +6 -0
- package/tasks/npm-publish.sh +1 -1
- package/build/PresentationWindow.test.d.ts +0 -1
- package/build/PresentationWindow.test.js +0 -340
- package/build/testUtils.d.ts +0 -43
- package/build/testUtils.js +0 -209
package/build/WindowLoadError.js
CHANGED
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,12 +3,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
10
|
extendStatics(d, b);
|
|
13
11
|
function __() { this.constructor = d; }
|
|
14
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/build/embeddedApps.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Presentation, ApplicationVersion
|
|
2
|
-
export default function createEmbeddedApp(presentation: Presentation, applicationVersion: ApplicationVersion
|
|
1
|
+
import { Presentation, ApplicationVersion } from './types';
|
|
2
|
+
export default function createEmbeddedApp(presentation: Presentation, applicationVersion: ApplicationVersion): string;
|
package/build/embeddedApps.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function createEmbeddedApp(presentation, applicationVersion
|
|
3
|
+
function createEmbeddedApp(presentation, applicationVersion) {
|
|
4
4
|
// build matches
|
|
5
|
-
var parameterRegex = /(:([\w
|
|
5
|
+
var parameterRegex = /(:([\w-]+))(.?$|[^\w-])/gm;
|
|
6
6
|
var matches = [];
|
|
7
7
|
var match = null;
|
|
8
8
|
do {
|
|
@@ -17,40 +17,19 @@ function createEmbeddedApp(presentation, applicationVersion, metadata) {
|
|
|
17
17
|
var queryParamVariableName = m[1]; // Where the value of your input will be injected. E.g. ":location"
|
|
18
18
|
var queryParamName = m[2]; // The query param name. E.g. "location"
|
|
19
19
|
var _a = queryParamVariableName.split(':'), variableName = _a[1];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (variableName
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// port numbers in the embedded app url.
|
|
34
|
-
if (!isNaN(Number(variableName)))
|
|
35
|
-
return;
|
|
36
|
-
var presentationProperty = applicationVersion.presentationProperties.find(function (p) { return p.name === variableName; });
|
|
37
|
-
// If the presentation property is not found (this shouldn't happen), default to encoding the value.
|
|
38
|
-
// Otherwise, only skip encoding if the presentation property's encode property is false.
|
|
39
|
-
shouldEncodeValue =
|
|
40
|
-
!presentationProperty || presentationProperty.encode !== false;
|
|
41
|
-
value = presentation.applicationVariables[queryParamName];
|
|
42
|
-
if (value === undefined)
|
|
43
|
-
value = '';
|
|
44
|
-
if (Array.isArray(value)) {
|
|
45
|
-
value = JSON.stringify(value);
|
|
46
|
-
}
|
|
47
|
-
// Presentation property specific handling.
|
|
48
|
-
if (presentationProperty) {
|
|
49
|
-
// If the presentation property is a file, use the url property as the value.
|
|
50
|
-
if (presentationProperty.type === 'file' && value && value.url) {
|
|
51
|
-
value = value.url;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
20
|
+
// Don't replace variables that are numbers to allow setting
|
|
21
|
+
// port numbers in the embedded app url.
|
|
22
|
+
if (!isNaN(Number(variableName)))
|
|
23
|
+
return;
|
|
24
|
+
var presentationProperty = applicationVersion.presentationProperties.find(function (p) { return p.name === variableName; });
|
|
25
|
+
// If the presentation property is not found (this shouldn't happen), default to encoding the value.
|
|
26
|
+
// Otherwise, only skip encoding if the presentation property's encode property is false.
|
|
27
|
+
var shouldEncodeValue = !presentationProperty || presentationProperty.encode !== false;
|
|
28
|
+
var value = presentation.applicationVariables[queryParamName];
|
|
29
|
+
if (value === undefined)
|
|
30
|
+
value = '';
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
value = JSON.stringify(value);
|
|
54
33
|
}
|
|
55
34
|
if (shouldEncodeValue) {
|
|
56
35
|
value = encodeURIComponent(value);
|
|
@@ -15,116 +15,63 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var embeddedApps_1 = __importDefault(require("./embeddedApps"));
|
|
18
|
-
var createPresentation = function (overrides) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} }, overrides));
|
|
27
|
-
};
|
|
28
|
-
var createApplicationVersion = function (overrides) {
|
|
29
|
-
if (overrides === void 0) { overrides = {}; }
|
|
30
|
-
return (__assign({ id: 'id', name: 'name', applicationId: 'applicationId', embeddedUrlFormat: null, configurableDuration: false, sourceUrl: null, presentationProperties: [] }, overrides));
|
|
31
|
-
};
|
|
32
|
-
var createMetadata = function (overrides) {
|
|
33
|
-
if (overrides === void 0) { overrides = {}; }
|
|
34
|
-
return (__assign({ renderMode: 'live' }, overrides));
|
|
35
|
-
};
|
|
18
|
+
var createPresentation = function (overrides) { return (__assign({ id: 'id', name: 'name', applicationDeploymentId: 'applicationDeploymentId', themeId: null, applicationVariables: {}, duration: 0, r: {
|
|
19
|
+
resource: {
|
|
20
|
+
updatedAt: '',
|
|
21
|
+
createdAt: ''
|
|
22
|
+
},
|
|
23
|
+
presentationsPlaylists: []
|
|
24
|
+
} }, overrides)); };
|
|
25
|
+
var createApplicationVersion = function (overrides) { return (__assign({ id: 'id', name: 'name', applicationId: 'applicationId', embeddedUrlFormat: null, configurableDuration: false, sourceUrl: null, presentationProperties: [] }, overrides)); };
|
|
36
26
|
test('Replaces variable in query parameteers', function () {
|
|
37
|
-
expect(
|
|
38
|
-
embeddedUrlFormat: 'https://example.com?foo=:foo'
|
|
39
|
-
})
|
|
27
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
28
|
+
embeddedUrlFormat: 'https://example.com?foo=:foo'
|
|
29
|
+
}))).toBe('https://example.com?foo=bar');
|
|
40
30
|
});
|
|
41
31
|
test('Replaces variable in path', function () {
|
|
42
|
-
expect(
|
|
43
|
-
embeddedUrlFormat: 'https://example.com/:foo'
|
|
44
|
-
})
|
|
32
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
33
|
+
embeddedUrlFormat: 'https://example.com/:foo'
|
|
34
|
+
}))).toBe('https://example.com/bar');
|
|
45
35
|
});
|
|
46
36
|
test('Replaces undefined variable with empty string', function () {
|
|
47
|
-
expect(
|
|
48
|
-
embeddedUrlFormat: 'https://example.com/:foo'
|
|
49
|
-
})
|
|
37
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: {} }), createApplicationVersion({
|
|
38
|
+
embeddedUrlFormat: 'https://example.com/:foo'
|
|
39
|
+
}))).toBe('https://example.com/');
|
|
50
40
|
});
|
|
51
41
|
test('Replaces variable with underscore', function () {
|
|
52
|
-
expect(
|
|
53
|
-
embeddedUrlFormat: 'https://example.com/:foo_1'
|
|
54
|
-
})
|
|
42
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo_1: 'bar' } }), createApplicationVersion({
|
|
43
|
+
embeddedUrlFormat: 'https://example.com/:foo_1'
|
|
44
|
+
}))).toBe('https://example.com/bar');
|
|
55
45
|
});
|
|
56
46
|
test('Replaces variable with hyphen', function () {
|
|
57
|
-
expect(
|
|
58
|
-
embeddedUrlFormat: 'https://example.com/:foo-1'
|
|
59
|
-
})
|
|
47
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { 'foo-1': 'bar' } }), createApplicationVersion({
|
|
48
|
+
embeddedUrlFormat: 'https://example.com/:foo-1'
|
|
49
|
+
}))).toBe('https://example.com/bar');
|
|
60
50
|
});
|
|
61
51
|
test('Does not replace variable that is a number', function () {
|
|
62
|
-
expect(
|
|
63
|
-
embeddedUrlFormat: 'http://localhost:8080?foo=:foo'
|
|
64
|
-
})
|
|
52
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: 'bar' } }), createApplicationVersion({
|
|
53
|
+
embeddedUrlFormat: 'http://localhost:8080?foo=:foo'
|
|
54
|
+
}))).toBe('http://localhost:8080?foo=bar');
|
|
65
55
|
});
|
|
66
56
|
test('Encodes a variables containing special characters', function () {
|
|
67
57
|
var fooValue = 'Lorem Ipsum. !@#$%^&*()-. More Text';
|
|
68
58
|
var fooValueEncoded = 'Lorem%20Ipsum.%20!%40%23%24%25%5E%26*()-.%20More%20Text';
|
|
69
|
-
expect(
|
|
70
|
-
embeddedUrlFormat: "http://localhost:8080?foo=:foo"
|
|
71
|
-
})
|
|
59
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: fooValue } }), createApplicationVersion({
|
|
60
|
+
embeddedUrlFormat: "http://localhost:8080?foo=:foo"
|
|
61
|
+
}))).toBe("http://localhost:8080?foo=" + fooValueEncoded);
|
|
72
62
|
});
|
|
73
63
|
test('Does not encode value if presentation property disables encoding', function () {
|
|
74
|
-
expect(
|
|
75
|
-
applicationVariables: { url: 'https://raydiant.com' }
|
|
64
|
+
expect(embeddedApps_1.default(createPresentation({
|
|
65
|
+
applicationVariables: { url: 'https://raydiant.com' }
|
|
76
66
|
}), createApplicationVersion({
|
|
77
67
|
embeddedUrlFormat: ":url",
|
|
78
|
-
presentationProperties: [
|
|
79
|
-
|
|
80
|
-
],
|
|
81
|
-
}), createMetadata())).toBe("https://raydiant.com");
|
|
68
|
+
presentationProperties: [{ name: 'url', encode: false }]
|
|
69
|
+
}))).toBe("https://raydiant.com");
|
|
82
70
|
});
|
|
83
71
|
test('Encodes a variables containing an array', function () {
|
|
84
72
|
var fooValue = ['option-a', 'option-b', 'option-c'];
|
|
85
73
|
var fooValueEncoded = '%5B%22option-a%22%2C%22option-b%22%2C%22option-c%22%5D';
|
|
86
|
-
expect(
|
|
87
|
-
embeddedUrlFormat: "http://localhost:8080?foo=:foo"
|
|
88
|
-
})
|
|
89
|
-
});
|
|
90
|
-
test('Replaces $renderMode with metadata', function () {
|
|
91
|
-
var presentation = createPresentation();
|
|
92
|
-
var applicationVersion = createApplicationVersion({
|
|
93
|
-
embeddedUrlFormat: 'https://example.com?renderMode=:$renderMode',
|
|
94
|
-
});
|
|
95
|
-
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata({ renderMode: 'preview' }))).toBe('https://example.com?renderMode=preview');
|
|
96
|
-
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata({ renderMode: 'live' }))).toBe('https://example.com?renderMode=live');
|
|
97
|
-
});
|
|
98
|
-
test('Replaces undefined metadata with empty string', function () {
|
|
99
|
-
var presentation = createPresentation();
|
|
100
|
-
var applicationVersion = createApplicationVersion({
|
|
101
|
-
embeddedUrlFormat: 'https://example.com?invalid=:$invalid',
|
|
102
|
-
});
|
|
103
|
-
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata())).toBe('https://example.com?invalid=');
|
|
104
|
-
});
|
|
105
|
-
test('Replace protocol, ip and port', function () {
|
|
106
|
-
expect((0, embeddedApps_1.default)(createPresentation({
|
|
107
|
-
applicationVariables: {
|
|
108
|
-
protocol: 'http',
|
|
109
|
-
ip: '192.168.1.0',
|
|
110
|
-
port: 3000,
|
|
111
|
-
},
|
|
112
|
-
}), createApplicationVersion({
|
|
113
|
-
embeddedUrlFormat: ":protocol://:ip::port",
|
|
114
|
-
}), createMetadata())).toBe("http://192.168.1.0:3000");
|
|
115
|
-
});
|
|
116
|
-
test('File input uses url as value', function () {
|
|
117
|
-
expect((0, embeddedApps_1.default)(createPresentation({
|
|
118
|
-
applicationVariables: { file: { url: 'https://image.png' } },
|
|
119
|
-
}), createApplicationVersion({
|
|
120
|
-
embeddedUrlFormat: "https://example.come?image=:file",
|
|
121
|
-
presentationProperties: [{ type: 'file', name: 'file' }],
|
|
122
|
-
}), createMetadata())).toBe("https://example.come?image=".concat(encodeURIComponent('https://image.png')));
|
|
123
|
-
});
|
|
124
|
-
test('Replaces $token with presentation token', function () {
|
|
125
|
-
var presentation = createPresentation({ token: 'abc' });
|
|
126
|
-
var applicationVersion = createApplicationVersion({
|
|
127
|
-
embeddedUrlFormat: 'https://example.com?token=:$token',
|
|
128
|
-
});
|
|
129
|
-
expect((0, embeddedApps_1.default)(presentation, applicationVersion, createMetadata())).toBe('https://example.com?token=abc');
|
|
74
|
+
expect(embeddedApps_1.default(createPresentation({ applicationVariables: { foo: fooValue } }), createApplicationVersion({
|
|
75
|
+
embeddedUrlFormat: "http://localhost:8080?foo=:foo"
|
|
76
|
+
}))).toBe("http://localhost:8080?foo=" + fooValueEncoded);
|
|
130
77
|
});
|
package/build/index.js
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
2
|
+
function __export(m) {
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
+
}
|
|
16
5
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
6
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
7
|
};
|
|
19
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.PresentationWindow = exports.PlaylistWindowManagerState = exports.PlaylistWindowManager = void 0;
|
|
21
9
|
var PlaylistWindowManager_1 = __importDefault(require("./PlaylistWindowManager"));
|
|
22
10
|
exports.PlaylistWindowManager = PlaylistWindowManager_1.default;
|
|
23
|
-
|
|
11
|
+
__export(require("./PlaylistWindowManager"));
|
|
24
12
|
var PlaylistWindowManagerState_1 = __importDefault(require("./PlaylistWindowManagerState"));
|
|
25
13
|
exports.PlaylistWindowManagerState = PlaylistWindowManagerState_1.default;
|
|
26
|
-
|
|
14
|
+
__export(require("./PlaylistWindowManagerState"));
|
|
27
15
|
var PresentationWindow_1 = __importDefault(require("./PresentationWindow"));
|
|
28
16
|
exports.PresentationWindow = PresentationWindow_1.default;
|
|
29
|
-
|
|
30
|
-
__exportStar(require("./types"), exports);
|
|
17
|
+
__export(require("./PresentationWindow"));
|
package/build/preload.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var electron_1 = require("electron");
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
electron_1.ipcRenderer.send(windowId, type, payload);
|
|
7
|
-
}
|
|
3
|
+
var electron_1 = require("electron"); // eslint-disable-line
|
|
4
|
+
var sendMessage = function (windowId, type, payload) {
|
|
5
|
+
electron_1.ipcRenderer.send.apply(electron_1.ipcRenderer, [windowId, type].concat(payload));
|
|
8
6
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
electron_1.ipcRenderer.on('electron-main', function (_, message) {
|
|
14
|
-
if (typeof internals.receiveMessage === 'function') {
|
|
15
|
-
internals.receiveMessage(message);
|
|
7
|
+
var messageHandler = function (_, message) {
|
|
8
|
+
var receiveMessage = window.receiveMessage;
|
|
9
|
+
if (typeof receiveMessage === 'function') {
|
|
10
|
+
receiveMessage(message);
|
|
16
11
|
}
|
|
17
12
|
else {
|
|
18
|
-
|
|
13
|
+
throw new Error('receiveMessage is not defined');
|
|
19
14
|
}
|
|
20
|
-
}
|
|
15
|
+
};
|
|
16
|
+
// Add sendMessage and messageHandler to window so that app renderer knows we're
|
|
17
|
+
// running in an Electron environment.
|
|
18
|
+
window.sendMessage = sendMessage;
|
|
19
|
+
window.messageHandler = messageHandler;
|
|
20
|
+
electron_1.ipcRenderer.on('electron-main', messageHandler);
|
package/build/types.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export interface Presentation {
|
|
|
19
19
|
playlistId: string;
|
|
20
20
|
}>;
|
|
21
21
|
};
|
|
22
|
-
token?: string;
|
|
23
22
|
}
|
|
24
23
|
export interface ApplicationVersion {
|
|
25
24
|
id: string;
|
|
@@ -30,7 +29,6 @@ export interface ApplicationVersion {
|
|
|
30
29
|
sourceUrl: string | null;
|
|
31
30
|
presentationProperties: Array<{
|
|
32
31
|
name: string;
|
|
33
|
-
type: string;
|
|
34
32
|
encode?: boolean;
|
|
35
33
|
}>;
|
|
36
34
|
}
|
|
@@ -73,12 +71,6 @@ export interface WindowBounds {
|
|
|
73
71
|
width: number;
|
|
74
72
|
height: number;
|
|
75
73
|
}
|
|
76
|
-
export interface WorkerState {
|
|
77
|
-
[key: string]: any;
|
|
78
|
-
}
|
|
79
|
-
export interface PreviewState {
|
|
80
|
-
inputs: Record<string, any>;
|
|
81
|
-
}
|
|
82
74
|
export interface CreateWindowOptions {
|
|
83
75
|
windowId: string;
|
|
84
76
|
parentWindowId?: string;
|
|
@@ -108,8 +100,7 @@ export interface PresentationWindowRenderer {
|
|
|
108
100
|
showWindow(windowId: string, isFocused: boolean): void;
|
|
109
101
|
hideWindow(windowId: string): void;
|
|
110
102
|
removeWindow(windowId: string): Promise<void>;
|
|
111
|
-
|
|
112
|
-
sendMessageObject(windowId: string, type: string, payload?: any): void;
|
|
103
|
+
sendMessage(windowId: string, message: string): void;
|
|
113
104
|
muteWindow(windowId: string): void;
|
|
114
105
|
unMuteWindow(windowId: string): void;
|
|
115
106
|
}
|
|
@@ -124,7 +115,7 @@ export interface OpenChildWindowOptions {
|
|
|
124
115
|
isMuted: boolean;
|
|
125
116
|
theme?: Theme;
|
|
126
117
|
}
|
|
127
|
-
export type Path = Array<string | number>;
|
|
118
|
+
export declare type Path = Array<string | number>;
|
|
128
119
|
export interface BuilderState {
|
|
129
120
|
inputs: InputState[];
|
|
130
121
|
profileId?: string;
|
|
@@ -133,36 +124,3 @@ export interface InputState {
|
|
|
133
124
|
path: Path;
|
|
134
125
|
state: any;
|
|
135
126
|
}
|
|
136
|
-
export interface EmbeddedAppMetadata {
|
|
137
|
-
renderMode: 'preview' | 'live';
|
|
138
|
-
}
|
|
139
|
-
export interface AnalyticsEvent {
|
|
140
|
-
type: string;
|
|
141
|
-
source: string;
|
|
142
|
-
productCategory?: string | null;
|
|
143
|
-
}
|
|
144
|
-
export interface ChargeRequest {
|
|
145
|
-
requestId: string;
|
|
146
|
-
amount: number;
|
|
147
|
-
items: Array<{
|
|
148
|
-
name: string;
|
|
149
|
-
price: number;
|
|
150
|
-
description?: string;
|
|
151
|
-
sku?: string;
|
|
152
|
-
quantity?: number;
|
|
153
|
-
}>;
|
|
154
|
-
}
|
|
155
|
-
export interface Charge {
|
|
156
|
-
id: string;
|
|
157
|
-
status: string;
|
|
158
|
-
}
|
|
159
|
-
export interface ChargeResponse {
|
|
160
|
-
requestId: string;
|
|
161
|
-
charge?: Charge;
|
|
162
|
-
error?: {
|
|
163
|
-
message: string;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
export interface Terminal {
|
|
167
|
-
status: string;
|
|
168
|
-
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { BrowserWindow, BrowserView, ipcMain, IpcMainEvent } from 'electron';
|
|
|
3
3
|
import {
|
|
4
4
|
PresentationWindowRenderer,
|
|
5
5
|
CreateWindowOptions,
|
|
6
|
-
WindowBounds
|
|
6
|
+
WindowBounds
|
|
7
7
|
} from './types';
|
|
8
8
|
|
|
9
9
|
interface BrowserViewRendererWindow {
|
|
@@ -31,14 +31,15 @@ export default class BrowserViewRenderer implements PresentationWindowRenderer {
|
|
|
31
31
|
parentWindowId,
|
|
32
32
|
bounds,
|
|
33
33
|
backgroundColor,
|
|
34
|
-
receiveMessageCallback
|
|
34
|
+
receiveMessageCallback
|
|
35
35
|
}: CreateWindowOptions) {
|
|
36
36
|
const window = {
|
|
37
37
|
view: new BrowserView({
|
|
38
38
|
webPreferences: {
|
|
39
39
|
preload: path.join(__dirname, 'preload.js'),
|
|
40
40
|
contextIsolation: false,
|
|
41
|
-
|
|
41
|
+
backgroundThrottling: false
|
|
42
|
+
}
|
|
42
43
|
}),
|
|
43
44
|
|
|
44
45
|
bounds: bounds || { ...this.mainWindow.getBounds(), x: 0, y: 0 },
|
|
@@ -51,7 +52,7 @@ export default class BrowserViewRenderer implements PresentationWindowRenderer {
|
|
|
51
52
|
if (receiveMessageCallback) {
|
|
52
53
|
receiveMessageCallback(type, payload);
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
this.windows[windowId] = window;
|
|
@@ -70,7 +71,7 @@ export default class BrowserViewRenderer implements PresentationWindowRenderer {
|
|
|
70
71
|
if (!parentWindowId) {
|
|
71
72
|
window.view.setAutoResize({
|
|
72
73
|
width: true,
|
|
73
|
-
height: true
|
|
74
|
+
height: true
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
Event,
|
|
8
8
|
BrowserWindowConstructorOptions,
|
|
9
9
|
BrowserViewConstructorOptions,
|
|
10
|
-
RenderProcessGoneDetails
|
|
10
|
+
RenderProcessGoneDetails
|
|
11
11
|
} from 'electron';
|
|
12
12
|
import {
|
|
13
13
|
PresentationWindowRenderer,
|
|
14
14
|
CreateWindowOptions,
|
|
15
15
|
WindowBounds,
|
|
16
|
-
Logger
|
|
16
|
+
Logger
|
|
17
17
|
} from './types';
|
|
18
18
|
import WindowUnresponsiveError from './WindowUnresponsiveError';
|
|
19
19
|
|
|
@@ -50,8 +50,7 @@ interface BrowserWindowRendererOptions {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export default class BrowserWindowRenderer
|
|
53
|
-
implements PresentationWindowRenderer
|
|
54
|
-
{
|
|
53
|
+
implements PresentationWindowRenderer {
|
|
55
54
|
private windows: {
|
|
56
55
|
[windowId: string]: BrowserWindowRendererWindow;
|
|
57
56
|
} = {};
|
|
@@ -68,7 +67,8 @@ export default class BrowserWindowRenderer
|
|
|
68
67
|
webPreferences: {
|
|
69
68
|
preload: path.join(__dirname, 'preload.js'),
|
|
70
69
|
contextIsolation: false,
|
|
71
|
-
|
|
70
|
+
backgroundThrottling: false
|
|
71
|
+
}
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
private proxySettings: ProxySettings | null = null;
|
|
@@ -94,7 +94,7 @@ export default class BrowserWindowRenderer
|
|
|
94
94
|
bounds = this.opts.bounds,
|
|
95
95
|
backgroundColor,
|
|
96
96
|
receiveMessageCallback,
|
|
97
|
-
errorCallback
|
|
97
|
+
errorCallback
|
|
98
98
|
}: CreateWindowOptions) {
|
|
99
99
|
const window: BrowserWindowRendererWindow = {
|
|
100
100
|
parentWindowId,
|
|
@@ -106,7 +106,8 @@ export default class BrowserWindowRenderer
|
|
|
106
106
|
webPreferences: {
|
|
107
107
|
preload: path.join(__dirname, 'preload.js'),
|
|
108
108
|
contextIsolation: false,
|
|
109
|
-
|
|
109
|
+
backgroundThrottling: false
|
|
110
|
+
}
|
|
110
111
|
})
|
|
111
112
|
: this.createOrGetPooledBrowserWindow(windowId, {
|
|
112
113
|
show: false,
|
|
@@ -121,7 +122,8 @@ export default class BrowserWindowRenderer
|
|
|
121
122
|
webPreferences: {
|
|
122
123
|
preload: path.join(__dirname, 'preload.js'),
|
|
123
124
|
contextIsolation: false,
|
|
124
|
-
|
|
125
|
+
backgroundThrottling: false
|
|
126
|
+
}
|
|
125
127
|
}),
|
|
126
128
|
// If we are creating a child window and renderChildWindowsAsBrowserViews is false that means
|
|
127
129
|
// we are rendering child windows with BrowserWindow. BrowserWindows are positioned absolutely so
|
|
@@ -132,7 +134,7 @@ export default class BrowserWindowRenderer
|
|
|
132
134
|
? {
|
|
133
135
|
...bounds,
|
|
134
136
|
x: bounds.x + this.opts.bounds.x,
|
|
135
|
-
y: bounds.y + this.opts.bounds.y
|
|
137
|
+
y: bounds.y + this.opts.bounds.y
|
|
136
138
|
}
|
|
137
139
|
: bounds,
|
|
138
140
|
|
|
@@ -173,7 +175,7 @@ export default class BrowserWindowRenderer
|
|
|
173
175
|
`Window '${windowId}' render process gone`
|
|
174
176
|
)
|
|
175
177
|
);
|
|
176
|
-
}
|
|
178
|
+
}
|
|
177
179
|
};
|
|
178
180
|
|
|
179
181
|
// Attached crash handlers to skip presentation on error.
|
|
@@ -236,7 +238,7 @@ export default class BrowserWindowRenderer
|
|
|
236
238
|
window.view.setBounds({
|
|
237
239
|
...window.bounds,
|
|
238
240
|
x: window.bounds.x + this.opts.bounds.x,
|
|
239
|
-
y: window.bounds.y + this.opts.bounds.y
|
|
241
|
+
y: window.bounds.y + this.opts.bounds.y
|
|
240
242
|
});
|
|
241
243
|
} else {
|
|
242
244
|
window.view.setBounds(window.bounds);
|
|
@@ -457,7 +459,7 @@ export default class BrowserWindowRenderer
|
|
|
457
459
|
this.logger.info(`Found free browser window from pool`, { windowId });
|
|
458
460
|
} else {
|
|
459
461
|
this.logger.info(`No free browser windows, adding new window to pool`, {
|
|
460
|
-
windowId
|
|
462
|
+
windowId
|
|
461
463
|
});
|
|
462
464
|
}
|
|
463
465
|
}
|
|
@@ -507,7 +509,7 @@ export default class BrowserWindowRenderer
|
|
|
507
509
|
this.logger.info(`Found free browser view from pool`, { windowId });
|
|
508
510
|
} else {
|
|
509
511
|
this.logger.info(`No free browser views, adding new view to pool`, {
|
|
510
|
-
windowId
|
|
512
|
+
windowId
|
|
511
513
|
});
|
|
512
514
|
}
|
|
513
515
|
}
|
|
@@ -589,7 +591,7 @@ class WindowPool<T extends BrowserWindow | BrowserView> {
|
|
|
589
591
|
return {
|
|
590
592
|
total: inuse + free,
|
|
591
593
|
inuse,
|
|
592
|
-
free
|
|
594
|
+
free
|
|
593
595
|
};
|
|
594
596
|
}
|
|
595
597
|
}
|