Skip to content

Commit 447689c

Browse files
committed
initial commit
0 parents  commit 447689c

File tree

7 files changed

+166
-0
lines changed

7 files changed

+166
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*~
2+
\#*
3+
.\#*
4+
.DS_Store
5+
compiled/
6+
/doc/

.travis.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
language: c
2+
3+
# Based on: https://github.com/greghendershott/travis-racket
4+
5+
env:
6+
global:
7+
# Supply a global RACKET_DIR environment variable. This is where
8+
# Racket will be installed. A good idea is to use ~/racket because
9+
# that doesn't require sudo to install.
10+
- RACKET_DIR=~/racket
11+
matrix:
12+
# Supply at least one RACKET_VERSION environment variable. This is
13+
# used by the install-racket.sh script (run at before_install,
14+
# below) to select the version of Racket to download and install.
15+
#
16+
# Supply more than one RACKET_VERSION (as in the example below) to
17+
# create a Travis-CI build matrix to test against multiple Racket
18+
# versions.
19+
- RACKET_VERSION=6.12
20+
- RACKET_VERSION=7.0
21+
- RACKET_VERSION=7.1
22+
- RACKET_VERSION=7.2
23+
- RACKET_VERSION=HEAD
24+
25+
matrix:
26+
allow_failures:
27+
# - env: RACKET_VERSION=HEAD
28+
fast_finish: true
29+
30+
before_install:
31+
- git clone https://github.com/greghendershott/travis-racket.git ~/travis-racket
32+
- cat ~/travis-racket/install-racket.sh | bash # pipe to bash not sh!
33+
- export PATH="${RACKET_DIR}/bin:${PATH}" #install-racket.sh can't set for us
34+
35+
install:
36+
- raco pkg install --auto --name rackt
37+
38+
before_script:
39+
40+
# Here supply steps such as raco make, raco test, etc. You can run
41+
# `raco pkg install --deps search-auto` to install any required
42+
# packages without it getting stuck on a confirmation prompt.
43+
script:
44+
- raco test -x -p rackt
45+
46+
after_success:
47+
- raco setup --check-pkg-deps --pkgs rackt
48+
- raco pkg install --auto cover cover-coveralls
49+
- raco cover -b -f coveralls -d $TRAVIS_BUILD_DIR/coverage .

LICENSE

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
rackt
2+
3+
MIT License
4+
5+
Copyright (c) 2021 Sergey Golovin
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rackt
2+
=====
3+
README text here.

info.rkt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#lang info
2+
(define collection "rackt")
3+
(define deps '("base"))
4+
(define build-deps '("scribble-lib" "racket-doc" "rackunit-lib"))
5+
(define scribblings '(("scribblings/rackt.scrbl" ())))
6+
(define pkg-desc "Description Here")
7+
(define version "0.1")
8+
(define pkg-authors '(daynin))

main.rkt

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#lang racketscript/base
2+
3+
(require racketscript/interop
4+
racket/list)
5+
6+
(define React ($/require/* "react"))
7+
(define ReactDOM ($/require/* "react-dom"))
8+
9+
(provide render
10+
<el
11+
create-context
12+
use-state
13+
use-effect
14+
use-context
15+
use-reducer
16+
use-callback
17+
use-memo
18+
use-ref
19+
use-imperative-handle
20+
use-layout-effect
21+
use-debug-value)
22+
23+
;; Basic hooks
24+
(define (use-state default-state)
25+
(apply values (js-array->list (#js.React.useState default-state))))
26+
27+
(define use-effect #js.React.useEffect)
28+
29+
(define use-context #js.React.useContext)
30+
31+
;; Additional hooks
32+
(define (use-reducer reducer initial-state [init $/undefined])
33+
(apply values (js-array->list (#js.React.useReducer reducer initial-state init))))
34+
35+
(define use-callback #js.React.useCallback)
36+
37+
(define use-memo #js.React.useMemo)
38+
39+
(define use-ref #js.React.useRef)
40+
41+
(define use-imperative-handle #js.React.useImperativeHandle)
42+
43+
(define use-layout-effect #js.React.useLayoutEffect)
44+
45+
(define use-debug-value #js.React.useDebugValue)
46+
47+
;; Basic API
48+
(define create-context #js.React.createContext)
49+
50+
(define create-element
51+
(lambda (component #:props [props null] . children)
52+
(apply #js.React.createElement
53+
(append
54+
(list (racket->js component) props)
55+
(map racket->js (flatten children))))))
56+
57+
(define (racket->js node)
58+
(cond
59+
[(or (string? node) (number? node)) ($/str node)]
60+
[else node]))
61+
62+
;; A small alias for readability
63+
(define <el create-element)
64+
65+
(define (render react-element node-id)
66+
(#js.ReactDOM.render react-element (#js*.document.getElementById node-id)))
67+

scribblings/rackt.scrbl

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#lang scribble/manual
2+
@require[@for-label[rackt
3+
racket/base]]
4+
5+
@title{rackt}
6+
@author{daynin}
7+
8+
@defmodule[rackt]
9+
10+
Package Description Here

0 commit comments

Comments
 (0)