Skip to content

Commit b490af0

Browse files
committed
Refactor: transition the SDK to use Datastar v1.0.0-RC6
1 parent cfe7d01 commit b490af0

File tree

20 files changed

+119
-101
lines changed

20 files changed

+119
-101
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Release notes for the Clojure SDK
22

3+
## 2025-10-27 - RC4
4+
This version's purpose is to transition the SDK to the new Datastar attribute
5+
syntax introduced in
6+
[v1.0.0-RC6](https://github.com/starfederation/datastar/releases/tag/v1.0.0-RC.6).
7+
8+
9+
### Changes
10+
- BREAKING: The SDK APIs remain the same except for 2
11+
vars:
12+
- `starfederation.datastar.clojure.api/CDN-url`
13+
- `starfederation.datastar.clojure.api/CDN-map-url`
14+
15+
These now point to Datastar v1.0.0-RC6. If you use them,
16+
updating to this version of the SDK will change your Datastar CDN import.
17+
Your app will break until you transition to the new `:data-*` syntax.
18+
- Examples and tests now use the new syntax along with the RC6 js bundle.
19+
320
## 2025-09-14 - RC3
421

522
### Fixed

doc/maintainers-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
- `bb run test:bb`: run unit tests for the SDK in Babashka.
4848
- `bb run test:sdk-common`: start the server used to run the
4949
[SDKs' common tests](https://github.com/starfederation/datastar/tree/develop/sdk/tests).
50-
- `bb run test:sdk-common`: run the common SDK test (go program)
50+
- `bb run test:sdk-common-go`: run the common SDK test (go program)
5151

5252
### Cljdoc tasks
5353

libraries/sdk/src/main/starfederation/datastar/clojure/api.clj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ Some scripts are provided:
5353
;; CDN
5454
;; -----------------------------------------------------------------------------
5555
(def CDN-url
56-
"URL for the Datastar js bundle"
57-
"https://cdn.jsdelivr.net/gh/starfederation/datastar@main/bundles/datastar.js")
56+
"URL for the Datastar js bundle tracking the latest Datastar, currently
57+
v1.0.0-RC6."
5858

59+
"https://cdn.jsdelivr.net/gh/starfederation/[email protected]/bundles/datastar.js")
5960

6061
(def CDN-map-url
61-
"URL for the Datastar js source map"
62-
"https://cdn.jsdelivr.net/gh/starfederation/datastar@main/bundles/datastar.js.map")
62+
"URL for the Datastar source map going with [[CDN-url]]."
63+
"https://cdn.jsdelivr.net/gh/starfederation/datastar@1.0.0-RC.6/bundles/datastar.js.map")
6364

6465
;; -----------------------------------------------------------------------------
6566
;; SSE generator management

libraries/sdk/src/main/starfederation/datastar/clojure/api/scripts.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
(comment
5353
(= (->script-tag "console.log('hello')" {})
54-
"<script data-on-load=\"el.remove()\">console.log('hello')</script>")
54+
"<script data-init=\"el.remove()\">console.log('hello')</script>")
5555

5656
(= (->script-tag "console.log('hello')"
5757
{common/auto-remove false})
@@ -67,6 +67,6 @@
6767
(= (->script-tag "console.log('hello');\nconsole.log('world!!!')"
6868
{common/auto-remove :true
6969
common/attributes {:type "module" :data-something 1}})
70-
"<script type=\"module\" data-something=\"1\" data-on-load=\"el.remove()\">console.log('hello');\nconsole.log('world!!!')</script>"))
70+
"<script type=\"module\" data-something=\"1\" data-init=\"el.remove()\">console.log('hello');\nconsole.log('world!!!')</script>"))
7171

7272

