Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v21 syntax #296

Closed
delaneyj opened this issue Dec 1, 2024 · 10 comments
Closed

v21 syntax #296

delaneyj opened this issue Dec 1, 2024 · 10 comments
Assignees
Milestone

Comments

@delaneyj
Copy link
Collaborator

delaneyj commented Dec 1, 2024

Datastar v0.21 API

Datastar makes signals declarative. Signal values are accessed in expressions using the syntax signalName.value.

Attributes

Attributes take the form data-{pluginName}-{key}.{modifier}, with key and modifier being optional.

data-bind

data-bind="foo"

data-indicator

data-indicator="foo"

data-ref

data-ref="foo"

data-signals

data-signals="{foo: 1, bar: 2}"

data-signals-foo="1"

data-computed

data-computed="{baz: foo.value * bar.value}"

data-computed-baz="foo.value * bar.value"

data-on

data-on="{click: sseGet()}"

data-on-click="sseGet()"

data-attrs

data-attrs="{disabled: foo.value, hidden: bar.value}"

data-attrs-disabled="foo.value"

data-class

data-class="{hidden: foo.value, visible: bar.value}"

data-class-hidden="foo.value"

data-show

data-show="foo.value"

data-text

data-text="foo.value"

data-persist

data-persist

data-persist="{key: 'foo bar'}"

data-persist-key="'foo bar'"

data-intersects

data-intersects="console.log(foo.value)"

data-scroll-into-view

data-scroll-into-view

data-view-transition

data-view-transition="vtName"

Actions

Actions take the form {pluginName}({arguments}).

SSE Plugin

sse(url, {method='get', headers={}, remote=true})

DOM Plugins

clipboard()

Logic Plugins

setAll(regexp, value)

toggleAll(regexp, value)

@bencroker
Copy link
Collaborator

We should carefully consider whether to namespace actions using @ or ds, to help prevent naming conflicts. Also, because signals are user-defined, whereas actions are not, it could be confusing to see customAction() in your data attribute.

One other thing to consider is whether sse should be renamed request. I realise that sse might be considered more specific, but it describes the response rather than the action, which is to make a request to the backend.

<div data-on-click="request(url, {method: 'post'})"></div>

@bencroker
Copy link
Collaborator

We decided against namespacing actions, and in favour of sse.

Also, this syntax presents issues, so we’ll not proceeding with it for now.
data-computed="{baz: foo.value * bar.value}"

delaneyj added a commit that referenced this issue Dec 3, 2024
fix bind/intersect lazy reactiveExpression gen
delaneyj added a commit that referenced this issue Dec 4, 2024
delaneyj added a commit that referenced this issue Dec 5, 2024
* refactor: Use Docker-dev for the base image, and build all the things

* refactor: Log in to the registry

* refactor: Run on workflow changes

* chore: revert changes

* Improve homepage title

* delete everything first

* add top level sdk folder
move go SDK
add back bundles and stuff to make tsbuild work

* update go SDK url

* fix: Fix issue with `make task`

* fix: Fix multiple linux arch’s, add `support` as a `deploy` dep

* refactor: Install `flyctl`

* refactor: Output to the current directory

* refactor: ignore .out

* refactor: Run via Docker container

* refactor: Use `flyctl` instead of the alias

* refactor: Docker-in-Docker

As per “The Socket Solution” here: https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

* refactor: Fix comment

* refactor: Make fly alias

* refactor: Use fly alias

* add vendored back in

* fix: Revert relative paths

* refactor: Revert ignoring `.out`

* refactor: Run flyctl in the CI container

* refactor: Remove flyctl

* refactor: Remove socket bind mount

* refactor: Add `flyctl` back in so `make task deploy` can be done locally

* add types and nested signals

* Add canonical meta tag

* add more stuff back in

* add ( i think ) the rest of the plugins

* lazy generation ReactiveExpresison, get click to edit working

* data-merge-signals to data-signals
start @action to action

* Add WIP release notes

* update more examples removing @ syntax and moving to sse action

* remove deprecated examples

* The great $ purge of 2024

* Add error codes

* working on v21 syntax  #296
fix bind/intersect lazy reactiveExpression gen

* Fix todo demo

* Reorder plugins

* Start markdown errors

* Finish markdown errors

* Update release notes

* Add release note

* Update release note

* remove dup and require checks

* fix signals JSON usage
fix throttle/debounce lead/trail port

