@youcan/cli 1.0.2 → 1.0.4
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/bin/index.js
CHANGED
|
@@ -108,6 +108,7 @@ function command(cli) {
|
|
|
108
108
|
description: 'starts a dev server and watches over the current directory',
|
|
109
109
|
options: [
|
|
110
110
|
{ name: '-p, --preview', description: 'opens a preview window' },
|
|
111
|
+
{ name: '-d, --disable-hardware-acceleration', description: 'disable hardware acceleration' },
|
|
111
112
|
],
|
|
112
113
|
action: async (options) => {
|
|
113
114
|
let socket;
|
|
@@ -125,7 +126,7 @@ function command(cli) {
|
|
|
125
126
|
if (options.preview) {
|
|
126
127
|
socket = connectPreviewServer();
|
|
127
128
|
socket.emit('theme:dev', { themeId });
|
|
128
|
-
previewTheme(`https://${domain}/themes/${themeId}/preview
|
|
129
|
+
previewTheme(`https://${domain}/themes/${themeId}/preview`, options);
|
|
129
130
|
}
|
|
130
131
|
stdout.info(`Watching for changes in ${kleur.bold().white(cwd())}...`);
|
|
131
132
|
chokidar
|
|
@@ -4,12 +4,15 @@ import puppeteer from 'puppeteer';
|
|
|
4
4
|
import stdout from '../../utils/system/stdout.js';
|
|
5
5
|
import config from '../../config/index.js';
|
|
6
6
|
|
|
7
|
-
async function openPreviewPage(url) {
|
|
8
|
-
const
|
|
7
|
+
async function openPreviewPage(url, disableHardwareAcceleration) {
|
|
8
|
+
const options = {
|
|
9
9
|
headless: false,
|
|
10
10
|
defaultViewport: null,
|
|
11
11
|
userDataDir: '/tmp/youcan_puppeteer',
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
|
+
if (disableHardwareAcceleration)
|
|
14
|
+
options.args = ['--disable-gpu'];
|
|
15
|
+
const browser = await puppeteer.launch(options);
|
|
13
16
|
browser.on('disconnected', () => {
|
|
14
17
|
stdout.info('Browser closed');
|
|
15
18
|
return process.exit(0);
|
|
@@ -18,10 +21,10 @@ async function openPreviewPage(url) {
|
|
|
18
21
|
await page.goto(url);
|
|
19
22
|
return page;
|
|
20
23
|
}
|
|
21
|
-
async function previewTheme(url) {
|
|
24
|
+
async function previewTheme(url, options) {
|
|
22
25
|
const httpServer = createServer();
|
|
23
26
|
const io = new Server(httpServer);
|
|
24
|
-
const previewPage = await openPreviewPage(url);
|
|
27
|
+
const previewPage = await openPreviewPage(url, options.disableHardwareAcceleration);
|
|
25
28
|
io.on('connection', (socket) => {
|
|
26
29
|
socket.on('theme:update', async () => {
|
|
27
30
|
await previewPage.reload({ waitUntil: 'domcontentloaded' });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function previewTheme(url: string): Promise<void>;
|
|
1
|
+
export default function previewTheme(url: string, options: Record<string, string>): Promise<void>;
|