@aurumjs/html 0.10.12

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +152 -0
  3. package/package.json +52 -0
  4. package/prebuilt/esnext/builtin_components/portal.d.ts +9 -0
  5. package/prebuilt/esnext/builtin_components/portal.d.ts.map +1 -0
  6. package/prebuilt/esnext/builtin_components/portal.js +40 -0
  7. package/prebuilt/esnext/builtin_components/portal.js.map +1 -0
  8. package/prebuilt/esnext/builtin_components/router_link.d.ts +21 -0
  9. package/prebuilt/esnext/builtin_components/router_link.d.ts.map +1 -0
  10. package/prebuilt/esnext/builtin_components/router_link.js +54 -0
  11. package/prebuilt/esnext/builtin_components/router_link.js.map +1 -0
  12. package/prebuilt/esnext/index.d.ts +18 -0
  13. package/prebuilt/esnext/index.d.ts.map +1 -0
  14. package/prebuilt/esnext/index.js +18 -0
  15. package/prebuilt/esnext/index.js.map +1 -0
  16. package/prebuilt/esnext/jsx-dev-runtime.d.ts +2 -0
  17. package/prebuilt/esnext/jsx-dev-runtime.d.ts.map +1 -0
  18. package/prebuilt/esnext/jsx-dev-runtime.js +2 -0
  19. package/prebuilt/esnext/jsx-dev-runtime.js.map +1 -0
  20. package/prebuilt/esnext/jsx-runtime.d.ts +28 -0
  21. package/prebuilt/esnext/jsx-runtime.d.ts.map +1 -0
  22. package/prebuilt/esnext/jsx-runtime.js +26 -0
  23. package/prebuilt/esnext/jsx-runtime.js.map +1 -0
  24. package/prebuilt/esnext/nodes/input.d.ts +41 -0
  25. package/prebuilt/esnext/nodes/input.d.ts.map +1 -0
  26. package/prebuilt/esnext/nodes/input.js +92 -0
  27. package/prebuilt/esnext/nodes/input.js.map +1 -0
  28. package/prebuilt/esnext/nodes/rendering_helpers.d.ts +8 -0
  29. package/prebuilt/esnext/nodes/rendering_helpers.d.ts.map +1 -0
  30. package/prebuilt/esnext/nodes/rendering_helpers.js +173 -0
  31. package/prebuilt/esnext/nodes/rendering_helpers.js.map +1 -0
  32. package/prebuilt/esnext/nodes/select.d.ts +17 -0
  33. package/prebuilt/esnext/nodes/select.d.ts.map +1 -0
  34. package/prebuilt/esnext/nodes/select.js +95 -0
  35. package/prebuilt/esnext/nodes/select.js.map +1 -0
  36. package/prebuilt/esnext/nodes/simple_dom_nodes.d.ts +866 -0
  37. package/prebuilt/esnext/nodes/simple_dom_nodes.d.ts.map +1 -0
  38. package/prebuilt/esnext/nodes/simple_dom_nodes.js +531 -0
  39. package/prebuilt/esnext/nodes/simple_dom_nodes.js.map +1 -0
  40. package/prebuilt/esnext/nodes/textarea.d.ts +34 -0
  41. package/prebuilt/esnext/nodes/textarea.d.ts.map +1 -0
  42. package/prebuilt/esnext/nodes/textarea.js +61 -0
  43. package/prebuilt/esnext/nodes/textarea.js.map +1 -0
  44. package/prebuilt/esnext/rendering/dom_runtime.d.ts +91 -0
  45. package/prebuilt/esnext/rendering/dom_runtime.d.ts.map +1 -0
  46. package/prebuilt/esnext/rendering/dom_runtime.js +970 -0
  47. package/prebuilt/esnext/rendering/dom_runtime.js.map +1 -0
  48. package/prebuilt/esnext/rendering/render_batch.d.ts +15 -0
  49. package/prebuilt/esnext/rendering/render_batch.d.ts.map +1 -0
  50. package/prebuilt/esnext/rendering/render_batch.js +73 -0
  51. package/prebuilt/esnext/rendering/render_batch.js.map +1 -0
  52. package/prebuilt/esnext/rendering/renderers/dom_adapter.d.ts +199 -0
  53. package/prebuilt/esnext/rendering/renderers/dom_adapter.d.ts.map +1 -0
  54. package/prebuilt/esnext/rendering/renderers/dom_adapter.js +525 -0
  55. package/prebuilt/esnext/rendering/renderers/dom_adapter.js.map +1 -0
  56. package/prebuilt/esnext/rendering/renderers/string_adapter.d.ts +4 -0
  57. package/prebuilt/esnext/rendering/renderers/string_adapter.d.ts.map +1 -0
  58. package/prebuilt/esnext/rendering/renderers/string_adapter.js +112 -0
  59. package/prebuilt/esnext/rendering/renderers/string_adapter.js.map +1 -0
  60. package/prebuilt/esnext/rendering/renderers/vdom_adapter.d.ts +11 -0
  61. package/prebuilt/esnext/rendering/renderers/vdom_adapter.d.ts.map +1 -0
  62. package/prebuilt/esnext/rendering/renderers/vdom_adapter.js +23 -0
  63. package/prebuilt/esnext/rendering/renderers/vdom_adapter.js.map +1 -0
  64. package/prebuilt/esnext/utilities/aurum.d.ts +155 -0
  65. package/prebuilt/esnext/utilities/aurum.d.ts.map +1 -0
  66. package/prebuilt/esnext/utilities/aurum.js +282 -0
  67. package/prebuilt/esnext/utilities/aurum.js.map +1 -0
  68. package/prebuilt/esnext/utilities/sanitize.d.ts +25 -0
  69. package/prebuilt/esnext/utilities/sanitize.d.ts.map +1 -0
  70. package/prebuilt/esnext/utilities/sanitize.js +191 -0
  71. package/prebuilt/esnext/utilities/sanitize.js.map +1 -0
