-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor broser-exteionsion/source/react-lowcode
- Loading branch information
Jozef Slezak
committed
Mar 3, 2021
1 parent
2d6b5c5
commit ad93242
Showing
33 changed files
with
186 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
packages/browser-extension/source/InjectScript/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { FetchFS, CacheFS } from '.' | ||
import { CodeRW } from '../react-lowcode/io/rw' | ||
|
||
// IMPORT THIS ONLY IN InjectScript/index.ts and DevToolScript.index.ts | ||
export const io = new CacheFS(new FetchFS('http://localhost:7500')) | ||
|
||
export const ioRefreshEditor = withWriteListener(io, (path: string/*, content: string*/) => { | ||
console.log('written', path) | ||
}) | ||
|
||
function withWriteListener(rw: CodeRW, listener: (path: string, content: string) => void): CodeRW { | ||
return { | ||
readFile(path: string, encoding?: string): Promise<string | undefined> { | ||
return rw.readFile(path, encoding) | ||
}, | ||
writeFile(path: string, content: string) { | ||
return rw.writeFile(path, content).then(() => { | ||
listener(path, content) | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/browser-extension/source/localization/localizations.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...owser-extension/source/tsx/transformer.ts → ...n/source/react-lowcode/ast/transformer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/browser-extension/source/react-lowcode/attributes/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import ts from "typescript" | ||
import { Attribute } from "../ast/find" | ||
|
||
export const findAttributeByName = ( | ||
attributes: Array<Attribute>, | ||
attributeName: string | ||
) => { | ||
const attribute = attributes.find(a => a[attributeName]) | ||
return attribute ? attribute[attributeName] : null | ||
} | ||
|
||
export const jsxElementGetAttributes = (node: ts.JsxOpeningLikeElement) => { | ||
const attributes: Array<Attribute> = [] | ||
|
||
node.attributes.forEachChild((a: unknown) => { | ||
const attribute = a as ts.JsxAttribute | ||
const { initializer } = attribute | ||
|
||
if (!initializer) return | ||
|
||
if (initializer && ts.isStringLiteral(initializer)) { | ||
attributes.push({ | ||
[attribute.name.text]: initializer.text, | ||
}) | ||
} else if (initializer && ts.isJsxExpression(initializer)) { | ||
attributes.push({ | ||
[attribute.name.text]: | ||
//@ts-ignore | ||
initializer.expression?.escapedText, | ||
}) | ||
} | ||
}) | ||
return attributes | ||
} |
20 changes: 4 additions & 16 deletions
20
...ges/browser-extension/source/tsx/clone.ts → ...nsion/source/react-lowcode/clone/clone.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.