@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.
Files changed (140) hide show
  1. package/L1_Foundation/L1_Foundation.js +13 -0
  2. package/L1_Foundation/bootstrap/bootstrap.js +11 -0
  3. package/L1_Foundation/bootstrap/bootstrap_hooks.js +123 -0
  4. package/L1_Foundation/bootstrap/bootstrap_index.js +15 -0
  5. package/L1_Foundation/bootstrap/bootstrap_logger.js +135 -0
  6. package/L1_Foundation/bootstrap/cdn_loader.js +217 -0
  7. package/L1_Foundation/bootstrap/module_registry.js +102 -0
  8. package/L1_Foundation/bootstrap/prism_loader.js +164 -0
  9. package/L1_Foundation/config/client_config.js +110 -0
  10. package/L1_Foundation/config/config.js +7 -0
  11. package/L1_Foundation/connection/connection.js +8 -0
  12. package/L1_Foundation/connection/websocket_connection.js +122 -0
  13. package/L1_Foundation/constants/bifrost_constants.js +284 -0
  14. package/L1_Foundation/constants/constants.js +7 -0
  15. package/L1_Foundation/logger/logger.js +10 -0
  16. package/L2_Handling/L2_Handling.js +15 -0
  17. package/L2_Handling/cache/cache.js +22 -0
  18. package/L2_Handling/cache/cache_constants.js +69 -0
  19. package/L2_Handling/cache/orchestration/cache_manager.js +299 -0
  20. package/L2_Handling/cache/orchestration/cache_orchestrator.js +260 -0
  21. package/L2_Handling/cache/orchestration/orchestration.js +12 -0
  22. package/L2_Handling/cache/storage/session_manager.js +289 -0
  23. package/L2_Handling/cache/storage/storage.js +10 -0
  24. package/L2_Handling/cache/storage/storage_manager.js +590 -0
  25. package/L2_Handling/display/composite/composite.js +13 -0
  26. package/L2_Handling/display/composite/dashboard_renderer.js +221 -0
  27. package/L2_Handling/display/composite/swiper_renderer.js +564 -0
  28. package/L2_Handling/display/composite/terminal_renderer.js +922 -0
  29. package/L2_Handling/display/composite/wizard_conditional_renderer.js +274 -0
  30. package/L2_Handling/display/display.js +30 -0
  31. package/L2_Handling/display/feedback/feedback.js +11 -0
  32. package/L2_Handling/display/feedback/progressbar_renderer.js +418 -0
  33. package/L2_Handling/display/feedback/spinner_renderer.js +246 -0
  34. package/L2_Handling/display/inputs/button_renderer.js +634 -0
  35. package/L2_Handling/display/inputs/form_renderer.js +583 -0
  36. package/L2_Handling/display/inputs/input_renderer.js +658 -0
  37. package/L2_Handling/display/inputs/inputs.js +12 -0
  38. package/L2_Handling/display/navigation/menu_renderer.js +206 -0
  39. package/L2_Handling/display/navigation/navigation.js +11 -0
  40. package/L2_Handling/display/navigation/navigation_renderer.js +703 -0
  41. package/L2_Handling/display/orchestration/orchestration.js +11 -0
  42. package/L2_Handling/display/orchestration/renderer.js +430 -0
  43. package/L2_Handling/display/orchestration/zdisplay_orchestrator.js +1759 -0
  44. package/L2_Handling/display/outputs/alert_renderer.js +161 -0
  45. package/L2_Handling/display/outputs/audio_renderer.js +94 -0
  46. package/L2_Handling/display/outputs/card_renderer.js +229 -0
  47. package/L2_Handling/display/outputs/code_renderer.js +66 -0
  48. package/L2_Handling/display/outputs/dl_renderer.js +131 -0
  49. package/L2_Handling/display/outputs/header_renderer.js +162 -0
  50. package/L2_Handling/display/outputs/icon_renderer.js +107 -0
  51. package/L2_Handling/display/outputs/image_renderer.js +145 -0
  52. package/L2_Handling/display/outputs/list_renderer.js +190 -0
  53. package/L2_Handling/display/outputs/outputs.js +19 -0
  54. package/L2_Handling/display/outputs/table_renderer.js +765 -0
  55. package/L2_Handling/display/outputs/text_renderer.js +818 -0
  56. package/L2_Handling/display/outputs/typography_renderer.js +293 -0
  57. package/L2_Handling/display/outputs/video_renderer.js +116 -0
  58. package/L2_Handling/display/primitives/document_structure_primitives.js +319 -0
  59. package/L2_Handling/display/primitives/form_primitives.js +526 -0
  60. package/L2_Handling/display/primitives/generic_containers.js +109 -0
  61. package/L2_Handling/display/primitives/interactive_primitives.js +305 -0
  62. package/L2_Handling/display/primitives/link_primitives.js +552 -0
  63. package/L2_Handling/display/primitives/lists_primitives.js +262 -0
  64. package/L2_Handling/display/primitives/media_primitives.js +383 -0
  65. package/L2_Handling/display/primitives/primitives.js +19 -0
  66. package/L2_Handling/display/primitives/semantic_element_primitive.js +226 -0
  67. package/L2_Handling/display/primitives/table_primitives.js +528 -0
  68. package/L2_Handling/display/primitives/typography_primitives.js +175 -0
  69. package/L2_Handling/display/specialized/input_request_renderer.js +467 -0
  70. package/L2_Handling/display/specialized/specialized.js +10 -0
  71. package/L2_Handling/hooks/hooks.js +9 -0
  72. package/L2_Handling/hooks/menu_integration.js +57 -0
  73. package/L2_Handling/hooks/widget_hook_manager.js +292 -0
  74. package/L2_Handling/message/message.js +8 -0
  75. package/L2_Handling/message/message_handler.js +701 -0
  76. package/L2_Handling/navigation/navigation.js +8 -0
  77. package/L2_Handling/navigation/navigation_manager.js +403 -0
  78. package/L2_Handling/zhooks/features/cache_live.js +287 -0
  79. package/L2_Handling/zhooks/features/crumbs_live.js +292 -0
  80. package/L2_Handling/zhooks/zhooks_manager.js +65 -0
  81. package/L2_Handling/zvaf/zvaf.js +8 -0
  82. package/L2_Handling/zvaf/zvaf_manager.js +334 -0
  83. package/L3_Abstraction/L3_Abstraction.js +12 -0
  84. package/L3_Abstraction/orchestrator/container_unwrapper.js +101 -0
  85. package/L3_Abstraction/orchestrator/group_renderer.js +698 -0
  86. package/L3_Abstraction/orchestrator/input_event_handler.js +797 -0
  87. package/L3_Abstraction/orchestrator/metadata_processor.js +249 -0
  88. package/L3_Abstraction/orchestrator/navbar_builder.js +201 -0
  89. package/L3_Abstraction/orchestrator/orchestrator.js +13 -0
  90. package/L3_Abstraction/orchestrator/wizard_gate_handler.js +360 -0
  91. package/L3_Abstraction/renderer/renderer.js +1 -0
  92. package/L3_Abstraction/session/session.js +1 -0
  93. package/L4_Orchestration/L4_Orchestration.js +11 -0
  94. package/L4_Orchestration/client/client.js +1 -0
  95. package/L4_Orchestration/facade/facade.js +9 -0
  96. package/L4_Orchestration/facade/manager_registry.js +118 -0
  97. package/L4_Orchestration/facade/renderer_registry.js +274 -0
  98. package/L4_Orchestration/lifecycle/asset_loader.js +255 -0
  99. package/L4_Orchestration/lifecycle/initializer.js +135 -0
  100. package/L4_Orchestration/lifecycle/lifecycle.js +8 -0
  101. package/L4_Orchestration/rendering/facade.js +94 -0
  102. package/L4_Orchestration/rendering/rendering.js +7 -0
  103. package/LICENSE +21 -0
  104. package/README.md +82 -0
  105. package/bifrost_client.js +204 -0
  106. package/bifrost_core.js +1686 -0
  107. package/docs/ARCHITECTURE.md +111 -0
  108. package/docs/PROTOCOL.md +106 -0
  109. package/docs/RENDERERS.md +101 -0
  110. package/docs/SECURITY.md +92 -0
  111. package/package.json +24 -0
  112. package/syntax/prism-zconfig.js +41 -0
  113. package/syntax/prism-zenv.js +69 -0
  114. package/syntax/prism-zolo-theme.css +288 -0
  115. package/syntax/prism-zolo.js +380 -0
  116. package/syntax/prism-zschema.js +38 -0
  117. package/syntax/prism-zspark.js +25 -0
  118. package/syntax/prism-zui.js +68 -0
  119. package/zSys/accessibility/accessibility.js +10 -0
  120. package/zSys/accessibility/emoji_accessibility.js +173 -0
  121. package/zSys/dom/block_utils.js +122 -0
  122. package/zSys/dom/container_utils.js +370 -0
  123. package/zSys/dom/dom.js +13 -0
  124. package/zSys/dom/dom_utils.js +328 -0
  125. package/zSys/dom/encoding_utils.js +117 -0
  126. package/zSys/dom/style_utils.js +71 -0
  127. package/zSys/errors/error_display.js +299 -0
  128. package/zSys/errors/errors.js +10 -0
  129. package/zSys/theme/color_utils.js +274 -0
  130. package/zSys/theme/dark_mode_utils.js +272 -0
  131. package/zSys/theme/size_utils.js +256 -0
  132. package/zSys/theme/spacing_utils.js +405 -0
  133. package/zSys/theme/theme.js +14 -0
  134. package/zSys/theme/zbase.css +1735 -0
  135. package/zSys/theme/zbase_inject.js +161 -0
  136. package/zSys/theme/ztheme_utils.js +305 -0
  137. package/zSys/validation/error_boundary.js +201 -0
  138. package/zSys/validation/validation.js +11 -0
  139. package/zSys/validation/validation_utils.js +238 -0
  140. package/zSys/zSys.js +14 -0