src/bb-example/src/main/bb_example/animation/rendering.clj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
rows (:x size)
8383
columns (:y size)
8484
!pc (volatile! (transient [:div.pseudo-canvas {:style (grid-style state)
85-
:data-on-click on-click}]))]
85+
:data-on:click on-click}]))]
8686
(doseq [r (range 1 (inc rows))
8787
c (range 1 (inc columns))]
8888
(vswap! !pc conj! (pseudo-pixel state r c)))
@@ -101,24 +101,24 @@
101101
[:div
102102
[:h3 "Controls"]
103103
[:ul.h-list
104-
[:li [:button {:data-on-click (d*/sse-get "/refresh")} "refresh"]]
105-
[:li [:button {:data-on-click (d*/sse-get "/reset")} "reset"]]
106-
[:li [:button {:data-on-click (d*/sse-get "/random-10")} "add 10"]]
107-
[:li [:button {:data-on-click (d*/sse-get "/step1")} "step1"]]
104+
[:li [:button {:data-on:click (d*/sse-get "/refresh")} "refresh"]]
105+
[:li [:button {:data-on:click (d*/sse-get "/reset")} "reset"]]
106+
[:li [:button {:data-on:click (d*/sse-get "/random-10")} "add 10"]]
107+
[:li [:button {:data-on:click (d*/sse-get "/step1")} "step1"]]
108108
(if (:animator state)
109109
(h/html
110-
[:li [:button {:data-on-click (d*/sse-get "/pause")} "pause"]])
110+
[:li [:button {:data-on:click (d*/sse-get "/pause")} "pause"]])
111111
(h/html
112-
[:li [:button {:data-on-click (d*/sse-get "/play")} "play"]]))]
112+
[:li [:button {:data-on:click (d*/sse-get "/play")} "play"]]))]
113113

114-
[:ul.h-list {:data-signals-rows (-> state :size :x)
115-
:data-signals-columns (-> state :size :y)}
114+
[:ul.h-list {:data-signals:rows (-> state :size :x)
115+
:data-signals:columns (-> state :size :y)}
116116
[:li "rows: " [:input {:type "number"
117117
:data-bind "rows"
118-
:data-on-change (d*/sse-post "/resize")}]]
118+
:data-on:change (d*/sse-post "/resize")}]]
119119
[:li "columns: " [:input {:type "number"
120120
:data-bind "columns"
121-
:data-on-change (d*/sse-post "/resize")}]]]]))
121+
:data-on:change (d*/sse-post "/resize")}]]]]))
122122

123123

124124
(defn log-pane [state]
@@ -170,7 +170,7 @@
170170
(defn page [state]
171171
(h/html
172172
(c/page-scaffold
173-
[:div {:data-on-load (d*/sse-get "/updates")}
173+
[:div {:data-init (d*/sse-get "/updates")}
174174
[:style (h/raw css)]
175175
[:h2.center "Babashka Test"]
176176
(content state)])))

src/dev/examples/animation_gzip/rendering.clj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
columns (:y size)]
8787
(dt/loopr
8888
[pc (transient [:div.pseudo-canvas {:style (grid-style state)
89-
:data-on-click on-click}])]
89+
:data-on:click on-click}])]
9090
[r (range 1 (inc rows))
9191
c (range 1 (inc columns))]
9292
(recur (conj! pc (pseudo-pixel state r c)))
@@ -105,24 +105,24 @@
105105
[:div
106106
[:h3 "Controls"]
107107
[:ul.h-list
108-
[:li [:button {:data-on-click (d*/sse-get "/refresh")} "refresh"]]
109-
[:li [:button {:data-on-click (d*/sse-get "/reset")} "reset"]]
110-
[:li [:button {:data-on-click (d*/sse-get "/random-10")} "add 10"]]
111-
[:li [:button {:data-on-click (d*/sse-get "/step1")} "step1"]]
108+
[:li [:button {:data-on:click (d*/sse-get "/refresh")} "refresh"]]
109+
[:li [:button {:data-on:click (d*/sse-get "/reset")} "reset"]]
110+
[:li [:button {:data-on:click (d*/sse-get "/random-10")} "add 10"]]
111+
[:li [:button {:data-on:click (d*/sse-get "/step1")} "step1"]]
112112
(if (:animator state)
113113
(hc/compile
114-
[:li [:button {:data-on-click (d*/sse-get "/pause")} "pause"]])
114+
[:li [:button {:data-on:click (d*/sse-get "/pause")} "pause"]])
115115
(hc/compile
116-
[:li [:button {:data-on-click (d*/sse-get "/play")} "play"]]))]
116+
[:li [:button {:data-on:click (d*/sse-get "/play")} "play"]]))]
117117

