@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,292 @@
1
+ /**
2
+ * WidgetHookManager - Registers all default widget hooks
3
+ *
4
+ * Responsibilities:
5
+ * - Register onDisplay hook (auto-rendering)
6
+ * - Register onRenderChunk hook (progressive rendering)
7
+ * - Register onInput hook (input rendering)
8
+ * - Register onProgressBar/onProgressComplete hooks
9
+ * - Register onSpinnerStart/onSpinnerStop hooks
10
+ * - Register onSwiperInit/onSwiperUpdate/onSwiperComplete hooks
11
+ * - Register onZDash hook (dashboard rendering)
12
+ *
13
+ * Extracted from bifrost_client.js (Phase 3.4)
14
+ */
15
+
16
+ export class WidgetHookManager {
17
+ constructor(client) {
18
+ this.client = client;
19
+ this.logger = client.logger;
20
+ this.hooks = client.hooks;
21
+ }
22
+
23
+ /**
24
+ * Register all default widget hooks
25
+ */
26
+ async registerAllWidgetHooks() {
27
+ let count = 0;
28
+
29
+ await this.registerDisplayHook() && count++;
30
+ await this.registerRenderChunkHook() && count++;
31
+ await this.registerInputHook() && count++;
32
+ count += await this.registerProgressBarHooks();
33
+ count += await this.registerSpinnerHooks();
34
+ count += await this.registerSwiperHooks();
35
+ await this.registerDashboardHook() && count++;
36
+ await this.registerWizardGateResultHook() && count++;
37
+ await this.registerMenuHook() && count++;
38
+
39
+ this.logger.log(`[WidgetHookManager] Registered ${count} hooks`);
40
+ }
41
+
42
+ /**
43
+ * Register onDisplay hook for auto-rendering
44
+ */
45
+ async registerDisplayHook() {
46
+ if (!this.hooks.has('onDisplay')) {
47
+ this.hooks.register('onDisplay', async (event) => {
48
+ this.logger.debug('[WidgetHookManager] onDisplay triggered:', event.display_event || event.event);
49
+
50
+ // Check if this is a zDialog event (form)
51
+ if (event.event === 'zDialog' || event.display_event === 'zDialog') {
52
+ this.logger.debug('[WidgetHookManager] zDialog event - routing to FormRenderer');
53
+ this.logger.debug('[WidgetHookManager] Event structure:', event);
54
+ await this.client._ensureFormRenderer();
55
+
56
+ const formData = event.data || event;
57
+ this.logger.debug('[WidgetHookManager] FormData passed to renderer:', formData);
58
+ this.logger.debug('[WidgetHookManager] Has _dialogId?', formData._dialogId);
59
+ const formElement = this.client.formRenderer.renderForm(formData);
60
+
61
+ // Append form to appropriate container
62
+ const rootZone = document.getElementById(this.client.options.targetElement);
63
+ const containers = rootZone ? rootZone.querySelectorAll('.zContainer') : [];
64
+ const targetZone = containers.length > 0 ? containers[containers.length - 1] : rootZone;
65
+
66
+ if (targetZone) {
67
+ targetZone.appendChild(formElement);
68
+ }
69
+ } else {
70
+ // Regular zDisplay event - delegate to orchestrator
71
+ await this.client._ensureZDisplayOrchestrator();
72
+ await this.client.zDisplayOrchestrator.renderZDisplayEvent(event);
73
+ }
74
+ });
75
+ return true;
76
+ }
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * Register onRenderChunk hook for progressive rendering
82
+ */
83
+ async registerRenderChunkHook() {
84
+ if (!this.hooks.has('onRenderChunk')) {
85
+ this.hooks.register('onRenderChunk', async (message) => {
86
+ this.logger.debug('[WidgetHookManager] onRenderChunk triggered: chunk', message.chunk_num);
87
+
88
+ // CRITICAL: Render first, cache after
89
+ await this.client._renderChunkProgressive(message);
90
+ this.logger.debug('[WidgetHookManager] Chunk rendered, preparing to cache');
91
+
92
+ // _zScripts are pre-loaded at init (bifrost_client.js). Guard kept as
93
+ // fallback for edge cases where early load was skipped (e.g. config not yet ready).
94
+ if (!this.client._zScriptsLoaded && message.chunk_num === 1) {
95
+ this.logger.debug('[WidgetHookManager] First chunk rendered - loading _zScripts (fallback)');
96
+ this.client._loadZScripts();
97
+ this.client._zScriptsLoaded = true;
98
+ }
99
+
100
+ // Cache page after render (debounced)
101
+ // FIX: Ensure DOM updates are flushed before caching
102
+ if (this.client._cachePageTimeout) {
103
+ clearTimeout(this.client._cachePageTimeout);
104
+ }
105
+
106
+ this.client._cachePageTimeout = setTimeout(async () => {
107
+ // Wait for DOM updates to flush (requestAnimationFrame ensures rendering is complete)
108
+ await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
109
+
110
+ if (this.client.cache && typeof document !== 'undefined') {
111
+ try {
112
+ this.logger.debug('[Cache] DOM flushed, snapshotting page into trail');
113
+ await this.client._snapshotCurrentPage();
114
+ } catch (error) {
115
+ this.logger.error('[Cache] Error snapshotting page:', error);
116
+ }
117
+ }
118
+ }, 1000); // TIMEOUTS.DEBOUNCE_WIDGET (increased from 500ms for safer debouncing)
119
+ });
120
+ return true;
121
+ }
122
+ return false;
123
+ }
124
+
125
+ /**
126
+ * Register onInput hook for input rendering
127
+ */
128
+ async registerInputHook() {
129
+ if (!this.hooks.has('onInput')) {
130
+ this.hooks.register('onInput', async (inputRequest) => {
131
+ this.logger.debug('[WidgetHookManager] onInput triggered:', inputRequest.type);
132
+ const inputType = inputRequest.type || inputRequest.data?.type || 'string';
133
+
134
+ // Use InputRequestRenderer directly instead of ZDisplayRenderer
135
+ await this.client._ensureInputRequestRenderer();
136
+
137
+ if (inputType === 'selection') {
138
+ this.client.inputRequestRenderer.renderSelectionRequest(inputRequest);
139
+ } else if (inputType === 'button') {
140
+ this.client.inputRequestRenderer.renderButtonRequest(inputRequest);
141
+ } else {
142
+ this.client.inputRequestRenderer.renderInputRequest(inputRequest);
143
+ }
144
+ });
145
+ return true;
146
+ }
147
+ return false;
148
+ }
149
+
150
+ /**
151
+ * Register progress bar hooks
152
+ */
153
+ async registerProgressBarHooks() {
154
+ let count = 0;
155
+
156
+ if (!this.hooks.has('onProgressBar')) {
157
+ this.hooks.register('onProgressBar', async (event) => {
158
+ this.logger.debug('[WidgetHookManager] Progress bar update');
159
+ await this.client._ensureProgressBarRenderer();
160
+ this.client.progressBarRenderer.render(event);
161
+ });
162
+ count++;
163
+ }
164
+
165
+ if (!this.hooks.has('onProgressComplete')) {
166
+ this.hooks.register('onProgressComplete', async (event) => {
167
+ this.logger.debug('[WidgetHookManager] Progress complete');
168
+ await this.client._ensureProgressBarRenderer();
169
+ this.client.progressBarRenderer.complete(event);
170
+ });
171
+ count++;
172
+ }
173
+
174
+ return count;
175
+ }
176
+
177
+ /**
178
+ * Register spinner hooks
179
+ */
180
+ async registerSpinnerHooks() {
181
+ let count = 0;
182
+
183
+ if (!this.hooks.has('onSpinnerStart')) {
184
+ this.hooks.register('onSpinnerStart', async (event) => {
185
+ this.logger.debug('[WidgetHookManager] Spinner start');
186
+ await this.client._ensureSpinnerRenderer();
187
+ this.client.spinnerRenderer.start(event);
188
+ });
189
+ count++;
190
+ }
191
+
192
+ if (!this.hooks.has('onSpinnerStop')) {
193
+ this.hooks.register('onSpinnerStop', async (event) => {
194
+ this.logger.debug('[WidgetHookManager] Spinner stop');
195
+ await this.client._ensureSpinnerRenderer();
196
+ this.client.spinnerRenderer.stop(event);
197
+ });
198
+ count++;
199
+ }
200
+
201
+ return count;
202
+ }
203
+
204
+ /**
205
+ * Register swiper hooks
206
+ */
207
+ async registerSwiperHooks() {
208
+ let count = 0;
209
+
210
+ if (!this.hooks.has('onSwiperInit')) {
211
+ this.hooks.register('onSwiperInit', async (event) => {
212
+ this.logger.debug('[WidgetHookManager] Swiper init');
213
+ await this.client._ensureSwiperRenderer();
214
+ this.client.swiperRenderer.init(event);
215
+ });
216
+ count++;
217
+ }
218
+
219
+ if (!this.hooks.has('onSwiperUpdate')) {
220
+ this.hooks.register('onSwiperUpdate', async (event) => {
221
+ this.logger.debug('[WidgetHookManager] Swiper update');
222
+ await this.client._ensureSwiperRenderer();
223
+ this.client.swiperRenderer.update(event);
224
+ });
225
+ count++;
226
+ }
227
+
228
+ if (!this.hooks.has('onSwiperComplete')) {
229
+ this.hooks.register('onSwiperComplete', async (event) => {
230
+ this.logger.debug('[WidgetHookManager] Swiper complete');
231
+ await this.client._ensureSwiperRenderer();
232
+ this.client.swiperRenderer.complete(event);
233
+ });
234
+ count++;
235
+ }
236
+
237
+ return count;
238
+ }
239
+
240
+ /**
241
+ * Register dashboard hook
242
+ */
243
+ async registerDashboardHook() {
244
+ if (!this.hooks.has('onZDash')) {
245
+ this.hooks.register('onZDash', async (dashConfig) => {
246
+ this.logger.debug('[WidgetHookManager] onZDash triggered');
247
+ await this.client._ensureDashboardRenderer();
248
+ await this.client.dashboardRenderer.render(dashConfig, this.client._zVaFElement);
249
+ });
250
+ return true;
251
+ }
252
+ return false;
253
+ }
254
+
255
+ /**
256
+ * Register wizard gate result hook
257
+ */
258
+ async registerWizardGateResultHook() {
259
+ if (!this.hooks.has('onWizardGateResult')) {
260
+ this.hooks.register('onWizardGateResult', async (message) => {
261
+ this.logger.debug('[WidgetHookManager] onWizardGateResult triggered for gate:', message.gateKey);
262
+ await this.client._ensureZDisplayOrchestrator();
263
+ await this.client.zDisplayOrchestrator.handleWizardGateResult(message);
264
+ });
265
+ return true;
266
+ }
267
+ return false;
268
+ }
269
+
270
+ /**
271
+ * Register onMenu hook — default for all zBifrost apps
272
+ */
273
+ async registerMenuHook() {
274
+ if (!this.hooks.has('onMenu')) {
275
+ this.hooks.register('onMenu', async (message) => {
276
+ this.logger.debug('[WidgetHookManager] onMenu triggered');
277
+ await this.client._ensureMenuRenderer();
278
+ // New zMenu primitive: flat options array, no menu_key
279
+ if (Array.isArray(message.options) && !message.menu_key) {
280
+ this.client.menuRenderer.renderZMenu(message);
281
+ } else {
282
+ this.client.menuRenderer.renderMenu(message);
283
+ }
284
+ });
285
+ return true;
286
+ }
287
+ return false;
288
+ }
289
+ }
290
+
291
+ export default WidgetHookManager;
292
+
@@ -0,0 +1,8 @@
1
+ /**
2
+ * L2_Handling/message - Message Routing & Processing
3
+ *
4
+ * WebSocket message routing, event type detection, error handling.
5
+ * Depends on: L1_Foundation (Logger, Constants)
6
+ */
7
+
8
+ export { MessageHandler } from './message_handler.js';