@@ -0,0 +1,305 @@
1
+ /**
2
+ *
3
+ * Interactive Primitives - User Action Elements
4
+ *
5
+ *
6
+ * HTML elements that respond to user interaction.
7
+ * Used for buttons, links, and disclosure widgets.
8
+ *
9
+ * @module rendering/interactive_primitives
10
+ * @layer 0.0 (RAWEST - interactive elements)
11
+ * @pattern Pure Factory Functions
12
+ *
13
+ * Philosophy:
14
+ * - Semantic interaction (buttons for actions, links for navigation)
15
+ * - Type enforcement (button types, link hrefs)
16
+ * - Accessibility (proper roles, keyboard support)
17
+ * - NO styling, NO classes (dress up later)
18
+ *
19
+ * Interactive Types:
20
+ * - <button>: Triggers an action (submit, reset, generic button)
21
+ * - <a>: Navigation/hyperlink (internal, external, anchor)
22
+ * - <details> + <summary>: Collapsible disclosure widget
23
+ *
24
+ * Accessibility:
25
+ * - Buttons have implicit role="button", keyboard accessible
26
+ * - Links have implicit role="link", keyboard accessible
27
+ * - Details/Summary native disclosure, keyboard accessible (Space/Enter)
28
+ *
29
+ * Dependencies:
30
+ * - utils/dom_utils.js (createElement, setAttributes)
31
+ *
32
+ * Exports:
33
+ * - createButton(type, attributes) → HTMLButtonElement
34
+ * - createLink(href, attributes) → HTMLAnchorElement
35
+ * - createDetails(attributes) → HTMLDetailsElement
36
+ * - createSummary(attributes) → HTMLElement
37
+ *
38
+ * Example:
39
+ * ```javascript
40
+ * import { createButton, createLink } from './interactive_primitives.js';
41
+ *
42
+ * const btn = createButton('button', { id: 'action-btn' });
43
+ * btn.textContent = 'Click Me';
44
+ * btn.onclick = () => console.log('Clicked!');
45
+ *
46
+ * const link = createLink('/about', { class: 'nav-link' });
47
+ * link.textContent = 'About';
48
+ * ```
49
+ */
50
+
51
+ // ─────────────────────────────────────────────────────────────────
52
+ // Imports
53
+ // ─────────────────────────────────────────────────────────────────
54
+
55
+ // Layer 2: Utilities
56
+ import { createElement, setAttributes } from '../../../zSys/dom/dom_utils.js';
57
+
58
+ //
59
+ // Button Element
60
+ //
61
+
62
+ /**
63
+ * Create a <button> element
64
+ *
65
+ * Used for triggering actions (submit forms, open modals, toggle state).
66
+ * Default type is "button" to prevent accidental form submissions.
67
+ *
68
+ * Button Types:
69
+ * - "button": Generic clickable button (default, safest)
70
+ * - "submit": Submits a form
71
+ * - "reset": Resets form inputs to defaults
72
+ *
73
+ * Best Practice:
74
+ * - Use <button> for actions (not <a> styled as button)
75
+ * - Always specify type="button" unless submitting a form
76
+ * - Add aria-label for icon-only buttons
77
+ * - Use disabled attribute (not aria-disabled) for true disabling
78
+ *
79
+ * @param {string} [type='button'] - Button type: 'button', 'submit', or 'reset'
80
+ * @param {Object} [attributes={}] - HTML attributes (id, class, disabled, aria-*, etc.)
81
+ * @returns {HTMLButtonElement} The created button element
82
+ *
83
+ * @example
84
+ * // Generic action button (safest default)
85
+ * const actionBtn = createButton('button', { id: 'save-btn' });
86
+ * actionBtn.textContent = 'Save';
87
+ *
88
+ * // Submit button for forms
89
+ * const submitBtn = createButton('submit', { form: 'login-form' });
90
+ * submitBtn.textContent = 'Log In';
91
+ *
92
+ * // Reset button
93
+ * const resetBtn = createButton('reset');
94
+ * resetBtn.textContent = 'Clear';
95
+ *
96
+ * // Icon-only button (needs aria-label)
97
+ * const iconBtn = createButton('button', { 'aria-label': 'Close dialog' });
98
+ *
99
+ * // Disabled button
100
+ * const disabledBtn = createButton('button', { disabled: true });
101
+ */
102
+ export function createButton(type = 'button', attributes = {}) {
103
+ const button = createElement('button');
104
+
105
+ // Validate button type (default to 'button' for safety)
106
+ const validTypes = ['button', 'submit', 'reset'];
107
+ const validType = validTypes.includes(type) ? type : 'button';
108
+
109
+ if (type && !validTypes.includes(type)) {
110
+ console.warn(`[interactive_primitives] createButton: Invalid type "${type}", defaulting to "button"`);
111
+ }
112
+
113
+ // Extract class attribute separately (needs special handling)
114
+ const { class: classString, ...otherAttributes } = attributes;
115
+
116
+ // Set type first, then other attributes
117
+ setAttributes(button, { type: validType, ...otherAttributes });
118
+
119
+ // Handle class separately using classList.add() to avoid overwriting
120
+ if (classString) {
121
+ const classes = classString.split(' ').filter(c => c.trim());
122
+ if (classes.length > 0) {
123
+ button.classList.add(...classes);
124
+ }
125
+ }
126
+
127
+ return button;
128
+ }
129
+
130
+ //
131
+ // Link/Anchor Element
132
+ //
133
+
134
+ /**
135
+ * Create an <a> (anchor/link) element
136
+ *
137
+ * Used for navigation and hyperlinks (pages, sections, external sites).
138
+ * IMPORTANT: href is REQUIRED for semantic correctness and accessibility.
139
+ *
140
+ * Link Types:
141
+ * - Internal: "/about", "/products/123" (same-origin navigation)
142
+ * - External: "https://example.com" (cross-origin navigation)
143
+ * - Anchor: "#section-id" (same-page jump)
144
+ * - JavaScript: "javascript:void(0)" (NOT RECOMMENDED - use button instead)
145
+ * - Download: href + download attribute
146
+ *
147
+ * Best Practice:
148
+ * - Use <a> for navigation (not <button> styled as link)
149
+ * - Always provide href (without href, it's not keyboard accessible)
150
+ * - Add target="_blank" + rel="noopener noreferrer" for external links
151
+ * - Use download attribute for file downloads
152
+ * - For actions (not navigation), use <button> instead
153
+ *
154
+ * @param {string} href - Link destination (URL, #anchor, or relative path)
155
+ * @param {Object} [attributes={}] - HTML attributes (target, rel, download, aria-*, etc.)
156
+ * @returns {HTMLAnchorElement} The created link element
157
+ *
158
+ * @example
159
+ * // Internal navigation
160
+ * const aboutLink = createLink('/about', { class: 'nav-link' });
161
+ * aboutLink.textContent = 'About Us';
162
+ *
163
+ * // External link (secure)
164
+ * const externalLink = createLink('https://example.com', {
165
+ * target: '_blank',
166
+ * rel: 'noopener noreferrer'
167
+ * });
168
+ * externalLink.textContent = 'Visit Example';
169
+ *
170
+ * // Anchor link (same-page jump)
171
+ * const anchorLink = createLink('#features', { 'aria-label': 'Jump to features' });
172
+ * anchorLink.textContent = 'See Features';
173
+ *
174
+ * // Download link
175
+ * const downloadLink = createLink('/files/report.pdf', { download: 'report.pdf' });
176
+ * downloadLink.textContent = 'Download Report';
177
+ *
178
+ * // Email link
179
+ * const emailLink = createLink('mailto:hello@example.com');
180
+ * emailLink.textContent = 'Contact Us';
181
+ */
182
+ export function createLink(href, attributes = {}) {
183
+ // Validate href (required for semantic link)
184
+ if (!href) {
185
+ console.warn('[interactive_primitives] createLink: href is required for semantic links, defaulting to "#"');
186
+ href = '#';
187
+ }
188
+
189
+ const link = createElement('a');
190
+
191
+ // Set href first, then merge with user attributes
192
+ setAttributes(link, { href, ...attributes });
193
+
194
+ return link;
195
+ }
196
+
197
+ //
198
+ // Disclosure Widget (Details + Summary)
199
+ //
200
+
201
+ /**
202
+ * Create a <details> element
203
+ *
204
+ * Native collapsible disclosure widget (accordion, FAQ, expandable section).
205
+ * Works without JavaScript, fully keyboard accessible (Space/Enter to toggle).
206
+ *
207
+ * Structure:
208
+ * - <details> is the container
209
+ * - First child must be <summary> (the clickable toggle)
210
+ * - Remaining children are the revealed content
211
+ *
212
+ * State:
213
+ * - Closed by default (add `open` attribute to start expanded)
214
+ * - Toggle event: 'toggle' fires on state change
215
+ *
216
+ * Best Practice:
217
+ * - First child MUST be <summary>
218
+ * - Use for progressive disclosure (FAQs, advanced options)
219
+ * - Listen to 'toggle' event for custom behavior
220
+ * - Can be styled with [open] selector
221
+ *
222
+ * @param {Object} [attributes={}] - HTML attributes (id, class, open, data-*, etc.)
223
+ * @returns {HTMLDetailsElement} The created details element
224
+ *
225
+ * @example
226
+ * // Collapsible FAQ item (closed by default)
227
+ * const faq = createDetails({ id: 'faq-1' });
228
+ * const question = createSummary();
229
+ * question.textContent = 'What is zCLI?';
230
+ * const answer = document.createElement('p');
231
+ * answer.textContent = 'zCLI is a command-line interface framework.';
232
+ * faq.appendChild(question);
233
+ * faq.appendChild(answer);
234
+ *
235
+ * // Expandable section (open by default)
236
+ * const section = createDetails({ open: true, class: 'expandable' });
237
+ *
238
+ * // With toggle event listener
239
+ * const details = createDetails({ 'data-section': 'advanced' });
240
+ * details.addEventListener('toggle', (e) => {
241
+ * console.log('Expanded:', e.target.open);
242
+ * });
243
+ */
244
+ export function createDetails(attributes = {}) {
245
+ const details = createElement('details');
246
+
247
+ if (Object.keys(attributes).length > 0) {
248
+ setAttributes(details, attributes);
249
+ }
250
+
251
+ return details;
252
+ }
253
+
254
+ /**
255
+ * Create a <summary> element
256
+ *
257
+ * The clickable heading/toggle for a <details> element.
258
+ * MUST be the first child of <details>.
259
+ * Acts as a button (keyboard accessible via Space/Enter).
260
+ *
261
+ * Behavior:
262
+ * - Clicking toggles the <details> parent
263
+ * - Has implicit disclosure triangle/marker (can be styled)
264
+ * - Can contain phrasing content (text, icons, etc.)
265
+ *
266
+ * Best Practice:
267
+ * - Must be first child of <details>
268
+ * - Keep concise (it's a heading/label)
269
+ * - Can style marker with ::marker pseudo-element
270
+ *
271
+ * @param {Object} [attributes={}] - HTML attributes (id, class, data-*, etc.)
272
+ * @returns {HTMLElement} The created summary element
273
+ *
274
+ * @example
275
+ * // Basic summary
276
+ * const summary = createSummary();
277
+ * summary.textContent = 'Click to expand';
278
+ *
279
+ * // Summary with icon
280
+ * const iconSummary = createSummary({ class: 'summary-with-icon' });
281
+ * iconSummary.innerHTML = '<i class="bi bi-chevron-down"></i> More Options';
282
+ *
283
+ * // Summary with data attribute
284
+ * const dataSummary = createSummary({ 'data-section-id': '5' });
285
+ */
286
+ export function createSummary(attributes = {}) {
287
+ const summary = createElement('summary');
288
+
289
+ if (Object.keys(attributes).length > 0) {
290
+ setAttributes(summary, attributes);
291
+ }
292
+
293
+ return summary;
294
+ }
295
+
296
+ //
297
+ // Default Export (for convenience)
298
+ //
299
+ export default {
300
+ createButton,
301
+ createLink,
302
+ createDetails,
303
+ createSummary
304
+ };
305
+