Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump package versions for deploy #1257

Merged
merged 7 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/setup-pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ runs:
version: 8
run_install: false

- run: pnpm install -g node-gyp @mapbox/node-pre-gyp
shell: bash

# - name: Get pnpm store directory
# shell: bash
# run: |
Expand Down
3 changes: 2 additions & 1 deletion dev/browser/basic/umd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
</head>
<body>
<script type="module" src="./index.ts"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest/dist/tf.min.js"></script>
<script src="/node_modules/upscaler/node_modules/@upscalerjs/default-model/dist/umd/index.min.js"></script>
<script src="/node_modules/upscaler/dist/browser/umd/upscaler.min.js"></script>
<script src="/node_modules/upscaler/dist/browser/umd/upscaler.js"></script>
</body>
</html>

8 changes: 7 additions & 1 deletion dev/browser/basic/umd/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const upscaler = new window['Upscaler']({
model: window['DefaultUpscalerJSModel'],
model: {
...window['DefaultUpscalerJSModel'],
path: '/node_modules/upscaler/node_modules/@upscalerjs/default-model/models/model.json',
},
});

import flower from '../flower-small.png';
upscaler.upscale(flower).then(console.log);
Binary file added dev/browser/deployed/flower-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions dev/browser/deployed/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>UpscalerJS Development: Deployed model</title>
<link rel="stylesheet" href="../global.css" />
</head>
<body>
<script type="module" src="./index.ts"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@upscalerjs/default-model@latest/dist/umd/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/upscaler@latest/dist/browser/umd/upscaler.min.js"></script>
</body>
</html>

7 changes: 7 additions & 0 deletions dev/browser/deployed/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const upscaler = new window['Upscaler']({
model: window['DefaultUpscalerJSModel'],
})

import flower from './flower-small.png';
upscaler.upscale(flower).then(console.log);

