Socket
Socket
Sign inDemoInstall

backpage

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backpage - npm Package Compare versions

Comparing version 0.0.1-14 to 0.0.1-15

2

bld/backpage/backpage.d.ts

@@ -22,3 +22,3 @@ import type { ReactNode } from 'react';

*/
guide(): Promise<void>;
guide(): void;
render(node: ReactNode): void;

@@ -25,0 +25,0 @@ unmount(): void;

@@ -86,6 +86,5 @@ import { createRequire } from 'module';

*/
async guide() {
const url = await this.getURL();
console.info(`\
guide() {
void this.getURL().then(url => {
console.info(`
${Chalk.bold('BackPage')} ${Chalk.dim(`v${version}`)}

@@ -97,2 +96,3 @@

`);
});
}

@@ -99,0 +99,0 @@ render(node) {

@@ -1,1 +0,1 @@

export declare function getPersistentToken(path?: string): Promise<string>;
export declare function getPersistentToken(path?: string): string;
import { randomUUID } from 'crypto';
import { mkdir, readFile, writeFile } from 'fs/promises';
import { mkdirSync, readFileSync, writeFileSync } from 'fs';
import { dirname } from 'path';
export async function getPersistentToken(path = '.backpage/uuid') {
let uuid = await readFile(path, 'utf8').then(text => text.trim(), () => undefined);
export function getPersistentToken(path = '.backpage/uuid') {
let uuid;
try {
uuid = readFileSync(path, 'utf8').trim();
}
catch (_a) {
// ignore
}
if (!uuid) {
uuid = randomUUID();
await mkdir(dirname(path), { recursive: true });
await writeFile(path, uuid);
mkdirSync(dirname(path), { recursive: true });
writeFileSync(path, uuid);
}

@@ -11,0 +17,0 @@ return uuid;

{
"name": "backpage",
"version": "0.0.1-14",
"version": "0.0.1-15",
"description": "Naive static HTML streaming based on React for Node.js CLI applications.",

@@ -5,0 +5,0 @@ "repository": "https://github.com/vilicvane/backpage.git",

@@ -34,3 +34,3 @@ [![NPM version](https://img.shields.io/npm/v/backpage?color=%23cb3837&style=flat-square)](https://www.npmjs.com/package/backpage)

import {BackPage} from 'backpage';
import React, {useState, useEffect} from 'react';
import React from 'react';

@@ -44,3 +44,3 @@ import {App} from './app.js';

// Print page information including URL.
await page.guide();
page.guide();

@@ -54,2 +54,4 @@ // Send notification to browser (if connected).

```tsx
import React, {useState, useEffect} from 'react';
export const App = () => {

@@ -80,3 +82,3 @@ const [count, setCount] = useState(0);

// You can also use any random UUID for temporary page.
token: await getPersistentToken(),
token: getPersistentToken(),
// Different pages can be setup using the same token with different names.

@@ -86,3 +88,3 @@ name: 'project-name',

await page.guide();
page.guide();
```

@@ -89,0 +91,0 @@

import {randomUUID} from 'crypto';
import {mkdir, readFile, writeFile} from 'fs/promises';
import {mkdirSync, readFileSync, writeFileSync} from 'fs';
import {dirname} from 'path';
export async function getPersistentToken(
path = '.backpage/uuid',
): Promise<string> {
let uuid = await readFile(path, 'utf8').then(
text => text.trim(),
() => undefined,
);
export function getPersistentToken(path = '.backpage/uuid'): string {
let uuid: string | undefined;
try {
uuid = readFileSync(path, 'utf8').trim();
} catch {
// ignore
}
if (!uuid) {
uuid = randomUUID();
await mkdir(dirname(path), {recursive: true});
await writeFile(path, uuid);
mkdirSync(dirname(path), {recursive: true});
writeFileSync(path, uuid);
}

@@ -19,0 +20,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc