webxdc-dev
Advanced tools
Comparing version 0.13.1 to 0.14.0
@@ -12,3 +12,8 @@ "use strict"; | ||
const SIMULATOR_PATHS = ["/webxdc.js", "/webxdc", "/webxdc/.websocket"]; | ||
function createFrontend(appInfo, instances, injectFrontend, getIndexHtml, autoOpen) { | ||
const CONTENT_SECURITY_POLICY = `default-src 'self';\ | ||
style-src 'self' 'unsafe-inline' blob: ;\ | ||
font-src 'self' data: blob: ;\ | ||
script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: ;\ | ||
img-src 'self' data: blob: ;`; | ||
function createFrontend(appInfo, instances, injectFrontend, getIndexHtml) { | ||
const expressApp = (0, express_1.default)(); | ||
@@ -47,5 +52,2 @@ const wsInstance = (0, express_ws_1.default)(expressApp); | ||
instance.start(); | ||
if (autoOpen) { | ||
instance.open(); | ||
} | ||
res.json({ | ||
@@ -81,2 +83,6 @@ status: "ok", | ||
injectSim(wsInstance.app); | ||
wsInstance.app.use((req, res, next) => { | ||
res.setHeader("Content-Security-Policy", CONTENT_SECURITY_POLICY); | ||
next(); | ||
}); | ||
if (location.type === "url") { | ||
@@ -83,0 +89,0 @@ // serve webxdc project from URL by proxying |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Instances = void 0; | ||
const ws_1 = require("ws"); | ||
const open_1 = __importDefault(require("open")); | ||
const message_1 = require("./message"); | ||
const waitOn_1 = require("./waitOn"); | ||
const app_1 = require("./app"); | ||
@@ -38,8 +24,2 @@ const color_1 = require("./color"); | ||
} | ||
open() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield (0, waitOn_1.waitOnUrl)(this.url, OPEN_TIMEOUT); | ||
yield (0, open_1.default)(this.url); | ||
}); | ||
} | ||
} | ||
@@ -118,10 +98,2 @@ class Instances { | ||
} | ||
open() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// open the URLs | ||
for (const instance of this.instances.values()) { | ||
yield instance.open(); | ||
} | ||
}); | ||
} | ||
clear() { | ||
@@ -128,0 +100,0 @@ this.processor.clear(); |
@@ -27,6 +27,5 @@ "use strict"; | ||
.option("-p, --port <port>", "start port for webxdc-dev UI, instance ports are incremented by one each", parsePort, 7000) | ||
.option("-o, --open", "Automatically open instance tabs", false) | ||
.description("Run webxdc-dev simulator with webxdc from dev server URL, .xdc file or dist directory") | ||
.action((location, options) => { | ||
(0, run_1.run)(location, options.port, inject, options.open); | ||
(0, run_1.run)(location, options.port, inject); | ||
}); | ||
@@ -33,0 +32,0 @@ return program; |
@@ -13,3 +13,3 @@ "use strict"; | ||
const appInfo_1 = require("./appInfo"); | ||
function actualRun(appInfo, basePort, inject, autoOpen) { | ||
function actualRun(appInfo, basePort, inject) { | ||
const { injectFrontend, injectSim, getIndexHtml } = inject; | ||
@@ -21,3 +21,3 @@ const instances = new instance_1.Instances(appInfo, injectSim, basePort); | ||
} | ||
const frontend = (0, app_1.createFrontend)(appInfo, instances, injectFrontend, getIndexHtml, autoOpen); | ||
const frontend = (0, app_1.createFrontend)(appInfo, instances, injectFrontend, getIndexHtml); | ||
frontend.listen(basePort, () => { | ||
@@ -28,7 +28,4 @@ console.log("Starting webxdc-dev frontend"); | ||
(0, open_1.default)("http://localhost:" + basePort); | ||
if (autoOpen) { | ||
instances.open(); | ||
} | ||
} | ||
function run(locationStr, basePort, inject, autoOpen) { | ||
function run(locationStr, basePort, inject) { | ||
let location; | ||
@@ -53,3 +50,3 @@ try { | ||
.then((appInfo) => { | ||
actualRun(appInfo, basePort, inject, autoOpen); | ||
actualRun(appInfo, basePort, inject); | ||
}) | ||
@@ -56,0 +53,0 @@ .catch((e) => { |
{ | ||
"name": "webxdc-dev", | ||
"version": "0.13.1", | ||
"version": "0.14.0", | ||
"description": "A dev tool for Webxdc", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/webxdc/webxdc-dev#readme", |
{ | ||
"name": "webxdc-dev", | ||
"version": "0.13.1", | ||
"version": "0.14.0", | ||
"description": "A dev tool for Webxdc", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/webxdc/webxdc-dev#readme", |
@@ -31,21 +31,25 @@ # webxdc-dev | ||
When you start `webxdc-dev`, it opens a browser window with the webxdc-dev UI. | ||
Two webxdc application instances are already running. You can click on | ||
instances to open them in new tab. You can also add new instances. | ||
Two webxdc application instances are already running. You can start the | ||
instance in the embedded UI with the start button in each instance header. You | ||
can reload any instance with the reload button. | ||
The "messages" tab lets you see all updates sent and received from the dev | ||
server. Hover over the fields to see the complete text. | ||
You can add new instances by pressing the "Add instance" button. You can reset | ||
all instance state and messages by pressing the "Reset" button. | ||
You can see filtered messages by clicking in the "messages", "sent" and | ||
"received" columns. You can use your browser back button to go back. | ||
The sidebar to the right lets you see all updates sent and received from the | ||
dev server. Hover over the fields to see the complete text. Click on a message | ||
to see full information. You can also filter messages. You can collapse the | ||
sidebar with the arrow. | ||
Each instance header also contains additional information: the port number on | ||
which the instance was opened, the amount of updates this instance sent and | ||
received since last reset. You can click on this information to control | ||
the filters in the messages sidebar. | ||
The "info" tab lets you see basic information about the webxdc application you | ||
are running. | ||
The "mobile" tab shows webxdc instances in iframes instead. On the right side | ||
you can see the messages sent. Click on a message to see more information. You | ||
can also filter messages, and see messages specific to a device by clicking on | ||
the sent & received counts as well as the port number. | ||
The dev tool console shows messages with the same color prefix as the instance | ||
UIs. | ||
The dev tool console shows messages with the same color prefix as well. | ||
### Clean state | ||
@@ -57,4 +61,4 @@ | ||
The UI also lets you clear the state - this refreshes both server and client | ||
state, and is as if you restarted `webxdc-dev`. | ||
The UI also lets you clear the state with the `reset` button - this refreshes | ||
both server and client state, and is as if you restarted `webxdc-dev`. | ||
@@ -61,0 +65,0 @@ ### Running a directory |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
249
331558
1713