/shadowfy

Primary LanguageTypeScriptMIT LicenseMIT

@asuka 405/shadowfy

 

@asuka 405/shadowfy

Github top language Github language count Repository size License


๐Ÿšง @asukaโˆ’405/shadowfy ๐Ÿš€ Under construction... ๐Ÿšง



About   |   Features   |   Technologies   |   Requirements   |   Starting   |   License   |   Author


๐ŸŽฏ About

Write your HTML or JSX in a seperate file and use Shadowfy to convert them into basic web components
This node module does not work ๐Ÿ’€
We'll be publishing Shadowfy v0.3, beta version of Web component based web framework.๐Ÿ’•

โœจ Features

โœ… JSX to Web Component
โœ… HTML containers into their seperate light DOM component

๐Ÿš€ Technologies

The following tools were used in this project:

โ˜‘๏ธ Requirements

Before starting โœ…, you need to have Git and Node installed.

๐Ÿงช Sample execution

  • Clone the repo from github
  • Pass the following arguments
    • src_dir : path to source directory
    • out_dir : path to compiled directory
    • Pass these arguments in the shadowfy or compiler function as an object
  Shadowfy({
      src_dir: "./path/to/src/dir",
      out_dir: './path/to/out/dir'
  })
  • run the script
# Install dependencies
$ yarn add @babel/core @babel/preset-react --dev

# run the script
$ node shadowfy.js
  • This will generate the compiled code to the given path.

โš™๏ธ Tweak the code

Here's the structure of project so tha you can go and tweak the code:

shadowfy
โ”œโ”€ compilers
โ”‚  โ”œโ”€ compiler.js
โ”‚  โ”œโ”€ CompilerI.js
โ”‚  โ””โ”€ templates.js
โ”œโ”€ ghost.png
โ”œโ”€ LICENSE
โ”œโ”€ package-lock.json
โ”œโ”€ package.json
โ”œโ”€ README.md
โ”œโ”€ router
โ”‚  โ””โ”€ router.js
โ””โ”€ shadowfy.js

  • The compiler takes the BFS approach
    • It reads files and dirs in first layer i.e "./src/"
    • if a directory comes, it pushes the path in queue, else it compiles the file
CompilerI.js
โ”œโ”€ src
โ”œโ”€ out
โ”œโ”€ queue -> contains list of directories to compile next
โ”‚  โ”œโ”€ src -> src_dir
โ”‚  โ”œโ”€ out -> out_dir
โ”‚  โ””โ”€ out_name -> name of out dir extracted from out_dir
โ”œโ”€ convert() -> initiate compilation
โ”œโ”€ dir_proc() -> create and push new queue item
โ”œโ”€ file_proc() -> read & compile a file
โ”œโ”€ register_proc() -> register a file as a web component
โ”œโ”€ compile_proc() -> implemented by children classes
โ”œโ”€ getName() -> extract dir name from path

๐Ÿ“ License

This project is under license from MIT. For more details, see the LICENSE file.

Made with โค๏ธ by Suryansh

 

Back to top