Comparing version 0.0.1-11 to 0.0.1-12
import type { ReactNode } from 'react'; | ||
import type { TunnelNotification, TunnelNotifyOptions } from './tunnel.js'; | ||
import type { FrontPageTunnelOptions } from './tunnels/index.js'; | ||
export type BackPageOptions = FrontPageTunnelOptions & { | ||
import type { CloudTunnelOptions, FrontPageTunnelOptions } from './tunnels/index.js'; | ||
export type BackPageOptions = (FrontPageTunnelOptions | CloudTunnelOptions) & { | ||
title?: string; | ||
@@ -6,0 +6,0 @@ notify?: Partial<TunnelNotifyOptions> & { |
@@ -7,3 +7,3 @@ import { createRequire } from 'module'; | ||
import { BackPageContext } from './components/index.js'; | ||
import { FrontPageTunnel } from './tunnels/index.js'; | ||
import { CloudTunnel, FrontPageTunnel } from './tunnels/index.js'; | ||
const require = createRequire(import.meta.url); | ||
@@ -52,3 +52,6 @@ const { version, description } = require('../../package.json'); | ||
}; | ||
this.tunnel = new FrontPageTunnel(options); | ||
this.tunnel = | ||
'token' in options | ||
? new CloudTunnel(options) | ||
: new FrontPageTunnel(options); | ||
const notifyFallback = notifyOptions === null || notifyOptions === void 0 ? void 0 : notifyOptions.fallback; | ||
@@ -55,0 +58,0 @@ if (notifyFallback) { |
export * from './backpage.js'; | ||
export * from './components/index.js'; | ||
export * from './paths.js'; | ||
export * from './tunnel.js'; | ||
export * from './tunnels/index.js'; |
@@ -8,4 +8,5 @@ import { window } from './@jsdom.js'; | ||
export * from './components/index.js'; | ||
export * from './paths.js'; | ||
export * from './tunnel.js'; | ||
export * from './tunnels/index.js'; | ||
//# sourceMappingURL=index.js.map |
import { createServer } from 'http'; | ||
import Express from 'express'; | ||
import ExpressWS from 'express-ws'; | ||
import { FRONTPAGE_BUNDLED_PATH, FRONTPAGE_INDEX_PATH, FRONTPAGE_RES_DIR, } from '../@paths.js'; | ||
import { FRONTPAGE_BUNDLED_PATH, FRONTPAGE_INDEX_PATH, FRONTPAGE_RES_DIR, } from '../paths.js'; | ||
import { Tunnel, TunnelClient } from '../tunnel.js'; | ||
@@ -61,6 +61,4 @@ const HOST_DEFAULT = 'localhost'; | ||
ws.on('message', data => { | ||
if (typeof data === 'string') { | ||
const message = JSON.parse(data); | ||
this.emitMessage(message); | ||
} | ||
const message = JSON.parse(data.toString()); | ||
this.emitMessage(message); | ||
}); | ||
@@ -67,0 +65,0 @@ } |
@@ -0,1 +1,2 @@ | ||
export * from './cloud-tunnel.js'; | ||
export * from './frontpage-tunnel.js'; |
@@ -0,2 +1,3 @@ | ||
export * from './cloud-tunnel.js'; | ||
export * from './frontpage-tunnel.js'; | ||
//# sourceMappingURL=index.js.map |
import DiffMatchPatch from 'diff-match-patch'; | ||
import morphdom from 'morphdom'; | ||
// Using string replace also handles the case of HTTPS. | ||
const WS_URL = new URL('/', location.href).href.replace(/^http/, 'ws'); | ||
const WS_URL = location.href.replace(/^http/, 'ws'); | ||
const RECONNECT_INTERVAL = 1000; | ||
@@ -15,12 +15,10 @@ const dmp = new DiffMatchPatch(); | ||
ws.addEventListener('message', ({ data }) => { | ||
if (typeof data === 'string') { | ||
const message = JSON.parse(data); | ||
switch (message.type) { | ||
case 'update': | ||
update(message); | ||
break; | ||
case 'notify': | ||
void notify(message); | ||
break; | ||
} | ||
const message = JSON.parse(data); | ||
switch (message.type) { | ||
case 'update': | ||
update(message); | ||
break; | ||
case 'notify': | ||
void notify(message); | ||
break; | ||
} | ||
@@ -27,0 +25,0 @@ }); |
@@ -0,3 +1,5 @@ | ||
export * from './back-cloud-message.js'; | ||
export * from './back-front-message.js'; | ||
export * from './cloud-back-message.js'; | ||
export * from './diff-match-patch.js'; | ||
export * from './front-back-message.js'; |
@@ -0,4 +1,6 @@ | ||
export * from './back-cloud-message.js'; | ||
export * from './back-front-message.js'; | ||
export * from './cloud-back-message.js'; | ||
export * from './diff-match-patch.js'; | ||
export * from './front-back-message.js'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "backpage", | ||
"version": "0.0.1-11", | ||
"version": "0.0.1-12", | ||
"description": "Naive static HTML streaming based on React for Node.js CLI applications.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/vilicvane/backpage.git", |
@@ -10,3 +10,4 @@ import {window} from './@jsdom.js'; | ||
export * from './components/index.js'; | ||
export * from './paths.js'; | ||
export * from './tunnel.js'; | ||
export * from './tunnels/index.js'; |
@@ -14,3 +14,3 @@ import type {Server} from 'http'; | ||
FRONTPAGE_RES_DIR, | ||
} from '../@paths.js'; | ||
} from '../paths.js'; | ||
import {Tunnel, TunnelClient} from '../tunnel.js'; | ||
@@ -82,7 +82,5 @@ | ||
ws.on('message', data => { | ||
if (typeof data === 'string') { | ||
const message = JSON.parse(data) as FrontBackMessage; | ||
const message = JSON.parse(data.toString()) as FrontBackMessage; | ||
this.emitMessage(message); | ||
} | ||
this.emitMessage(message); | ||
}); | ||
@@ -89,0 +87,0 @@ } |
@@ -0,1 +1,2 @@ | ||
export * from './cloud-tunnel.js'; | ||
export * from './frontpage-tunnel.js'; |
@@ -12,3 +12,3 @@ import DiffMatchPatch from 'diff-match-patch'; | ||
// Using string replace also handles the case of HTTPS. | ||
const WS_URL = new URL('/', location.href).href.replace(/^http/, 'ws'); | ||
const WS_URL = location.href.replace(/^http/, 'ws'); | ||
@@ -33,13 +33,11 @@ const RECONNECT_INTERVAL = 1000; | ||
ws.addEventListener('message', ({data}) => { | ||
if (typeof data === 'string') { | ||
const message = JSON.parse(data) as BackFrontMessage; | ||
const message = JSON.parse(data) as BackFrontMessage; | ||
switch (message.type) { | ||
case 'update': | ||
update(message); | ||
break; | ||
case 'notify': | ||
void notify(message); | ||
break; | ||
} | ||
switch (message.type) { | ||
case 'update': | ||
update(message); | ||
break; | ||
case 'notify': | ||
void notify(message); | ||
break; | ||
} | ||
@@ -46,0 +44,0 @@ }); |
@@ -0,3 +1,5 @@ | ||
export * from './back-cloud-message.js'; | ||
export * from './back-front-message.js'; | ||
export * from './cloud-back-message.js'; | ||
export * from './diff-match-patch.js'; | ||
export * from './front-back-message.js'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
201706
90
4648