domma-js 0.56.0 → 0.58.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/README.md +2 -2
- package/assets/types/generated/public/assets/flags/africa.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/americas.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/asia.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/europe.d.ts +9 -0
- package/assets/types/generated/public/assets/flags/index.d.ts +11 -0
- package/assets/types/generated/public/assets/flags/oceania.d.ts +2 -0
- package/assets/types/generated/public/assets/icons/buildings.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/code.d.ts +2 -0
- package/assets/types/generated/public/assets/icons/commerce.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/communication.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/devices.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/emojis.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/files.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/finance.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/forms.d.ts +5 -0
- package/assets/types/generated/public/assets/icons/health.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/index.d.ts +24 -0
- package/assets/types/generated/public/assets/icons/media.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/navigation.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/seasonal.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/social.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/sport.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/status.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/transport.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/ui.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/weather.d.ts +6 -0
- package/assets/types/generated/src/auth.d.ts +424 -0
- package/assets/types/generated/src/avatar.d.ts +270 -0
- package/assets/types/generated/src/binding-source.d.ts +58 -0
- package/assets/types/generated/src/butterfly-drawing.d.ts +2 -0
- package/assets/types/generated/src/component-factory.d.ts +150 -0
- package/assets/types/generated/src/component.d.ts +162 -0
- package/assets/types/generated/src/components/back-to-top.d.ts +150 -0
- package/assets/types/generated/src/components/badge.d.ts +208 -0
- package/assets/types/generated/src/components/card.d.ts +189 -0
- package/assets/types/generated/src/components/command-palette.d.ts +352 -0
- package/assets/types/generated/src/components/dropzone.d.ts +342 -0
- package/assets/types/generated/src/components/focus-trap.d.ts +238 -0
- package/assets/types/generated/src/components/loader.d.ts +133 -0
- package/assets/types/generated/src/components/modal.d.ts +339 -0
- package/assets/types/generated/src/components/range-slider.d.ts +267 -0
- package/assets/types/generated/src/components/shared.d.ts +91 -0
- package/assets/types/generated/src/components/split-pane.d.ts +239 -0
- package/assets/types/generated/src/components/toast.d.ts +284 -0
- package/assets/types/generated/src/components/tooltip.d.ts +200 -0
- package/assets/types/generated/src/components/virtual-list.d.ts +340 -0
- package/assets/types/generated/src/config.d.ts +193 -0
- package/assets/types/generated/src/context-cursor.d.ts +69 -0
- package/assets/types/generated/src/context-menu.d.ts +596 -0
- package/assets/types/generated/src/dates.d.ts +367 -0
- package/assets/types/generated/src/dom.d.ts +1221 -0
- package/assets/types/generated/src/effects.d.ts +1281 -0
- package/assets/types/generated/src/elements.d.ts +4994 -0
- package/assets/types/generated/src/escape.d.ts +5 -0
- package/assets/types/generated/src/flags-bundle.d.ts +4 -0
- package/assets/types/generated/src/flags.d.ts +338 -0
- package/assets/types/generated/src/forms.d.ts +1060 -0
- package/assets/types/generated/src/globals.d.ts +45 -0
- package/assets/types/generated/src/http.d.ts +131 -0
- package/assets/types/generated/src/i18n.d.ts +261 -0
- package/assets/types/generated/src/icons.d.ts +213 -0
- package/assets/types/generated/src/index.d.ts +249 -0
- package/assets/types/generated/src/input-group.d.ts +135 -0
- package/assets/types/generated/src/models.d.ts +968 -0
- package/assets/types/generated/src/popover.d.ts +413 -0
- package/assets/types/generated/src/router.d.ts +344 -0
- package/assets/types/generated/src/safe-url.d.ts +10 -0
- package/assets/types/generated/src/sanitize.d.ts +97 -0
- package/assets/types/generated/src/schema-builder.d.ts +420 -0
- package/assets/types/generated/src/skeleton.d.ts +135 -0
- package/assets/types/generated/src/smooth-caret.d.ts +61 -0
- package/assets/types/generated/src/sortable.d.ts +368 -0
- package/assets/types/generated/src/storage.d.ts +93 -0
- package/assets/types/generated/src/tables.d.ts +901 -0
- package/assets/types/generated/src/theme.d.ts +262 -0
- package/assets/types/generated/src/ticker-tape-drawing.d.ts +2 -0
- package/assets/types/generated/src/treeview.d.ts +504 -0
- package/assets/types/generated/src/utils.d.ts +1667 -0
- package/assets/types/generated/src/web-components/base/domma-element.d.ts +134 -0
- package/assets/types/generated/src/web-components/index.d.ts +14 -0
- package/assets/types/generated/vendor/domma-reactive.d.ts +587 -0
- package/assets/types/index.d.ts +104 -226
- package/package.json +5 -2
- package/public/dist/bundles/domma-complete.css +20 -14
- package/public/dist/bundles/domma-data-focused.css +20 -14
- package/public/dist/bundles/domma-essentials.css +20 -14
- package/public/dist/bundles/domma-full.css +20 -14
- package/public/dist/bundles/domma-minimal.css +8 -8
- package/public/dist/domma-flags.esm.js +3 -3
- package/public/dist/domma-flags.esm.js.map +1 -1
- package/public/dist/domma-flags.min.js +3 -3
- package/public/dist/domma-flags.min.js.map +1 -1
- package/public/dist/domma-syntax.min.js +3 -3
- package/public/dist/domma.css +3 -3
- package/public/dist/domma.esm.js +5 -5
- package/public/dist/domma.esm.js.map +1 -1
- package/public/dist/domma.min.js +5 -5
- package/public/dist/domma.min.js.map +1 -1
- package/public/dist/elements.css +9 -3
- package/public/dist/grid.css +3 -3
- package/public/dist/syntax.css +3 -3
- package/public/dist/themes/domma-themes.css +3 -3
- package/templates/kickstart/.claude/snippets.md +1 -1
- package/templates/kickstart/CLAUDE.md +1 -1
- package/templates/kickstart/frontend/types/domma.d.ts +7 -4
- package/templates/kickstart-spa/.claude/snippets.md +1 -1
- package/assets/types/config.d.ts +0 -136
- package/assets/types/dates.d.ts +0 -209
- package/assets/types/dom.d.ts +0 -448
- package/assets/types/elements.d.ts +0 -1168
- package/assets/types/flags.d.ts +0 -130
- package/assets/types/http.d.ts +0 -97
- package/assets/types/i18n.d.ts +0 -99
- package/assets/types/icons.d.ts +0 -147
- package/assets/types/models.d.ts +0 -260
- package/assets/types/smooth-caret.d.ts +0 -12
- package/assets/types/storage.d.ts +0 -93
- package/assets/types/tables.d.ts +0 -327
- package/assets/types/theme.d.ts +0 -137
- package/assets/types/utils.d.ts +0 -675
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
export namespace router {
|
|
2
|
+
let _routes: any[];
|
|
3
|
+
let _views: {};
|
|
4
|
+
let _currentRoute: any;
|
|
5
|
+
let _container: any;
|
|
6
|
+
let _defaultRoute: string;
|
|
7
|
+
let _notFoundView: any;
|
|
8
|
+
let _middleware: any[];
|
|
9
|
+
let _transitioning: boolean;
|
|
10
|
+
let _routing: boolean;
|
|
11
|
+
let _missedChange: boolean;
|
|
12
|
+
let _shownPath: any;
|
|
13
|
+
let _transitions: {};
|
|
14
|
+
let _initialised: boolean;
|
|
15
|
+
let _templateCache: {};
|
|
16
|
+
/**
|
|
17
|
+
* Initialise the router
|
|
18
|
+
* @param {RouterOptions} options - Configuration options (see RouterOptions: container, routes, views, default, notFound, transitions)
|
|
19
|
+
* @returns {Router} Router instance for chaining
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* R.init({
|
|
23
|
+
* container: '#app',
|
|
24
|
+
* routes: [
|
|
25
|
+
* { path: '/', view: 'home', title: 'Home' },
|
|
26
|
+
* { path: '/about', view: 'about', title: 'About' }
|
|
27
|
+
* ],
|
|
28
|
+
* views: { home: homeView, about: aboutView },
|
|
29
|
+
* transitions: { duration: 300 }
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
function init(options?: RouterOptions): Router;
|
|
33
|
+
/**
|
|
34
|
+
* Navigate to a route
|
|
35
|
+
* @param {string} path - Route path (without #)
|
|
36
|
+
* @param {NavigateOptions} [options] - Navigation options (`replace`: replace current history entry)
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* R.navigate('/about');
|
|
41
|
+
* R.navigate('/user/123', { replace: true });
|
|
42
|
+
*/
|
|
43
|
+
function navigate(path: string, options?: NavigateOptions): void;
|
|
44
|
+
/**
|
|
45
|
+
* Go back in browser history
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* R.back();
|
|
50
|
+
*/
|
|
51
|
+
function back(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Go forward in browser history
|
|
54
|
+
* @returns {void}
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* R.forward();
|
|
58
|
+
*/
|
|
59
|
+
function forward(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get current route information
|
|
62
|
+
* @returns {Route|null} Current route object or null
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const currentRoute = R.current();
|
|
66
|
+
* console.log(currentRoute.path, currentRoute.params);
|
|
67
|
+
*/
|
|
68
|
+
function current(): Route | null;
|
|
69
|
+
/**
|
|
70
|
+
* Register a view
|
|
71
|
+
* @param {string} name - View name
|
|
72
|
+
* @param {RouterView} view - Template string, render function, or view object
|
|
73
|
+
* @returns {Router} Router instance for chaining
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* R.view('home', '<h1>Home</h1>');
|
|
77
|
+
* R.view('about', { template: '<h1>About</h1>', onMount: ($el) => {} });
|
|
78
|
+
* R.view('user', async (params) => `<h1>User ${params.id}</h1>`);
|
|
79
|
+
*/
|
|
80
|
+
function view(name: string, view: RouterView): Router;
|
|
81
|
+
/**
|
|
82
|
+
* Add a route
|
|
83
|
+
* @param {RouteDefinition} route - Route definition (path supports :param for dynamic segments; view, title, onEnter, onLeave, meta)
|
|
84
|
+
* @returns {Router} Router instance for chaining
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* R.route({
|
|
88
|
+
* path: '/user/:id',
|
|
89
|
+
* view: 'user',
|
|
90
|
+
* title: 'User Profile',
|
|
91
|
+
* onEnter: async (params) => { await loadUser(params.id); }
|
|
92
|
+
* });
|
|
93
|
+
*/
|
|
94
|
+
function route(route: RouteDefinition): Router;
|
|
95
|
+
/**
|
|
96
|
+
* Add middleware function
|
|
97
|
+
* @param {RouterMiddleware} fn - Middleware function (to, from, next)
|
|
98
|
+
* @returns {Router} Router instance for chaining
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* R.use((to, from, next) => {
|
|
102
|
+
* if (to.meta.requiresAuth && !isAuthenticated()) {
|
|
103
|
+
* R.navigate('/login');
|
|
104
|
+
* } else {
|
|
105
|
+
* next();
|
|
106
|
+
* }
|
|
107
|
+
* });
|
|
108
|
+
*/
|
|
109
|
+
function use(fn: RouterMiddleware): Router;
|
|
110
|
+
/**
|
|
111
|
+
* Destroy the router and clean up
|
|
112
|
+
* @returns {void}
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* R.destroy();
|
|
116
|
+
*/
|
|
117
|
+
function destroy(): void;
|
|
118
|
+
function _runRouteChange(): Promise<void>;
|
|
119
|
+
function _reportError(error: any, route: any, view: any): void;
|
|
120
|
+
/**
|
|
121
|
+
* Run the route for the current address. Changes are handled one at a time:
|
|
122
|
+
* an address change that arrives while one is running (its middleware, the
|
|
123
|
+
* fade out, the render, the fade in) is remembered, and once the change in
|
|
124
|
+
* hand is done the router catches up with the address - if it still differs
|
|
125
|
+
* from what is on screen. Dropping it left the hash on one route and the
|
|
126
|
+
* screen on another (a link, Back/Forward or a typed address within the
|
|
127
|
+
* transition).
|
|
128
|
+
*/
|
|
129
|
+
function _handleRouteChange(): Promise<void>;
|
|
130
|
+
function _routeOnce(): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* A refused change (a guard that did not call next(), onLeave/onEnter returning
|
|
133
|
+
* false) leaves the screen where it was, so the address goes back to it -
|
|
134
|
+
* replaceState, which fires no hashchange, so nothing routes a second time.
|
|
135
|
+
* Not when the address has moved on meanwhile (a guard that navigated elsewhere,
|
|
136
|
+
* or restored it itself).
|
|
137
|
+
*/
|
|
138
|
+
function _restoreAddress(attempted: any): void;
|
|
139
|
+
function _stripQuery(path: any): string;
|
|
140
|
+
function _parseQuery(path: any): {
|
|
141
|
+
[k: string]: string;
|
|
142
|
+
};
|
|
143
|
+
function _decode(segment: any): any;
|
|
144
|
+
function _matchRoute(path: any): {
|
|
145
|
+
route: any;
|
|
146
|
+
params: {};
|
|
147
|
+
};
|
|
148
|
+
function _extractParams(pattern: any, path: any): {};
|
|
149
|
+
function _runMiddleware(to: any, from: any): Promise<boolean | {
|
|
150
|
+
redirect: any;
|
|
151
|
+
}>;
|
|
152
|
+
function _renderView(viewName: any, params: any): Promise<void>;
|
|
153
|
+
function _showContainer(): void;
|
|
154
|
+
function _loadTemplate(url: any): Promise<any>;
|
|
155
|
+
function _renderContent(view: any, params: any, $container: any): Promise<void>;
|
|
156
|
+
function _renderTemplate(template: any, params: any, partials?: {}): any;
|
|
157
|
+
function _renderNotFound(path: any): Promise<void>;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Values of a route's `:param` segments, decoded (`/user/:id` at `#/user/42` -> `{id: '42'}`).
|
|
161
|
+
* The not-found view gets `{path}`, the address that matched nothing.
|
|
162
|
+
*/
|
|
163
|
+
export type RouteParams = Record<string, string>;
|
|
164
|
+
/**
|
|
165
|
+
* The query string of an address as an object (`#/search?q=a%20b&f` -> `{q: 'a b', f: ''}`).
|
|
166
|
+
*/
|
|
167
|
+
export type RouteQuery = Record<string, string>;
|
|
168
|
+
/**
|
|
169
|
+
* A route as registered with `R.init({routes})` or `R.route()`.
|
|
170
|
+
*/
|
|
171
|
+
export type RouteDefinition = {
|
|
172
|
+
/**
|
|
173
|
+
* - Route path; `:name` segments are parameters (`/user/:id`). A query string is not part of the match
|
|
174
|
+
*/
|
|
175
|
+
path: string;
|
|
176
|
+
/**
|
|
177
|
+
* - Name of the view to render (a key of `views` / `R.view()`)
|
|
178
|
+
*/
|
|
179
|
+
view: string;
|
|
180
|
+
/**
|
|
181
|
+
* - Sets `document.title` when the route is entered
|
|
182
|
+
*/
|
|
183
|
+
title?: string;
|
|
184
|
+
/**
|
|
185
|
+
* - Runs before the view renders (may be async). Returning (or resolving to) `false` cancels the change and puts the address back
|
|
186
|
+
*/
|
|
187
|
+
onEnter?: (params: RouteParams, to: Route) => unknown;
|
|
188
|
+
/**
|
|
189
|
+
* - Runs when leaving this route (may be async). Returning (or resolving to) `false` cancels the change
|
|
190
|
+
*/
|
|
191
|
+
onLeave?: () => unknown;
|
|
192
|
+
/**
|
|
193
|
+
* - Custom metadata, e.g. `{requiresAuth: true}` for a middleware to read
|
|
194
|
+
*/
|
|
195
|
+
meta?: Record<string, any>;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* The route being entered or currently shown (`R.current()`, a middleware's `to`/`from`):
|
|
199
|
+
* its definition plus the address it was reached at.
|
|
200
|
+
*/
|
|
201
|
+
export type Route = Omit<RouteDefinition, "path"> & {
|
|
202
|
+
path: string;
|
|
203
|
+
params: RouteParams;
|
|
204
|
+
query: RouteQuery;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* A view given as a function: called with the route params, returns the HTML (may be async).
|
|
208
|
+
*/
|
|
209
|
+
export type ViewRenderFunction = (params: RouteParams) => string | Promise<string>;
|
|
210
|
+
/**
|
|
211
|
+
* A view object. `template` (or `templateUrl`) is rendered with the route params through Domma's
|
|
212
|
+
* template engine (`{{name}}`, partials as `{{> name}}`).
|
|
213
|
+
*/
|
|
214
|
+
export type ViewDefinition = {
|
|
215
|
+
/**
|
|
216
|
+
* - Inline template, or a function returning the HTML
|
|
217
|
+
*/
|
|
218
|
+
template?: string | ViewRenderFunction;
|
|
219
|
+
/**
|
|
220
|
+
* - URL of a template file, fetched once and cached (used when `template` is not set)
|
|
221
|
+
*/
|
|
222
|
+
templateUrl?: string;
|
|
223
|
+
/**
|
|
224
|
+
* - Partial name -> template URL, each fetched and cached
|
|
225
|
+
*/
|
|
226
|
+
partials?: Record<string, string>;
|
|
227
|
+
/**
|
|
228
|
+
* - Called after the view's HTML is in the container
|
|
229
|
+
*/
|
|
230
|
+
onMount?: ($container: import("./dom.js").DommaCollection) => void;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* A view that renders a standalone component (`Domma.component()`): the container is emptied and
|
|
234
|
+
* the custom element appended, with the props set as attributes (camelCase -> kebab-case; `true`
|
|
235
|
+
* is an empty attribute, `false`/`null` none, objects JSON).
|
|
236
|
+
*/
|
|
237
|
+
export type ComponentViewDefinition = {
|
|
238
|
+
/**
|
|
239
|
+
* - Custom element tag name
|
|
240
|
+
*/
|
|
241
|
+
component: string;
|
|
242
|
+
/**
|
|
243
|
+
* - Props, or a function of the route params returning them
|
|
244
|
+
*/
|
|
245
|
+
props?: Record<string, any> | ((params: RouteParams) => Record<string, any>);
|
|
246
|
+
/**
|
|
247
|
+
* - Called after the element is appended
|
|
248
|
+
*/
|
|
249
|
+
onMount?: ($container: import("./dom.js").DommaCollection) => void;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Anything `R.view()` / `R.init({views})` accepts: a template string, a render function, a view
|
|
253
|
+
* object or a component view.
|
|
254
|
+
*/
|
|
255
|
+
export type RouterView = string | ViewRenderFunction | ViewDefinition | ComponentViewDefinition;
|
|
256
|
+
/**
|
|
257
|
+
* Transition settings. Only `duration` is used (the fade out and in); `enter`/`leave` are stored.
|
|
258
|
+
*/
|
|
259
|
+
export type RouterTransitions = {
|
|
260
|
+
/**
|
|
261
|
+
* - Enter animation
|
|
262
|
+
*/
|
|
263
|
+
enter?: string;
|
|
264
|
+
/**
|
|
265
|
+
* - Leave animation
|
|
266
|
+
*/
|
|
267
|
+
leave?: string;
|
|
268
|
+
/**
|
|
269
|
+
* - Animation duration in ms
|
|
270
|
+
*/
|
|
271
|
+
duration?: number;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Options for `R.init()`.
|
|
275
|
+
*/
|
|
276
|
+
export type RouterOptions = {
|
|
277
|
+
/**
|
|
278
|
+
* - Selector for the view container element (throws when not found)
|
|
279
|
+
*/
|
|
280
|
+
container: string;
|
|
281
|
+
/**
|
|
282
|
+
* - Route definitions
|
|
283
|
+
*/
|
|
284
|
+
routes?: RouteDefinition[];
|
|
285
|
+
/**
|
|
286
|
+
* - View registry `{name: view}`
|
|
287
|
+
*/
|
|
288
|
+
views?: Record<string, RouterView>;
|
|
289
|
+
/**
|
|
290
|
+
* - Route used when the address has no hash
|
|
291
|
+
*/
|
|
292
|
+
default?: string;
|
|
293
|
+
/**
|
|
294
|
+
* - Name of the view rendered for an address no route matches
|
|
295
|
+
*/
|
|
296
|
+
notFound?: string;
|
|
297
|
+
/**
|
|
298
|
+
* - Transition animation options (replaces the defaults as a whole)
|
|
299
|
+
*/
|
|
300
|
+
transitions?: RouterTransitions;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Options for `R.navigate()`.
|
|
304
|
+
*/
|
|
305
|
+
export type NavigateOptions = {
|
|
306
|
+
/**
|
|
307
|
+
* - Replace the current history entry instead of adding one
|
|
308
|
+
*/
|
|
309
|
+
replace?: boolean;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* A middleware's `next`: call it to let the change go ahead, or with a path to go there instead
|
|
313
|
+
* (replacing the refused entry). Not calling it refuses the change.
|
|
314
|
+
*/
|
|
315
|
+
export type RouterNext = (redirect?: string) => void;
|
|
316
|
+
/**
|
|
317
|
+
* A middleware, run in order before every route change (may be async).
|
|
318
|
+
*/
|
|
319
|
+
export type RouterMiddleware = (to: Route, from: Route | null, next: RouterNext) => void | Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* Payload of the `router:beforeChange` and `router:afterChange` events (`M.subscribe`).
|
|
322
|
+
*/
|
|
323
|
+
export type RouterChangeEvent = {
|
|
324
|
+
from: Route | null;
|
|
325
|
+
to: Route;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Payload of the `router:error` event (`M.subscribe`): a failed route change or render.
|
|
329
|
+
*/
|
|
330
|
+
export type RouterErrorEvent = {
|
|
331
|
+
error: any;
|
|
332
|
+
/**
|
|
333
|
+
* - The address being routed
|
|
334
|
+
*/
|
|
335
|
+
route: string;
|
|
336
|
+
/**
|
|
337
|
+
* - The view being rendered, when the failure was in a render
|
|
338
|
+
*/
|
|
339
|
+
view?: string;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* The router (`R`, `Domma.router`).
|
|
343
|
+
*/
|
|
344
|
+
export type Router = typeof router;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} href
|
|
3
|
+
* @returns {string|null} the resolved absolute URL, or null when it is not safe
|
|
4
|
+
*/
|
|
5
|
+
export function safeUrl(href: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} href
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function isSafeUrl(href: string): boolean;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main sanitisation function
|
|
3
|
+
*
|
|
4
|
+
* @param {string} html - HTML string to sanitise
|
|
5
|
+
* @param {SanitiseOptions} [options] - Sanitisation options (preset, allowedTags, allowedAttrs, allowDataAttrs)
|
|
6
|
+
* @returns {string} - Sanitised HTML
|
|
7
|
+
*/
|
|
8
|
+
export function sanitise(html: string, options?: SanitiseOptions): string;
|
|
9
|
+
/**
|
|
10
|
+
* Sanitise for basic text with minimal formatting
|
|
11
|
+
* Only allows: b, i, em, strong, br
|
|
12
|
+
*
|
|
13
|
+
* @param {string} html - HTML string to sanitise
|
|
14
|
+
* @returns {string} - Sanitised HTML
|
|
15
|
+
*/
|
|
16
|
+
export function sanitiseBasic(html: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Sanitise for user-generated content (strict)
|
|
19
|
+
* Only allows: b, i, em, strong, p, br, a, ul, ol, li
|
|
20
|
+
*
|
|
21
|
+
* @param {string} html - HTML string to sanitise
|
|
22
|
+
* @returns {string} - Sanitised HTML
|
|
23
|
+
*/
|
|
24
|
+
export function sanitiseUserContent(html: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Escape HTML completely (no tags allowed)
|
|
27
|
+
* Use for plain text that should be displayed as-is
|
|
28
|
+
*
|
|
29
|
+
* @param {string} text - Text to escape
|
|
30
|
+
* @returns {string} - Escaped text
|
|
31
|
+
*/
|
|
32
|
+
export function escape(text: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Check if DOMPurify is loaded
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
export function hasDOMPurify(): boolean;
|
|
38
|
+
declare const _default: Sanitize;
|
|
39
|
+
export default _default;
|
|
40
|
+
/**
|
|
41
|
+
* Options for `sanitise()`. Used only when DOMPurify is loaded; without it the input is
|
|
42
|
+
* HTML-escaped whatever the options say.
|
|
43
|
+
*/
|
|
44
|
+
export type SanitiseOptions = {
|
|
45
|
+
/**
|
|
46
|
+
* - Allowlist preset ('default', 'strict', 'basic')
|
|
47
|
+
*/
|
|
48
|
+
preset?: "default" | "strict" | "basic";
|
|
49
|
+
/**
|
|
50
|
+
* - Custom allowed tags (overrides preset)
|
|
51
|
+
*/
|
|
52
|
+
allowedTags?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* - Custom allowed attributes (overrides preset)
|
|
55
|
+
*/
|
|
56
|
+
allowedAttrs?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* - Allow data-* attributes
|
|
59
|
+
*/
|
|
60
|
+
allowDataAttrs?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The sanitise module (`Domma.sanitize`).
|
|
64
|
+
*/
|
|
65
|
+
export type Sanitize = {
|
|
66
|
+
/**
|
|
67
|
+
* - Sanitise HTML (DOMPurify, or HTML escaping without it)
|
|
68
|
+
*/
|
|
69
|
+
sanitise: typeof sanitise;
|
|
70
|
+
/**
|
|
71
|
+
* - Allow only b, i, em, strong, br
|
|
72
|
+
*/
|
|
73
|
+
sanitiseBasic: typeof sanitiseBasic;
|
|
74
|
+
/**
|
|
75
|
+
* - Allow only b, i, em, strong, p, br, a, ul, ol, li
|
|
76
|
+
*/
|
|
77
|
+
sanitiseUserContent: typeof sanitiseUserContent;
|
|
78
|
+
/**
|
|
79
|
+
* - Escape HTML completely (no tags allowed)
|
|
80
|
+
*/
|
|
81
|
+
escape: typeof escape;
|
|
82
|
+
/**
|
|
83
|
+
* - Whether DOMPurify is loaded
|
|
84
|
+
*/
|
|
85
|
+
hasDOMPurify: typeof hasDOMPurify;
|
|
86
|
+
/**
|
|
87
|
+
* - Whether a URL is safe to put in an href/src
|
|
88
|
+
*/
|
|
89
|
+
isSafeUrl: typeof isSafeUrl;
|
|
90
|
+
/**
|
|
91
|
+
* - The resolved absolute URL when safe, else null
|
|
92
|
+
*/
|
|
93
|
+
safeUrl: typeof safeUrl;
|
|
94
|
+
};
|
|
95
|
+
import { isSafeUrl } from './safe-url.js';
|
|
96
|
+
import { safeUrl } from './safe-url.js';
|
|
97
|
+
export { isSafeUrl, safeUrl };
|