sdc_client 0.58.6 → 0.158.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.
Files changed (39) hide show
  1. package/.github/workflows/node.js.yml +2 -2
  2. package/.idea/inspectionProfiles/Project_Default.xml +17 -0
  3. package/.idea/workspace.xml +122 -23
  4. package/.readthedocs.yaml +13 -0
  5. package/dist/index.js +70 -51
  6. package/dist/ugly.index.js +1 -1
  7. package/docs/api-reference.rst +225 -0
  8. package/docs/conf.py +11 -0
  9. package/docs/controllers.rst +228 -0
  10. package/docs/events-and-dom.rst +120 -0
  11. package/docs/getting-started.rst +143 -0
  12. package/docs/index.rst +22 -0
  13. package/docs/models.rst +351 -0
  14. package/docs/overview.rst +66 -0
  15. package/docs/requirements.txt +1 -0
  16. package/eslint.config.js +60 -0
  17. package/gulp/gulp.jsx +15 -13
  18. package/package.json +13 -3
  19. package/src/index.js +44 -11
  20. package/src/simpleDomControl/AbstractSDC.js +287 -286
  21. package/src/simpleDomControl/sdc_controller.js +157 -132
  22. package/src/simpleDomControl/sdc_dom_events.js +99 -88
  23. package/src/simpleDomControl/sdc_events.js +39 -40
  24. package/src/simpleDomControl/sdc_main.js +88 -67
  25. package/src/simpleDomControl/sdc_model.js +1510 -0
  26. package/src/simpleDomControl/sdc_params.js +44 -29
  27. package/src/simpleDomControl/sdc_server_call.js +153 -154
  28. package/src/simpleDomControl/sdc_socket.js +8 -829
  29. package/src/simpleDomControl/sdc_test_utils.js +77 -80
  30. package/src/simpleDomControl/sdc_utils.js +295 -176
  31. package/src/simpleDomControl/sdc_view.js +245 -177
  32. package/test/model.test.js +332 -0
  33. package/test/models/Author.js +145 -0
  34. package/test/models/Book.js +112 -0
  35. package/test/models/BookContent.js +114 -0
  36. package/test/models/SdcUser.js +75 -0
  37. package/test/models/src.js +8 -0
  38. package/test/sdc_model_dates.ai.test.js +57 -0
  39. package/test/sdc_server_call.ai.test.js +267 -0
