@zolomedia/bifrost-client 1.7.74
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/L1_Foundation/L1_Foundation.js +13 -0
- package/L1_Foundation/bootstrap/bootstrap.js +11 -0
- package/L1_Foundation/bootstrap/bootstrap_hooks.js +123 -0
- package/L1_Foundation/bootstrap/bootstrap_index.js +15 -0
- package/L1_Foundation/bootstrap/bootstrap_logger.js +135 -0
- package/L1_Foundation/bootstrap/cdn_loader.js +217 -0
- package/L1_Foundation/bootstrap/module_registry.js +102 -0
- package/L1_Foundation/bootstrap/prism_loader.js +164 -0
- package/L1_Foundation/config/client_config.js +110 -0
- package/L1_Foundation/config/config.js +7 -0
- package/L1_Foundation/connection/connection.js +8 -0
- package/L1_Foundation/connection/websocket_connection.js +122 -0
- package/L1_Foundation/constants/bifrost_constants.js +284 -0
- package/L1_Foundation/constants/constants.js +7 -0
- package/L1_Foundation/logger/logger.js +10 -0
- package/L2_Handling/L2_Handling.js +15 -0
- package/L2_Handling/cache/cache.js +22 -0
- package/L2_Handling/cache/cache_constants.js +69 -0
- package/L2_Handling/cache/orchestration/cache_manager.js +299 -0
- package/L2_Handling/cache/orchestration/cache_orchestrator.js +260 -0
- package/L2_Handling/cache/orchestration/orchestration.js +12 -0
- package/L2_Handling/cache/storage/session_manager.js +289 -0
- package/L2_Handling/cache/storage/storage.js +10 -0
- package/L2_Handling/cache/storage/storage_manager.js +590 -0
- package/L2_Handling/display/composite/composite.js +13 -0
- package/L2_Handling/display/composite/dashboard_renderer.js +221 -0
- package/L2_Handling/display/composite/swiper_renderer.js +564 -0
- package/L2_Handling/display/composite/terminal_renderer.js +922 -0
- package/L2_Handling/display/composite/wizard_conditional_renderer.js +274 -0
- package/L2_Handling/display/display.js +30 -0
- package/L2_Handling/display/feedback/feedback.js +11 -0
- package/L2_Handling/display/feedback/progressbar_renderer.js +418 -0
- package/L2_Handling/display/feedback/spinner_renderer.js +246 -0
- package/L2_Handling/display/inputs/button_renderer.js +634 -0
- package/L2_Handling/display/inputs/form_renderer.js +583 -0
- package/L2_Handling/display/inputs/input_renderer.js +658 -0
- package/L2_Handling/display/inputs/inputs.js +12 -0
- package/L2_Handling/display/navigation/menu_renderer.js +206 -0
- package/L2_Handling/display/navigation/navigation.js +11 -0
- package/L2_Handling/display/navigation/navigation_renderer.js +703 -0
- package/L2_Handling/display/orchestration/orchestration.js +11 -0
- package/L2_Handling/display/orchestration/renderer.js +430 -0
- package/L2_Handling/display/orchestration/zdisplay_orchestrator.js +1759 -0
- package/L2_Handling/display/outputs/alert_renderer.js +161 -0
- package/L2_Handling/display/outputs/audio_renderer.js +94 -0
- package/L2_Handling/display/outputs/card_renderer.js +229 -0
- package/L2_Handling/display/outputs/code_renderer.js +66 -0
- package/L2_Handling/display/outputs/dl_renderer.js +131 -0
- package/L2_Handling/display/outputs/header_renderer.js +162 -0
- package/L2_Handling/display/outputs/icon_renderer.js +107 -0
- package/L2_Handling/display/outputs/image_renderer.js +145 -0
- package/L2_Handling/display/outputs/list_renderer.js +190 -0
- package/L2_Handling/display/outputs/outputs.js +19 -0
- package/L2_Handling/display/outputs/table_renderer.js +765 -0
- package/L2_Handling/display/outputs/text_renderer.js +818 -0
- package/L2_Handling/display/outputs/typography_renderer.js +293 -0
- package/L2_Handling/display/outputs/video_renderer.js +116 -0
- package/L2_Handling/display/primitives/document_structure_primitives.js +319 -0
- package/L2_Handling/display/primitives/form_primitives.js +526 -0
- package/L2_Handling/display/primitives/generic_containers.js +109 -0
- package/L2_Handling/display/primitives/interactive_primitives.js +305 -0
- package/L2_Handling/display/primitives/link_primitives.js +552 -0
- package/L2_Handling/display/primitives/lists_primitives.js +262 -0
- package/L2_Handling/display/primitives/media_primitives.js +383 -0
- package/L2_Handling/display/primitives/primitives.js +19 -0
- package/L2_Handling/display/primitives/semantic_element_primitive.js +226 -0
- package/L2_Handling/display/primitives/table_primitives.js +528 -0
- package/L2_Handling/display/primitives/typography_primitives.js +175 -0
- package/L2_Handling/display/specialized/input_request_renderer.js +467 -0
- package/L2_Handling/display/specialized/specialized.js +10 -0
- package/L2_Handling/hooks/hooks.js +9 -0
- package/L2_Handling/hooks/menu_integration.js +57 -0
- package/L2_Handling/hooks/widget_hook_manager.js +292 -0
- package/L2_Handling/message/message.js +8 -0
- package/L2_Handling/message/message_handler.js +701 -0
- package/L2_Handling/navigation/navigation.js +8 -0
- package/L2_Handling/navigation/navigation_manager.js +403 -0
- package/L2_Handling/zhooks/features/cache_live.js +287 -0
- package/L2_Handling/zhooks/features/crumbs_live.js +292 -0
- package/L2_Handling/zhooks/zhooks_manager.js +65 -0
- package/L2_Handling/zvaf/zvaf.js +8 -0
- package/L2_Handling/zvaf/zvaf_manager.js +334 -0
- package/L3_Abstraction/L3_Abstraction.js +12 -0
- package/L3_Abstraction/orchestrator/container_unwrapper.js +101 -0
- package/L3_Abstraction/orchestrator/group_renderer.js +698 -0
- package/L3_Abstraction/orchestrator/input_event_handler.js +797 -0
- package/L3_Abstraction/orchestrator/metadata_processor.js +249 -0
- package/L3_Abstraction/orchestrator/navbar_builder.js +201 -0
- package/L3_Abstraction/orchestrator/orchestrator.js +13 -0
- package/L3_Abstraction/orchestrator/wizard_gate_handler.js +360 -0
- package/L3_Abstraction/renderer/renderer.js +1 -0
- package/L3_Abstraction/session/session.js +1 -0
- package/L4_Orchestration/L4_Orchestration.js +11 -0
- package/L4_Orchestration/client/client.js +1 -0
- package/L4_Orchestration/facade/facade.js +9 -0
- package/L4_Orchestration/facade/manager_registry.js +118 -0
- package/L4_Orchestration/facade/renderer_registry.js +274 -0
- package/L4_Orchestration/lifecycle/asset_loader.js +255 -0
- package/L4_Orchestration/lifecycle/initializer.js +135 -0
- package/L4_Orchestration/lifecycle/lifecycle.js +8 -0
- package/L4_Orchestration/rendering/facade.js +94 -0
- package/L4_Orchestration/rendering/rendering.js +7 -0
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/bifrost_client.js +204 -0
- package/bifrost_core.js +1686 -0
- package/docs/ARCHITECTURE.md +111 -0
- package/docs/PROTOCOL.md +106 -0
- package/docs/RENDERERS.md +101 -0
- package/docs/SECURITY.md +92 -0
- package/package.json +24 -0
- package/syntax/prism-zconfig.js +41 -0
- package/syntax/prism-zenv.js +69 -0
- package/syntax/prism-zolo-theme.css +288 -0
- package/syntax/prism-zolo.js +380 -0
- package/syntax/prism-zschema.js +38 -0
- package/syntax/prism-zspark.js +25 -0
- package/syntax/prism-zui.js +68 -0
- package/zSys/accessibility/accessibility.js +10 -0
- package/zSys/accessibility/emoji_accessibility.js +173 -0
- package/zSys/dom/block_utils.js +122 -0
- package/zSys/dom/container_utils.js +370 -0
- package/zSys/dom/dom.js +13 -0
- package/zSys/dom/dom_utils.js +328 -0
- package/zSys/dom/encoding_utils.js +117 -0
- package/zSys/dom/style_utils.js +71 -0
- package/zSys/errors/error_display.js +299 -0
- package/zSys/errors/errors.js +10 -0
- package/zSys/theme/color_utils.js +274 -0
- package/zSys/theme/dark_mode_utils.js +272 -0
- package/zSys/theme/size_utils.js +256 -0
- package/zSys/theme/spacing_utils.js +405 -0
- package/zSys/theme/theme.js +14 -0
- package/zSys/theme/zbase.css +1735 -0
- package/zSys/theme/zbase_inject.js +161 -0
- package/zSys/theme/ztheme_utils.js +305 -0
- package/zSys/validation/error_boundary.js +201 -0
- package/zSys/validation/validation.js +11 -0
- package/zSys/validation/validation_utils.js +238 -0
- package/zSys/zSys.js +14 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Lists Primitives - Enumerated Content Elements
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* HTML list elements for ordered, unordered, and description lists.
|
|
7
|
+
* Used for grouping related items with semantic meaning.
|
|
8
|
+
*
|
|
9
|
+
* @module rendering/lists_primitives
|
|
10
|
+
* @layer 0.0 (RAWEST - list structure)
|
|
11
|
+
* @pattern Pure Factory Functions
|
|
12
|
+
*
|
|
13
|
+
* Philosophy:
|
|
14
|
+
* - Semantic enumeration (ordered vs unordered)
|
|
15
|
+
* - Description lists for key-value pairs
|
|
16
|
+
* - NO styling, NO classes (dress up later)
|
|
17
|
+
* - Parent-child relationship (list → items)
|
|
18
|
+
*
|
|
19
|
+
* List Types:
|
|
20
|
+
* - <ul> + <li>: Unordered list (bullets, no sequence importance)
|
|
21
|
+
* - <ol> + <li>: Ordered list (numbers, sequence matters)
|
|
22
|
+
* - <dl> + <dt> + <dd>: Description list (term-definition pairs)
|
|
23
|
+
*
|
|
24
|
+
* zReboot Defaults:
|
|
25
|
+
* - Lists: margin-top: 0, margin-bottom: 1rem, padding-left: 2rem
|
|
26
|
+
* - Nested lists: margin-bottom: 0
|
|
27
|
+
*
|
|
28
|
+
* Dependencies:
|
|
29
|
+
* - utils/dom_utils.js (createElement, setAttributes)
|
|
30
|
+
*
|
|
31
|
+
* Exports:
|
|
32
|
+
* - createList(ordered, attributes) → HTMLUListElement | HTMLOListElement
|
|
33
|
+
* - createListItem(attributes) → HTMLLIElement
|
|
34
|
+
* - createDescriptionList(attributes) → HTMLDListElement
|
|
35
|
+
* - createDescriptionTerm(attributes) → HTMLElement (dt)
|
|
36
|
+
* - createDescriptionDetails(attributes) → HTMLElement (dd)
|
|
37
|
+
*
|
|
38
|
+
* Example:
|
|
39
|
+
* ```javascript
|
|
40
|
+
* import { createList, createListItem } from './lists_primitives.js';
|
|
41
|
+
*
|
|
42
|
+
* // Unordered list
|
|
43
|
+
* const ul = createList(false, { id: 'features' });
|
|
44
|
+
* const li1 = createListItem();
|
|
45
|
+
* li1.textContent = 'Feature 1';
|
|
46
|
+
* ul.appendChild(li1);
|
|
47
|
+
*
|
|
48
|
+
* // Ordered list
|
|
49
|
+
* const ol = createList(true, { id: 'steps' });
|
|
50
|
+
* const step1 = createListItem();
|
|
51
|
+
* step1.textContent = 'Step 1';
|
|
52
|
+
* ol.appendChild(step1);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
// ─────────────────────────────────────────────────────────────────
|
|
57
|
+
// Imports
|
|
58
|
+
// ─────────────────────────────────────────────────────────────────
|
|
59
|
+
|
|
60
|
+
// Layer 2: Utilities
|
|
61
|
+
import { createElement, setAttributes } from '../../../zSys/dom/dom_utils.js';
|
|
62
|
+
|
|
63
|
+
//
|
|
64
|
+
// Ordered & Unordered Lists
|
|
65
|
+
//
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Create a list element (<ul> or <ol>)
|
|
69
|
+
*
|
|
70
|
+
* Used for grouping related items in a list structure.
|
|
71
|
+
* - Unordered (<ul>): Items where order doesn't matter (features, tags, bullets)
|
|
72
|
+
* - Ordered (<ol>): Items where sequence is important (steps, rankings, instructions)
|
|
73
|
+
*
|
|
74
|
+
* zReboot Defaults:
|
|
75
|
+
* - margin-top: 0
|
|
76
|
+
* - margin-bottom: 1rem
|
|
77
|
+
* - padding-left: 2rem (for bullets/numbers)
|
|
78
|
+
*
|
|
79
|
+
* @param {boolean} [ordered=false] - If true, creates <ol>; otherwise <ul>
|
|
80
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, start, type, etc.)
|
|
81
|
+
* @returns {HTMLUListElement|HTMLOListElement} The created list element
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Unordered list (bullets)
|
|
85
|
+
* const features = createList(false, { id: 'features-list' });
|
|
86
|
+
*
|
|
87
|
+
* // Ordered list (numbers)
|
|
88
|
+
* const steps = createList(true, { id: 'instructions' });
|
|
89
|
+
*
|
|
90
|
+
* // Ordered list starting at 5
|
|
91
|
+
* const continuation = createList(true, { start: 5 });
|
|
92
|
+
*
|
|
93
|
+
* // Roman numerals (type="I", "i", "A", "a")
|
|
94
|
+
* const romanList = createList(true, { type: 'I' });
|
|
95
|
+
*/
|
|
96
|
+
export function createList(ordered = false, attributes = {}) {
|
|
97
|
+
const tag = ordered ? 'ol' : 'ul';
|
|
98
|
+
const list = createElement(tag);
|
|
99
|
+
|
|
100
|
+
if (Object.keys(attributes).length > 0) {
|
|
101
|
+
setAttributes(list, attributes);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return list;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Create a <li> (list item) element
|
|
109
|
+
*
|
|
110
|
+
* Used as children of <ul> or <ol> lists.
|
|
111
|
+
* Represents a single item in the list.
|
|
112
|
+
*
|
|
113
|
+
* Best Practice:
|
|
114
|
+
* - Must be a direct child of <ul>, <ol>, or <menu>
|
|
115
|
+
* - Can contain flow content (text, images, nested lists, etc.)
|
|
116
|
+
*
|
|
117
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, value, data-*, etc.)
|
|
118
|
+
* @returns {HTMLLIElement} The created list item element
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* // Basic list item
|
|
122
|
+
* const item = createListItem();
|
|
123
|
+
* item.textContent = 'First item';
|
|
124
|
+
*
|
|
125
|
+
* // List item with custom value (for <ol>)
|
|
126
|
+
* const customItem = createListItem({ value: 10 });
|
|
127
|
+
*
|
|
128
|
+
* // List item with data attribute
|
|
129
|
+
* const dataItem = createListItem({ 'data-item-id': '123' });
|
|
130
|
+
*/
|
|
131
|
+
export function createListItem(attributes = {}) {
|
|
132
|
+
const li = createElement('li');
|
|
133
|
+
|
|
134
|
+
if (Object.keys(attributes).length > 0) {
|
|
135
|
+
setAttributes(li, attributes);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return li;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//
|
|
142
|
+
// Description Lists (Key-Value Pairs)
|
|
143
|
+
//
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Create a <dl> (description list) element
|
|
147
|
+
*
|
|
148
|
+
* Used for name-value groups (glossaries, metadata, key-value pairs).
|
|
149
|
+
* Contains <dt> (term) and <dd> (description/definition) pairs.
|
|
150
|
+
*
|
|
151
|
+
* Common Uses:
|
|
152
|
+
* - Glossaries (term → definition)
|
|
153
|
+
* - Metadata (key → value)
|
|
154
|
+
* - FAQ (question → answer)
|
|
155
|
+
* - Product specs (feature → value)
|
|
156
|
+
*
|
|
157
|
+
* Structure:
|
|
158
|
+
* - One or more <dt> followed by one or more <dd>
|
|
159
|
+
* - Can have multiple <dt> for one <dd> (synonyms)
|
|
160
|
+
* - Can have multiple <dd> for one <dt> (multiple definitions)
|
|
161
|
+
*
|
|
162
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, data-*, etc.)
|
|
163
|
+
* @returns {HTMLDListElement} The created description list element
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* // Glossary
|
|
167
|
+
* const glossary = createDescriptionList({ id: 'glossary' });
|
|
168
|
+
*
|
|
169
|
+
* // Product specifications
|
|
170
|
+
* const specs = createDescriptionList({ class: 'product-specs' });
|
|
171
|
+
*
|
|
172
|
+
* // FAQ
|
|
173
|
+
* const faq = createDescriptionList({ 'aria-label': 'Frequently Asked Questions' });
|
|
174
|
+
*/
|
|
175
|
+
export function createDescriptionList(attributes = {}) {
|
|
176
|
+
const dl = createElement('dl');
|
|
177
|
+
|
|
178
|
+
if (Object.keys(attributes).length > 0) {
|
|
179
|
+
setAttributes(dl, attributes);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return dl;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Create a <dt> (description term) element
|
|
187
|
+
*
|
|
188
|
+
* Represents the term/name in a description list.
|
|
189
|
+
* Must be a child of <dl> and paired with <dd>.
|
|
190
|
+
*
|
|
191
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, data-*, etc.)
|
|
192
|
+
* @returns {HTMLElement} The created description term element
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // Glossary term
|
|
196
|
+
* const term = createDescriptionTerm();
|
|
197
|
+
* term.textContent = 'HTML';
|
|
198
|
+
*
|
|
199
|
+
* // Product feature name
|
|
200
|
+
* const feature = createDescriptionTerm({ class: 'spec-name' });
|
|
201
|
+
* feature.textContent = 'Weight';
|
|
202
|
+
*
|
|
203
|
+
* // FAQ question
|
|
204
|
+
* const question = createDescriptionTerm({ id: 'faq-1' });
|
|
205
|
+
* question.textContent = 'What is zCLI?';
|
|
206
|
+
*/
|
|
207
|
+
export function createDescriptionTerm(attributes = {}) {
|
|
208
|
+
const dt = createElement('dt');
|
|
209
|
+
|
|
210
|
+
if (Object.keys(attributes).length > 0) {
|
|
211
|
+
setAttributes(dt, attributes);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return dt;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Create a <dd> (description details) element
|
|
219
|
+
*
|
|
220
|
+
* Represents the description/value in a description list.
|
|
221
|
+
* Must be a child of <dl> and paired with <dt>.
|
|
222
|
+
*
|
|
223
|
+
* zReboot Defaults:
|
|
224
|
+
* - margin-left: 0 (reset browser default indent)
|
|
225
|
+
*
|
|
226
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, data-*, etc.)
|
|
227
|
+
* @returns {HTMLElement} The created description details element
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* // Glossary definition
|
|
231
|
+
* const definition = createDescriptionDetails();
|
|
232
|
+
* definition.textContent = 'HyperText Markup Language';
|
|
233
|
+
*
|
|
234
|
+
* // Product feature value
|
|
235
|
+
* const value = createDescriptionDetails({ class: 'spec-value' });
|
|
236
|
+
* value.textContent = '1.2 kg';
|
|
237
|
+
*
|
|
238
|
+
* // FAQ answer
|
|
239
|
+
* const answer = createDescriptionDetails({ 'data-answer-id': '1' });
|
|
240
|
+
* answer.textContent = 'zCLI is a command-line interface framework.';
|
|
241
|
+
*/
|
|
242
|
+
export function createDescriptionDetails(attributes = {}) {
|
|
243
|
+
const dd = createElement('dd');
|
|
244
|
+
|
|
245
|
+
if (Object.keys(attributes).length > 0) {
|
|
246
|
+
setAttributes(dd, attributes);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return dd;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
//
|
|
253
|
+
// Default Export (for convenience)
|
|
254
|
+
//
|
|
255
|
+
export default {
|
|
256
|
+
createList,
|
|
257
|
+
createListItem,
|
|
258
|
+
createDescriptionList,
|
|
259
|
+
createDescriptionTerm,
|
|
260
|
+
createDescriptionDetails
|
|
261
|
+
};
|
|
262
|
+
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Media Primitives - Rich Content Elements
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* HTML media elements for images, video, audio, and responsive images.
|
|
7
|
+
* Used for displaying rich content with native browser controls.
|
|
8
|
+
*
|
|
9
|
+
* @module rendering/media_primitives
|
|
10
|
+
* @layer 0.0 (RAWEST - media elements)
|
|
11
|
+
* @pattern Pure Factory Functions
|
|
12
|
+
*
|
|
13
|
+
* Philosophy:
|
|
14
|
+
* - Native media elements with browser controls
|
|
15
|
+
* - Responsive images via <picture> + <source>
|
|
16
|
+
* - Accessibility (alt text, captions)
|
|
17
|
+
* - NO styling, NO classes (dress up later)
|
|
18
|
+
*
|
|
19
|
+
* Media Types:
|
|
20
|
+
* - <img>: Single image with src/alt
|
|
21
|
+
* - <video>: Video player with controls
|
|
22
|
+
* - <audio>: Audio player with controls
|
|
23
|
+
* - <picture> + <source>: Responsive images (art direction)
|
|
24
|
+
* - <source>: Source element for picture/video/audio
|
|
25
|
+
*
|
|
26
|
+
* Accessibility:
|
|
27
|
+
* - Images REQUIRE alt text (enforced)
|
|
28
|
+
* - Video/audio support captions via <track> elements
|
|
29
|
+
* - Native controls are keyboard accessible
|
|
30
|
+
*
|
|
31
|
+
* Dependencies:
|
|
32
|
+
* - utils/dom_utils.js (createElement, setAttributes)
|
|
33
|
+
*
|
|
34
|
+
* Exports:
|
|
35
|
+
* - createImage(src, alt, attributes) → HTMLImageElement
|
|
36
|
+
* - createVideo(src, attributes) → HTMLVideoElement
|
|
37
|
+
* - createAudio(src, attributes) → HTMLAudioElement
|
|
38
|
+
* - createPicture(attributes) → HTMLPictureElement
|
|
39
|
+
* - createSource(srcset, media, type) → HTMLSourceElement
|
|
40
|
+
*
|
|
41
|
+
* Example:
|
|
42
|
+
* ```javascript
|
|
43
|
+
* import { createImage, createPicture, createSource } from './media_primitives.js';
|
|
44
|
+
*
|
|
45
|
+
* // Simple image
|
|
46
|
+
* const img = createImage('photo.jpg', 'A beautiful sunset');
|
|
47
|
+
*
|
|
48
|
+
* // Responsive image
|
|
49
|
+
* const picture = createPicture();
|
|
50
|
+
* const srcLarge = createSource('large.jpg', '(min-width: 1024px)');
|
|
51
|
+
* const srcMedium = createSource('medium.jpg', '(min-width: 640px)');
|
|
52
|
+
* const fallback = createImage('small.jpg', 'Responsive image');
|
|
53
|
+
* picture.appendChild(srcLarge);
|
|
54
|
+
* picture.appendChild(srcMedium);
|
|
55
|
+
* picture.appendChild(fallback);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
// ─────────────────────────────────────────────────────────────────
|
|
60
|
+
// Imports
|
|
61
|
+
// ─────────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
// Layer 2: Utilities
|
|
64
|
+
import { createElement, setAttributes } from '../../../zSys/dom/dom_utils.js';
|
|
65
|
+
|
|
66
|
+
//
|
|
67
|
+
// Image Element
|
|
68
|
+
//
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create an <img> element
|
|
72
|
+
*
|
|
73
|
+
* Used for displaying images with required alt text for accessibility.
|
|
74
|
+
* The most common media element in web documents.
|
|
75
|
+
*
|
|
76
|
+
* Semantic Meaning:
|
|
77
|
+
* - Single image source
|
|
78
|
+
* - Alt text is REQUIRED (accessibility)
|
|
79
|
+
* - Can be styled with width/height attributes or CSS
|
|
80
|
+
*
|
|
81
|
+
* Accessibility:
|
|
82
|
+
* - Alt text should describe the image content
|
|
83
|
+
* - Decorative images can use alt="" (empty string)
|
|
84
|
+
* - Complex images may need longer descriptions
|
|
85
|
+
*
|
|
86
|
+
* @param {string} src - Image source URL or path (REQUIRED)
|
|
87
|
+
* @param {string} [alt=''] - Alternative text for accessibility (defaults to empty for decorative)
|
|
88
|
+
* @param {Object} [attributes={}] - Additional HTML attributes (id, class, width, height, loading, etc.)
|
|
89
|
+
* @returns {HTMLImageElement} The created img element
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* // Basic image
|
|
93
|
+
* const photo = createImage('sunset.jpg', 'A beautiful sunset over the ocean');
|
|
94
|
+
*
|
|
95
|
+
* // Image with dimensions
|
|
96
|
+
* const thumbnail = createImage('thumb.jpg', 'Product thumbnail', {
|
|
97
|
+
* width: '150',
|
|
98
|
+
* height: '150'
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* // Lazy-loaded image
|
|
102
|
+
* const lazyImg = createImage('large.jpg', 'High-res photo', {
|
|
103
|
+
* loading: 'lazy'
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* // Decorative image (empty alt)
|
|
107
|
+
* const decoration = createImage('pattern.png', '', { class: 'bg-pattern' });
|
|
108
|
+
*/
|
|
109
|
+
export function createImage(src, alt = '', attributes = {}) {
|
|
110
|
+
if (!src) {
|
|
111
|
+
console.error('[media_primitives] createImage: src is required');
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const img = createElement('img');
|
|
116
|
+
|
|
117
|
+
// Set required attributes
|
|
118
|
+
img.src = src;
|
|
119
|
+
img.alt = alt;
|
|
120
|
+
|
|
121
|
+
// Set additional attributes
|
|
122
|
+
if (Object.keys(attributes).length > 0) {
|
|
123
|
+
setAttributes(img, attributes);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return img;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//
|
|
130
|
+
// Video Element
|
|
131
|
+
//
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Create a <video> element
|
|
135
|
+
*
|
|
136
|
+
* Used for displaying video content with native browser controls.
|
|
137
|
+
* Supports multiple source formats for cross-browser compatibility.
|
|
138
|
+
*
|
|
139
|
+
* Semantic Meaning:
|
|
140
|
+
* - Video player with native controls
|
|
141
|
+
* - Can contain multiple <source> elements for format fallback
|
|
142
|
+
* - Can include <track> elements for captions/subtitles
|
|
143
|
+
*
|
|
144
|
+
* Native Attributes:
|
|
145
|
+
* - controls: Show playback controls (recommended)
|
|
146
|
+
* - autoplay: Start playing automatically (avoid - accessibility concern)
|
|
147
|
+
* - loop: Loop the video
|
|
148
|
+
* - muted: Mute audio (required for autoplay in most browsers)
|
|
149
|
+
* - poster: Placeholder image before playback
|
|
150
|
+
* - preload: 'none' | 'metadata' | 'auto'
|
|
151
|
+
*
|
|
152
|
+
* @param {string} [src] - Optional video source URL (can also use <source> children)
|
|
153
|
+
* @param {Object} [attributes={}] - HTML attributes (controls, width, height, poster, etc.)
|
|
154
|
+
* @returns {HTMLVideoElement} The created video element
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* // Basic video with controls
|
|
158
|
+
* const video = createVideo('movie.mp4', { controls: true });
|
|
159
|
+
*
|
|
160
|
+
* // Video with poster and dimensions
|
|
161
|
+
* const videoWithPoster = createVideo('demo.mp4', {
|
|
162
|
+
* controls: true,
|
|
163
|
+
* poster: 'poster.jpg',
|
|
164
|
+
* width: '640',
|
|
165
|
+
* height: '360'
|
|
166
|
+
* });
|
|
167
|
+
*
|
|
168
|
+
* // Video with multiple sources (append <source> elements after creation)
|
|
169
|
+
* const responsiveVideo = createVideo(null, { controls: true });
|
|
170
|
+
* // Then append createSource() elements for format fallback
|
|
171
|
+
*/
|
|
172
|
+
export function createVideo(src = null, attributes = {}) {
|
|
173
|
+
const video = createElement('video');
|
|
174
|
+
|
|
175
|
+
// Set src if provided (optional - can use <source> children instead)
|
|
176
|
+
if (src) {
|
|
177
|
+
video.src = src;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Set additional attributes (controls, width, height, etc.)
|
|
181
|
+
if (Object.keys(attributes).length > 0) {
|
|
182
|
+
setAttributes(video, attributes);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return video;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
//
|
|
189
|
+
// Audio Element
|
|
190
|
+
//
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Create an <audio> element
|
|
194
|
+
*
|
|
195
|
+
* Used for displaying audio content with native browser controls.
|
|
196
|
+
* Supports multiple source formats for cross-browser compatibility.
|
|
197
|
+
*
|
|
198
|
+
* Semantic Meaning:
|
|
199
|
+
* - Audio player with native controls
|
|
200
|
+
* - Can contain multiple <source> elements for format fallback
|
|
201
|
+
* - Can include <track> elements for captions
|
|
202
|
+
*
|
|
203
|
+
* Native Attributes:
|
|
204
|
+
* - controls: Show playback controls (recommended)
|
|
205
|
+
* - autoplay: Start playing automatically (avoid - accessibility concern)
|
|
206
|
+
* - loop: Loop the audio
|
|
207
|
+
* - muted: Mute audio
|
|
208
|
+
* - preload: 'none' | 'metadata' | 'auto'
|
|
209
|
+
*
|
|
210
|
+
* @param {string} [src] - Optional audio source URL (can also use <source> children)
|
|
211
|
+
* @param {Object} [attributes={}] - HTML attributes (controls, loop, etc.)
|
|
212
|
+
* @returns {HTMLAudioElement} The created audio element
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // Basic audio with controls
|
|
216
|
+
* const audio = createAudio('song.mp3', { controls: true });
|
|
217
|
+
*
|
|
218
|
+
* // Looping audio
|
|
219
|
+
* const bgMusic = createAudio('background.mp3', {
|
|
220
|
+
* controls: true,
|
|
221
|
+
* loop: true
|
|
222
|
+
* });
|
|
223
|
+
*
|
|
224
|
+
* // Audio with multiple sources (append <source> elements after creation)
|
|
225
|
+
* const compatAudio = createAudio(null, { controls: true });
|
|
226
|
+
* // Then append createSource() elements for format fallback
|
|
227
|
+
*/
|
|
228
|
+
export function createAudio(src = null, attributes = {}) {
|
|
229
|
+
const audio = createElement('audio');
|
|
230
|
+
|
|
231
|
+
// Set src if provided (optional - can use <source> children instead)
|
|
232
|
+
if (src) {
|
|
233
|
+
audio.src = src;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Set additional attributes (controls, loop, etc.)
|
|
237
|
+
if (Object.keys(attributes).length > 0) {
|
|
238
|
+
setAttributes(audio, attributes);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return audio;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
//
|
|
245
|
+
// Picture Element (Responsive Images)
|
|
246
|
+
//
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Create a <picture> element
|
|
250
|
+
*
|
|
251
|
+
* Used for responsive images with art direction (different images for different contexts).
|
|
252
|
+
* Contains multiple <source> elements and a fallback <img> element.
|
|
253
|
+
*
|
|
254
|
+
* Semantic Meaning:
|
|
255
|
+
* - Container for responsive image sources
|
|
256
|
+
* - Browser selects best source based on media queries and formats
|
|
257
|
+
* - Fallback <img> is REQUIRED (last child)
|
|
258
|
+
*
|
|
259
|
+
* Usage Pattern:
|
|
260
|
+
* 1. Create <picture> element
|
|
261
|
+
* 2. Append <source> elements (most specific first)
|
|
262
|
+
* 3. Append fallback <img> element (REQUIRED, always last)
|
|
263
|
+
*
|
|
264
|
+
* Art Direction vs Resolution Switching:
|
|
265
|
+
* - Art direction: Different crops/compositions for different screens
|
|
266
|
+
* - Resolution switching: Same image at different resolutions (use <img srcset> instead)
|
|
267
|
+
*
|
|
268
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, etc.)
|
|
269
|
+
* @returns {HTMLPictureElement} The created picture element
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* // Responsive image with art direction
|
|
273
|
+
* const picture = createPicture({ id: 'hero-image' });
|
|
274
|
+
*
|
|
275
|
+
* // Add sources (desktop, tablet, mobile)
|
|
276
|
+
* const desktop = createSource('wide.jpg', '(min-width: 1024px)');
|
|
277
|
+
* const tablet = createSource('medium.jpg', '(min-width: 640px)');
|
|
278
|
+
* const fallback = createImage('small.jpg', 'Hero image');
|
|
279
|
+
*
|
|
280
|
+
* picture.appendChild(desktop);
|
|
281
|
+
* picture.appendChild(tablet);
|
|
282
|
+
* picture.appendChild(fallback); // REQUIRED - always last
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* // Modern image format fallback (WebP → JPEG)
|
|
286
|
+
* const modernPicture = createPicture();
|
|
287
|
+
* const webp = createSource('photo.webp', null, 'image/webp');
|
|
288
|
+
* const jpeg = createImage('photo.jpg', 'Photo');
|
|
289
|
+
*
|
|
290
|
+
* modernPicture.appendChild(webp);
|
|
291
|
+
* modernPicture.appendChild(jpeg); // REQUIRED fallback
|
|
292
|
+
*/
|
|
293
|
+
export function createPicture(attributes = {}) {
|
|
294
|
+
const picture = createElement('picture');
|
|
295
|
+
|
|
296
|
+
if (Object.keys(attributes).length > 0) {
|
|
297
|
+
setAttributes(picture, attributes);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return picture;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
//
|
|
304
|
+
// Source Element (for picture/video/audio)
|
|
305
|
+
//
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Create a <source> element
|
|
309
|
+
*
|
|
310
|
+
* Used within <picture>, <video>, or <audio> elements to provide
|
|
311
|
+
* multiple source options with media queries or format fallbacks.
|
|
312
|
+
*
|
|
313
|
+
* Semantic Meaning:
|
|
314
|
+
* - Specifies alternative media sources
|
|
315
|
+
* - Browser selects first compatible source
|
|
316
|
+
* - Can filter by media query (responsive) or format (compatibility)
|
|
317
|
+
*
|
|
318
|
+
* Usage Contexts:
|
|
319
|
+
* - <picture>: Responsive images (srcset + media query)
|
|
320
|
+
* - <video>: Format fallback (src + type: video/mp4, video/webm, etc.)
|
|
321
|
+
* - <audio>: Format fallback (src + type: audio/mp3, audio/ogg, etc.)
|
|
322
|
+
*
|
|
323
|
+
* @param {string} srcset - Source URL or srcset value
|
|
324
|
+
* @param {string} [media=null] - Media query for responsive images (e.g., "(min-width: 768px)")
|
|
325
|
+
* @param {string} [type=null] - MIME type for format fallback (e.g., "image/webp", "video/mp4")
|
|
326
|
+
* @returns {HTMLSourceElement} The created source element
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* // Responsive image source (for <picture>)
|
|
330
|
+
* const desktop = createSource('large.jpg', '(min-width: 1024px)');
|
|
331
|
+
* const tablet = createSource('medium.jpg', '(min-width: 640px)');
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* // Modern format source (for <picture>)
|
|
335
|
+
* const webp = createSource('photo.webp', null, 'image/webp');
|
|
336
|
+
* const avif = createSource('photo.avif', null, 'image/avif');
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* // Video format sources (for <video>)
|
|
340
|
+
* const webm = createSource('movie.webm', null, 'video/webm');
|
|
341
|
+
* const mp4 = createSource('movie.mp4', null, 'video/mp4');
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* // Audio format sources (for <audio>)
|
|
345
|
+
* const ogg = createSource('song.ogg', null, 'audio/ogg');
|
|
346
|
+
* const mp3 = createSource('song.mp3', null, 'audio/mpeg');
|
|
347
|
+
*/
|
|
348
|
+
export function createSource(srcset, media = null, type = null) {
|
|
349
|
+
if (!srcset) {
|
|
350
|
+
console.error('[media_primitives] createSource: srcset is required');
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const source = createElement('source');
|
|
355
|
+
|
|
356
|
+
// For <picture>: use srcset attribute
|
|
357
|
+
// For <video>/<audio>: srcset becomes src attribute
|
|
358
|
+
source.srcset = srcset;
|
|
359
|
+
|
|
360
|
+
// Media query for responsive images (optional)
|
|
361
|
+
if (media) {
|
|
362
|
+
source.media = media;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// MIME type for format fallback (optional)
|
|
366
|
+
if (type) {
|
|
367
|
+
source.type = type;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return source;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
//
|
|
374
|
+
// Default Export (for convenience)
|
|
375
|
+
//
|
|
376
|
+
export default {
|
|
377
|
+
createImage,
|
|
378
|
+
createVideo,
|
|
379
|
+
createAudio,
|
|
380
|
+
createPicture,
|
|
381
|
+
createSource
|
|
382
|
+
};
|
|
383
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering Primitives Module Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* Low-level DOM element creation primitives.
|
|
5
|
+
*
|
|
6
|
+
* @module rendering/primitives
|
|
7
|
+
* @layer 0 (Primitives)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from './document_structure_primitives.js';
|
|
11
|
+
export * from './form_primitives.js';
|
|
12
|
+
export * from './generic_containers.js';
|
|
13
|
+
export * from './interactive_primitives.js';
|
|
14
|
+
export * from './link_primitives.js';
|
|
15
|
+
export * from './lists_primitives.js';
|
|
16
|
+
export * from './media_primitives.js';
|
|
17
|
+
export * from './table_primitives.js';
|
|
18
|
+
export * from './typography_primitives.js';
|
|
19
|
+
export * from './semantic_element_primitive.js';
|