* make js obj helper
auto formatting
signal value needed explicit period prefix for value
data-signals lazy generates due to possible expressons
removeSignal applies after eval

* update test, 127/127

* Create VSCode extension (#295)

* Add attributes

* Finish attributes

* Fix repo URL

* Finish

* change attributes

* fix attributes

* VSCode extension improvements

* fix data-attributes example

* Fix a BEN!

* support individual data-class-foo calls

* error page

* Rework error pages

* Simplify

* Rework errors

* Fixes

* Delete `console.log` from library

* #296 persist back in

* Add missing error

* remove mouse move until I implement correctly

* i hate javascript

* . syntax for modifiers now :

* Extract plugin rules

* Add clarification comment

* support xor key or value for bind/ref/indicator

* Add KeyValRules

* Remove unused properties

* Update VSCode extension

* Update docs

* Improve getting started guide

* logic restored

* autogen error sidebar links

* fixed Restructure folders #287

* fix scroll test
* Prep docs for release

* Fixed check for exclusive requirements

* Build

* img diff

* add errors to nested signals
fix getting started

---------

Co-authored-by: Andrew Welch <[email protected]>
Co-authored-by: Ben Croker <[email protected]>
Co-authored-by: Ben Croker <[email protected]>
delaneyj added a commit that referenced this issue Dec 5, 2024
* Fix newline in SDK protocol for paths. (#281)

* Fix newline in SDK protocol for paths.
Fixes #272

* Update PHP SDK

* Fix newline in SDK protocol for paths in Go SDK #272

* Tweak wording

---------

Co-authored-by: Ben Croker <[email protected]>

* Rename data-store to data-merge-signals. (#280)

* Make title dynamic in site (#277)

* Make title dynamic in site
Fixes #263

* Update meta tags

---------

Co-authored-by: Ben Croker <[email protected]>

* Add release note

* Rename data-store to data-merge-signals.
Fixes #269

* Fix backend reference docs and example

* feat: Add fly-deploy.yaml, manually triggered via GH only for now

* Rename data-store to data-merge-signals.
Fixes #269

* Update SDK #269

---------

Co-authored-by: Ben Croker <[email protected]>
Co-authored-by: Andrew Welch <[email protected]>
Co-authored-by: Ben Croker <[email protected]>

* side effects

* Delaneyj/issue270 (#282)

* Start work on data-model removal #270

* move files  #270

* move all test and examples to data-bind from data-model

* merge consts

* Add release note

---------

Co-authored-by: Ben Croker <[email protected]>

* Move to `@` for actions (#283)

* move to @ for actions

* Rename store to signals for #284  (#289)

* Rename store to signals #284 passes tests

---------

Co-authored-by: Delaney Gillilan <[email protected]>

* Update CHANGELOG.md

* Release notes

* Preprocessor to macro (#290)

* Preprocessor to macro Fixes #285

---------

Co-authored-by: Andrew Welch <[email protected]>

* Remove RefMacro

* Tweka wording

* Fix docs

* Support explicit syntax (#297)

* refactor: Use Docker-dev for the base image, and build all the things

* refactor: Log in to the registry

* refactor: Run on workflow changes

* chore: revert changes

* Improve homepage title

* delete everything first

* add top level sdk folder
move go SDK
add back bundles and stuff to make tsbuild work

* update go SDK url

* fix: Fix issue with `make task`

* fix: Fix multiple linux arch’s, add `support` as a `deploy` dep

* refactor: Install `flyctl`

* refactor: Output to the current directory

* refactor: ignore .out

* refactor: Run via Docker container

* refactor: Use `flyctl` instead of the alias

* refactor: Docker-in-Docker

As per “The Socket Solution” here: https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

* refactor: Fix comment

* refactor: Make fly alias

* refactor: Use fly alias

* add vendored back in

* fix: Revert relative paths

* refactor: Revert ignoring `.out`

* refactor: Run flyctl in the CI container

* refactor: Remove flyctl

* refactor: Remove socket bind mount

* refactor: Add `flyctl` back in so `make task deploy` can be done locally

* add types and nested signals

* Add canonical meta tag

* add more stuff back in

* add ( i think ) the rest of the plugins

* lazy generation ReactiveExpresison, get click to edit working

* data-merge-signals to data-signals
start @action to action

* Add WIP release notes

* update more examples removing @ syntax and moving to sse action

* remove deprecated examples

* The great $ purge of 2024

* Add error codes

* working on v21 syntax  #296
fix bind/intersect lazy reactiveExpression gen

* Fix todo demo

* Reorder plugins

* Start markdown errors

* Finish markdown errors

* Update release notes

* Add release note

* Update release note

* remove dup and require checks

* fix signals JSON usage
fix throttle/debounce lead/trail port

* make js obj helper
auto formatting
signal value needed explicit period prefix for value
data-signals lazy generates due to possible expressons
removeSignal applies after eval

* update test, 127/127

* Create VSCode extension (#295)

* Add attributes

* Finish attributes

* Fix repo URL

* Finish

* change attributes

* fix attributes

* VSCode extension improvements

* fix data-attributes example

* Fix a BEN!

* support individual data-class-foo calls

* error page

* Rework error pages

* Simplify

* Rework errors

* Fixes

* Delete `console.log` from library

* #296 persist back in

* Add missing error

* remove mouse move until I implement correctly

* i hate javascript

* . syntax for modifiers now :

* Extract plugin rules

* Add clarification comment

* support xor key or value for bind/ref/indicator

* Add KeyValRules

* Remove unused properties

* Update VSCode extension

* Update docs

* Improve getting started guide

* logic restored

* autogen error sidebar links

* fixed Restructure folders #287

* fix scroll test
* Prep docs for release

* Fixed check for exclusive requirements

* Build

* img diff

* add errors to nested signals
fix getting started

---------

Co-authored-by: Andrew Welch <[email protected]>
Co-authored-by: Ben Croker <[email protected]>
Co-authored-by: Ben Croker <[email protected]>

* fix signals type elision

---------

Co-authored-by: Ben Croker <[email protected]>
Co-authored-by: Andrew Welch <[email protected]>
Co-authored-by: Ben Croker <[email protected]>
@delaneyj
Copy link
Collaborator Author

delaneyj commented Dec 5, 2024

Fixed in #308

@delaneyj delaneyj closed this as completed Dec 5, 2024
@khalwat
Copy link
Contributor

khalwat commented Dec 6, 2024

We decided against namespacing actions, and in favour of sse.

Also, this syntax presents issues, so we’ll not proceeding with it for now. data-computed="{baz: foo.value * bar.value}"

Lodging my requisite objection: Datastar actions should have a prefix to avoid the inevitable ("not if but when") namespace collisions, and to mark them as being from or related to this thing called Datastar.

I'd rather see:

dsGet()
dsPut()
dsClipboard()

than:

sseGet()
ssePut()
clipboard()

@bencroker
Copy link
Collaborator

bencroker commented Dec 6, 2024

Just to clarify, there is only sse() (no sseGet, ssePut, etc.).

https://github.com/starfederation/datastar/blob/develop/site/static/md/reference/plugins_backend.md#sse

@khalwat
Copy link
Contributor

khalwat commented Dec 9, 2024

I know... and I'm not a fan. The fact that you want to put shortcuts in the IDE autocomplete or the Craft Datastar APIs make me think they really should be in the Datastar API itself.

@bencroker
Copy link
Collaborator

Well, plugins in Datastar should each have a single concern. By moving get(), post(), etc. into a single action, we consolidated 5 plugins with the same concern into a single plugin. Your objection sounds like personal taste, which is fine. Autocompletion is only there to save a few keystrokes.

@khalwat
Copy link
Contributor

khalwat commented Dec 9, 2024

Sounds like a limitation of the plugin system, if a single plugin can't provide multiple actions.

Probably you should be ok with removing the autocomplete macros from the VSCode plugin if the current API is fine.

@bencroker
Copy link
Collaborator

Sounds like a limitation of the plugin system, if a single plugin can't provide multiple actions.

Yes, I believe it is.

Probably you should be ok with removing the autocomplete macros from the VSCode plugin if the current API is fine.

Yeah I probably will.

@khalwat
Copy link
Contributor

khalwat commented Dec 9, 2024

Since it mirrors the fetch API I guess it's something people will be familiar with so I'm good with it, just won't provide expansion shortcuts in the IntelliJ plugin.

The difference is in a JS context, you'll get pretty good syntax checking... the trick is getting VSCode/IntelliJ to know the attribute is a JS expression, and offer the language syntax injection there.

I haven't figured that out yet for IntelliJ yet, but hopefully it's possible. I'm not sure about VSCode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants