@xuda.io/runtime-bundle 1.0.1437 → 1.0.1439
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/js/xuda-runtime-bundle.js +209 -15
- package/js/xuda-runtime-bundle.min.js +2 -2
- package/js/xuda-runtime-mini-bundle.js +10 -2
- package/js/xuda-runtime-mini-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +209 -15
- package/js/xuda-runtime-slim.min.es.js +205 -28
- package/js/xuda-runtime-slim.min.js +2 -2
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +132 -2
- package/js/xuda-worker-bundle.js +132 -2
- package/js/xuda-worker-bundle.min.js +1 -1
- package/js/xuda_common-bundle.js +122 -0
- package/js/xuda_common-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -23837,6 +23837,128 @@ func.runtime.platform.set_cursor = function (element, cursor) {
|
|
|
23837
23837
|
node.style.cursor = cursor;
|
|
23838
23838
|
}
|
|
23839
23839
|
};
|
|
23840
|
+
func.runtime.program.normalize_doc_for_runtime = function (doc) {
|
|
23841
|
+
if (!doc || doc.__xudaRuntimeNormalized || !Array.isArray(doc.progUi) || !doc.progUi.length) {
|
|
23842
|
+
return doc;
|
|
23843
|
+
}
|
|
23844
|
+
|
|
23845
|
+
const normalize_tag_name = function (tag_name) {
|
|
23846
|
+
return `${tag_name || ''}`.trim().toLowerCase();
|
|
23847
|
+
};
|
|
23848
|
+
const merge_attributes = function (target, source) {
|
|
23849
|
+
const merged = { ...(target || {}) };
|
|
23850
|
+
const source_attributes = source || {};
|
|
23851
|
+
const keys = Object.keys(source_attributes);
|
|
23852
|
+
|
|
23853
|
+
for (let index = 0; index < keys.length; index++) {
|
|
23854
|
+
const key = keys[index];
|
|
23855
|
+
const value = source_attributes[key];
|
|
23856
|
+
if (typeof value === 'undefined') {
|
|
23857
|
+
continue;
|
|
23858
|
+
}
|
|
23859
|
+
|
|
23860
|
+
if (key === 'class' && merged.class && value) {
|
|
23861
|
+
const next_value = `${merged.class} ${value}`.trim();
|
|
23862
|
+
merged.class = Array.from(new Set(next_value.split(/\s+/).filter(Boolean))).join(' ');
|
|
23863
|
+
continue;
|
|
23864
|
+
}
|
|
23865
|
+
|
|
23866
|
+
if (key === 'style' && merged.style && value) {
|
|
23867
|
+
merged.style = `${merged.style}; ${value}`.trim();
|
|
23868
|
+
continue;
|
|
23869
|
+
}
|
|
23870
|
+
|
|
23871
|
+
if (typeof merged[key] === 'undefined') {
|
|
23872
|
+
merged[key] = value;
|
|
23873
|
+
}
|
|
23874
|
+
}
|
|
23875
|
+
|
|
23876
|
+
return merged;
|
|
23877
|
+
};
|
|
23878
|
+
const normalize_nodes = function (nodes, state) {
|
|
23879
|
+
const normalized_nodes = [];
|
|
23880
|
+
|
|
23881
|
+
for (let index = 0; index < (nodes || []).length; index++) {
|
|
23882
|
+
const node = nodes[index];
|
|
23883
|
+
if (!node || typeof node !== 'object') {
|
|
23884
|
+
continue;
|
|
23885
|
+
}
|
|
23886
|
+
|
|
23887
|
+
const tag_name = normalize_tag_name(node.tagName);
|
|
23888
|
+
|
|
23889
|
+
if (tag_name === '!doctype') {
|
|
23890
|
+
state.changed = true;
|
|
23891
|
+
continue;
|
|
23892
|
+
}
|
|
23893
|
+
|
|
23894
|
+
if (tag_name === 'html') {
|
|
23895
|
+
state.changed = true;
|
|
23896
|
+
state.root_attributes = merge_attributes(state.root_attributes, node.attributes);
|
|
23897
|
+
normalized_nodes.push.apply(normalized_nodes, normalize_nodes(node.children, state));
|
|
23898
|
+
continue;
|
|
23899
|
+
}
|
|
23900
|
+
|
|
23901
|
+
if (tag_name === 'head') {
|
|
23902
|
+
state.changed = true;
|
|
23903
|
+
normalized_nodes.push.apply(normalized_nodes, normalize_nodes(node.children, state));
|
|
23904
|
+
continue;
|
|
23905
|
+
}
|
|
23906
|
+
|
|
23907
|
+
if (tag_name === 'body') {
|
|
23908
|
+
state.changed = true;
|
|
23909
|
+
state.root_attributes = merge_attributes(state.root_attributes, node.attributes);
|
|
23910
|
+
normalized_nodes.push.apply(normalized_nodes, normalize_nodes(node.children, state));
|
|
23911
|
+
continue;
|
|
23912
|
+
}
|
|
23913
|
+
|
|
23914
|
+
let next_node = node;
|
|
23915
|
+
if (Array.isArray(node.children) && node.children.length) {
|
|
23916
|
+
const next_children = normalize_nodes(node.children, state);
|
|
23917
|
+
if (next_children !== node.children) {
|
|
23918
|
+
next_node = {
|
|
23919
|
+
...node,
|
|
23920
|
+
children: next_children,
|
|
23921
|
+
};
|
|
23922
|
+
state.changed = true;
|
|
23923
|
+
}
|
|
23924
|
+
}
|
|
23925
|
+
|
|
23926
|
+
normalized_nodes.push(next_node);
|
|
23927
|
+
}
|
|
23928
|
+
|
|
23929
|
+
return normalized_nodes;
|
|
23930
|
+
};
|
|
23931
|
+
|
|
23932
|
+
const [root_node, ...extra_nodes] = doc.progUi;
|
|
23933
|
+
if (!root_node || typeof root_node !== 'object') {
|
|
23934
|
+
return doc;
|
|
23935
|
+
}
|
|
23936
|
+
|
|
23937
|
+
const state = {
|
|
23938
|
+
changed: false,
|
|
23939
|
+
root_attributes: {},
|
|
23940
|
+
};
|
|
23941
|
+
|
|
23942
|
+
const normalized_children = normalize_nodes([...(root_node.children || []), ...extra_nodes], state);
|
|
23943
|
+
const merged_attributes = merge_attributes(root_node.attributes, state.root_attributes);
|
|
23944
|
+
|
|
23945
|
+
if (!state.changed && !Object.keys(state.root_attributes).length) {
|
|
23946
|
+
doc.__xudaRuntimeNormalized = true;
|
|
23947
|
+
return doc;
|
|
23948
|
+
}
|
|
23949
|
+
|
|
23950
|
+
return {
|
|
23951
|
+
...doc,
|
|
23952
|
+
__xudaRuntimeNormalized: true,
|
|
23953
|
+
progUi: [
|
|
23954
|
+
{
|
|
23955
|
+
...root_node,
|
|
23956
|
+
attributes: merged_attributes,
|
|
23957
|
+
children: normalized_children,
|
|
23958
|
+
},
|
|
23959
|
+
],
|
|
23960
|
+
};
|
|
23961
|
+
};
|
|
23840
23962
|
|
|
23841
23963
|
func.runtime.env = {
|
|
23842
23964
|
get_url_params: function () {
|
|
@@ -26900,6 +27022,13 @@ func.utils.DOCS_OBJ = {};
|
|
|
26900
27022
|
func.utils.DOCS_OBJ.get = async function (SESSION_ID, idP) {
|
|
26901
27023
|
if (!idP || idP === '0') return;
|
|
26902
27024
|
|
|
27025
|
+
const normalize_runtime_doc = function (doc) {
|
|
27026
|
+
if (!doc || !func.runtime.program?.normalize_doc_for_runtime) {
|
|
27027
|
+
return doc;
|
|
27028
|
+
}
|
|
27029
|
+
return func.runtime.program.normalize_doc_for_runtime(doc);
|
|
27030
|
+
};
|
|
27031
|
+
|
|
26903
27032
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
26904
27033
|
const _app_id = _session.app_id;
|
|
26905
27034
|
if (!DOCS_OBJ[_app_id]) {
|
|
@@ -26921,7 +27050,8 @@ func.utils.DOCS_OBJ.get = async function (SESSION_ID, idP) {
|
|
|
26921
27050
|
}
|
|
26922
27051
|
let val = _session.project_data?.programs?.[idP];
|
|
26923
27052
|
if (val) {
|
|
26924
|
-
|
|
27053
|
+
DOCS_OBJ[_app_id][idP] = normalize_runtime_doc(val);
|
|
27054
|
+
return DOCS_OBJ[_app_id][idP];
|
|
26925
27055
|
}
|
|
26926
27056
|
}
|
|
26927
27057
|
|
|
@@ -26929,7 +27059,7 @@ func.utils.DOCS_OBJ.get = async function (SESSION_ID, idP) {
|
|
|
26929
27059
|
const module = await func.common.get_module(SESSION_ID, `xuda-progs-loader-module.mjs`);
|
|
26930
27060
|
|
|
26931
27061
|
if (idP !== 'system') {
|
|
26932
|
-
DOCS_OBJ[_app_id][idP] = await module.DOCS_OBJ_get(SESSION_ID, idP);
|
|
27062
|
+
DOCS_OBJ[_app_id][idP] = normalize_runtime_doc(await module.DOCS_OBJ_get(SESSION_ID, idP));
|
|
26933
27063
|
if (DOCS_OBJ[_app_id][idP] && xu_isEmpty(DOCS_OBJ[_app_id][idP])) {
|
|
26934
27064
|
await func.utils.remove_cached_objects(SESSION_ID);
|
|
26935
27065
|
|
|
@@ -36735,6 +36865,68 @@ const create_runtime_head_element = function (doc, tag_name, attributes, asset_k
|
|
|
36735
36865
|
return node;
|
|
36736
36866
|
};
|
|
36737
36867
|
|
|
36868
|
+
const queue_runtime_html_script_task = function (task) {
|
|
36869
|
+
const queue =
|
|
36870
|
+
func.runtime.render._html_script_queue ||
|
|
36871
|
+
(func.runtime.render._html_script_queue = {
|
|
36872
|
+
items: [],
|
|
36873
|
+
scheduled: false,
|
|
36874
|
+
running: false,
|
|
36875
|
+
});
|
|
36876
|
+
|
|
36877
|
+
queue.items.push(task);
|
|
36878
|
+
|
|
36879
|
+
if (queue.scheduled || queue.running) {
|
|
36880
|
+
return;
|
|
36881
|
+
}
|
|
36882
|
+
|
|
36883
|
+
queue.scheduled = true;
|
|
36884
|
+
|
|
36885
|
+
const drain_queue = async function () {
|
|
36886
|
+
if (queue.running) {
|
|
36887
|
+
return;
|
|
36888
|
+
}
|
|
36889
|
+
|
|
36890
|
+
queue.running = true;
|
|
36891
|
+
queue.scheduled = false;
|
|
36892
|
+
|
|
36893
|
+
try {
|
|
36894
|
+
while (queue.items.length) {
|
|
36895
|
+
const next_task = queue.items.shift();
|
|
36896
|
+
await next_task();
|
|
36897
|
+
}
|
|
36898
|
+
} catch (error) {
|
|
36899
|
+
console.error(error);
|
|
36900
|
+
} finally {
|
|
36901
|
+
queue.running = false;
|
|
36902
|
+
if (queue.items.length && !queue.scheduled) {
|
|
36903
|
+
queue.scheduled = true;
|
|
36904
|
+
schedule_runtime_html_script_queue();
|
|
36905
|
+
}
|
|
36906
|
+
}
|
|
36907
|
+
};
|
|
36908
|
+
|
|
36909
|
+
const schedule_runtime_html_script_queue = function () {
|
|
36910
|
+
const win = func.runtime.platform.get_window?.();
|
|
36911
|
+
const run_later = function () {
|
|
36912
|
+
setTimeout(function () {
|
|
36913
|
+
drain_queue();
|
|
36914
|
+
}, 0);
|
|
36915
|
+
};
|
|
36916
|
+
|
|
36917
|
+
if (win?.requestAnimationFrame) {
|
|
36918
|
+
win.requestAnimationFrame(function () {
|
|
36919
|
+
win.requestAnimationFrame(run_later);
|
|
36920
|
+
});
|
|
36921
|
+
return;
|
|
36922
|
+
}
|
|
36923
|
+
|
|
36924
|
+
run_later();
|
|
36925
|
+
};
|
|
36926
|
+
|
|
36927
|
+
schedule_runtime_html_script_queue();
|
|
36928
|
+
};
|
|
36929
|
+
|
|
36738
36930
|
const upsert_runtime_head_element = async function (options) {
|
|
36739
36931
|
const doc = func.runtime.platform.get_document?.();
|
|
36740
36932
|
const head = doc?.head;
|
|
@@ -36848,19 +37040,21 @@ const render_runtime_html_asset = async function (options) {
|
|
|
36848
37040
|
if (!src && !content.trim()) {
|
|
36849
37041
|
return options.$container;
|
|
36850
37042
|
}
|
|
36851
|
-
|
|
36852
|
-
|
|
36853
|
-
|
|
36854
|
-
|
|
36855
|
-
|
|
36856
|
-
|
|
36857
|
-
|
|
36858
|
-
|
|
36859
|
-
|
|
36860
|
-
|
|
36861
|
-
|
|
36862
|
-
|
|
36863
|
-
|
|
37043
|
+
queue_runtime_html_script_task(async function () {
|
|
37044
|
+
await upsert_runtime_head_element({
|
|
37045
|
+
tag_name,
|
|
37046
|
+
attributes,
|
|
37047
|
+
content,
|
|
37048
|
+
asset_key,
|
|
37049
|
+
signature,
|
|
37050
|
+
find_existing_attr: src
|
|
37051
|
+
? {
|
|
37052
|
+
name: 'src',
|
|
37053
|
+
value: src,
|
|
37054
|
+
}
|
|
37055
|
+
: null,
|
|
37056
|
+
await_load: !!src,
|
|
37057
|
+
});
|
|
36864
37058
|
});
|
|
36865
37059
|
return options.$container;
|
|
36866
37060
|
}
|