118-
[:ul.h-list {:data-signals-rows (-> state :size :x)
119-
:data-signals-columns (-> state :size :y)}
118+
[:ul.h-list {:data-signals:rows (-> state :size :x)
119+
:data-signals:columns (-> state :size :y)}
120120
[:li "rows: " [:input {:type "number"
121121
:data-bind "rows"
122-
:data-on-change (d*/sse-post "/resize")}]]
122+
:data-on:change (d*/sse-post "/resize")}]]
123123
[:li "columns: " [:input {:type "number"
124124
:data-bind "columns"
125-
:data-on-change (d*/sse-post "/resize")}]]]]))
125+
:data-on:change (d*/sse-post "/resize")}]]]]))
126126

127127

128128
(defn log-pane [state]
@@ -172,7 +172,7 @@
172172
(defn page [state]
173173
(h/html
174174
(c/page-scaffold
175-
[:div {:data-on-load (d*/sse-get "/updates")}
175+
[:div {:data-init (d*/sse-get "/updates")}
176176
[:style (h/raw css)]
177177
[:h2.center "lets get something fun going"]
178178
(content state)])))

src/dev/examples/form_behavior/core.clj

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
[:input {:type "text"
3838
:id "input1"
3939
:name "input-1"
40-
:data-bind-input1 true}]
40+
:data-bind:input1 true}]
4141

4242

4343
[:br]
@@ -48,48 +48,48 @@
4848
;; GET
4949
[:div
5050
[:h4 "GET"]
51-
[:button { :data-on-click "@get('/endpoint')"} "get - no ct - no type"][:br]
52-
[:button {:type "button" :data-on-click "@get('/endpoint')"} "get - no ct - type"][:br]
53-
[:button { :data-on-click "@get('/endpoint', {contentType: 'form'})"} "get - ct - no type "][:br]
54-
[:button {:type "button" :data-on-click "@get('/endpoint', {contentType: 'form'})"} "get - ct -type"][:br]]
51+
[:button { :data-on:click "@get('/endpoint')"} "get - no ct - no type"][:br]
52+
[:button {:type "button" :data-on:click "@get('/endpoint')"} "get - no ct - type"][:br]
53+
[:button { :data-on:click "@get('/endpoint', {contentType: 'form'})"} "get - ct - no type "][:br]
54+
[:button {:type "button" :data-on:click "@get('/endpoint', {contentType: 'form'})"} "get - ct -type"][:br]]
5555

5656
;; POST
5757
[:div
5858
[:h4 "POST"]
59-
[:button { :data-on-click "@post('/endpoint')"} "post - no ct - no type"][:br]
60-
[:button {:type "button" :data-on-click "@post('/endpoint')"} "post - no ct - type"][:br]
61-
[:button { :data-on-click "@post('/endpoint', {contentType: 'form'})"} "post - ct - no type "][:br]
62-
[:button {:type "button" :data-on-click "@post('/endpoint', {contentType: 'form'})"} "post - ct -type"][:br]]
59+
[:button { :data-on:click "@post('/endpoint')"} "post - no ct - no type"][:br]
60+
[:button {:type "button" :data-on:click "@post('/endpoint')"} "post - no ct - type"][:br]
61+
[:button { :data-on:click "@post('/endpoint', {contentType: 'form'})"} "post - ct - no type "][:br]
62+
[:button {:type "button" :data-on:click "@post('/endpoint', {contentType: 'form'})"} "post - ct -type"][:br]]
6363

6464
;; PUT
6565
[:div
6666
[:h4 "PUT"]
67-
[:button { :data-on-click "@put('/endpoint')"} "put - no ct - no type"][:br]
68-
[:button {:type "button" :data-on-click "@put('/endpoint')"} "put - no ct - type"][:br]
69-
[:button { :data-on-click "@put('/endpoint', {contentType: 'form'})"} "put - ct - no type "][:br]
70-
[:button {:type "button" :data-on-click "@put('/endpoint', {contentType: 'form'})"} "put - ct -type"][:br]]
67+
[:button { :data-on:click "@put('/endpoint')"} "put - no ct - no type"][:br]
68+
[:button {:type "button" :data-on:click "@put('/endpoint')"} "put - no ct - type"][:br]
69+
[:button { :data-on:click "@put('/endpoint', {contentType: 'form'})"} "put - ct - no type "][:br]
70+
[:button {:type "button" :data-on:click "@put('/endpoint', {contentType: 'form'})"} "put - ct -type"][:br]]
7171

