Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
daynin committed Jun 28, 2021
0 parents commit 447689c
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*~
\#*
.\#*
.DS_Store
compiled/
/doc/
49 changes: 49 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
language: c

# Based on: https://github.com/greghendershott/travis-racket

env:
global:
# Supply a global RACKET_DIR environment variable. This is where
# Racket will be installed. A good idea is to use ~/racket because
# that doesn't require sudo to install.
- RACKET_DIR=~/racket
matrix:
# Supply at least one RACKET_VERSION environment variable. This is
# used by the install-racket.sh script (run at before_install,
# below) to select the version of Racket to download and install.
#
# Supply more than one RACKET_VERSION (as in the example below) to
# create a Travis-CI build matrix to test against multiple Racket
# versions.
- RACKET_VERSION=6.12
- RACKET_VERSION=7.0
- RACKET_VERSION=7.1
- RACKET_VERSION=7.2
- RACKET_VERSION=HEAD

matrix:
allow_failures:
# - env: RACKET_VERSION=HEAD
fast_finish: true

before_install:
- git clone https://github.com/greghendershott/travis-racket.git ~/travis-racket
- cat ~/travis-racket/install-racket.sh | bash # pipe to bash not sh!
- export PATH="${RACKET_DIR}/bin:${PATH}" #install-racket.sh can't set for us

install:
- raco pkg install --auto --name rackt

before_script:

# Here supply steps such as raco make, raco test, etc. You can run
# `raco pkg install --deps search-auto` to install any required
# packages without it getting stuck on a confirmation prompt.
script:
- raco test -x -p rackt

after_success:
- raco setup --check-pkg-deps --pkgs rackt
- raco pkg install --auto cover cover-coveralls
- raco cover -b -f coveralls -d $TRAVIS_BUILD_DIR/coverage .
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
rackt

MIT License

Copyright (c) 2021 Sergey Golovin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rackt
=====
README text here.
8 changes: 8 additions & 0 deletions info.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#lang info
(define collection "rackt")
(define deps '("base"))
(define build-deps '("scribble-lib" "racket-doc" "rackunit-lib"))
(define scribblings '(("scribblings/rackt.scrbl" ())))
(define pkg-desc "Description Here")
(define version "0.1")
(define pkg-authors '(daynin))
67 changes: 67 additions & 0 deletions main.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#lang racketscript/base

(require racketscript/interop
racket/list)

(define React ($/require/* "react"))
(define ReactDOM ($/require/* "react-dom"))

(provide render
<el
create-context
use-state
use-effect
use-context
use-reducer
use-callback
use-memo
use-ref
use-imperative-handle
use-layout-effect
use-debug-value)

;; Basic hooks
(define (use-state default-state)
(apply values (js-array->list (#js.React.useState default-state))))

(define use-effect #js.React.useEffect)

(define use-context #js.React.useContext)

;; Additional hooks
(define (use-reducer reducer initial-state [init $/undefined])
(apply values (js-array->list (#js.React.useReducer reducer initial-state init))))

(define use-callback #js.React.useCallback)

(define use-memo #js.React.useMemo)

(define use-ref #js.React.useRef)

(define use-imperative-handle #js.React.useImperativeHandle)

(define use-layout-effect #js.React.useLayoutEffect)

(define use-debug-value #js.React.useDebugValue)

;; Basic API
(define create-context #js.React.createContext)

(define create-element
(lambda (component #:props [props null] . children)
(apply #js.React.createElement
(append
(list (racket->js component) props)
(map racket->js (flatten children))))))

(define (racket->js node)
(cond
[(or (string? node) (number? node)) ($/str node)]
[else node]))

;; A small alias for readability
(define <el create-element)

(define (render react-element node-id)
(#js.ReactDOM.render react-element (#js*.document.getElementById node-id)))

10 changes: 10 additions & 0 deletions scribblings/rackt.scrbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#lang scribble/manual
@require[@for-label[rackt
racket/base]]

@title{rackt}
@author{daynin}

@defmodule[rackt]

Package Description Here

0 comments on commit 447689c

Please sign in to comment.