@@ -0,0 +1,120 @@
1
+ Events and DOM
2
+ ==============
3
+
4
+ Application event bus
5
+ ---------------------
6
+
7
+ SimpleDomControlClient includes a small application-level event bus in addition
8
+ to browser DOM events.
9
+
10
+ Exports:
11
+
12
+ - ``setEvent(name, functionName = name)``
13
+ - ``on(name, controller)``
14
+ - ``trigger(name, ...args)``
15
+ - ``allOff(controller)``
16
+
17
+ Usage:
18
+
19
+ .. code-block:: javascript
20
+
21
+ import { setEvent, on, trigger } from "sdc_client";
22
+
23
+ setEvent("pushMsg", "handleMessage");
24
+
25
+ class Toasts {
26
+ handleMessage(title, message) {
27
+ console.log(title, message);
28
+ }
29
+ }
30
+
31
+ const toasts = new Toasts();
32
+ on("pushMsg", toasts);
33
+ trigger("pushMsg", "Saved", "The item was stored.");
34
+
35
+ The server transport uses this event bus to emit:
36
+
37
+ - ``pushMsg`` for non-error messages
38
+ - ``pushErrorMsg`` for error messages
39
+ - ``onNavLink`` for redirects
40
+
41
+ DOM event delegation
42
+ --------------------
43
+
44
+ The DOM event system listens on ``window`` for standard browser events and
45
+ dispatches them to controller handlers declared on matching elements.
46
+
47
+ The pipeline works as follows:
48
+
49
+ 1. ``initEvents()`` subscribes to standard browser events.
50
+ 2. When jQuery triggers a previously unseen custom event, the runtime adds it
51
+ to the watched event list automatically.
52
+ 3. ``windowEventHandler()`` walks from the event target upward through the DOM.
53
+ 4. For each element with a matching ``sdc_<event>`` attribute, the handler
54
+ resolves the owning controller.
55
+ 5. The handler name is matched either directly on the controller or through the
56
+ controller event map.
57
+
58
+ Declarative event attributes
59
+ ----------------------------
60
+
61
+ Elements can carry event attributes directly:
62
+
63
+ .. code-block:: html
64
+
65
+ <button sdc_click="save">Save</button>
66
+
67
+ If ``save`` exists on the current controller, it will be called with:
68
+
69
+ - ``$element``: the matched jQuery element
70
+ - ``event``: the native event object
71
+
72
+ Controller event maps
73
+ ---------------------
74
+
75
+ A more maintainable pattern is to define events in the controller:
76
+
77
+ .. code-block:: javascript
78
+
79
+ this.events.unshift({
80
+ click: {
81
+ ".save-button": "save",
82
+ ".delete-button": "removeItem",
83
+ },
84
+ });
85
+
86
+ At refresh time, ``setControllerEvents()`` finds the matching selectors and
87
+ adds internal ``sdc_<event>`` attributes to the corresponding DOM nodes.
88
+
89
+ DOM reconciliation
90
+ ------------------
91
+
92
+ The client contains a custom reconciliation step used by ``app.reconcile()``
93
+ and controller refresh operations.
94
+
95
+ Goals of reconciliation:
96
+
97
+ - keep matching DOM branches when possible
98
+ - update attributes and data bindings
99
+ - preserve stable nodes such as input elements
100
+ - remove and insert only what changed
101
+
102
+ The implementation builds trees for the virtual and real DOM, computes a
103
+ longest-common-branch style diff, then applies keep, delete, and insert
104
+ operations in index order.
105
+
106
+ This is the main reason refreshed content can preserve existing input elements
107
+ instead of replacing them outright.
108
+
109
+ Safe removal semantics
110
+ ----------------------
111
+
112
+ Always prefer the SDC-safe helpers over direct jQuery removal when a subtree may
113
+ contain controllers:
114
+
115
+ - ``app.safeRemove($elem)``
116
+ - ``app.safeEmpty($elem)``
117
+ - ``app.safeReplace($elem, $new)``
118
+
119
+ These helpers call controller ``remove()`` methods first so child controllers
120
+ can unregister application events, close sockets, and clean up forms.
@@ -0,0 +1,143 @@
1
+ Getting Started
2
+ ===============
3
+
4
+ Requirements
5
+ ------------
6
+
7
+ SimpleDomControlClient is designed to be used together with the Django package
8
+ ``simpledomcontrol``. The backend is expected to provide:
9
+
10
+ - Controller content endpoints referenced by ``contentUrl``.
11
+ - Optional server controller methods for ``serverCall()``.
12
+ - Model WebSocket endpoints for ``SdcQuerySet`` and ``SdcModel`` usage.
13
+ - Global values such as ``window.CSRF_TOKEN`` and optionally
14
+ ``window.SERVER_CALL_VIA_WEB_SOCKET``.
15
+
16
+ Installation
17
+ ------------
18
+
19
+ Install the package in a frontend project:
20
+
21
+ .. code-block:: bash
22
+
23
+ yarn add sdc_client
24
+
25
+ or:
26
+
27
+ .. code-block:: bash
28
+
29
+ npm install sdc_client
30
+
31
+ Basic bootstrap
32
+ ---------------
33
+
34
+ Import the runtime, define a controller, register it, and call ``init_sdc()``.
35
+
36
+ .. code-block:: javascript
37
+
38
+ import { app, AbstractSDC } from "sdc_client";
39
+
40
+ class HelloWorld extends AbstractSDC {
41
+ constructor() {
42
+ super();
43
+ this.contentUrl = "/sdc_view/demo/hello-world/";
44
+ this.events.unshift({
45
+ click: {
46
+ ".reload-button": "handleReload",
47
+ },
48
+ });
49
+ }
50
+
51
+ onInit(name = "World") {
52
+ this.name = name;
53
+ }
54
+
55
+ handleReload() {
56
+ return this.reload();
57
+ }
58
+ }
59
+
60
+ app.register(HelloWorld);
61
+ app.init_sdc();
62
+
63
+ In the HTML:
64
+
65
+ .. code-block:: html
66
+
67
+ <hello-world data-name='"Ada"'></hello-world>
68
+
69
+ Tag name mapping
70
+ ----------------
71
+
72
+ Controller classes are mapped to tag names automatically.
73
+
74
+ - ``HelloWorld`` becomes ``<hello-world>``.
75
+ - A class ending in ``Controller`` has the suffix removed.
76
+ - ``UserListController`` becomes ``<user-list>``.
77
+
78
+ The mapping is implemented by ``app.controllerToTag()``.
79
+
80
+ Controller content loading
81
+ --------------------------
82
+
83
+ If a controller sets ``contentUrl``, the runtime fetches HTML for that
84
+ controller before rendering nested child controllers.
85
+
86
+ Important behavior:
87
+
88
+ - ``contentUrl = ""`` means no remote HTML is fetched.
89
+ - URLs containing placeholder values such as ``"%(user_id)s"`` are re-parsed
90
+ from DOM data attributes and force ``contentReload = true``.
91
+ - Responses are cached per controller tag unless ``contentReload`` is true.
92
+
93
+ Using ``data-*`` parameters
94
+ ---------------------------
95
+
96
+ ``onInit()`` arguments are populated from the DOM element's ``data-*``
97
+ attributes. The final argument is always an object with the remaining data
98
+ values.
99
+
100
+ Example:
101
+
102
+ .. code-block:: html
103
+
104
+ <user-card
105
+ data-user-id="7"
106
+ data-title='"Admin"'
107
+ data-active="true">
108
+ </user-card>
109
+
110
+ .. code-block:: javascript
111
+
112
+ class UserCard extends AbstractSDC {
113
+ onInit(userId, title, active, rest) {
114
+ this.userId = userId; // 7
115
+ this.title = title; // "Admin"
116
+ this.active = active; // true
117
+ this.rest = rest; // remaining data attributes
118
+ }
119
+ }
120
+
121
+ The parameter parser converts:
122
+
123
+ - integers to ``number``
124
+ - floats to ``number``
125
+ - ``true`` and ``false`` to ``boolean``
126
+ - ``none`` to ``null``
127
+ - ``undefined`` to ``undefined``
128
+ - quoted strings to plain strings
129
+ - controller property names to the corresponding controller value or method
130
+
131
+ Global controllers
132
+ ------------------
133
+
134
+ Register a controller as global when it should be instantiated once and exposed
135
+ through the global controller tree rather than repeated per matching DOM
136
+ container.
137
+
138
+ .. code-block:: javascript
139
+
140
+ app.registerGlobal(NotificationsController);
141
+
142
+ Global controllers are created during ``app.init_sdc()`` before regular body
143
+ controllers are resolved.
package/docs/index.rst ADDED
@@ -0,0 +1,22 @@
1
+ SimpleDomControlClient
2
+ ======================
3
+
4
+ SimpleDomControlClient is the browser-side runtime for the Django package
5
+ ``simpledomcontrol``. It scans the DOM for registered custom tags, creates
6
+ controller instances, loads HTML fragments from the server, binds DOM events,
7
+ and synchronizes model data through AJAX and WebSockets.
8
+
9
+ This documentation is organized around the way the library is used in a real
10
+ application: bootstrap the runtime, register controllers, render content,
11
+ handle events, and talk to server-backed models.
12
+
13
+ .. toctree::
14
+ :maxdepth: 2
15
+ :caption: Contents
16
+
17
+ overview
18
+ getting-started
19
+ controllers
20
+ models
21
+ events-and-dom
22
+ api-reference
@@ -0,0 +1,351 @@
1
+ Models
2
+ ======
3
+
4
+ Overview
5
+ --------
6
+
7
+ Model support in SimpleDomControlClient is centered on two pieces:
8
+
9
+ ``SdcModel``
10
+ A client-side object representing one backend record.
11
+
12
+ ``SdcQuerySet``
13
+ A live collection wrapper that loads, updates, saves, deletes, and renders
14
+ model-backed content over the SDC model transport.
15
+
16
+ The client expects the backend to expose the SDC model WebSocket protocol for:
17
+
18
+ - connect handshakes
19
+ - queryset loading
20
+ - item updates
21
+ - item creation
22
+ - deletion
23
+ - server-rendered views
24
+ - server-rendered forms
25
+ - chunked file uploads
26
+
27
+ Registering model classes
28
+ -------------------------
29
+
30
+ Model classes must be registered by name so queryset responses can be turned
31
+ into the correct JavaScript class.
32
+
33
+ .. code-block:: javascript
34
+
35
+ import { registerModel } from "sdc_client";
36
+ import Author from "./models/Author.js";
37
+ import Book from "./models/Book.js";
38
+
39
+ registerModel("Author", Author);
40
+ registerModel("Book", Book);
41
+
42
+ The registry is global. Once a class is registered, any queryset for that model
43
+ name can construct typed instances.
44
+
45
+ How controllers use models
46
+ --------------------------
47
+
48
+ Controllers usually create querysets through ``AbstractSDC.querySet()``:
49
+
50
+ .. code-block:: javascript
51
+
52
+ class AuthorList extends AbstractSDC {
53
+ onInit() {
54
+ this.authors = this.querySet("Author", { active: true });
55
+ }
56
+
57
+ async onLoad(html) {
58
+ await this.authors.load();
59
+ return super.onLoad(html);
60
+ }
61
+ }
62
+
63
+ This attaches the queryset to the controller so open sockets can be tracked and
64
+ closed when the controller is removed.
65
+
66
+ ``SdcQuerySet`` as a collection
67
+ -------------------------------
68
+
69
+ ``SdcQuerySet`` behaves like an array-like collection through a proxy.
70
+
71
+ You can:
72
+
73
+ - read ``queryset.length``
74
+ - access ``queryset[0]``
75
+ - iterate with ``for (const item of queryset)``
76
+ - call ``queryset.getIds()`` to get the current primary keys
77
+ - call ``queryset.byId(id)`` to look up a loaded instance
78
+
79
+ Example:
80
+
81
+ .. code-block:: javascript
82
+
83
+ await this.authors.load();
84
+
85
+ for (const author of this.authors) {
86
+ console.log(author.id, author.name);
87
+ }
88
+
89
+ const ada = this.authors.byId(1);
90
+
91
+ Loading and refreshing data
92
+ ---------------------------
93
+
94
+ There are two important ways to fetch queryset data:
95
+
96
+ ``load(modelQuery = null)``
97
+ Clears the current queryset cache and fetches matching rows from the server.
98
+ Use this when you want a fresh dataset and do not need to preserve the
99
+ current ``valuesList`` content.
100
+
101
+ ``update({ modelQuery = null, item = null })``
102
+ Refreshes server state as an alternative to ``load()``. Use this when the
103
+ queryset already exists and should be synchronized again. It can refresh:
104
+
105
+ - the active queryset filter
106
+ - a replacement filter passed through ``modelQuery``
107
+ - one specific item when ``item`` is provided
108
+
109
+ Typical guidance:
110
+
111
+ - use ``load()`` for the initial fetch
112
+ - use ``update()`` when the queryset already exists and you want to re-sync it
113
+ - use ``update({ item })`` when one known model may have changed and only that
114
+ record needs to be refreshed
115
+
116
+ Example:
117
+
118
+ .. code-block:: javascript
119
+
120
+ await this.authors.load({ active: true });
121
+
122
+ // Later, refresh the same queryset
123
+ await this.authors.update({});
124
+
125
+ // Refresh a specific item only
126
+ await this.authors.update({ item: this.authors.byId(1) });
127
+
128
+ Filtering and identity helpers
129
+ ------------------------------
130
+
131
+ ``setFilter(modelQuery)``
132
+ Replaces the queryset filter.
133
+
134
+ ``addFilter(modelQuery)``
135
+ Merges additional constraints into the current filter.
136
+
137
+ ``setIds(ids)``
138
+ Rebuilds the queryset from ids, another queryset, a single model, or a list
139
+ of ids. This is mainly useful for relation fields and client-side relation
140
+ synchronization.
141
+
142
+ ``get(modelQuery = null)``
143
+ Loads and returns exactly one item. It throws when the result count is not
144
+ exactly one.
145
+
146
+ Creating and saving models
147
+ --------------------------
148
+
149
+ ``new()``
150
+ Creates a new empty registered model instance, binds it to the queryset, and
151
+ appends it to ``valuesList``.
152
+
153
+ ``save({ pk = null, formName = "edit_form", data = null })``
154
+ Saves one or more existing models. If ``pk`` is given, the queryset saves
155
+ that one item. Otherwise it saves the current queryset items. If ``data`` is
156
+ omitted, the client uses the model's ``serialize()`` output.
157
+
158
+ ``create({ elem, data = null })``
159
+ Creates a new backend record. If ``data`` is omitted, the payload is taken
160
+ from the model instance serialization.
161
+
162
+ ``delete({ pk = null, elem = null })``
163
+ Deletes a record by primary key or by model object.
164
+
165
+ Example:
166
+
167
+ .. code-block:: javascript
168
+
169
+ const author = this.authors.new();
170
+ author.name = "Ada Lovelace";
171
+ author.age = 36;
172
+
173
+ await this.authors.create({ elem: author });
174
+
175
+ author.age = 37;
176
+ await this.authors.save({ pk: author.id });
177
+
178
+ Server-rendered model views
179
+ ---------------------------
180
+
181
+ ``SdcQuerySet`` can request server-rendered HTML and return it as a container
182
+ that is automatically passed through ``app.refresh()`` when the response
183
+ arrives.
184
+
185
+ Available methods:
186
+
187
+ ``view({ viewName, modelQuery, cbResolve, cbReject, templateContext, eventType })``
188
+ Generic named view renderer.
189
+
190
+ ``listView({ modelQuery, cbResolve, cbReject, templateContext })``
191
+ Convenience wrapper for list-style rendering.
192
+
193
+ ``detailView({ pk, cbResolve, cbReject, templateContext })``
194
+ Convenience wrapper for a single object detail view.
195
+
196
+ Example:
197
+
198
+ .. code-block:: javascript
199
+
200
+ const $list = this.authors.listView({
201
+ modelQuery: { active: true },
202
+ templateContext: { compact: true },
203
+ });
204
+
205
+ this.$container.find(".results").append($list);
206
+
207
+ Form synchronization and ``SdcModel`` state
208
+ -------------------------------------------
209
+
210
+ The most important rule for model forms is this:
211
+
212
+ ``SdcModel`` properties and form fields are expected to stay synchronized.
213
+
214
+ The form is not treated as an independent data store. It is a view of the
215
+ model object.
216
+
217
+ That synchronization happens in both directions:
218
+
219
+ ``syncModelToForm($form)``
220
+ Copies model properties into the form.
221
+
222
+ ``syncForm($form)``
223
+ Reads values from the form back into the ``SdcModel`` object and returns the
224
+ data used for submission.
225
+
226
+ This behavior matters because the default controller submit flow operates on the
227
+ model instance associated with the form, not on a detached raw payload.
228
+
229
+ Practical consequences:
230
+
231
+ - when model properties change, the form should be updated from the model
232
+ - when the user edits the form, the model should be updated from the form
233
+ - hidden fields are parsed back into typed JavaScript values
234
+ - file inputs become ``File`` objects on the model
235
+ - relation fields are converted into related ids or queryset-backed relations
236
+
237
+ The model object therefore remains the source of truth across:
238
+
239
+ - initial form rendering
240
+ - edits
241
+ - create calls
242
+ - save calls
243
+ - validation error flows
244
+ - later refreshes of the same object
245
+
246
+ How queryset form rendering works
247
+ ---------------------------------
248
+
249
+ The internal queryset form helper fetches server-rendered create or edit forms
250
+ and attaches the metadata expected by controller form submission.
251
+
252
+ When a form is prepared, the client:
253
+
254
+ - renders the returned HTML into the target container
255
+ - marks the form as create or edit
256
+ - stores ``data("model", modelObj)``
257
+ - stores ``data("model_pk", pk)``
258
+ - stores ``data("form_name", formName)``
259
+ - adds ``sdc_submit="submitModelFormDistributor"`` if missing
260
+ - registers the form on the model via ``addForm($form)``
261
+
262
+ This is why ``AbstractSDC.defaultSubmitModelForm()`` can read the bound model
263
+ from the form and choose between ``create()`` and ``save()`` automatically.
264
+
265
+ Validation errors and model-backed forms
266
+ ----------------------------------------
267
+
268
+ On submit failure, the controller default form handler reconciles returned form
269
+ HTML back into the existing DOM rather than replacing the entire subtree
270
+ blindly.
271
+
272
+ That allows the application to:
273
+
274
+ - keep the controller tree intact
275
+ - preserve more stable DOM nodes where possible
276
+ - show backend validation errors in the rendered form
277
+ - continue working with the same underlying ``SdcModel`` instance
278
+
279
+ Even when the error HTML changes, the client-side model object still represents
280
+ the active record being edited.
281
+
282
+ Relationships
283
+ -------------
284
+
285
+ The test suite shows two important serialization conventions:
286
+
287
+ - many-to-one relations are serialized as a single related primary key
288
+ - one-to-many relations are serialized as a list of related primary keys
289
+
290
+ This lets model instances expose richer client-side relation objects while
291
+ sending backend-friendly payloads.
292
+
293
+ Expected ``SdcModel`` capabilities
294
+ ----------------------------------
295
+
296
+ The client code and tests imply that registered model classes should provide at
297
+ least the following behavior:
298
+
299
+ - scalar field properties such as ``id``, ``name``, ``title``, and similar
300
+ - relation fields that can accept ids and queryset/model objects
301
+ - ``serialize()`` for backend payload generation
302
+ - ``syncModelToForm($form)`` for writing model state into form fields
303
+ - ``syncForm($form)`` for reading form fields back into model state
304
+ - ``addForm($form)`` for tracking rendered forms
305
+ - queryset linkage so save/create operations know where the model belongs
306
+
307
+ Connection lifecycle
308
+ --------------------
309
+
310
+ Each queryset manages its own WebSocket connection state.
311
+
312
+ Important methods and callbacks:
313
+
314
+ ``isConnected()``
315
+ Ensures the socket is open and the backend handshake has completed.
316
+
317
+ ``close()``
318
+ Closes the queryset socket and disables automatic reconnect.
319
+
320
+ ``noOpenRequests()``
321
+ Resolves when all currently tracked socket requests have completed.
322
+
323
+ ``onUpdate``
324
+ Callback invoked when the server pushes an update event.
325
+
326
+ ``onCreate``
327
+ Callback invoked when the server pushes a create event.
328
+
329
+ File uploads
330
+ ------------
331
+
332
+ If a model contains ``File`` values, the queryset uploads them in chunks before
333
+ issuing the final ``save()`` or ``create()`` request.
334
+
335
+ This process is automatic:
336
+
337
+ - file properties are detected on the model object
338
+ - the file is split into chunks
339
+ - upload metadata is sent with each chunk
340
+ - the final save/create payload references the uploaded file data
341
+
342
+ Summary
343
+ -------
344
+
345
+ Use the model layer when you need more than static controller HTML:
346
+
347
+ - ``load()`` for initial queryset fetches
348
+ - ``update()`` for re-synchronizing existing queryset state
349
+ - ``new()``, ``create()``, ``save()``, and ``delete()`` for persistence
350
+ - ``listView()`` and ``detailView()`` for server-rendered model fragments
351
+ - synchronized forms where the ``SdcModel`` object remains the source of truth
@@ -0,0 +1,66 @@
1
+ Overview
2
+ ========
3
+
4
+ What the project does
5
+ ---------------------
6
+
7
+ SimpleDomControlClient provides a lightweight component system built around
8
+ custom HTML tags and controller classes.
9
+
10
+ The client is responsible for:
11
+
12
+ - Registering controller classes against tag names such as ``<user-list>``.
13
+ - Finding those tags in the DOM and instantiating controller objects.
14
+ - Loading controller HTML from the backend through ``contentUrl``.
15
+ - Running controller lifecycle hooks such as ``onInit()``, ``onLoad()``,
16
+ ``willShow()``, and ``onRefresh()``.
17
+ - Delegating browser events to controller methods.
18
+ - Refreshing and reconciling DOM updates without discarding matching existing
19
+ elements.
20
+ - Calling backend controller methods through AJAX or WebSockets.
21
+ - Loading and saving server-backed model data through ``SdcQuerySet`` and
22
+ ``SdcModel``.
23
+
24
+ Architecture at a glance
25
+ ------------------------
26
+
27
+ The main exported building blocks are:
28
+
29
+ ``app``
30
+ Global runtime object. It boots the library, registers controllers,
31
+ refreshes content, and exposes DOM-safe helper methods.
32
+
33
+ ``AbstractSDC``
34
+ Base class for all controllers. It provides lifecycle hooks, parent/child
35
+ relationships, event configuration, server calls, and model/query helpers.
36
+
37
+ ``SdcQuerySet`` and ``SdcModel``
38
+ Client-side model abstractions used to query, create, update, delete, and
39
+ render model-backed content.
40
+
41
+ ``on()``, ``trigger()``, ``allOff()``, ``setEvent()``
42
+ A small application event bus separate from browser DOM events.
43
+
44
+ Runtime flow
45
+ ------------
46
+
47
+ At startup, ``app.init_sdc()`` performs the following steps:
48
+
49
+ 1. Initializes DOM event delegation.
50
+ 2. Ensures the transport layer is ready when server calls use WebSockets.
51
+ 3. Builds root controllers for the page body and global controllers.
52
+ 4. Scans the DOM for all registered controller tags.
53
+ 5. Creates controller instances and binds them to their DOM containers.
54
+ 6. Resolves tag parameters from ``data-*`` attributes and calls ``onInit()``.
55
+ 7. Loads controller HTML from the backend when ``contentUrl`` is defined.
56
+ 8. Replaces nested registered tags recursively.
57
+ 9. Wires configured DOM events and triggers ``onRefresh()``.
58
+
59
+ How this differs from common SPA frameworks
60
+ -------------------------------------------
61
+
62
+ SimpleDomControlClient is not a virtual-DOM-first SPA framework. The server
63
+ still produces much of the HTML, and controllers are thin client-side objects
64
+ that coordinate DOM behavior around that HTML. The library keeps enough client
65
+ state to support dynamic updates, forms, and model synchronization without
66
+ requiring a full frontend build architecture.
@@ -0,0 +1 @@
1
+ sphinx>=7,<9