7272
;; PATCH
7373
[:div
7474
[:h4 "PATCH"]
75-
[:button { :data-on-click "@patch('/endpoint')"} "patch - no ct - no type"][:br]
76-
[:button {:type "button" :data-on-click "@patch('/endpoint')"} "patch - no ct - type"][:br]
77-
[:button { :data-on-click "@patch('/endpoint', {contentType: 'form'})"} "patch - ct - no type "][:br]
78-
[:button {:type "button" :data-on-click "@patch('/endpoint', {contentType: 'form'})"} "patch - ct -type"][:br]]
75+
[:button { :data-on:click "@patch('/endpoint')"} "patch - no ct - no type"][:br]
76+
[:button {:type "button" :data-on:click "@patch('/endpoint')"} "patch - no ct - type"][:br]
77+
[:button { :data-on:click "@patch('/endpoint', {contentType: 'form'})"} "patch - ct - no type "][:br]
78+
[:button {:type "button" :data-on:click "@patch('/endpoint', {contentType: 'form'})"} "patch - ct -type"][:br]]
7979

8080
;; DELETE
8181
[:div
8282
[:h4 "DELETE"]
83-
[:button { :data-on-click "@delete('/endpoint')"} "delete - no ct - no type"][:br]
84-
[:button {:type "button" :data-on-click "@delete('/endpoint')"} "delete - no ct - type"][:br]
85-
[:button { :data-on-click "@delete('/endpoint', {contentType: 'form'})"} "delete - ct - no type "][:br]
86-
[:button {:type "button" :data-on-click "@delete('/endpoint', {contentType: 'form'})"} "delete - ct -type"][:br]]]]
83+
[:button { :data-on:click "@delete('/endpoint')"} "delete - no ct - no type"][:br]
84+
[:button {:type "button" :data-on:click "@delete('/endpoint')"} "delete - no ct - type"][:br]
85+
[:button { :data-on:click "@delete('/endpoint', {contentType: 'form'})"} "delete - ct - no type "][:br]
86+
[:button {:type "button" :data-on:click "@delete('/endpoint', {contentType: 'form'})"} "delete - ct -type"][:br]]]]
8787
[:h3 "Outside form "]
8888
[:button
89-
{:id "get-no-form", :data-on-click "@get('/endpoint')"}
89+
{:id "get-no-form", :data-on:click "@get('/endpoint')"}
9090
"get no form"]
9191
[:button
92-
{:id "post-no-form", :data-on-click "@post('/endpoint')"}
92+
{:id "post-no-form", :data-on:click "@post('/endpoint')"}
9393
"post no form"]
9494

9595
[:br]])))

src/dev/examples/forms/datastar.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
[:div
2727
[:h2 "Html GET form"]
2828
[:form {:action ""
29-
:data-on-submit "@get('/datastar/get', {contentType: 'form'})"} "submit"
29+
:data-on:submit "@get('/datastar/get', {contentType: 'form'})"} "submit"
3030
[:input {:type "text"
3131
:id "input1"
3232
:name "input1"
33-
:data-bind-input1 true}]
33+
:data-bind:input1 true}]
3434
[:button "submit"]]
3535
(result-area result)])))
3636

@@ -56,11 +56,11 @@
5656
(c/page-scaffold
5757
[:div
5858
[:h2 "Html POST form !!!!"]
59-
[:form {:action "" :data-on-submit "@post('/datastar/post', {contentType: 'form'})"}
59+
[:form {:action "" :data-on:submit "@post('/datastar/post', {contentType: 'form'})"}
6060
[:input {:type "text"
6161
:id "input1"
6262
:name "input1"
63-
:data-bind-input1 true}]
63+
:data-bind:input1 true}]
6464
[:button "submit"]]
6565
(result-area result)])))
6666

src/dev/examples/forms/html.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
[:input {:type "text"
1818
:id "input1"
1919
:name "input1"
20-
:data-bind-input1 true}]
20+
:data-bind:input1 true}]
2121
[:button "submit"]]
2222
[:div result]])))
2323

@@ -38,7 +38,7 @@
3838
[:input {:type "text"
3939
:id "input1"
4040
:name "input1"
41-
:data-bind-input1 true}]
41+
:data-bind:input1 true}]
4242
[:button "submit"]]
4343
[:div result]])))
4444

0 commit comments

Comments
 (0)