Skip to content

Commit

Permalink
chore(playground): remove dependency to platform
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Sep 19, 2024
1 parent 4656093 commit e70b1f9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 419 deletions.
3 changes: 0 additions & 3 deletions commons/lib/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ registerNamespaceMapping((ns, active, skip) => {
/cloud\/.*/,
/datastore[/-].*/,
/broker\/.*/,
/mainchain[/-].*/,
/sidechain[/-].*/,
/ramps[/-].*/,
);
skip.push(/desktop[/-]?.*/, /DevtoolsSessionLogger/);
} else if (ns.includes('ulx:desktop')) {
Expand Down
2 changes: 1 addition & 1 deletion double-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"devDependencies": {
"@ulixee/repo-tools": "^1.0.33",
"typescript": "^5.3.3"
"typescript": "^5.6.2"
},
"workspaces": [
"analyze",
Expand Down
50 changes: 19 additions & 31 deletions playground/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import '@ulixee/commons/lib/SourceMapSupport';
import DefaultHero, { ConnectionToHeroCore, IHeroCreateOptions } from '@ulixee/hero';
import Core from '@ulixee/hero-core';
import DefaultHero, { IHeroCreateOptions } from '@ulixee/hero';
import { CloudNode } from '@ulixee/cloud';
import UlixeeHostsConfig from '@ulixee/commons/config/hosts';

const { version } = require('./package.json');
import TransportBridge from '@ulixee/net/lib/TransportBridge';

export * from '@ulixee/hero';
export { Core };

// eslint-disable-next-line @typescript-eslint/naming-convention
let _heroCore: Core;
function initCore(): Core {
if (_heroCore) return _heroCore;
Core.events.once('browser-has-no-open-windows', ({ browser }) => browser.close());
Core.events.once('all-browsers-closed', () => {
// eslint-disable-next-line no-console
console.log('Automatically shutting down Hero Core (Browser Closed)');
return Core.shutdown();
});
_heroCore = new Core();
return _heroCore;
}

let counter = 0;
export default class Hero extends DefaultHero {
constructor(createOptions: IHeroCreateOptions = {}) {
Expand All @@ -21,32 +32,9 @@ If you're starting to run real production scenarios, you likely want to look int
https://ulixee.org/docs/hero/advanced-concepts/client-vs-core
`);
}
createOptions.connectionToCore = { host: getCoreHost() };
const transportBridge = new TransportBridge();
createOptions.connectionToCore = new ConnectionToHeroCore(transportBridge.transportToCore);
initCore().addConnection(transportBridge.transportToClient);
super(createOptions);
}
}

async function getCoreHost(): Promise<string> {
let coreHost = UlixeeHostsConfig.global.getVersionHost(version);

if (coreHost?.startsWith('localhost')) {
coreHost = await UlixeeHostsConfig.global.checkLocalVersionHost(version, coreHost);
}

// start a cloud if none already started
if (!coreHost) {
const cloud = new CloudNode();
await cloud.listen();
coreHost = await cloud.address;
console.log('Started Ulixee Cloud at %s', coreHost);
} else {
console.log('Connecting to Ulixee Cloud at %s', coreHost);
}

Core.events.once('browser-has-no-open-windows', ({ browser }) => browser.close());
Core.events.once('all-browsers-closed', () => {
console.log('Automatically shutting down Hero Core (Browser Closed)');
return Core.shutdown();
});
return coreHost;
}
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"./package.json": "./package.json"
},
"dependencies": {
"@ulixee/cloud": "2.0.0-alpha.29",
"@ulixee/net": "2.0.0-alpha.29",
"@ulixee/commons": "2.0.0-alpha.29",
"@ulixee/hero": "2.0.0-alpha.29",
"@ulixee/hero-core": "2.0.0-alpha.29"
Expand Down
3 changes: 3 additions & 0 deletions real-user-agents/paths.dist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "./data"
}
Loading

0 comments on commit e70b1f9

Please sign in to comment.