arethesis 0.0.0-stage → 0.1.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 (137) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/LICENSE +21 -0
  3. package/README.md +121 -2
  4. package/dist/arethesis-z8eGA7mL.js +5177 -0
  5. package/dist/arethesis-z8eGA7mL.js.map +1 -0
  6. package/dist/arethesis.js +147 -0
  7. package/dist/arethesis.js.map +1 -0
  8. package/dist/binding/data-binder.d.ts +82 -0
  9. package/dist/binding/data-binder.d.ts.map +1 -0
  10. package/dist/binding/types.d.ts +119 -0
  11. package/dist/binding/types.d.ts.map +1 -0
  12. package/dist/binding/validation-engine.d.ts +22 -0
  13. package/dist/binding/validation-engine.d.ts.map +1 -0
  14. package/dist/components/component.d.ts +93 -0
  15. package/dist/components/component.d.ts.map +1 -0
  16. package/dist/components/decorators.d.ts +9 -0
  17. package/dist/components/decorators.d.ts.map +1 -0
  18. package/dist/components/runtime.d.ts +17 -0
  19. package/dist/components/runtime.d.ts.map +1 -0
  20. package/dist/components/template-loader.d.ts +37 -0
  21. package/dist/components/template-loader.d.ts.map +1 -0
  22. package/dist/components/types.d.ts +22 -0
  23. package/dist/components/types.d.ts.map +1 -0
  24. package/dist/components.js +568 -0
  25. package/dist/components.js.map +1 -0
  26. package/dist/core/arethesis.d.ts +96 -0
  27. package/dist/core/arethesis.d.ts.map +1 -0
  28. package/dist/core/types.d.ts +40 -0
  29. package/dist/core/types.d.ts.map +1 -0
  30. package/dist/data/list-view-registry.d.ts +69 -0
  31. package/dist/data/list-view-registry.d.ts.map +1 -0
  32. package/dist/data/object-store.d.ts +88 -0
  33. package/dist/data/object-store.d.ts.map +1 -0
  34. package/dist/data/optimistic-updates.d.ts +59 -0
  35. package/dist/data/optimistic-updates.d.ts.map +1 -0
  36. package/dist/data/persistence-manager.d.ts +56 -0
  37. package/dist/data/persistence-manager.d.ts.map +1 -0
  38. package/dist/data/types.d.ts +145 -0
  39. package/dist/data/types.d.ts.map +1 -0
  40. package/dist/http/auth-manager.d.ts +60 -0
  41. package/dist/http/auth-manager.d.ts.map +1 -0
  42. package/dist/http/http-client.d.ts +77 -0
  43. package/dist/http/http-client.d.ts.map +1 -0
  44. package/dist/http/http-error.d.ts +35 -0
  45. package/dist/http/http-error.d.ts.map +1 -0
  46. package/dist/http/mapping.d.ts +21 -0
  47. package/dist/http/mapping.d.ts.map +1 -0
  48. package/dist/http/types.d.ts +237 -0
  49. package/dist/http/types.d.ts.map +1 -0
  50. package/dist/index.d.ts +60 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/kit/data-table.d.ts +57 -0
  53. package/dist/kit/data-table.d.ts.map +1 -0
  54. package/dist/kit/flex-view.d.ts +42 -0
  55. package/dist/kit/flex-view.d.ts.map +1 -0
  56. package/dist/kit/form.d.ts +13 -0
  57. package/dist/kit/form.d.ts.map +1 -0
  58. package/dist/kit/index.d.ts +18 -0
  59. package/dist/kit/index.d.ts.map +1 -0
  60. package/dist/kit/list.d.ts +10 -0
  61. package/dist/kit/list.d.ts.map +1 -0
  62. package/dist/mixins/context-menu.d.ts +3 -0
  63. package/dist/mixins/context-menu.d.ts.map +1 -0
  64. package/dist/mixins/draggable.d.ts +3 -0
  65. package/dist/mixins/draggable.d.ts.map +1 -0
  66. package/dist/mixins/dropdown.d.ts +3 -0
  67. package/dist/mixins/dropdown.d.ts.map +1 -0
  68. package/dist/mixins/editable.d.ts +3 -0
  69. package/dist/mixins/editable.d.ts.map +1 -0
  70. package/dist/mixins/grid-navigation.d.ts +3 -0
  71. package/dist/mixins/grid-navigation.d.ts.map +1 -0
  72. package/dist/mixins/index.d.ts +19 -0
  73. package/dist/mixins/index.d.ts.map +1 -0
  74. package/dist/mixins/infinite-scroll.d.ts +3 -0
  75. package/dist/mixins/infinite-scroll.d.ts.map +1 -0
  76. package/dist/mixins/registry.d.ts +41 -0
  77. package/dist/mixins/registry.d.ts.map +1 -0
  78. package/dist/mixins/resizable.d.ts +3 -0
  79. package/dist/mixins/resizable.d.ts.map +1 -0
  80. package/dist/mixins/sortable.d.ts +3 -0
  81. package/dist/mixins/sortable.d.ts.map +1 -0
  82. package/dist/mixins/tooltip.d.ts +3 -0
  83. package/dist/mixins/tooltip.d.ts.map +1 -0
  84. package/dist/mixins/types.d.ts +165 -0
  85. package/dist/mixins/types.d.ts.map +1 -0
  86. package/dist/mixins/utils.d.ts +22 -0
  87. package/dist/mixins/utils.d.ts.map +1 -0
  88. package/dist/plugins/async-validators.d.ts +9 -0
  89. package/dist/plugins/async-validators.d.ts.map +1 -0
  90. package/dist/plugins/builtins.d.ts +9 -0
  91. package/dist/plugins/builtins.d.ts.map +1 -0
  92. package/dist/plugins/date-utils.d.ts +16 -0
  93. package/dist/plugins/date-utils.d.ts.map +1 -0
  94. package/dist/plugins/plugin-manager.d.ts +29 -0
  95. package/dist/plugins/plugin-manager.d.ts.map +1 -0
  96. package/dist/plugins/rich-text.d.ts +15 -0
  97. package/dist/plugins/rich-text.d.ts.map +1 -0
  98. package/dist/plugins/types.d.ts +50 -0
  99. package/dist/plugins/types.d.ts.map +1 -0
  100. package/dist/realtime/azure-pubsub-manager.d.ts +49 -0
  101. package/dist/realtime/azure-pubsub-manager.d.ts.map +1 -0
  102. package/dist/realtime/collab/collab-session.d.ts +75 -0
  103. package/dist/realtime/collab/collab-session.d.ts.map +1 -0
  104. package/dist/realtime/collab/cursor-overlay.d.ts +20 -0
  105. package/dist/realtime/collab/cursor-overlay.d.ts.map +1 -0
  106. package/dist/realtime/collab/textarea-adapter.d.ts +27 -0
  107. package/dist/realtime/collab/textarea-adapter.d.ts.map +1 -0
  108. package/dist/realtime/ot/client.d.ts +27 -0
  109. package/dist/realtime/ot/client.d.ts.map +1 -0
  110. package/dist/realtime/ot/server.d.ts +36 -0
  111. package/dist/realtime/ot/server.d.ts.map +1 -0
  112. package/dist/realtime/ot/text-operation.d.ts +55 -0
  113. package/dist/realtime/ot/text-operation.d.ts.map +1 -0
  114. package/dist/realtime/reconnect.d.ts +22 -0
  115. package/dist/realtime/reconnect.d.ts.map +1 -0
  116. package/dist/realtime/sse-manager.d.ts +37 -0
  117. package/dist/realtime/sse-manager.d.ts.map +1 -0
  118. package/dist/realtime/types.d.ts +122 -0
  119. package/dist/realtime/types.d.ts.map +1 -0
  120. package/dist/realtime/websocket-manager.d.ts +34 -0
  121. package/dist/realtime/websocket-manager.d.ts.map +1 -0
  122. package/dist/theme.css +516 -0
  123. package/dist/utils/backoff.d.ts +18 -0
  124. package/dist/utils/backoff.d.ts.map +1 -0
  125. package/dist/utils/dates.d.ts +22 -0
  126. package/dist/utils/dates.d.ts.map +1 -0
  127. package/dist/utils/dom.d.ts +16 -0
  128. package/dist/utils/dom.d.ts.map +1 -0
  129. package/dist/utils/emitter.d.ts +17 -0
  130. package/dist/utils/emitter.d.ts.map +1 -0
  131. package/dist/utils/path.d.ts +33 -0
  132. package/dist/utils/path.d.ts.map +1 -0
  133. package/dist/utils/sanitize.d.ts +20 -0
  134. package/dist/utils/sanitize.d.ts.map +1 -0
  135. package/dist/utils/url.d.ts +16 -0
  136. package/dist/utils/url.d.ts.map +1 -0
  137. package/package.json +95 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ The first public release.