@@ -0,0 +1,525 @@
1
+ import { handleClass, handleStyle } from '../../nodes/rendering_helpers.js';
2
+ import { createRenderSession, linkAurumDomNodeChildren, registerAurumDomNode, registerAurumRenderBinding } from '@aurumjs/rendering';
3
+ import { AurumElement, renderInternal } from '../dom_runtime.js';
4
+ import { AURUM_DEVTOOLS_DEBUG_BUILD_ENABLED, DataSource } from '@aurumjs/streams';
5
+ import { writeTo } from '@aurumjs/streams';
6
+ import { queueRenderUpdate, renderBatchState } from '../render_batch.js';
7
+ /**
8
+ * @internal
9
+ */
10
+ export const defaultEvents = {
11
+ drag: 'onDrag',
12
+ dragstart: 'onDragStart',
13
+ dragend: 'onDragEnd',
14
+ dragexit: 'onDragExit',
15
+ dragover: 'onDragOver',
16
+ dragenter: 'onDragEnter',
17
+ dragleave: 'onDragLeave',
18
+ drop: 'onDrop',
19
+ blur: 'onBlur',
20
+ focus: 'onFocus',
21
+ click: 'onClick',
22
+ dblclick: 'onDblClick',
23
+ // Standard DOM-style aliases retained alongside Aurum's historical names.
24
+ doubleclick: 'onDoubleClick',
25
+ keydown: 'onKeyDown',
26
+ keypress: 'onKeyPress',
27
+ keyup: 'onKeyUp',
28
+ contextmenu: 'onContextMenu',
29
+ mousedown: 'onMouseDown',
30
+ mouseup: 'onMouseUp',
31
+ mousemove: 'onMouseMove',
32
+ mouseenter: 'onMouseEnter',
33
+ mouseleave: 'onMouseLeave',
34
+ mousewheel: 'onMouseWheel',
35
+ wheel: 'onWheel',
36
+ load: 'onLoad',
37
+ error: 'onError',
38
+ transitionend: 'onTransitionEnd',
39
+ transitionstart: 'onTransitionStart',
40
+ transitionrun: 'onTransitionRun',
41
+ transitioncancel: 'onTransitionCancel',
42
+ animationend: 'onAnimationEnd',
43
+ animationstart: 'onAnimationStart',
44
+ animationiteration: 'onAnimationIteration',
45
+ animationcancel: 'onAnimationCancel',
46
+ auxclick: 'onAuxClick',
47
+ beforeinput: 'onBeforeInput',
48
+ beforematch: 'onBeforeMatch',
49
+ compositionend: 'onCompositionEnd',
50
+ compositionstart: 'onCompositionStart',
51
+ compositionupdate: 'onCompositionUpdate',
52
+ contentvisibilityautostatechange: 'onContentVisibilityAutoStateChange',
53
+ copy: 'onCopy',
54
+ cut: 'onCut',
55
+ paste: 'onPaste',
56
+ focusin: 'onFocusIn',
57
+ focusout: 'onFocusOut',
58
+ fullscreenchange: 'onFullscreenChange',
59
+ fullscreenerror: 'onFullscreenError',
60
+ gotpointercapture: 'onGotPointerCapture',
61
+ lostpointercapture: 'onLostPointerCapture',
62
+ pointercancel: 'onPointerCancel',
63
+ pointerdown: 'onPointerDown',
64
+ pointerenter: 'onPointerEnter',
65
+ pointerleave: 'onPointerLeave',
66
+ pointermove: 'onPointerMove',
67
+ pointerout: 'onPointerOut',
68
+ pointerover: 'onPointerOver',
69
+ pointerup: 'onPointerUp',
70
+ scroll: 'onScroll',
71
+ scrollend: 'onScrollEnd',
72
+ securitypolicyviolation: 'onSecurityPolicyViolation',
73
+ touchcancel: 'onTouchCancel',
74
+ touchend: 'onTouchEnd',
75
+ touchmove: 'onTouchMove',
76
+ touchstart: 'onTouchStart',
77
+ attach: 'onAttach',
78
+ detach: 'onDetach'
79
+ };
80
+ /**
81
+ * @internal
82
+ */
83
+ export const defaultAttributes = [
84
+ 'id',
85
+ 'name',
86
+ 'draggable',
87
+ 'tabIndex',
88
+ 'role',
89
+ 'contenteditable',
90
+ 'accesskey',
91
+ 'autocapitalize',
92
+ 'autofocus',
93
+ 'dir',
94
+ 'enterkeyhint',
95
+ 'hidden',
96
+ 'inert',
97
+ 'inputmode',
98
+ 'is',
99
+ 'itemid',
100
+ 'itemprop',
101
+ 'itemref',
102
+ 'itemscope',
103
+ 'itemtype',
104
+ 'lang',
105
+ 'nonce',
106
+ 'part',
107
+ 'popover',
108
+ 'spellcheck',
109
+ 'translate',
110
+ 'slot',
111
+ 'title',
112
+ 'ariaAtomic',
113
+ 'ariaAutoComplete',
114
+ 'ariaBrailleLabel',
115
+ 'ariaBrailleRoleDescription',
116
+ 'ariaBusy',
117
+ 'ariaChecked',
118
+ 'ariaColCount',
119
+ 'ariaColIndex',
120
+ 'ariaColIndexText',
121
+ 'ariaColSpan',
122
+ 'ariaControlsElements',
123
+ 'ariaCurrent',
124
+ 'ariaDescribedByElements',
125
+ 'ariaDescription',
126
+ 'ariaDetailsElements',
127
+ 'ariaDisabled',
128
+ 'ariaErrorMessageElements',
129
+ 'ariaExpanded',
130
+ 'ariaFlowToElements',
131
+ 'ariaHasPopup',
132
+ 'ariaHidden',
133
+ 'ariaInvalid',
134
+ 'ariaKeyShortcuts',
135
+ 'ariaLabel',
136
+ 'ariaLabelledByElements',
137
+ 'ariaLevel',
138
+ 'ariaLive',
139
+ 'ariaModal',
140
+ 'ariaMultiLine',
141
+ 'ariaMultiSelectable',
142
+ 'ariaOrientation',
143
+ 'ariaOwnsElements',
144
+ 'ariaPlaceholder',
145
+ 'ariaPosInSet',
146
+ 'ariaPressed',
147
+ 'ariaReadOnly',
148
+ 'ariaRelevant',
149
+ 'ariaRequired',
150
+ 'ariaRoleDescription',
151
+ 'ariaRowCount',
152
+ 'ariaRowIndex',
153
+ 'ariaRowIndexText',
154
+ 'ariaRowSpan',
155
+ 'ariaSelected',
156
+ 'ariaSetSize',
157
+ 'ariaSort',
158
+ 'ariaValueMax',
159
+ 'ariaValueMin',
160
+ 'ariaValueNow',
161
+ 'ariaValueText'
162
+ ];
163
+ export function DomNodeCreator(nodeName, extraAttributes, extraEvents, extraLogic, svg = false, bindAllValidAttributes = false) {
164
+ const acceptedAttributes = new Set([...defaultAttributes, ...(extraAttributes !== null && extraAttributes !== void 0 ? extraAttributes : [])].map(normalizeAttributeName));
165
+ const eventByProp = createEventMap(extraEvents);
166
+ return function (props, children, api) {
167
+ let node;
168
+ if (svg) {
169
+ node = document.createElementNS('http://www.w3.org/2000/svg', nodeName);
170
+ }
171
+ else {
172
+ node = document.createElement(nodeName);
173
+ }
174
+ if (AURUM_DEVTOOLS_DEBUG_BUILD_ENABLED)
175
+ registerAurumDomNode(node, api.cancellationToken, api.renderSession);
176
+ if (props) {
177
+ processHTMLNodeInternal(node, props, () => api.cancellationToken, acceptedAttributes, eventByProp, api.renderSession, bindAllValidAttributes);
178
+ }
179
+ //@ts-ignore
180
+ const renderedChildren = renderInternal(children, api.renderSession);
181
+ const childNodes = Array.isArray(renderedChildren) ? renderedChildren : renderedChildren ? [renderedChildren] : [];
182
+ connectChildren(node, childNodes);
183
+ if (AURUM_DEVTOOLS_DEBUG_BUILD_ENABLED) {
184
+ linkAurumDomNodeChildren(node, childNodes.filter((child) => child instanceof HTMLElement || child instanceof SVGElement), api.cancellationToken);
185
+ }
186
+ if (props) {
187
+ if (props.onAttach) {
188
+ api.onAttach(() => props.onAttach(node));
189
+ }
190
+ if (props.onDetach) {
191
+ api.onDetach(() => {
192
+ if (node.isConnected) {
193
+ node.parentElement.removeChild(node);
194
+ }
195
+ props.onDetach(node);
196
+ });
197
+ }
198
+ }
199
+ extraLogic === null || extraLogic === void 0 ? void 0 : extraLogic(node, props, api.cancellationToken);
200
+ return node;
201
+ };
202
+ }
203
+ /** Creates an intrinsic HTML host factory for tags without a specialized Aurum node implementation. */
204
+ export function createGenericIntrinsicFactory(nodeName) {
205
+ return DomNodeCreator(nodeName, undefined, undefined, undefined, false, true);
206
+ }
207
+ function connectChildren(target, children) {
208
+ if (children === undefined || children === null || children.length === 0) {
209
+ return;
210
+ }
211
+ for (const child of children) {
212
+ if (!child) {
213
+ continue;
214
+ }
215
+ if (child instanceof Text || child instanceof HTMLElement || child instanceof SVGElement) {
216
+ target.appendChild(child);
217
+ }
218
+ else if (child instanceof AurumElement) {
219
+ child.attachToDom(target, target.childNodes.length);
220
+ }
221
+ else {
222
+ if (typeof child === 'function') {
223
+ throw new Error(`Unexpected child type passed to DOM Node: function. Did you mean to use a component? To use a component use JSX syntax such as <MyComponent/> it works even with function references. <props.myReference/>`);
224
+ }
225
+ throw new Error(`Unexpected child type passed to DOM Node: ${children}. If this is a valid child type make sure you don't have 2 copies of Aurum loaded`);
226
+ }
227
+ }
228
+ }
229
+ export function processHTMLNode(node, props, cleanUp, extraAttributes, extraEvents, renderSession, bindAllValidAttributes = false) {
230
+ processHTMLNodeInternal(node, props, () => cleanUp, new Set([...defaultAttributes, ...(extraAttributes !== null && extraAttributes !== void 0 ? extraAttributes : [])].map(normalizeAttributeName)), createEventMap(extraEvents), renderSession, bindAllValidAttributes);
231
+ }
232
+ function processHTMLNodeInternal(node, props, getCleanUp, acceptedAttributes, eventByProp, renderSession, bindAllValidAttributes = false) {
233
+ let boundAttributes;
234
+ for (const key of Object.keys(props)) {
235
+ const value = props[key];
236
+ if (value === undefined)
237
+ continue;
238
+ if (key === 'dangerouslySetInnerHTML') {
239
+ node.innerHTML = value.__html;
240
+ continue;
241
+ }
242
+ const eventName = eventByProp.get(key);
243
+ if (eventName !== undefined) {
244
+ if (value)
245
+ node.addEventListener(eventName === 'doubleclick' ? 'dblclick' : eventName, (event) => writeTo(value, event));
246
+ continue;
247
+ }
248
+ if (reservedIntrinsicProps.has(key) || typeof value === 'function')
249
+ continue;
250
+ const attributeName = normalizeAttributeName(key);
251
+ if (boundAttributes !== undefined && boundAttributes.has(attributeName))
252
+ continue;
253
+ if (acceptedAttributes.has(attributeName) || key.includes('-') || (bindAllValidAttributes && isValidGenericHTMLAttribute(node, key, value))) {
254
+ assignSourceToDOM(node, value, attributeName, getCleanUp, renderSession);
255
+ (boundAttributes !== null && boundAttributes !== void 0 ? boundAttributes : (boundAttributes = new Set())).add(attributeName);
256
+ }
257
+ }
258
+ bindStyle(node, props.style, getCleanUp, renderSession);
259
+ bindClass(node, props.class, getCleanUp, renderSession);
260
+ }
261
+ function createEventMap(extraEvents) {
262
+ const result = new Map();
263
+ for (const eventName of Object.keys(defaultEvents))
264
+ result.set(defaultEvents[eventName], eventName);
265
+ if (extraEvents) {
266
+ for (const eventName of Object.keys(extraEvents))
267
+ result.set(extraEvents[eventName], eventName);
268
+ }
269
+ return result;
270
+ }
271
+ export function createEventHandlers(node, events, props) {
272
+ for (const key in events) {
273
+ if (props[events[key]]) {
274
+ //@ts-ignore
275
+ node.addEventListener(key === 'doubleclick' ? 'dblclick' : key, (e) => writeTo(props[events[key]], e));
276
+ }
277
+ }
278
+ }
279
+ const attributeAliases = Object.assign(Object.create(null), {
280
+ accessKey: 'accesskey',
281
+ acceptCharset: 'accept-charset',
282
+ autoComplete: 'autocomplete',
283
+ autoFocus: 'autofocus',
284
+ colSpan: 'colspan',
285
+ contentEditable: 'contenteditable',
286
+ crossOrigin: 'crossorigin',
287
+ dateTime: 'datetime',
288
+ formAction: 'formaction',
289
+ formEncType: 'formenctype',
290
+ formMethod: 'formmethod',
291
+ formNoValidate: 'formnovalidate',
292
+ formTarget: 'formtarget',
293
+ htmlFor: 'for',
294
+ maxLength: 'maxlength',
295
+ minLength: 'minlength',
296
+ noValidate: 'novalidate',
297
+ readOnly: 'readonly',
298
+ referrerPolicy: 'referrerpolicy',
299
+ rowSpan: 'rowspan',
300
+ spellCheck: 'spellcheck',
301
+ srcSet: 'srcset',
302
+ tabIndex: 'tabindex',
303
+ useMap: 'usemap',
304
+ autoPlay: 'autoplay',
305
+ strokeWidth: 'stroke-width',
306
+ strokeLinecap: 'stroke-linecap',
307
+ strokeLinejoin: 'stroke-linejoin'
308
+ });
309
+ const propertyNamesByAttribute = {
310
+ 'accept-charset': 'acceptCharset',
311
+ accesskey: 'accessKey',
312
+ autocomplete: 'autocomplete',
313
+ autofocus: 'autofocus',
314
+ checked: 'checked',
315
+ colspan: 'colSpan',
316
+ contenteditable: 'contentEditable',
317
+ crossorigin: 'crossOrigin',
318
+ datetime: 'dateTime',
319
+ disabled: 'disabled',
320
+ for: 'htmlFor',
321
+ formnovalidate: 'formNoValidate',
322
+ maxlength: 'maxLength',
323
+ minlength: 'minLength',
324
+ multiple: 'multiple',
325
+ muted: 'muted',
326
+ novalidate: 'noValidate',
327
+ open: 'open',
328
+ readonly: 'readOnly',
329
+ referrerpolicy: 'referrerPolicy',
330
+ required: 'required',
331
+ rowspan: 'rowSpan',
332
+ selected: 'selected',
333
+ selectedindex: 'selectedIndex',
334
+ spellcheck: 'spellcheck',
335
+ tabindex: 'tabIndex',
336
+ usemap: 'useMap',
337
+ value: 'value'
338
+ };
339
+ const propertyBoundAttributes = new Set([
340
+ 'checked',
341
+ 'disabled',
342
+ 'multiple',
343
+ 'muted',
344
+ 'open',
345
+ 'readonly',
346
+ 'required',
347
+ 'selected',
348
+ 'selectedindex',
349
+ 'spellcheck',
350
+ 'value'
351
+ ]);
352
+ const reservedIntrinsicProps = new Set(['children', 'class', 'className', 'decorate', 'style', 'onAttach', 'onDetach']);
353
+ function normalizeAttributeName(key) {
354
+ const alias = attributeAliases[key];
355
+ if (alias !== undefined)
356
+ return alias;
357
+ if (key.length > 4 && key.startsWith('aria')) {
358
+ const fifthCharacter = key.charCodeAt(4);
359
+ if (fifthCharacter >= 65 && fifthCharacter <= 90) {
360
+ return key
361
+ .replace(/^aria/, 'aria-')
362
+ .replace(/([A-Z])/g, '-$1')
363
+ .toLowerCase()
364
+ .replace('aria--', 'aria-');
365
+ }
366
+ }
367
+ return key;
368
+ }
369
+ function propertyNameForAttribute(attributeName) {
370
+ var _a;
371
+ return (_a = propertyNamesByAttribute[attributeName.toLowerCase()]) !== null && _a !== void 0 ? _a : attributeName;
372
+ }
373
+ function isValidGenericHTMLAttribute(node, key, value) {
374
+ if (reservedIntrinsicProps.has(key) || key.startsWith('on') || typeof value === 'function')
375
+ return false;
376
+ const attributeName = normalizeAttributeName(key);
377
+ if (attributeName.startsWith('aria-') || attributeName.startsWith('data-'))
378
+ return true;
379
+ return propertyNameForAttribute(attributeName) in node;
380
+ }
381
+ function bindClass(node, value, getCleanUp, renderSession) {
382
+ if (!value)
383
+ return;
384
+ if (typeof value === 'string') {
385
+ node.setAttribute('class', value);
386
+ return;
387
+ }
388
+ if (value instanceof DataSource) {
389
+ const cleanUp = getCleanUp();
390
+ registerAurumRenderBinding(value, node, 'class', cleanUp, renderSession);
391
+ const normalize = (next) => (Array.isArray(next) ? next.filter(Boolean).join(' ') : String(next !== null && next !== void 0 ? next : ''));
392
+ const updateClass = (next) => {
393
+ if (cleanUp.isCancelled)
394
+ return;
395
+ node.setAttribute('class', normalize(next));
396
+ };
397
+ let previousValue = normalize(value.value);
398
+ node.setAttribute('class', previousValue);
399
+ value.listen((next) => {
400
+ const normalized = normalize(next);
401
+ if (normalized === previousValue)
402
+ return;
403
+ previousValue = normalized;
404
+ if (renderBatchState.active)
405
+ queueRenderUpdate(updateClass, updateClass, normalized);
406
+ else
407
+ updateClass(normalized);
408
+ }, cleanUp);
409
+ return;
410
+ }
411
+ const cleanUp = getCleanUp();
412
+ const result = handleClass(value, cleanUp);
413
+ if (result instanceof DataSource) {
414
+ registerAurumRenderBinding(result, node, 'class', cleanUp, renderSession);
415
+ const updateClass = (next) => {
416
+ if (cleanUp.isCancelled)
417
+ return;
418
+ node.setAttribute('class', next);
419
+ };
420
+ result.listenAndRepeat((next) => {
421
+ if (renderBatchState.active)
422
+ queueRenderUpdate(updateClass, updateClass, next);
423
+ else
424
+ updateClass(next);
425
+ }, cleanUp);
426
+ }
427
+ else {
428
+ node.setAttribute('class', result);
429
+ }
430
+ }
431
+ function bindStyle(node, value, getCleanUp, renderSession) {
432
+ if (!value)
433
+ return;
434
+ if (typeof value === 'string') {
435
+ node.setAttribute('style', value);
436
+ return;
437
+ }
438
+ const cleanUp = getCleanUp();
439
+ const result = handleStyle(value, cleanUp);
440
+ if (result instanceof DataSource) {
441
+ registerAurumRenderBinding(result, node, 'style', cleanUp, renderSession);
442
+ const updateStyle = (next) => {
443
+ if (cleanUp.isCancelled)
444
+ return;
445
+ node.setAttribute('style', next);
446
+ };
447
+ result.listenAndRepeat((next) => {
448
+ if (renderBatchState.active)
449
+ queueRenderUpdate(updateStyle, updateStyle, next);
450
+ else
451
+ updateStyle(next);
452
+ }, cleanUp);
453
+ }
454
+ else {
455
+ node.setAttribute('style', result);
456
+ }
457
+ }
458
+ /**
459
+ * Renders Aurum content synchronously in line. In case no lifecycle sync object is provided you have to manually call fireOnAttach and dispose at the appropriate times to ensure proper lifecycle handling such as attach and detach events
460
+ * @param content Content to render
461
+ * @param syncLifecycle Optional lifecycle sync object. If provided the lifecycle of the rendered content will be synchronized with the provided lifecycle (meaning attach and detach events will be fired when the lifecycle fires them)
462
+ */
463
+ export function aurumToHTML(content, syncLifecycle) {
464
+ const rs = createRenderSession();
465
+ const renderedContent = renderInternal(content, rs);
466
+ if (syncLifecycle) {
467
+ syncLifecycle.onAttach(() => rs.attachCalls.forEach((c) => c()));
468
+ syncLifecycle.onDetach(() => rs.sessionToken.cancel());
469
+ }
470
+ return {
471
+ content: renderedContent,
472
+ fireOnAttach: () => rs.attachCalls.forEach((c) => c()),
473
+ dispose: () => rs.sessionToken.cancel()
474
+ };
475
+ }
476
+ function assignSourceToDOM(node, data, attributeName, getCleanUp, renderSession) {
477
+ const propertyName = propertyNameForAttribute(attributeName);
478
+ const bindAsProperty = propertyBoundAttributes.has(attributeName.toLowerCase()) && propertyName in node;
479
+ const assign = (value) => {
480
+ if (bindAsProperty) {
481
+ node[propertyName] = value;
482
+ }
483
+ else if (typeof value === 'boolean') {
484
+ if (value)
485
+ node.setAttribute(attributeName, '');
486
+ else
487
+ node.removeAttribute(attributeName);
488
+ }
489
+ else {
490
+ node.setAttribute(attributeName, value.toString());
491
+ }
492
+ };
493
+ if (typeof data === 'string' || typeof data === 'number') {
494
+ assign(data);
495
+ }
496
+ else if (typeof data === 'boolean') {
497
+ assign(data);
498
+ }
499
+ else if (data instanceof DataSource) {
500
+ const cleanUp = getCleanUp();
501
+ registerAurumRenderBinding(data, node, `${bindAsProperty ? 'property' : 'attribute'}:${attributeName}`, cleanUp, renderSession);
502
+ if (typeof data.value === 'string' || typeof data.value === 'number' || typeof data.value === 'boolean')
503
+ assign(data.value);
504
+ const updateAttribute = (v) => {
505
+ if (cleanUp.isCancelled)
506
+ return;
507
+ if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean')
508
+ assign(v);
509
+ };
510
+ let previousValue = data.value;
511
+ data.listen((v) => {
512
+ if (v === previousValue || (Number.isNaN(v) && Number.isNaN(previousValue)))
513
+ return;
514
+ previousValue = v;
515
+ if (renderBatchState.active)
516
+ queueRenderUpdate(updateAttribute, updateAttribute, v);
517
+ else
518
+ updateAttribute(v);
519
+ }, cleanUp);
520
+ }
521
+ else {
522
+ throw new Error('Attributes only support types boolean, string, number and data sources');
523
+ }
524
+ }
525
+ //# sourceMappingURL=dom_adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom_adapter.js","sourceRoot":"","sources":["../../../../src/rendering/renderers/dom_adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAEH,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,0BAA0B,EAG7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAY,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,kCAAkC,EAAE,UAAU,EAAE,MA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,IAAI,OAAO,CAAC,WAAW;gBAAE,OAAO;YAChC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS;gBAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5F,CAAC,CAAC;QACF,IAAI,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;YACd,IAAI,CAAC,KAAK,aAAa,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBAAE,OAAO;YACpF,aAAa,GAAG,CAAC,CAAC;YAClB,IAAI,gBAAgB,CAAC,MAAM;gBAAE,iBAAiB,CAAC,eAAe,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;;gBAC/E,eAAe,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC,EAAE,OAAO,CAAC,CAAC;IAChB,CAAC;SAAM,CAAC;QACJ,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IAC9F,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Renderable } from '@aurumjs/rendering';
2
+ import { HTMLSanitizeConfig } from '../../utilities/sanitize.js';
3
+ export declare function aurumToString(content: Renderable, config?: HTMLSanitizeConfig): Promise<string>;
4
+ //# sourceMappingURL=string_adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string_adapter.d.ts","sourceRoot":"","sources":["../../../../src/rendering/renderers/string_adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,UAAU,EAGb,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,wBAAsB,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzG"}
@@ -0,0 +1,112 @@
1
+ import { createAPI, createRenderSession, isAurumDevtoolsDebugBuild, traceAurumComponentRender } from '@aurumjs/rendering';
2
+ import { ArrayDataSource, DataSource } from '@aurumjs/streams';
3
+ import { camelCaseToKebabCase } from '@aurumjs/streams';
4
+ import { getValueOf } from '@aurumjs/streams';
5
+ import { isAurumStyleClass } from '@aurumjs/streams';
6
+ export async function aurumToString(content, config = {}) {
7
+ return aurumToStringItem(content, config);
8
+ }
9
+ async function aurumToStringItem(content, config, parentSession) {
10
+ if (content === undefined || content === null || typeof content === 'boolean') {
11
+ return '';
12
+ }
13
+ if (Array.isArray(content)) {
14
+ const result = [];
15
+ for (const item of content) {
16
+ result.push(await aurumToStringItem(item, config, parentSession));
17
+ }
18
+ return result.join('');
19
+ }
20
+ if (content instanceof Promise) {
21
+ return aurumToStringItem((await content), config, parentSession);
22
+ }
23
+ if (['number', 'string', 'bigint'].includes(typeof content)) {
24
+ return content.toString();
25
+ }
26
+ else if (content instanceof DataSource) {
27
+ return aurumToStringItem(content.value, config, parentSession);
28
+ }
29
+ else if (content instanceof ArrayDataSource) {
30
+ return aurumToStringItem(content.getData(), config, parentSession);
31
+ }
32
+ else {
33
+ const item = content;
34
+ if (!item.isIntrinsic) {
35
+ const session = createRenderSession(parentSession);
36
+ try {
37
+ return await traceAurumComponentRender(item, session, () => {
38
+ const output = item.factory(item.props, item.children, createAPI(session));
39
+ const outputScope = isAurumDevtoolsDebugBuild() ? createRenderSession(session) : session;
40
+ if (outputScope !== session)
41
+ session.sessionToken.addCancellable(outputScope.sessionToken);
42
+ return aurumToStringItem(output, config, outputScope);
43
+ });
44
+ }
45
+ finally {
46
+ session.sessionToken.cancel();
47
+ }
48
+ }
49
+ if (config.tagBlacklist && config.tagBlacklist.includes(item.name)) {
50
+ return '';
51
+ }
52
+ if (config.tagWhitelist && !config.tagWhitelist.includes(item.name)) {
53
+ return '';
54
+ }
55
+ let propString = ' ';
56
+ let children = '';
57
+ if (item.children) {
58
+ children = await aurumToStringItem(item.children, config, parentSession);
59
+ }
60
+ for (const prop in item.props) {
61
+ if (config.attributeBlacklist && config.attributeBlacklist.includes(prop)) {
62
+ continue;
63
+ }
64
+ if (config.attributeWhitelist && !config.attributeWhitelist.includes(prop)) {
65
+ continue;
66
+ }
67
+ if (item.props[prop] != undefined) {
68
+ if (prop === 'style' && typeof item.props[prop] === 'object') {
69
+ propString = handleObjectStyle(propString, prop, item);
70
+ }
71
+ else if (prop === 'class' && typeof item.props[prop] === 'object') {
72
+ propString = handleObjectClass(propString, prop, item);
73
+ }
74
+ else {
75
+ propString += `${prop}="${item.props[prop].toString()}" `;
76
+ }
77
+ }
78
+ }
79
+ return `<${item.name}${propString.trimEnd()}>${children}</${item.name}>`;
80
+ }
81
+ }
82
+ // classes can be map like objects that map a class name to a boolean or boolean data source and the class only applies if the value is true
83
+ function handleObjectClass(propString, prop, item) {
84
+ return `${propString}${prop}="${resolveClass(item.props[prop])}" `;
85
+ }
86
+ function resolveClass(value) {
87
+ if (typeof value === 'string') {
88
+ return value;
89
+ }
90
+ if (isAurumStyleClass(value)) {
91
+ return value.className;
92
+ }
93
+ if (value instanceof DataSource) {
94
+ return resolveClass(value.value);
95
+ }
96
+ if (Array.isArray(value)) {
97
+ return value.map(resolveClass).filter(Boolean).join(' ');
98
+ }
99
+ if (typeof value === 'object' && value !== null) {
100
+ return Object.keys(value)
101
+ .filter((key) => getValueOf(value[key]))
102
+ .join(' ');
103
+ }
104
+ return '';
105
+ }
106
+ function handleObjectStyle(propString, prop, item) {
107
+ propString += `${prop}="${Object.keys(item.props[prop])
108
+ .map((key) => `${camelCaseToKebabCase(key)}:${getValueOf(item.props[prop][key])}`)
109
+ .join(';')};" `;
110
+ return propString;
111
+ }
112
+ //# sourceMappingURL=string_adapter.js.map