@xuda.io/xuda-worker-bundle 1.3.2692 → 1.3.2694

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 (2) hide show
  1. package/index.js +539 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -610,6 +610,147 @@ func.runtime.workers.delete_promise = function (SESSION_ID, worker_id, promise_q
610
610
  delete registry_entry.promise_queue[promise_queue_id];
611
611
  return true;
612
612
  };
613
+ func.runtime.render.clone_runtime_options = function (value) {
614
+ if (typeof structuredClone === 'function') {
615
+ try {
616
+ return structuredClone(value);
617
+ } catch (_) {}
618
+ }
619
+
620
+ if (Array.isArray(value)) {
621
+ return value.map(function (item) {
622
+ return func.runtime.render.clone_runtime_options(item);
623
+ });
624
+ }
625
+
626
+ if (value && typeof value === 'object') {
627
+ const cloned = {};
628
+ const keys = Object.keys(value);
629
+ for (let index = 0; index < keys.length; index++) {
630
+ const key = keys[index];
631
+ cloned[key] = func.runtime.render.clone_runtime_options(value[key]);
632
+ }
633
+ return cloned;
634
+ }
635
+
636
+ return value;
637
+ };
638
+ func.runtime.render.normalize_runtime_bootstrap = function (raw_options = {}) {
639
+ const options = raw_options || {};
640
+ let app_computing_mode = options.app_computing_mode || '';
641
+ let app_render_mode = options.app_render_mode || '';
642
+ let app_client_activation = options.app_client_activation || '';
643
+ let ssr_payload = options.ssr_payload || null;
644
+
645
+ if (typeof ssr_payload === 'string') {
646
+ try {
647
+ ssr_payload = JSON.parse(ssr_payload);
648
+ } catch (_) {
649
+ ssr_payload = null;
650
+ }
651
+ }
652
+
653
+ if (ssr_payload && typeof ssr_payload === 'object') {
654
+ ssr_payload = func.runtime.render.clone_runtime_options(ssr_payload);
655
+ }
656
+
657
+ if (!app_computing_mode) {
658
+ if (app_render_mode === 'ssr_first_page' || app_render_mode === 'ssr_full') {
659
+ app_computing_mode = 'server';
660
+ } else {
661
+ app_computing_mode = 'main';
662
+ }
663
+ }
664
+
665
+ switch (app_computing_mode) {
666
+ case 'main':
667
+ app_render_mode = 'csr';
668
+ app_client_activation = 'none';
669
+ break;
670
+
671
+ case 'worker':
672
+ app_render_mode = 'csr';
673
+ app_client_activation = 'none';
674
+ break;
675
+
676
+ default:
677
+ app_computing_mode = 'server';
678
+ if (app_render_mode !== 'ssr_full') {
679
+ app_render_mode = 'ssr_first_page';
680
+ }
681
+ app_client_activation = app_render_mode === 'ssr_full' ? 'hydrate' : 'takeover';
682
+ break;
683
+ }
684
+
685
+ if (ssr_payload && typeof ssr_payload === 'object') {
686
+ if (!ssr_payload.app_render_mode) {
687
+ ssr_payload.app_render_mode = app_render_mode;
688
+ }
689
+ if (!ssr_payload.app_client_activation) {
690
+ ssr_payload.app_client_activation = app_client_activation;
691
+ }
692
+ if (!ssr_payload.app_computing_mode) {
693
+ ssr_payload.app_computing_mode = app_computing_mode;
694
+ }
695
+ }
696
+
697
+ return {
698
+ app_computing_mode,
699
+ app_render_mode,
700
+ app_client_activation,
701
+ ssr_payload,
702
+ };
703
+ };
704
+ func.runtime.render.apply_runtime_bootstrap_defaults = function (target = {}) {
705
+ const normalized = func.runtime.render.normalize_runtime_bootstrap(target);
706
+ target.app_computing_mode = normalized.app_computing_mode;
707
+ target.app_render_mode = normalized.app_render_mode;
708
+ target.app_client_activation = normalized.app_client_activation;
709
+ target.ssr_payload = normalized.ssr_payload;
710
+ return normalized;
711
+ };
712
+ func.runtime.render.is_server_render_mode = function (target = {}) {
713
+ const normalized = func.runtime.render.normalize_runtime_bootstrap(target?.opt || target);
714
+ return normalized.app_computing_mode === 'server' && normalized.app_render_mode !== 'csr';
715
+ };
716
+ func.runtime.render.is_takeover_mode = function (target = {}) {
717
+ const normalized = func.runtime.render.normalize_runtime_bootstrap(target?.opt || target);
718
+ return normalized.app_client_activation === 'takeover';
719
+ };
720
+ func.runtime.render.is_hydration_mode = function (target = {}) {
721
+ const normalized = func.runtime.render.normalize_runtime_bootstrap(target?.opt || target);
722
+ return normalized.app_client_activation === 'hydrate';
723
+ };
724
+ func.runtime.render.get_ssr_payload = function (target = {}) {
725
+ if (target?.opt?.ssr_payload) {
726
+ return target.opt.ssr_payload;
727
+ }
728
+ if (target?.ssr_payload) {
729
+ return target.ssr_payload;
730
+ }
731
+ const win = func.runtime.platform.get_window();
732
+ return win?.__XUDA_SSR__ || null;
733
+ };
734
+ func.runtime.render.should_use_ssr_payload = function (SESSION_ID, paramsP) {
735
+ const session = SESSION_OBJ?.[SESSION_ID];
736
+ const payload = func.runtime.render.get_ssr_payload(session);
737
+ if (!payload || payload._consumed) {
738
+ return false;
739
+ }
740
+ if (paramsP?.prog_id && payload.prog_id && payload.prog_id !== paramsP.prog_id) {
741
+ return false;
742
+ }
743
+ return true;
744
+ };
745
+ func.runtime.render.mark_ssr_payload_consumed = function (SESSION_ID) {
746
+ const session = SESSION_OBJ?.[SESSION_ID];
747
+ const payload = func.runtime.render.get_ssr_payload(session);
748
+ if (!payload || typeof payload !== 'object') {
749
+ return false;
750
+ }
751
+ payload._consumed = true;
752
+ return true;
753
+ };
613
754
  func.runtime.render.get_root_data_system = function (SESSION_ID) {
614
755
  return SESSION_OBJ[SESSION_ID]?.DS_GLB?.[0]?.data_system || null;
615
756
  };