1 change: 1 addition & 0 deletions dev/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<body>
<ul>
<li><a href="/basic/">Basic</a></li>
<li><a href="/deployed/">Deployed</a></li>
<li><a href="/speed-tests/">Speed Tests</a></li>
<li><a href="/specific-model/">Specific Model</a></li>
<li><a href="/generate-homepage-gif/">Generate Homepage GIF</a></li>
Expand Down
1 change: 1 addition & 0 deletions dev/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"devDependencies": {
"@types/stats.js": "^0.17.0",
"@upscalerjs/default-model": "workspace:*",
"@upscalerjs/esrgan-legacy": "workspace:*",
"@upscalerjs/esrgan-medium": "workspace:*",
"@upscalerjs/esrgan-slim": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions internals/http-server/src/HttpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export class HttpServer {
this.port = getServerPort(httpServer);
if (this.useTunnel) {
this.tunnel = new Tunnel(this.port);
info('Starting server with tunnel');
info('Starting server with tunnel', this.name);
await this.tunnel.start();
info('Tunnel started', this.url);
info('Tunnel started', this.url, this.name);
}
const url = this.url;
if (!url) {
Expand Down
88 changes: 13 additions & 75 deletions internals/http-server/src/Tunnel.ts
Original file line number Diff line number Diff line change
@@ -1,95 +1,33 @@
import { tunnelmole } from 'tunnelmole';
// import localtunnel from 'localtunnel';
// import ngrok from 'ngrok';
// import { info, warn } from '@internals/common/logger';
// import { service, tunnel } from "cloudflared";
// import { warn } from '@internals/common/logger';
// import path from 'path';
// import * as url from 'url';

// const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
process.env.TUNNELMOLE_TELEMETRY = '0';

const regexp = new RegExp(/^http(.*) is forwarding to(.*)/);
const silenceTunnelmoleOutput = () => {
const origInfo = console.info;
console.info = (msg: string) => {
if (!regexp.test(msg)) {
origInfo.call(console, msg);
}
};
};
process.env.TUNNELMOLE_QUIET_MODE = '1';

// const regexp = new RegExp(/^http(.*) is forwarding to(.*)/);
// const silenceTunnelmoleOutput = () => {
// const origInfo = console.info;
// console.info = (msg: string) => {
// if (!regexp.test(msg)) {
// origInfo.call(console, msg);
// }
// };
// };

export class Tunnel {
port: number;
// private localtunnel?: ReturnType<typeof localtunnel>;
url?: string;
// private _stop: any;


constructor(port: number) {
this.port = port;
}

// get url() {
// // if (!this.localtunnel) {
// // throw new Error('Tunnel was never started, ensure you call start');
// // }
// // return this.localtunnel?.url;
// }

async start() {
// ngrok
// this.url = await ngrok.connect({
// addr: this.port,
// });

// local tunnel
// console.log(this.port)
// this.localtunnel = await localtunnel({ port: this.port });
// return this.localtunnel.url;


// tunnelmole
silenceTunnelmoleOutput();
// // silenceTunnelmoleOutput();
this.url = await tunnelmole({
port: this.port,
});
return this.url;

// // cloudflared
// const { url, stop, child, ...rest } = tunnel({ "--url": `localhost:${this.port}`, '--config': path.resolve(__dirname, './config.yaml')});

// child?.stdout?.on('data', data => console.log(data.toString()));
// child?.stderr?.on('data', data => console.log(data.toString()));
// console.log(rest, url)
// this._stop = stop;
// const timers = [
// setTimeout(() => {
// warn('Still awaiting cloudflare tunnel to start')
// }, 3000),
// setTimeout(() => {
// throw new Error('Cloudflare tunnel failed to start in 10 seconds')
// }, 5000),
// ];
// this.url = await url;
// timers.forEach(clearTimeout);
// return url;
}

async close() { // skipcq: JS-0105
// if (!this._stop) {
// throw new Error('No stop command was set')
// }
// return this._stop();
// localtunnel
// return new Promise(resolve => {
// if (this.localtunnel) {
// this.localtunnel.on('close', () => {
// info('tunnel has been closed');
// });
// } else {
// warn('Tunnel was never started, so it cannot be closed');
// }
// });
}
}
6 changes: 6 additions & 0 deletions internals/test-runner/src/ClientsideTestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,14 @@ export class ClientsideTestRunner {
});

// Note: these must be done sequentially; there's a race condition bug in tunnelmole
const timer = setTimeout(() => {
throw new Error('Could not start servers within 3 seconds');
}, 3000);

await this.fixturesServer.start();
await this.server.start();

clearTimeout(timer);
}

async stopServers(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion models/default-model/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upscalerjs/default-model",
"version": "1.0.0-beta.16",
"version": "1.0.0-beta.17",
"description": "ESRGAN Default Model for UpscalerJS. Upscale images and increase image resolution with AI using Javascript",
"keywords": [
"image enhancement",
Expand Down
2 changes: 1 addition & 1 deletion models/esrgan-legacy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upscalerjs/esrgan-legacy",
"version": "1.0.0-beta.13",
"version": "1.0.0-beta.14",
"description": "ESRGAN Legacy Models for UpscalerJS. Upscale images and increase image resolution with AI using Javascript",
"keywords": [
"image enhancement",
Expand Down
2 changes: 1 addition & 1 deletion models/esrgan-medium/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upscalerjs/esrgan-medium",
"version": "1.0.0-beta.12",
"version": "1.0.0-beta.13",
"description": "ESRGAN Medium Model for UpscalerJS. Upscale images and increase image resolution with AI using Javascript",
"keywords": [
"image enhancement",
Expand Down
2 changes: 1 addition & 1 deletion models/esrgan-slim/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upscalerjs/esrgan-slim",
"version": "1.0.0-beta.11",
"version": "1.0.0-beta.12",
"description": "ESRGAN Slim Model for UpscalerJS. Upscale images and increase image resolution with AI using Javascript",
"keywords": [
"image enhancement",
Expand Down
2 changes: 1 addition & 1 deletion models/esrgan-thick/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upscalerjs/esrgan-thick",
"version": "1.0.0-beta.15",
"version": "1.0.0-beta.16",
"description": "ESRGAN Thick Model for UpscalerJS. Upscale images and increase image resolution with AI using Javascript",
"keywords": [
"image enhancement",
Expand Down
2 changes: 1 addition & 1 deletion packages/upscalerjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "upscaler",
"version": "1.0.0-beta.18",
"version": "1.0.0-beta.19",
"description": "Enhance Images with Javascript and AI. Increase resolution, retouch, denoise, and more. Open Source, Browser and Node Compatible, MIT License.",
"exports": {
"./node": {
Expand Down
Loading
Loading