Skip to content

Commit

Permalink
feat(client): global instanceof checks
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Apr 10, 2023
1 parent e39575b commit b704669
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: '1.20'

- name: Clone ulixee/shared
run: git clone https://github.com/ulixee/shared.git
Expand Down
3 changes: 3 additions & 0 deletions client/connections/ConnectionToHeroCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ICoreConfigureOptions from '@ulixee/hero-interfaces/ICoreConfigureOptions
import { ConnectionToCore, WsTransportToCore } from '@ulixee/net';
import ICoreListenerPayload from '@ulixee/hero-interfaces/ICoreListenerPayload';
import ITransportToCore from '@ulixee/net/interfaces/ITransportToCore';
import addGlobalInstance from '@ulixee/commons/lib/addGlobalInstance';
import ICoreCommandRequestPayload from '@ulixee/hero-interfaces/ICoreCommandRequestPayload';
import DisconnectedError from '@ulixee/net/errors/DisconnectedError';
import ICoreResponsePayload from '@ulixee/net/interfaces/ICoreResponsePayload';
Expand Down Expand Up @@ -147,3 +148,5 @@ export default class ConnectionToHeroCore extends ConnectionToCore<any, {}> {
return host;
}
}

addGlobalInstance(ConnectionToHeroCore);
8 changes: 4 additions & 4 deletions client/lib/CoreSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ISessionMeta from '@ulixee/hero-interfaces/ISessionMeta';
import { IJsPath } from '@ulixee/js-path';
import { loggerSessionIdNames } from '@ulixee/commons/lib/Logger';
import IHeroMeta from '@ulixee/hero-interfaces/IHeroMeta';
import addGlobalInstance from '@ulixee/commons/lib/addGlobalInstance';
import * as readline from 'readline';
import { ReadLine } from 'readline';
import { CanceledPromiseError } from '@ulixee/commons/interfaces/IPendingWaitEvent';
Expand Down Expand Up @@ -154,10 +155,7 @@ export default class CoreSession
return await this.commandQueue.run('Session.getDetachedElements', sessionId, name);
}

public async getDetachedResources(
sessionId: string,
name: string,
): Promise<IDetachedResource[]> {
public async getDetachedResources(sessionId: string, name: string): Promise<IDetachedResource[]> {
return await this.commandQueue.run('Session.getDetachedResources', sessionId, name);
}

Expand Down Expand Up @@ -270,3 +268,5 @@ export default class CoreSession
this.cliPrompt.prompt(true);
}
}

addGlobalInstance(CoreSession);
3 changes: 3 additions & 0 deletions client/lib/Hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SuperDocument from '@ulixee/awaited-dom/impl/super-klasses/SuperDocument'
import IDomStorage from '@ulixee/unblocked-specification/agent/browser/IDomStorage';
import IUserProfile from '@ulixee/hero-interfaces/IUserProfile';
import { IRequestInit } from '@ulixee/awaited-dom/base/interfaces/official';
import addGlobalInstance from '@ulixee/commons/lib/addGlobalInstance';
import Response from '@ulixee/awaited-dom/impl/official-klasses/Response';
import {
ISuperElement,
Expand Down Expand Up @@ -724,6 +725,8 @@ export default class Hero extends AwaitedEventTarget<IHeroEvents> {
}
}

addGlobalInstance(Hero);

async function getCoreFrameForInteractions(
interactions: IInteractions,
): Promise<CoreFrameEnvironment> {
Expand Down
9 changes: 8 additions & 1 deletion client/lib/Tab.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import StateMachine from '@ulixee/awaited-dom/base/StateMachine';
import { ISuperElement, ISuperNode, ISuperNodeList } from '@ulixee/awaited-dom/base/interfaces/super';
import {
ISuperElement,
ISuperNode,
ISuperNodeList,
} from '@ulixee/awaited-dom/base/interfaces/super';
import { IRequestInit } from '@ulixee/awaited-dom/base/interfaces/official';
import SuperDocument from '@ulixee/awaited-dom/impl/super-klasses/SuperDocument';
import Storage from '@ulixee/awaited-dom/impl/official-klasses/Storage';
import addGlobalInstance from '@ulixee/commons/lib/addGlobalInstance';
import CSSStyleDeclaration from '@ulixee/awaited-dom/impl/official-klasses/CSSStyleDeclaration';
import Request from '@ulixee/awaited-dom/impl/official-klasses/Request';
import {
Expand Down Expand Up @@ -394,6 +399,8 @@ export default class Tab extends AwaitedEventTarget<IEventType> {
}
}

addGlobalInstance(Tab);

export function getCoreTab(tab: Tab): Promise<CoreTab> {
return tab[InternalPropertiesSymbol].coreTabPromise.then(x => {
if (x instanceof Error) throw x;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/CommandRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class CommandRunner {
return;
}

throw new Error(`Target for command not available (${targetName})`);
throw new Error(`Target for command not available (${targetName}:${method})`);
}

if (!targets[targetName].isAllowedCommand(method)) {
Expand Down
1 change: 0 additions & 1 deletion core/lib/InjectedScripts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as fs from 'fs';
import { IPage } from '@ulixee/unblocked-specification/agent/browser/IPage';
import { stringifiedTypeSerializerClass } from '@ulixee/commons/lib/TypeSerializer';
import { IFrame } from '@ulixee/unblocked-specification/agent/browser/IFrame';
import IDevtoolsSession from '@ulixee/unblocked-specification/agent/browser/IDevtoolsSession';

const pageScripts = {
Expand Down
3 changes: 1 addition & 2 deletions examples/example.org.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Hero from '@ulixee/hero';
import { LocationTrigger } from '@ulixee/unblocked-specification/agent/browser/Location';
import Hero, { LocationTrigger } from '@ulixee/hero';

// NOTE: You need to start a Ulixee Miner to run this example
async function run() {
Expand Down

0 comments on commit b704669

Please sign in to comment.