@@ -2450,10 +2591,19 @@ func.runtime.render.get_tree_node_id = function (nodeP, pathP) {
2450
2591
  };
2451
2592
  func.runtime.render.get_tree_controls = function (attributes) {
2452
2593
  const attrs = attributes || {};
2594
+ const get_first_defined = function (keys) {
2595
+ for (let index = 0; index < keys.length; index++) {
2596
+ const key = keys[index];
2597
+ if (Object.prototype.hasOwnProperty.call(attrs, key)) {
2598
+ return attrs[key];
2599
+ }
2600
+ }
2601
+ return null;
2602
+ };
2453
2603
  return {
2454
- xu_for: attrs['xu-for'] || attrs['xu-exp:xu-for'] || null,
2455
- xu_if: attrs['xu-if'] || attrs['xu-exp:xu-if'] || null,
2456
- xu_render: attrs['xu-render'] || attrs['xu-exp:xu-render'] || null,
2604
+ xu_for: get_first_defined(['xu-for', 'xu-exp:xu-for']),
2605
+ xu_if: get_first_defined(['xu-if', 'xu-exp:xu-if']),
2606
+ xu_render: get_first_defined(['xu-render', 'xu-exp:xu-render']),
2457
2607
  };
2458
2608
  };
2459
2609
  func.runtime.render.get_tree_node_capabilities = async function (options) {
@@ -2642,6 +2792,392 @@ func.runtime.render.sanitize_tree_for_debug = function (treeP) {
2642
2792
  };
2643
2793
  func.runtime.render.serialize_tree = function (treeP, spacing = 2) {
2644
2794
  return JSON.stringify(func.runtime.render.sanitize_tree_for_debug(treeP), null, spacing);
2795
+ };
2796
+ func.runtime = func.runtime || {};
2797
+ func.runtime.ui = func.runtime.ui || {};
2798
+ func.runtime.render = func.runtime.render || {};
2799
+ func.runtime.widgets = func.runtime.widgets || {};
2800
+
2801
+ // Shared string-renderer helpers live here so headless/server runtimes can materialize the render tree without a DOM.
2802
+
2803
+ func.runtime.render.HTML_VOID_TAGS = func.runtime.render.HTML_VOID_TAGS || {
2804
+ area: true,
2805
+ base: true,
2806
+ br: true,
2807
+ col: true,
2808
+ embed: true,
2809
+ hr: true,
2810
+ img: true,
2811
+ input: true,
2812
+ link: true,
2813
+ meta: true,
2814
+ param: true,
2815
+ source: true,
2816
+ track: true,
2817
+ wbr: true,
2818
+ };
2819
+ func.runtime.render.escape_html = function (value) {
2820
+ return `${value ?? ''}`
2821
+ .replaceAll('&', '&amp;')
2822
+ .replaceAll('<', '&lt;')
2823
+ .replaceAll('>', '&gt;')
2824
+ .replaceAll('"', '&quot;')
2825
+ .replaceAll("'", '&#039;');
2826
+ };
2827
+ func.runtime.render.escape_html_attribute = function (value) {
2828
+ return func.runtime.render.escape_html(value);
2829
+ };
2830
+ func.runtime.render.is_html_void_tag = function (tag_name) {
2831
+ return !!func.runtime.render.HTML_VOID_TAGS[(tag_name || '').toLowerCase()];
2832
+ };
2833
+ func.runtime.render.is_falsey_render_value = function (value) {
2834
+ if (value === false || value === null || typeof value === 'undefined') {
2835
+ return true;
2836
+ }
2837
+ if (typeof value === 'number') {
2838
+ return value === 0;
2839
+ }
2840
+ if (typeof value === 'string') {
2841
+ const normalized = value.trim().toLowerCase();
2842
+ return normalized === '' || normalized === 'false' || normalized === '0' || normalized === 'null' || normalized === 'undefined' || normalized === 'off' || normalized === 'no';
2843
+ }
2844
+ return false;
2845
+ };
2846
+ func.runtime.render.should_render_tree_node = function (treeP) {
2847
+ const controls = treeP?.meta?.controls || {};
2848
+ if (controls.xu_if !== null && controls.xu_if !== undefined && func.runtime.render.is_falsey_render_value(controls.xu_if)) {
2849
+ return false;
2850
+ }
2851
+ if (controls.xu_render !== null && controls.xu_render !== undefined && func.runtime.render.is_falsey_render_value(controls.xu_render)) {
2852
+ return false;
2853
+ }
2854
+ return true;
2855
+ };
2856
+ func.runtime.render.is_tree_control_attribute = function (key) {
2857
+ if (!key) {
2858
+ return false;
2859
+ }
2860
+ return (
2861
+ key.startsWith('xu-exp:') ||
2862
+ key === 'xu-widget' ||
2863
+ key === 'xu-method' ||
2864
+ key === 'xu-for' ||
2865
+ key === 'xu-for-key' ||
2866
+ key === 'xu-for-val' ||
2867
+ key === 'xu-if' ||
2868
+ key === 'xu-render' ||
2869
+ key === 'xu-bind' ||
2870
+ key === 'xu-content' ||
2871
+ key === 'xu-text' ||
2872
+ key === 'xu-html' ||
2873
+ key === 'xu-show' ||
2874
+ key === 'xu-panel-program' ||
2875
+ key === 'xu-teleport'
2876
+ );
2877
+ };
2878
+ func.runtime.render.get_string_renderer_tag_name = function (treeP) {
2879
+ switch (treeP?.kind) {
2880
+ case 'widget':
2881
+ case 'single_view':
2882
+ case 'multi_view':
2883
+ case 'panel':
2884
+ case 'teleport':
2885
+ return 'div';
2886
+ case 'placeholder':
2887
+ return null;
2888
+ case 'text':
2889
+ return null;
2890
+ default:
2891
+ return treeP?.tagName || 'div';
2892
+ }
2893
+ };
2894
+ func.runtime.render.get_tree_terminal_content = function (treeP) {
2895
+ const attributes = treeP?.attributes || {};
2896
+ if (typeof attributes['xu-html'] !== 'undefined' && attributes['xu-html'] !== null) {
2897
+ return {
2898
+ value: `${attributes['xu-html']}`,
2899
+ mode: 'html',
2900
+ };
2901
+ }
2902
+ if (typeof attributes['xu-content'] !== 'undefined' && attributes['xu-content'] !== null) {
2903
+ return {
2904
+ value: `${attributes['xu-content']}`,
2905
+ mode: 'html',
2906
+ };
2907
+ }
2908
+ if (typeof attributes['xu-text'] !== 'undefined' && attributes['xu-text'] !== null) {
2909
+ return {
2910
+ value: `${attributes['xu-text']}`,
2911
+ mode: 'text',
2912
+ };
2913
+ }
2914
+ if (treeP?.kind === 'text') {
2915
+ return {
2916
+ value: typeof treeP?.text !== 'undefined' && treeP?.text !== null ? `${treeP.text}` : `${treeP?.content || ''}`,
2917
+ mode: 'text',
2918
+ };
2919
+ }
2920
+ return null;
2921
+ };
2922
+ func.runtime.render.render_tree_terminal_content = function (treeP) {
2923
+ const terminal = func.runtime.render.get_tree_terminal_content(treeP);
2924
+ if (!terminal) {
2925
+ return null;
2926
+ }
2927
+ if (terminal.mode === 'html') {
2928
+ return terminal.value;
2929
+ }
2930
+ return func.runtime.render.escape_html(terminal.value);
2931
+ };
2932
+ func.runtime.render.get_widget_fallback_markup = function (treeP) {
2933
+ const widget_meta = treeP?.meta?.widget || {};
2934
+ const capability_state = widget_meta?.capabilities?.headless ? 'headless-capable' : 'browser-only';
2935
+ return `<!--xuda-widget:${func.runtime.render.escape_html(widget_meta.plugin_name || 'unknown')}:${capability_state}-->`;
2936
+ };
2937
+ func.runtime.render.get_tree_string_attributes = function (treeP, renderer_context) {
2938
+ const attributes = func.runtime.render.safe_clone_tree_value(treeP?.attributes || {});
2939
+ const attr_pairs = [];
2940
+ const keys = Object.keys(attributes);
2941
+
2942
+ for (let index = 0; index < keys.length; index++) {
2943
+ const key = keys[index];
2944
+ if (func.runtime.render.is_tree_control_attribute(key)) {
2945
+ continue;
2946
+ }
2947
+ const value = attributes[key];
2948
+ if (value === false || value === null || typeof value === 'undefined') {
2949
+ continue;
2950
+ }
2951
+ if (value === true) {
2952
+ attr_pairs.push(key);
2953
+ continue;
2954
+ }
2955
+ const normalized_value = typeof value === 'object' ? JSON.stringify(value) : `${value}`;
2956
+ attr_pairs.push(`${key}="${func.runtime.render.escape_html_attribute(normalized_value)}"`);
2957
+ }
2958
+
2959
+ attr_pairs.push(`data-xuda-kind="${func.runtime.render.escape_html_attribute(treeP?.kind || 'element')}"`);
2960
+ attr_pairs.push(`data-xuda-node-id="${func.runtime.render.escape_html_attribute(treeP?.id || treeP?.meta?.source_node_id || '')}"`);
2961
+ attr_pairs.push(`data-xuda-tree-id="${func.runtime.render.escape_html_attribute(treeP?.meta?.tree_id || '')}"`);
2962
+
2963
+ if (treeP?.kind === 'widget' && treeP?.meta?.widget) {
2964
+ attr_pairs.push(`data-xuda-widget="${func.runtime.render.escape_html_attribute(treeP.meta.widget.plugin_name || '')}"`);
2965
+ attr_pairs.push(`data-xuda-widget-method="${func.runtime.render.escape_html_attribute(treeP.meta.widget.method || '_default')}"`);
2966
+ attr_pairs.push(`data-xuda-widget-capability="${func.runtime.render.escape_html_attribute(treeP.meta.widget.capabilities?.headless ? 'headless' : 'browser')}"`);
2967
+ }
2968
+
2969
+ if (treeP?.kind === 'teleport' && treeP?.attributes?.['xu-teleport']) {
2970
+ attr_pairs.push(`data-xuda-teleport-target="${func.runtime.render.escape_html_attribute(treeP.attributes['xu-teleport'])}"`);
2971
+ }
2972
+
2973
+ if ((treeP?.meta?.controls?.xu_for !== null && treeP?.meta?.controls?.xu_for !== undefined) && !renderer_context?.strip_iteration_markers) {
2974
+ attr_pairs.push('data-xuda-xu-for="pending"');
2975
+ }
2976
+
2977
+ return attr_pairs.length ? ' ' + attr_pairs.join(' ') : '';
2978
+ };
2979
+ func.runtime.render.render_tree_children_to_string = async function (treeP, renderer_context) {
2980
+ if (!Array.isArray(treeP?.children) || !treeP.children.length) {
2981
+ return '';
2982
+ }
2983
+ let html = '';
2984
+ for (let index = 0; index < treeP.children.length; index++) {
2985
+ html += await func.runtime.render.render_tree_to_string(treeP.children[index], {
2986
+ ...renderer_context,
2987
+ parent_tree: treeP,
2988
+ });
2989
+ }
2990
+ return html;
2991
+ };
2992
+ func.runtime.render.render_tree_to_string = async function (treeP, renderer_context = {}) {
2993
+ if (!treeP) {
2994
+ return '';
2995
+ }
2996
+ if (Array.isArray(treeP)) {
2997
+ let html = '';
2998
+ for (let index = 0; index < treeP.length; index++) {
2999
+ html += await func.runtime.render.render_tree_to_string(treeP[index], renderer_context);
3000
+ }
3001
+ return html;
3002
+ }
3003
+
3004
+ const ensured_tree = await func.runtime.render.ensure_tree_node({
3005
+ SESSION_ID: renderer_context?.SESSION_ID,
3006
+ nodeP: treeP,
3007
+ paramsP: renderer_context?.paramsP,
3008
+ parent_infoP: renderer_context?.parent_infoP,
3009
+ keyP: renderer_context?.keyP,
3010
+ parent_nodeP: renderer_context?.parent_nodeP,
3011
+ });
3012
+
3013
+ if (!ensured_tree || !func.runtime.render.should_render_tree_node(ensured_tree)) {
3014
+ return '';
3015
+ }
3016
+
3017
+ if (ensured_tree.kind === 'placeholder') {
3018
+ if (renderer_context?.include_placeholders) {
3019
+ return `<!--xuda-placeholder:${func.runtime.render.escape_html(ensured_tree.id || '')}-->`;
3020
+ }
3021
+ return '';
3022
+ }
3023
+
3024
+ if (ensured_tree.kind === 'text') {
3025
+ return func.runtime.render.render_tree_terminal_content(ensured_tree) || '';
3026
+ }
3027
+
3028
+ const tag_name = func.runtime.render.get_string_renderer_tag_name(ensured_tree);
3029
+ if (!tag_name || tag_name.toLowerCase() === 'script') {
3030
+ return '';
3031
+ }
3032
+
3033
+ const attributes = func.runtime.render.get_tree_string_attributes(ensured_tree, renderer_context);
3034
+ const terminal_content = func.runtime.render.render_tree_terminal_content(ensured_tree);
3035
+ let children_html = terminal_content !== null ? terminal_content : await func.runtime.render.render_tree_children_to_string(ensured_tree, renderer_context);
3036
+
3037
+ if (ensured_tree.kind === 'widget' && !children_html) {
3038
+ children_html = func.runtime.render.get_widget_fallback_markup(ensured_tree);
3039
+ }
3040
+
3041
+ if (func.runtime.render.is_html_void_tag(tag_name)) {
3042
+ return `<${tag_name}${attributes}>`;
3043
+ }
3044
+
3045
+ return `<${tag_name}${attributes}>${children_html}</${tag_name}>`;
3046
+ };
3047
+ func.runtime.render.render_to_string = async function (options = {}) {
3048
+ const treeP = await func.runtime.render.ensure_tree_node({
3049
+ SESSION_ID: options.SESSION_ID,
3050
+ nodeP: options.treeP || options.nodeP,
3051
+ paramsP: options.paramsP,
3052
+ parent_infoP: options.parent_infoP,
3053
+ keyP: options.keyP,
3054
+ parent_nodeP: options.parent_nodeP,
3055
+ });
3056
+
3057
+ return await func.runtime.render.render_tree_to_string(treeP, options);
3058
+ };
3059
+ func.runtime.render.get_server_render_mode = function (options = {}) {
3060
+ const normalized = func.runtime.render.normalize_runtime_bootstrap({
3061
+ app_computing_mode: options.app_computing_mode,
3062
+ app_render_mode: options.app_render_mode,
3063
+ app_client_activation: options.app_client_activation,
3064
+ });
3065
+
3066
+ return normalized;
3067
+ };
3068
+ func.runtime.render.build_server_render_params = async function (options = {}) {
3069
+ const SESSION_ID = options.SESSION_ID;
3070
+ const prog_id = options.prog_id;
3071
+ const dsSessionP = options.dsSessionP;
3072
+ const _session = SESSION_OBJ?.[SESSION_ID] || {};
3073
+ const _ds = _session?.DS_GLB?.[dsSessionP] || {};
3074
+ const viewDoc = options.viewDoc || (await func.utils?.VIEWS_OBJ?.get?.(SESSION_ID, prog_id));
3075
+
3076
+ if (!viewDoc?.properties) {
3077
+ throw new Error(`view document not found for ${prog_id}`);
3078
+ }
3079
+
3080
+ const base_params = _ds?.screen_params ? func.runtime.render.safe_clone_tree_value(_ds.screen_params) : {};
3081
+ const screenId = options.screenId || base_params.screenId || `ssr_${prog_id}_${dsSessionP || '0'}`;
3082
+ const paramsP = {
3083
+ ...base_params,
3084
+ prog_id,
3085
+ sourceScreenP: null,
3086
+ $callingContainerP: null,
3087
+ triggerIdP: null,
3088
+ callingDataSource_objP: _ds,
3089
+ rowIdP: typeof options.rowIdP !== 'undefined' ? options.rowIdP : (_ds?.currentRecordId || null),
3090
+ renderType: viewDoc.properties?.renderType,
3091
+ parameters_obj_inP: options.parameters_obj_inP || base_params.parameters_obj_inP || options.parameters_raw_obj || {},
3092
+ source_functionP: options.source_functionP || base_params.source_functionP || 'render_string',
3093
+ is_panelP: false,
3094
+ screen_type: options.screen_type || base_params.screen_type || 'render_string',
3095
+ screenInfo: viewDoc,
3096
+ call_screen_propertiesP: base_params.call_screen_propertiesP,
3097
+ parentDataSourceNoP: typeof _ds?.parentDataSourceNo === 'undefined' || _ds?.parentDataSourceNo === null ? 0 : _ds.parentDataSourceNo,
3098
+ parameters_raw_obj: options.parameters_raw_obj || base_params.parameters_raw_obj || {},
3099
+ dsSessionP,
3100
+ screenId,
3101
+ containerIdP: base_params.containerIdP || `ssr_container_${screenId}`,
3102
+ };
3103
+
3104
+ if (_ds) {
3105
+ _ds.screen_params = paramsP;
3106
+ }
3107
+
3108
+ return paramsP;
3109
+ };
3110
+ func.runtime.render.build_prog_tree = async function (options = {}) {
3111
+ const SESSION_ID = options.SESSION_ID;
3112
+ const prog_id = options.prog_id;
3113
+ const viewDoc = options.viewDoc || (await func.utils?.VIEWS_OBJ?.get?.(SESSION_ID, prog_id));
3114
+
3115
+ if (!viewDoc?.progUi?.length) {
3116
+ throw new Error(`progUi not found for ${prog_id}`);
3117
+ }
3118
+
3119
+ const paramsP = options.paramsP || (await func.runtime.render.build_server_render_params({
3120
+ ...options,
3121
+ SESSION_ID,
3122
+ prog_id,
3123
+ viewDoc,
3124
+ }));
3125
+ const root_index = typeof options.root_index === 'number' ? options.root_index : 0;
3126
+ const root_node = func.runtime.render.safe_clone_tree_value(viewDoc.progUi[root_index]);
3127
+ const tree = await func.runtime.render.build_tree({
3128
+ SESSION_ID,
3129
+ nodeP: root_node,
3130
+ paramsP,
3131
+ });
3132
+
3133
+ return {
3134
+ tree,
3135
+ paramsP,
3136
+ viewDoc,
3137
+ };
3138
+ };
3139
+ func.runtime.render.build_ssr_payload = function (render_program, options = {}) {
3140
+ const runtime_profile = func.runtime.render.get_server_render_mode(options);
3141
+ return {
3142
+ contract: 'xuda.ssr.v1',
3143
+ prog_id: options.prog_id,
3144
+ screenId: render_program.paramsP.screenId,
3145
+ containerId: render_program.paramsP.containerIdP,
3146
+ app_computing_mode: runtime_profile.app_computing_mode,
3147
+ app_render_mode: runtime_profile.app_render_mode,
3148
+ app_client_activation: runtime_profile.app_client_activation,
3149
+ tree_contract: func.runtime.render.TREE_CONTRACT_VERSION,
3150
+ };
3151
+ };
3152
+ func.runtime.render.build_ssr_screen_html = function (html, render_program, options = {}) {
3153
+ const payload = func.runtime.render.build_ssr_payload(render_program, options);
3154
+ const screenId = func.runtime.render.escape_html_attribute(payload.screenId || '');
3155
+ const containerId = func.runtime.render.escape_html_attribute(payload.containerId || '');
3156
+ const activation = func.runtime.render.escape_html_attribute(payload.app_client_activation || 'takeover');
3157
+
3158
+ return `<div data-xuda-ssr-embed="true" class="xu_embed_div"><div id="${screenId}" class="xu_embed_container" data-xuda-ssr-screen="true" data-xuda-ssr-screen-id="${screenId}" data-xuda-activation="${activation}" style="display: contents;"><div id="${containerId}" data-xuda-ssr-root-frame="true" data-xuda-ssr-screen-id="${screenId}" data-xuda-activation="${activation}" style="display: contents;">${html}</div></div></div>`;
3159
+ };
3160
+ func.runtime.render.render_prog_to_string = async function (options = {}) {
3161
+ const render_program = await func.runtime.render.build_prog_tree(options);
3162
+ const html = await func.runtime.render.render_to_string({
3163
+ ...options,
3164
+ SESSION_ID: options.SESSION_ID,
3165
+ treeP: render_program.tree,
3166
+ paramsP: render_program.paramsP,
3167
+ });
3168
+ const ssr_payload = func.runtime.render.build_ssr_payload(render_program, options);
3169
+ const screen_html = func.runtime.render.build_ssr_screen_html(html, render_program, options);
3170
+
3171
+ return {
3172
+ prog_id: options.prog_id,
3173
+ dsSessionP: render_program.paramsP.dsSessionP,
3174
+ screenId: render_program.paramsP.screenId,
3175
+ html,
3176
+ screen_html,
3177
+ tree_json: func.runtime.render.serialize_tree(render_program.tree),
3178
+ paramsP: render_program.paramsP,
3179
+ ssr_payload,
3180
+ };
2645
3181
  };
2646
3182
  glb.DEBUG_INFO_OBJ = {};
2647
3183
  // var CONNECTION_ATTEMPTS = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle",
3
- "version": "1.3.2692",
3
+ "version": "1.3.2694",
4
4
  "description": "xuda framework",
5
5
  "main": "index.js",
6
6
  "scripts": {