Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Moc 96 use dsl for editing #105

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d46bbd1
Prototype interfaces for Reactor
jonathan-powwow Jul 25, 2024
7ad3f87
Add highlighting to applied modification
jonathan-powwow Jul 25, 2024
c498904
Merge remote-tracking branch 'origin/main' into MOC-96-use-dsl-for-ed…
jonathan-powwow Jul 26, 2024
c1669d8
Merge remote-tracking branch 'origin/main' into MOC-96-use-dsl-for-ed…
jonathan-powwow Jul 29, 2024
8d8abd5
Merge remote-tracking branch 'origin/main' into MOC-96-use-dsl-for-ed…
jonathan-powwow Jul 31, 2024
43e242e
Merge remote-tracking branch 'origin/main' into MOC-96-use-dsl-for-ed…
jonathan-powwow Jul 31, 2024
5fb679b
WIP: Use DSL for edits
jonathan-powwow Jul 31, 2024
2b036bf
Support unapply in all DSL commands except replaceAll
jonathankap Aug 1, 2024
a4bbcc6
Merge remote-tracking branch 'origin/main' into MOC-96-use-dsl-for-ed…
jonathankap Aug 1, 2024
fbb2002
All tests passing for apply/unapply modifications
jonathankap Aug 5, 2024
4614236
Merge remote-tracking branch 'origin/main' into MOC-96-use-dsl-for-ed…
jonathankap Aug 6, 2024
b8b1b88
Merge remote-tracking branch 'origin/improve_chat' into MOC-96-use-ds…
jonathankap Aug 6, 2024
2756e48
Implement reactor interface
jonathankap Aug 6, 2024
8121669
First modifications working end-to-end
jonathankap Aug 6, 2024
a027e89
Refactor reactor; Begin highlighter integration
jonathankap Aug 7, 2024
a3e1316
Merge branch 'improve_chat' into MOC-96-use-dsl-for-editing
jonathankap Aug 8, 2024
1911f29
Integrate chat and edit
jonathankap Aug 8, 2024
30373c9
Merge branch 'improve_chat' into MOC-96-use-dsl-for-editing
jonathankap Aug 8, 2024
b360b22
Merge remote-tracking branch 'origin/improve_chat' into MOC-96-use-ds…
jonathankap Aug 9, 2024
acd6782
Integrate highlighting
jonathankap Aug 9, 2024
ed5b036
Merge remote-tracking branch 'origin/improve_chat' into MOC-96-use-ds…
jonathankap Aug 9, 2024
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
74 changes: 74 additions & 0 deletions packages/reactor/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { EventEmitter } from 'events';

export interface Modification {
selector?: string;
xpath?: string;
Expand Down Expand Up @@ -25,10 +27,82 @@ export interface ModificationRequest {
modifications: Modification[];
}

export interface AppliedModification {
modificationRequest: ModificationRequest;
}

export interface DomJsonExportNode {
tag: string;
visible: boolean;
text?: string;
attributes?: Record<string, string>;
children?: DomJsonExportNode[];
}

interface ReactorEvents {
/**
* Called when a url is loaded by the browser. Can be used to modify the list
* of applied modifications.
* @param url the url that was loaded
*/
onUrlLoaded: (url: string) => void;

/**
* Called when a new page in an SPA is loaded by the browser. Can be used to
* modify the list of applied modifications.
* @param url the url that was loaded
* @param page the page that was loaded
*/
onPageLoaded: (url: string, page: string) => void;
}

/**
* Reactor applied modifications to the current page. Modifications
* are applied in the order they were added. Removing a modification
* unapplies it.
*/
interface Reactor extends EventEmitter {
/**
* Attach Reactor to the current tab. Reactor will start generating
* events and apply any modifications.
*/
attach(): void;

/**
* Detach Reactor from the current tab. Reactor will remove any applied
* modifications and stop generating events.
*/
detach(): void;

/**
* Get the list of currently applied modifications. This
* list is backed by the appliedModifications themselves, so
* make a change to the list will also apply/unapply any
* modifications as needed.
*
* @returns The list of applied modifications
*/
getAppliedModifications(): AppliedModification[];

/**
* Shortcut to add a modification. This is the equivalent of calling
* getAppliedModifications().push(modificationRequest)
*/
addModification(modificationRequest: ModificationRequest): void;

/**
* Shortcut to remove the most recently added modification. This
* is the equivalent of calling getAppliedModifications().pop()
*/
removeLastModification(): void;

/**
* Event listeners
*/
on: <K extends keyof ReactorEvents>(event: K, listener: ReactorEvents[K]) => this;

/**
* Event emitters
*/
emit: <K extends keyof ReactorEvents>(event: K, ...args: Parameters<ReactorEvents[K]>) => boolean;
}
Loading