6
+
7
+ ### Highlights
8
+
9
+ - **Component kit** (`arethesis/components`): `<a-data-table>`, `<a-flex-view>`, `<a-list>`, `<a-form>` and a themeable light/dark stylesheet.
10
+ - **Collaborative editing**: a convergent OT implementation (`TextOperation`, `OTClient`), a reference `CollabServer`, and `CollabSession` with presence, live cursors and offline edits.
11
+ - **Endpoints**: named endpoints with path params, response mapping with nested normalization, cursor pagination, cache modes (`cache-first`, `swr`) and batching.
12
+ - **List views** that load, page, sort, filter and refetch themselves.
13
+ - **Components** bind to lists with keyed reconciliation, loading/empty/error templates, infinite scroll, events and declarative islands (`data-source`, `data-list`, `data-hydrate`).
14
+ - **Nine mixins**: `draggable`, `editable`, `grid-navigation`, `infinite-scroll`, `sortable`, `resizable`, `dropdown`, `tooltip`, `context-menu`. All are keyboard accessible and emit events for declarative use.
15
+ - **Plugins**: a dependency-free `rich-text` editor, `date-utils` and `async-validators`, loadable by name.
16
+ - **Auth**: token storage options, 401 refresh-and-retry, cross-tab sync.
17
+ - **Persistence**: on by default, batched writes, `maxAge`, graceful fallback.
18
+
19
+ ### Security
20
+
21
+ - Bearer tokens are only sent to trusted origins.
22
+ - Link and image URLs are sanitized; `html` bindings are sanitized by default.
23
+ - Merges and mappings are protected against prototype pollution.
24
+ - Logout clears cached data from memory and IndexedDB.
25
+ - Azure Web PubSub cache invalidation only honors server messages.
26
+
27
+ ### Reliability
28
+
29
+ - Concurrent optimistic updates never undo each other (field-level rollback).
30
+ - Empty responses are handled cleanly, and POST/PATCH are never retried unless you opt in.
31
+ - A network blip during token refresh never logs the user out.
32
+ - Dates are parsed and formatted in local time everywhere.
33
+ - The OT engine is property-tested to converge for concurrent edits.
34
+ - Keyboard focus is never trapped by grid navigation.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ada Graves
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,122 @@
1
- # Temporary Holding Version
1
+ # Arethesis
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/aideendewinter/arethesis/actions/workflows/ci.yml/badge.svg)](https://github.com/aideendewinter/arethesis/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+
6
+ **Data-driven web components, without the framework tax.**
7
+
8
+ Arethesis gives server-rendered pages a normalized data store, config-driven APIs, live updates, collaborative editing, and accessible UI behaviors, all built on plain HTML and Light DOM custom elements. There's no virtual DOM, no compiler and no runtime dependencies.
9
+
10
+ ```bash
11
+ npm install arethesis
12
+ ```
13
+
14
+ - **Light DOM components.** Your CSS and dev tools just work, and server-rendered markup hydrates in place.
15
+ - **One normalized store.** Every object lives once under `type:id`. Change it anywhere and every view of it updates.
16
+ - **Config-driven HTTP.** Named endpoints, response mapping, nested normalization, cursor pagination, safe retries, batching and cache modes.
17
+ - **Live by default.** SSE cache invalidation, WebSocket channels, Azure Web PubSub, and convergent operational transformation for collaborative text.
18
+ - **Offline-ready.** IndexedDB persistence, TTLs, optimistic updates with field-level rollback.
19
+ - **Accessible behaviors.** Nine keyboard-friendly mixins with ARIA built in: sortable, grid navigation, dropdown, context menu and more.
20
+ - **Secure defaults.** Sanitized HTML and URLs, origin-scoped auth headers, prototype-pollution-safe merges, and a logout that wipes cached data.
21
+
22
+ **[Live examples →](https://aideendewinter.github.io/arethesis/)**: a 10,000-row directory, a kanban board, a collaborative editor, a live dashboard, a signup form, and an offline/caching playground. Run them locally with `npm run examples`; the source is in [`examples/`](examples/).
23
+
24
+ ---
25
+
26
+ ## 60-second tour
27
+
28
+ ```ts
29
+ import { getArethesis, defineType, defineEndpoint, Component, defineComponent } from 'arethesis';
30
+
31
+ // 1. Describe your data and where it comes from.
32
+ defineType({ name: 'Person', endpoint: 'getPerson', ttl: 5 * 60_000 });
33
+ defineEndpoint('getPerson', {
34
+ url: '/people/:id',
35
+ type: 'Person',
36
+ mapping: { fields: { id: 'id', name: 'fullName', email: 'contact.email' } },
37
+ });
38
+
39
+ // 2. Start the app.
40
+ const app = getArethesis();
41
+ await app.init({
42
+ http: { baseUrl: 'https://api.example.com' },
43
+ auth: { loginUrl: '/auth/login', refreshUrl: '/auth/refresh' },
44
+ sse: { url: '/events' }, // server pushes { type, id } to invalidate objects
45
+ });
46
+
47
+ // 3. Define a component. Its template is plain HTML.
48
+ @defineComponent({
49
+ tag: 'person-card',
50
+ html: `
51
+ <template id="main">
52
+ <h2 data-bind="name"></h2>
53
+ <a data-bind="email"></a>
54
+ </template>
55
+ <template id="loading"><div class="skeleton"></div></template>`,
56
+ })
57
+ class PersonCard extends Component {
58
+ static bindConfig = {
59
+ fields: { name: {}, email: { displayType: 'link', href: v => `mailto:${v}` } },
60
+ };
61
+ }
62
+ ```
63
+
64
+ ```html
65
+ <!-- 4. Use it anywhere. It fetches, renders, and refetches when the server says the data changed. -->
66
+ <person-card data-source="Person:42"></person-card>
67
+ ```
68
+
69
+ When the server sends `invalidate { type: "Person", id: 42 }` over SSE, every `<person-card>` showing person 42 refetches and patches only the text that changed.
70
+
71
+ ## What's inside
72
+
73
+ | Area | What you get |
74
+ | --- | --- |
75
+ | **Store** | `ObjectStore` with shallow/deep/custom merges, TTL, version-based conflict rejection, batching, per-object and per-type subscriptions |
76
+ | **Lists** | `ListView`s: deterministic ids, filters and sort sent to the server, cursor pagination, `load` / `loadMore` / `refresh`, auto-refetch when invalidated |
77
+ | **HTTP** | Named endpoints with `:params`, response mapping with nested normalization, retries only for idempotent methods, Retry-After, timeouts, AbortSignal, interceptors, GET dedupe, `cache-first` / `swr`, batching |
78
+ | **Auth** | JWT lifecycle with refresh before expiry, a 401 triggers refresh and one retry, local/session/memory storage, cross-tab sync, bearer token only sent to trusted origins |
79
+ | **Components** | `Component` base class: object and list binding, keyed reconciliation, loading/empty/error templates, retry, infinite scroll, `on`/`emit`, islands via `data-source` / `data-list` |
80
+ | **Binding** | `DataBinder`: 15 display types, two-way inputs, safe URL/HTML rendering, validation UI with an accessible error summary |
81
+ | **Validation** | 16 built-in validators, async validators with cancellation, `{param}` messages, translations |
82
+ | **Real-time** | `SSEManager`, `WebSocketManager`, `AzurePubSubManager` with shared reconnect/backoff, token refresh on reconnect, status events |
83
+ | **Collaboration** | `TextOperation` OT, `OTClient`, a reference `CollabServer`, and `CollabSession` with presence and live cursors |
84
+ | **Mixins** | `draggable`, `editable`, `grid-navigation`, `infinite-scroll`, `sortable`, `resizable`, `dropdown`, `tooltip`, `context-menu` |
85
+ | **Plugins** | `date-utils`, `async-validators`, a dependency-free `rich-text` editor, and an API for your own |
86
+ | **Component kit** | `<a-data-table>`, `<a-flex-view>`, `<a-list>`, `<a-form>` and a themeable stylesheet (light and dark) |
87
+
88
+ ## Documentation
89
+
90
+ - [Getting started](docs/getting-started.md)
91
+ - [Core concepts](docs/concepts.md)
92
+ - [Data: store, list views, optimistic updates, persistence](docs/data.md)
93
+ - [HTTP and authentication](docs/http.md)
94
+ - [Components](docs/components.md)
95
+ - [Binding and validation](docs/binding.md)
96
+ - [Real-time and collaboration](docs/realtime.md)
97
+ - [Mixins](docs/mixins.md)
98
+ - [Plugins](docs/plugins.md)
99
+ - [Component kit](docs/component-kit.md)
100
+ - [Security](docs/security.md)
101
+ - API reference: `npm run docs` generates it into `docs/api/`.
102
+
103
+ ## Browser support
104
+
105
+ Arethesis targets evergreen browsers (the last two versions of Chrome, Edge, Firefox and Safari). It uses Custom Elements, ES2022 classes and private fields, `AbortController`, `IntersectionObserver`, and (optionally) IndexedDB, `EventSource` and `WebSocket`.
106
+
107
+ ## Using decorators
108
+
109
+ `@defineComponent` works with TypeScript's `experimentalDecorators` and with standard decorators. If your toolchain does neither, call it as a function:
110
+
111
+ ```ts
112
+ class PersonCard extends Component {}
113
+ defineComponent({ tag: 'person-card', html: '…' })(PersonCard);
114
+ ```
115
+
116
+ ## Contributing
117
+
118
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Report security issues as described in [SECURITY.md](SECURITY.md).
119
+
120
+ ## License
121
+
122
+ [MIT](LICENSE)