sdc_client 0.158.9 → 0.160.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/CHANGELOG.md +58 -0
- package/LICENSE +21 -0
- package/dist/index.js +23 -13
- package/dist/ugly.index.js +2 -1
- package/dist/ugly.index.js.LICENSE.txt +1 -8
- package/gulp/gulp.jsx +11 -36
- package/package.json +23 -12
- package/src/index.js +31 -7
- package/src/simpleDomControl/AbstractSDC.js +15 -11
- package/src/simpleDomControl/sdc_controller.js +3 -3
- package/src/simpleDomControl/sdc_dom_events.js +5 -10
- package/src/simpleDomControl/sdc_events.js +3 -3
- package/src/simpleDomControl/sdc_main.js +34 -13
- package/src/simpleDomControl/sdc_model.js +225 -92
- package/src/simpleDomControl/sdc_params.js +0 -3
- package/src/simpleDomControl/sdc_server_call.js +21 -4
- package/src/simpleDomControl/sdc_test_utils.js +0 -1
- package/src/simpleDomControl/sdc_utils.js +59 -7
- package/src/simpleDomControl/sdc_view.js +16 -1
- package/.github/workflows/node.js.yml +0 -38
- package/.idea/inspectionProfiles/Project_Default.xml +0 -17
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -403
- package/.readthedocs.yaml +0 -13
- package/.tool-versions +0 -1
- package/SimpleDomControlClient.iml +0 -12
- package/docs/api-reference.rst +0 -225
- package/docs/conf.py +0 -11
- package/docs/controllers.rst +0 -228
- package/docs/events-and-dom.rst +0 -120
- package/docs/getting-started.rst +0 -143
- package/docs/index.rst +0 -22
- package/docs/models.rst +0 -351
- package/docs/overview.rst +0 -66
- package/docs/requirements.txt +0 -1
- package/eslint.config.js +0 -43
- package/gulpfile.cjs +0 -30
- package/jest.config.mjs +0 -197
- package/test/controller.test.js +0 -93
- package/test/dist.test.js +0 -127
- package/test/model.test.js +0 -330
- package/test/models/Author.js +0 -145
- package/test/models/Book.js +0 -112
- package/test/models/BookContent.js +0 -114
- package/test/models/SdcUser.js +0 -75
- package/test/models/src.js +0 -8
- package/test/sdc_model_dates.ai.test.js +0 -57
- package/test/sdc_server_call.ai.test.js +0 -267
- package/test/utils.js +0 -88
- package/test/view.test.js +0 -159
- package/test-setup.js +0 -4
- package/webpack.config/webpack.default.config.cjs +0 -14
- package/webpack.config/webpack.development.config.cjs +0 -14
- package/webpack.config/webpack.production.config.cjs +0 -11
package/docs/models.rst
DELETED
|
@@ -1,351 +0,0 @@
|
|
|
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
|
package/docs/overview.rst
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
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.
|
package/docs/requirements.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
sphinx>=7,<9
|
package/eslint.config.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import js from "@eslint/js";
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
|
|
4
|
-
export default [
|
|
5
|
-
{
|
|
6
|
-
ignores: ["dist/**", "node_modules/**"],
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
files: ["src/**/*.js"],
|
|
10
|
-
languageOptions: {
|
|
11
|
-
sourceType: "module",
|
|
12
|
-
ecmaVersion: "latest",
|
|
13
|
-
globals: {
|
|
14
|
-
...globals.browser,
|
|
15
|
-
...globals.node,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
rules: {
|
|
19
|
-
...js.configs.recommended.rules,
|
|
20
|
-
"no-console": "off",
|
|
21
|
-
"comma-dangle": ["warn", "only-multiline"],
|
|
22
|
-
"prefer-destructuring": ["error", { object: true, array: false }],
|
|
23
|
-
"no-restricted-imports": [
|
|
24
|
-
"error",
|
|
25
|
-
{
|
|
26
|
-
patterns: [
|
|
27
|
-
{
|
|
28
|
-
group: ["./*", "../*"],
|
|
29
|
-
message: "import statements should have an absolute path",
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
"max-len": [
|
|
35
|
-
"error",
|
|
36
|
-
{
|
|
37
|
-
code: 120,
|
|
38
|
-
ignoreComments: true,
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
];
|
package/gulpfile.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const gulp = require('gulp');
|
|
4
|
-
const webpack = require('webpack');
|
|
5
|
-
|
|
6
|
-
function javascript(done) {
|
|
7
|
-
const webpack_config = (process.env.NODE_ENV === 'development' ? './webpack.config/webpack.development.config.cjs' : './webpack.config/webpack.production.config.cjs');
|
|
8
|
-
|
|
9
|
-
const config = Object.assign({entry: {index: './src/index.js'}}, require(webpack_config));
|
|
10
|
-
|
|
11
|
-
webpack(config, (err, stats) => {
|
|
12
|
-
if (err) {
|
|
13
|
-
return done(err);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
console.log(stats.toString({colors: true, chunks: false}));
|
|
17
|
-
return done(stats.hasErrors() ? new Error('webpack build failed') : undefined);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
gulp.task('development', gulp.series((done) => {
|
|
23
|
-
process.env.NODE_ENV = 'development'
|
|
24
|
-
done();
|
|
25
|
-
}, javascript));
|
|
26
|
-
|
|
27
|
-
gulp.task('build', gulp.series((done) => {
|
|
28
|
-
process.env.NODE_ENV = 'production'
|
|
29
|
-
done();
|
|
30
|
-
}, javascript));
|
package/jest.config.mjs
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* For a detailed explanation regarding each configuration property, visit:
|
|
3
|
-
* https://jestjs.io/docs/configuration
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
// All imported modules in your tests should be mocked automatically
|
|
8
|
-
// automock: false,
|
|
9
|
-
|
|
10
|
-
// Stop running tests after `n` failures
|
|
11
|
-
// bail: 0,
|
|
12
|
-
|
|
13
|
-
// The directory where Jest should store its cached dependency information
|
|
14
|
-
// cacheDirectory: "/tmp/jest_rs",
|
|
15
|
-
|
|
16
|
-
// Automatically clear mock calls, instances, contexts and results before every test
|
|
17
|
-
// clearMocks: false,
|
|
18
|
-
|
|
19
|
-
// Indicates whether the coverage information should be collected while executing the test
|
|
20
|
-
collectCoverage: true,
|
|
21
|
-
|
|
22
|
-
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
23
|
-
// collectCoverageFrom: undefined,
|
|
24
|
-
|
|
25
|
-
// The directory where Jest should output its coverage files
|
|
26
|
-
coverageDirectory: "coverage",
|
|
27
|
-
|
|
28
|
-
// An array of regexp pattern strings used to skip coverage collection
|
|
29
|
-
// coveragePathIgnorePatterns: [
|
|
30
|
-
// "/node_modules/"
|
|
31
|
-
// ],
|
|
32
|
-
|
|
33
|
-
// Indicates which provider should be used to instrument code for coverage
|
|
34
|
-
coverageProvider: "v8",
|
|
35
|
-
|
|
36
|
-
// A list of reporter names that Jest uses when writing coverage reports
|
|
37
|
-
// coverageReporters: [
|
|
38
|
-
// "json",
|
|
39
|
-
// "text",
|
|
40
|
-
// "lcov",
|
|
41
|
-
// "clover"
|
|
42
|
-
// ],
|
|
43
|
-
|
|
44
|
-
// An object that configures minimum threshold enforcement for coverage results
|
|
45
|
-
// coverageThreshold: undefined,
|
|
46
|
-
|
|
47
|
-
// A path to a custom dependency extractor
|
|
48
|
-
// dependencyExtractor: undefined,
|
|
49
|
-
|
|
50
|
-
// Make calling deprecated APIs throw helpful error messages
|
|
51
|
-
// errorOnDeprecated: false,
|
|
52
|
-
|
|
53
|
-
// The default configuration for fake timers
|
|
54
|
-
// fakeTimers: {
|
|
55
|
-
// "enableGlobally": false
|
|
56
|
-
// },
|
|
57
|
-
|
|
58
|
-
// Force coverage collection from ignored files using an array of glob patterns
|
|
59
|
-
// forceCoverageMatch: [],
|
|
60
|
-
|
|
61
|
-
// A path to a module which exports an async function that is triggered once before all test suites
|
|
62
|
-
// globalSetup: undefined,
|
|
63
|
-
|
|
64
|
-
// A path to a module which exports an async function that is triggered once after all test suites
|
|
65
|
-
// globalTeardown: undefined,
|
|
66
|
-
|
|
67
|
-
// A set of global variables that need to be available in all test environments
|
|
68
|
-
// globals: {},
|
|
69
|
-
|
|
70
|
-
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
71
|
-
// maxWorkers: "50%",
|
|
72
|
-
|
|
73
|
-
// An array of directory names to be searched recursively up from the requiring module's location
|
|
74
|
-
// moduleDirectories: [
|
|
75
|
-
// "node_modules"
|
|
76
|
-
// ],
|
|
77
|
-
|
|
78
|
-
// An array of file extensions your modules use
|
|
79
|
-
// moduleFileExtensions: [
|
|
80
|
-
// "js",
|
|
81
|
-
// "mjs",
|
|
82
|
-
// "cjs",
|
|
83
|
-
// "jsx",
|
|
84
|
-
// "ts",
|
|
85
|
-
// "tsx",
|
|
86
|
-
// "json",
|
|
87
|
-
// "node"
|
|
88
|
-
// ],
|
|
89
|
-
|
|
90
|
-
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
91
|
-
// moduleNameMapper: {},
|
|
92
|
-
|
|
93
|
-
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
94
|
-
// modulePathIgnorePatterns: [],
|
|
95
|
-
|
|
96
|
-
// Activates notifications for test results
|
|
97
|
-
// notify: false,
|
|
98
|
-
|
|
99
|
-
// An enum that specifies notification mode. Requires { notify: true }
|
|
100
|
-
// notifyMode: "failure-change",
|
|
101
|
-
|
|
102
|
-
// A preset that is used as a base for Jest's configuration
|
|
103
|
-
// preset: undefined,
|
|
104
|
-
|
|
105
|
-
// Run tests from one or more projects
|
|
106
|
-
// projects: undefined,
|
|
107
|
-
|
|
108
|
-
// Use this configuration option to add custom reporters to Jest
|
|
109
|
-
// reporters: undefined,
|
|
110
|
-
|
|
111
|
-
// Automatically reset mock state before every test
|
|
112
|
-
// resetMocks: false,
|
|
113
|
-
|
|
114
|
-
// Reset the module registry before running each individual test
|
|
115
|
-
// resetModules: false,
|
|
116
|
-
|
|
117
|
-
// A path to a custom resolver
|
|
118
|
-
// resolver: undefined,
|
|
119
|
-
|
|
120
|
-
// Automatically restore mock state and implementation before every test
|
|
121
|
-
// restoreMocks: false,
|
|
122
|
-
|
|
123
|
-
// The root directory that Jest should scan for tests and modules within
|
|
124
|
-
// rootDir: undefined,
|
|
125
|
-
|
|
126
|
-
// A list of paths to directories that Jest should use to search for files in
|
|
127
|
-
// roots: [
|
|
128
|
-
// "<rootDir>"
|
|
129
|
-
// ],
|
|
130
|
-
|
|
131
|
-
// Allows you to use a custom runner instead of Jest's default test runner
|
|
132
|
-
// runner: "jest-runner",
|
|
133
|
-
|
|
134
|
-
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
135
|
-
setupFiles: [
|
|
136
|
-
"<rootDir>/test-setup.js"
|
|
137
|
-
],
|
|
138
|
-
|
|
139
|
-
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
140
|
-
// setupFilesAfterEnv: [],
|
|
141
|
-
|
|
142
|
-
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
143
|
-
// slowTestThreshold: 5,
|
|
144
|
-
|
|
145
|
-
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
146
|
-
// snapshotSerializers: [],
|
|
147
|
-
|
|
148
|
-
// The test environment that will be used for testing
|
|
149
|
-
testEnvironment: "jsdom",
|
|
150
|
-
|
|
151
|
-
// Options that will be passed to the testEnvironment
|
|
152
|
-
// testEnvironmentOptions: {},
|
|
153
|
-
|
|
154
|
-
// Adds a location field to test results
|
|
155
|
-
// testLocationInResults: false,
|
|
156
|
-
|
|
157
|
-
// The glob patterns Jest uses to detect test files
|
|
158
|
-
// testMatch: [
|
|
159
|
-
// "**/__tests__/**/*.[jt]s?(x)",
|
|
160
|
-
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
161
|
-
// ],
|
|
162
|
-
|
|
163
|
-
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
164
|
-
// testPathIgnorePatterns: [
|
|
165
|
-
// "/node_modules/"
|
|
166
|
-
// ],
|
|
167
|
-
|
|
168
|
-
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
169
|
-
// testRegex: [],
|
|
170
|
-
|
|
171
|
-
// This option allows the use of a custom results processor
|
|
172
|
-
// testResultsProcessor: undefined,
|
|
173
|
-
|
|
174
|
-
// This option allows use of a custom test runner
|
|
175
|
-
// testRunner: "jest-circus/runner",
|
|
176
|
-
|
|
177
|
-
// A map from regular expressions to paths to transformers
|
|
178
|
-
// transform: undefined,
|
|
179
|
-
|
|
180
|
-
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
181
|
-
// transformIgnorePatterns: [
|
|
182
|
-
// "/node_modules/",
|
|
183
|
-
// "\\.pnp\\.[^\\/]+$"
|
|
184
|
-
// ],
|
|
185
|
-
|
|
186
|
-
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
187
|
-
// unmockedModulePathPatterns: undefined,
|
|
188
|
-
|
|
189
|
-
// Indicates whether each individual test should be reported during the run
|
|
190
|
-
// verbose: undefined,
|
|
191
|
-
|
|
192
|
-
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
193
|
-
// watchPathIgnorePatterns: [],
|
|
194
|
-
|
|
195
|
-
// Whether to use watchman for file crawling
|
|
196
|
-
// watchman: true,
|
|
197
|
-
};
|