@xuda.io/runtime-bundle 1.0.1313 → 1.0.1315
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-slim.js
CHANGED
|
@@ -9038,7 +9038,7 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
9038
9038
|
const proxy = new Proxy(target, {
|
|
9039
9039
|
set(obj, prop, value) {
|
|
9040
9040
|
const oldValue = obj[prop];
|
|
9041
|
-
|
|
9041
|
+
let currentPath = [...path, prop];
|
|
9042
9042
|
|
|
9043
9043
|
// Set the new value
|
|
9044
9044
|
obj[prop] = value;
|
|
@@ -9050,9 +9050,9 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
9050
9050
|
|
|
9051
9051
|
// Notify of change
|
|
9052
9052
|
if (oldValue !== value) {
|
|
9053
|
-
|
|
9053
|
+
currentPath.shift();
|
|
9054
9054
|
onChange({
|
|
9055
|
-
path:
|
|
9055
|
+
path: currentPath.join('.'),
|
|
9056
9056
|
oldValue,
|
|
9057
9057
|
newValue: value,
|
|
9058
9058
|
type: 'set',
|
|
@@ -20018,4 +20018,96 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
|
|
|
20018
20018
|
init_worker_session(worker_id);
|
|
20019
20019
|
return worker_id;
|
|
20020
20020
|
};
|
|
20021
|
+
|
|
20022
|
+
func.index.set_ds_0_proxy = function (SESSION_ID) {
|
|
20023
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
20024
|
+
let _ds = _session.DS_GLB[0];
|
|
20025
|
+
|
|
20026
|
+
// const _ds = func.utils.clean_returned_datasource(SESSION_ID, dsSessionP);
|
|
20027
|
+
|
|
20028
|
+
function createWatchedObject(obj, onChange) {
|
|
20029
|
+
const watchers = new WeakMap();
|
|
20030
|
+
|
|
20031
|
+
function createProxy(target, path = []) {
|
|
20032
|
+
if (watchers.has(target)) {
|
|
20033
|
+
return watchers.get(target);
|
|
20034
|
+
}
|
|
20035
|
+
|
|
20036
|
+
const proxy = new Proxy(target, {
|
|
20037
|
+
set(obj, prop, value) {
|
|
20038
|
+
const oldValue = obj[prop];
|
|
20039
|
+
let currentPath = [...path, prop];
|
|
20040
|
+
|
|
20041
|
+
// Set the new value
|
|
20042
|
+
obj[prop] = value;
|
|
20043
|
+
|
|
20044
|
+
// If the new value is an object, make it observable too
|
|
20045
|
+
if (typeof value === 'object' && value !== null) {
|
|
20046
|
+
obj[prop] = createProxy(value, currentPath);
|
|
20047
|
+
}
|
|
20048
|
+
|
|
20049
|
+
// Notify of change
|
|
20050
|
+
if (oldValue !== value) {
|
|
20051
|
+
currentPath.shift();
|
|
20052
|
+
onChange({
|
|
20053
|
+
path: currentPath.join('.'),
|
|
20054
|
+
oldValue,
|
|
20055
|
+
newValue: value,
|
|
20056
|
+
type: 'set',
|
|
20057
|
+
timestamp: Date.now(),
|
|
20058
|
+
});
|
|
20059
|
+
}
|
|
20060
|
+
|
|
20061
|
+
return true;
|
|
20062
|
+
},
|
|
20063
|
+
|
|
20064
|
+
deleteProperty(obj, prop) {
|
|
20065
|
+
const oldValue = obj[prop];
|
|
20066
|
+
const currentPath = [...path, prop];
|
|
20067
|
+
|
|
20068
|
+
delete obj[prop];
|
|
20069
|
+
|
|
20070
|
+
onChange({
|
|
20071
|
+
path: currentPath.join('.'),
|
|
20072
|
+
oldValue,
|
|
20073
|
+
newValue: undefined,
|
|
20074
|
+
type: 'delete',
|
|
20075
|
+
timestamp: Date.now(),
|
|
20076
|
+
});
|
|
20077
|
+
|
|
20078
|
+
return true;
|
|
20079
|
+
},
|
|
20080
|
+
});
|
|
20081
|
+
|
|
20082
|
+
// Make nested objects observable
|
|
20083
|
+
for (const [key, value] of Object.entries(target)) {
|
|
20084
|
+
if (typeof value === 'object' && value !== null) {
|
|
20085
|
+
target[key] = createProxy(value, [...path, key]);
|
|
20086
|
+
}
|
|
20087
|
+
}
|
|
20088
|
+
|
|
20089
|
+
watchers.set(target, proxy);
|
|
20090
|
+
return proxy;
|
|
20091
|
+
}
|
|
20092
|
+
|
|
20093
|
+
return createProxy(obj);
|
|
20094
|
+
}
|
|
20095
|
+
|
|
20096
|
+
const watchedDs = createWatchedObject({ _ref: _ds }, async (change) => {
|
|
20097
|
+
// console.log('Change detected:', change);
|
|
20098
|
+
const { path, newValue } = change;
|
|
20099
|
+
try {
|
|
20100
|
+
const datasource_changes = {
|
|
20101
|
+
[dsSessionP]: {
|
|
20102
|
+
['datasource_main']: {
|
|
20103
|
+
watcher: { path, newValue },
|
|
20104
|
+
},
|
|
20105
|
+
},
|
|
20106
|
+
};
|
|
20107
|
+
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
20108
|
+
} catch (error) {}
|
|
20109
|
+
});
|
|
20110
|
+
|
|
20111
|
+
_session.DS_GLB[0] = watchedDs._ref;
|
|
20112
|
+
};
|
|
20021
20113
|
glb.SLIM_BUNDLE=1;
|
|
@@ -9039,7 +9039,7 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
9039
9039
|
const proxy = new Proxy(target, {
|
|
9040
9040
|
set(obj, prop, value) {
|
|
9041
9041
|
const oldValue = obj[prop];
|
|
9042
|
-
|
|
9042
|
+
let currentPath = [...path, prop];
|
|
9043
9043
|
|
|
9044
9044
|
// Set the new value
|
|
9045
9045
|
obj[prop] = value;
|
|
@@ -9051,9 +9051,9 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
9051
9051
|
|
|
9052
9052
|
// Notify of change
|
|
9053
9053
|
if (oldValue !== value) {
|
|
9054
|
-
|
|
9054
|
+
currentPath.shift();
|
|
9055
9055
|
onChange({
|
|
9056
|
-
path:
|
|
9056
|
+
path: currentPath.join('.'),
|
|
9057
9057
|
oldValue,
|
|
9058
9058
|
newValue: value,
|
|
9059
9059
|
type: 'set',
|
|
@@ -20019,4 +20019,96 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
|
|
|
20019
20019
|
init_worker_session(worker_id);
|
|
20020
20020
|
return worker_id;
|
|
20021
20021
|
};
|
|
20022
|
+
|
|
20023
|
+
func.index.set_ds_0_proxy = function (SESSION_ID) {
|
|
20024
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
20025
|
+
let _ds = _session.DS_GLB[0];
|
|
20026
|
+
|
|
20027
|
+
// const _ds = func.utils.clean_returned_datasource(SESSION_ID, dsSessionP);
|
|
20028
|
+
|
|
20029
|
+
function createWatchedObject(obj, onChange) {
|
|
20030
|
+
const watchers = new WeakMap();
|
|
20031
|
+
|
|
20032
|
+
function createProxy(target, path = []) {
|
|
20033
|
+
if (watchers.has(target)) {
|
|
20034
|
+
return watchers.get(target);
|
|
20035
|
+
}
|
|
20036
|
+
|
|
20037
|
+
const proxy = new Proxy(target, {
|
|
20038
|
+
set(obj, prop, value) {
|
|
20039
|
+
const oldValue = obj[prop];
|
|
20040
|
+
let currentPath = [...path, prop];
|
|
20041
|
+
|
|
20042
|
+
// Set the new value
|
|
20043
|
+
obj[prop] = value;
|
|
20044
|
+
|
|
20045
|
+
// If the new value is an object, make it observable too
|
|
20046
|
+
if (typeof value === 'object' && value !== null) {
|
|
20047
|
+
obj[prop] = createProxy(value, currentPath);
|
|
20048
|
+
}
|
|
20049
|
+
|
|
20050
|
+
// Notify of change
|
|
20051
|
+
if (oldValue !== value) {
|
|
20052
|
+
currentPath.shift();
|
|
20053
|
+
onChange({
|
|
20054
|
+
path: currentPath.join('.'),
|
|
20055
|
+
oldValue,
|
|
20056
|
+
newValue: value,
|
|
20057
|
+
type: 'set',
|
|
20058
|
+
timestamp: Date.now(),
|
|
20059
|
+
});
|
|
20060
|
+
}
|
|
20061
|
+
|
|
20062
|
+
return true;
|
|
20063
|
+
},
|
|
20064
|
+
|
|
20065
|
+
deleteProperty(obj, prop) {
|
|
20066
|
+
const oldValue = obj[prop];
|
|
20067
|
+
const currentPath = [...path, prop];
|
|
20068
|
+
|
|
20069
|
+
delete obj[prop];
|
|
20070
|
+
|
|
20071
|
+
onChange({
|
|
20072
|
+
path: currentPath.join('.'),
|
|
20073
|
+
oldValue,
|
|
20074
|
+
newValue: undefined,
|
|
20075
|
+
type: 'delete',
|
|
20076
|
+
timestamp: Date.now(),
|
|
20077
|
+
});
|
|
20078
|
+
|
|
20079
|
+
return true;
|
|
20080
|
+
},
|
|
20081
|
+
});
|
|
20082
|
+
|
|
20083
|
+
// Make nested objects observable
|
|
20084
|
+
for (const [key, value] of Object.entries(target)) {
|
|
20085
|
+
if (typeof value === 'object' && value !== null) {
|
|
20086
|
+
target[key] = createProxy(value, [...path, key]);
|
|
20087
|
+
}
|
|
20088
|
+
}
|
|
20089
|
+
|
|
20090
|
+
watchers.set(target, proxy);
|
|
20091
|
+
return proxy;
|
|
20092
|
+
}
|
|
20093
|
+
|
|
20094
|
+
return createProxy(obj);
|
|
20095
|
+
}
|
|
20096
|
+
|
|
20097
|
+
const watchedDs = createWatchedObject({ _ref: _ds }, async (change) => {
|
|
20098
|
+
// console.log('Change detected:', change);
|
|
20099
|
+
const { path, newValue } = change;
|
|
20100
|
+
try {
|
|
20101
|
+
const datasource_changes = {
|
|
20102
|
+
[dsSessionP]: {
|
|
20103
|
+
['datasource_main']: {
|
|
20104
|
+
watcher: { path, newValue },
|
|
20105
|
+
},
|
|
20106
|
+
},
|
|
20107
|
+
};
|
|
20108
|
+
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
20109
|
+
} catch (error) {}
|
|
20110
|
+
});
|
|
20111
|
+
|
|
20112
|
+
_session.DS_GLB[0] = watchedDs._ref;
|
|
20113
|
+
};
|
|
20022
20114
|
glb.SLIM_BUNDLE=1; glb.es=1; }
|