@muze-labs/simplyflow 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MUZE_ALIGNMENT.md +118 -0
- package/README.md +194 -0
- package/dist/simply.flow.js +3780 -0
- package/dist/simply.flow.min.js +2 -0
- package/dist/simply.flow.min.js.map +7 -0
- package/package.json +72 -0
- package/src/action.mjs +64 -0
- package/src/app.mjs +282 -0
- package/src/behavior.mjs +121 -0
- package/src/bind.mjs +522 -0
- package/src/bind.render.mjs +694 -0
- package/src/bind.transformers.mjs +25 -0
- package/src/command.mjs +225 -0
- package/src/dom.mjs +274 -0
- package/src/flow.mjs +84 -0
- package/src/highlight.mjs +11 -0
- package/src/include.mjs +239 -0
- package/src/model.mjs +290 -0
- package/src/path.mjs +47 -0
- package/src/render.mjs +54 -0
- package/src/route.mjs +418 -0
- package/src/shortcut.mjs +146 -0
- package/src/state.mjs +1347 -0
- package/src/suggest.mjs +68 -0
- package/src/symbols.mjs +9 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Muze alignment: simplyflow
|
|
2
|
+
|
|
3
|
+
> Initial alignment roadmap. It is intended as a practical maintenance document, not as a complete code audit.
|
|
4
|
+
|
|
5
|
+
## Muze design principles
|
|
6
|
+
|
|
7
|
+
Muze builds web software for technically curious non-professional programmers, without making the tools unattractive to professionals.
|
|
8
|
+
|
|
9
|
+
We prefer:
|
|
10
|
+
|
|
11
|
+
- simplicity over completeness
|
|
12
|
+
- small, decoupled, single-concern libraries
|
|
13
|
+
- correct abstractions that do not cross conceptual boundaries
|
|
14
|
+
- browser-native standards where possible
|
|
15
|
+
- lightweight abstractions only when they make developer code simpler
|
|
16
|
+
- stable, long-term APIs
|
|
17
|
+
- components and frameworks that are easy to adapt or replace
|
|
18
|
+
- standards-based or open-source hosting stacks that avoid lock-in
|
|
19
|
+
- software small enough to work well on slow devices and connections
|
|
20
|
+
- a view-source philosophy: invite developers to look under the hood and learn
|
|
21
|
+
|
|
22
|
+
When making tradeoffs, prefer composability, replaceability, web-platform alignment, and long-term simplicity over convenience, popularity, or feature completeness.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Muze package namespace policy
|
|
26
|
+
|
|
27
|
+
The `@muze-nl` npm namespace should be a trust signal. Packages published there should be close to production-ready: the public API is expected to be stable, the package can be installed and used by a fresh project, and the README should be clear about supported usage.
|
|
28
|
+
|
|
29
|
+
Experimental libraries should use the `@muze-labs` namespace until they are mature enough to carry the main Muze production-readiness signal. Moving from `@muze-labs` into `@muze-nl` should be treated as a release-readiness decision, not only a naming cleanup.
|
|
30
|
+
|
|
31
|
+
## Current assessment
|
|
32
|
+
|
|
33
|
+
SimplyFlow is powerful and useful, but it sits close to framework territory. It includes signals/effects, reactive databinding, and model helpers such as paging/sorting/filtering/columns. The main alignment task is to split and document these as composable layers rather than one large concept.
|
|
34
|
+
|
|
35
|
+
## Strengths
|
|
36
|
+
|
|
37
|
+
- Uses vanilla JavaScript concepts rather than requiring a large frontend framework.
|
|
38
|
+
- Signals/effects can be a small and useful primitive for browser apps.
|
|
39
|
+
- Databinding and model helpers solve real application problems.
|
|
40
|
+
- The README says it can be used standalone, which fits Muze’s decoupled-library goal.
|
|
41
|
+
|
|
42
|
+
## Alignment issues
|
|
43
|
+
|
|
44
|
+
### 1. Split the conceptual surface into explicit packages or modules
|
|
45
|
+
|
|
46
|
+
**Principle:** Small, decoupled, single-concern libraries.
|
|
47
|
+
|
|
48
|
+
**Problem:** State, effects, binding, model, paging, sort, filter, and columns are imported together in examples and presented as bundled libraries.
|
|
49
|
+
|
|
50
|
+
**Why it matters:** The library risks becoming a lightweight framework without a clear boundary.
|
|
51
|
+
|
|
52
|
+
**Suggested direction:** Document or package layers separately: `state`, `bind`, `model`, and optional model helpers. Make each usable and explainable on its own.
|
|
53
|
+
|
|
54
|
+
**Status:** Open
|
|
55
|
+
|
|
56
|
+
### 2. Clarify relationship to SimplyView and Muze projects
|
|
57
|
+
|
|
58
|
+
**Principle:** Replaceability and framework boundaries.
|
|
59
|
+
|
|
60
|
+
**Problem:** The README says SimplyFlow is intended for SimplyView but can be used standalone, and may be integrated into SimplyView once vetted.
|
|
61
|
+
|
|
62
|
+
**Why it matters:** Users need to know whether this is a stable standalone library or an experimental framework component.
|
|
63
|
+
|
|
64
|
+
**Suggested direction:** Add a “Relationship to SimplyView” section with current status and future compatibility promise.
|
|
65
|
+
|
|
66
|
+
**Status:** Open
|
|
67
|
+
|
|
68
|
+
### 3. Replace direct `src/` imports in public examples with stable imports
|
|
69
|
+
|
|
70
|
+
**Principle:** Stable APIs.
|
|
71
|
+
|
|
72
|
+
**Problem:** The README examples import from `simplyflow/src/state.mjs`, `src/bind.mjs`, and `src/model.mjs`.
|
|
73
|
+
|
|
74
|
+
**Why it matters:** Importing from source files exposes internal layout as public API and makes refactoring harder.
|
|
75
|
+
|
|
76
|
+
**Suggested direction:** Define stable export paths and update examples to use them. Keep source-path imports only in internal docs.
|
|
77
|
+
|
|
78
|
+
**Status:** Open
|
|
79
|
+
|
|
80
|
+
### 4. Add a minimal mental model document
|
|
81
|
+
|
|
82
|
+
**Principle:** View-source learnability.
|
|
83
|
+
|
|
84
|
+
**Problem:** Reactivity and databinding can become magical if the propagation model is not explained.
|
|
85
|
+
|
|
86
|
+
**Why it matters:** Curious developers should be able to predict when effects run and how DOM updates happen.
|
|
87
|
+
|
|
88
|
+
**Suggested direction:** Add a “How SimplyFlow works” guide: signals, effects, batching, binding lifecycle, cleanup, and model transformations.
|
|
89
|
+
|
|
90
|
+
**Status:** Open
|
|
91
|
+
|
|
92
|
+
### 5. Define production-readiness and experimental boundaries
|
|
93
|
+
|
|
94
|
+
**Principle:** Stable APIs and user trust.
|
|
95
|
+
|
|
96
|
+
**Problem:** The README warns the project is experimental and not for production unless users can fix problems themselves.
|
|
97
|
+
|
|
98
|
+
**Why it matters:** That honesty is good, but a Muze roadmap should say what must be done to change that status.
|
|
99
|
+
|
|
100
|
+
**Suggested direction:** Add a checklist for moving from experimental to stable: tests, import paths, docs, examples, API freeze, browser support, package metadata.
|
|
101
|
+
|
|
102
|
+
**Status:** Open
|
|
103
|
+
|
|
104
|
+
## Open questions
|
|
105
|
+
|
|
106
|
+
- Is SimplyFlow part of Muze’s core stack, or a transitional dependency for current apps?
|
|
107
|
+
- Should `bind` depend on `state`, or should it accept generic signal-like adapters?
|
|
108
|
+
- Should model helpers live in their own package?
|
|
109
|
+
|
|
110
|
+
## Non-goals
|
|
111
|
+
|
|
112
|
+
- Do not become a full frontend framework unless that is a deliberate separate project.
|
|
113
|
+
- Do not hide DOM/browser behavior behind opaque magic.
|
|
114
|
+
- Do not make all Muze apps depend on SimplyFlow by accident.
|
|
115
|
+
|
|
116
|
+
## Review cadence
|
|
117
|
+
|
|
118
|
+
Review this document before feature work, before releases, and whenever the public API or dependency surface changes. Close issues by changing their status to `Done` and leaving a short note about the decision.
|
package/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# SimplyFlow
|
|
2
|
+
|
|
3
|
+
SimplyFlow is an experimental browser library for building small reactive web applications with ordinary HTML and ordinary JavaScript data.
|
|
4
|
+
|
|
5
|
+
The intended beginner-facing API is:
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
import { app } from 'simplyflow/src/flow.mjs'
|
|
9
|
+
|
|
10
|
+
const counter = app({
|
|
11
|
+
container: document.getElementById('counter'),
|
|
12
|
+
|
|
13
|
+
data: {
|
|
14
|
+
count: 0
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
commands: {
|
|
18
|
+
add1() {
|
|
19
|
+
this.data.count++
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<div id="counter">
|
|
27
|
+
<button data-simply-command="add1">+</button>
|
|
28
|
+
<span data-simply-field="count"></span>
|
|
29
|
+
</div>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
For editable values, use `data-simply-edit`:
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<input data-simply-edit="name">
|
|
36
|
+
<span data-simply-field="name"></span>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The page updates automatically whenever `app.data` changes. Use `data-simply-edit` on form fields when the user should be able to edit a value directly. Text inputs, textareas and selects edit string values; checkboxes edit booleans or toggle values in arrays; radio buttons edit the selected value.
|
|
40
|
+
|
|
41
|
+
Buttons inside list templates can pass the current item or one of its fields to a command:
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<ul data-simply-list="todos">
|
|
45
|
+
<template>
|
|
46
|
+
<li>
|
|
47
|
+
<button data-simply-command="removeTodo" data-simply-value=":value.id">Remove</button>
|
|
48
|
+
<span data-simply-field="text"></span>
|
|
49
|
+
</li>
|
|
50
|
+
</template>
|
|
51
|
+
</ul>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Custom top-level options become app properties, so you can add services without extra ceremony:
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
const contacts = simply.app({
|
|
58
|
+
data: { contacts: [] },
|
|
59
|
+
api: metro.jsonApi('/api/'),
|
|
60
|
+
actions: {
|
|
61
|
+
async loadContacts() {
|
|
62
|
+
this.data.contacts = await this.api.get('contacts.json')
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If an unknown option looks like a typo of a built-in app option, SimplyFlow logs a warning, but still adds the option to the app.
|
|
69
|
+
|
|
70
|
+
Reusable element behavior can be attached with `data-simply-behavior`:
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<div data-simply-behavior="tabs"></div>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
const page = simply.app({
|
|
78
|
+
data: {},
|
|
79
|
+
behaviors: {
|
|
80
|
+
tabs(element) {
|
|
81
|
+
// Set up the tabs element.
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
HTML fragments can be included inside an app container without a build step:
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<link rel="simply-include" href="header.html">
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The include observer is scoped to the app and stops when `app.destroy()` is called.
|
|
94
|
+
|
|
95
|
+
Keyboard shortcuts can be added with the `shortcuts` option:
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
const notes = simply.app({
|
|
99
|
+
data: {},
|
|
100
|
+
shortcuts: {
|
|
101
|
+
'Control+s'() {
|
|
102
|
+
this.actions.save()
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Install
|
|
109
|
+
|
|
110
|
+
```shell
|
|
111
|
+
npm install simplyflow
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
or using Git:
|
|
115
|
+
|
|
116
|
+
```shell
|
|
117
|
+
git clone https://github.com/SimplyEdit/simplyflow.git
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Browser bundle
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<script src="https://cdn.jsdelivr.net/npm/simplyflow/dist/simply.flow.js"></script>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Then use the beginner-facing `simply.app()` API:
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
const counter = simply.app({
|
|
130
|
+
data: { count: 0 },
|
|
131
|
+
commands: {
|
|
132
|
+
add1() {
|
|
133
|
+
this.data.count++
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The tutorials focus on `simply.app()`, but the browser global also exposes the lower-level APIs directly for projects that use script tags and do not want a build step:
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
const data = simply.signal({ title: 'Hello' })
|
|
143
|
+
simply.bind({ root: data })
|
|
144
|
+
|
|
145
|
+
const table = simply.model({ data: [] })
|
|
146
|
+
table.addEffect(simply.model.sort({ property: 'title' }))
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The browser bundle also intentionally provides global `html` and `css` template tags. They return strings, but many code editors recognize these tag names and provide syntax highlighting inside template literals:
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
const page = simply.app({
|
|
153
|
+
templates: {
|
|
154
|
+
card: html`<article data-simply-field=":value.title"></article>`
|
|
155
|
+
},
|
|
156
|
+
styles: {
|
|
157
|
+
card: css`.selected { font-weight: bold; }`
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Module imports are still available when you prefer explicit imports:
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
import { signal, effect, batch } from 'simplyflow/src/state.mjs'
|
|
166
|
+
import { bind } from 'simplyflow/src/bind.mjs'
|
|
167
|
+
import { model, paging, sort, filter, columns } from 'simplyflow/src/model.mjs'
|
|
168
|
+
|
|
169
|
+
const data = signal({ title: 'Hello' })
|
|
170
|
+
bind({ root: data })
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
## Documentation
|
|
175
|
+
|
|
176
|
+
- [App API](docs/app.md)
|
|
177
|
+
- [Binding API](docs/bind.md)
|
|
178
|
+
- [Model API](docs/model.md)
|
|
179
|
+
- [State API](docs/state.md)
|
|
180
|
+
- [Commands](docs/command.md)
|
|
181
|
+
- [Actions](docs/action.md)
|
|
182
|
+
- [Routes](docs/route.md)
|
|
183
|
+
- [Behaviors](docs/behavior.md)
|
|
184
|
+
- [Includes](docs/include.md)
|
|
185
|
+
|
|
186
|
+
Or check the [examples](examples/) for more information.
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
[MIT](LICENSE) © Muze.nl
|
|
191
|
+
|
|
192
|
+
## Contributions
|
|
193
|
+
|
|
194
|
+
Contributions are welcome, but make sure that all code is MIT licensed. If you want to send a merge request, please make sure that there is a ticket that shows the bug/feature and reference it. If you find any problem, please do file a ticket, but you should not expect a timely resolution. This project is still very experimental, don't use it in production unless you are ready to fix problems yourself.
|