@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.
|
@@ -28169,7 +28169,7 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
28169
28169
|
const proxy = new Proxy(target, {
|
|
28170
28170
|
set(obj, prop, value) {
|
|
28171
28171
|
const oldValue = obj[prop];
|
|
28172
|
-
|
|
28172
|
+
let currentPath = [...path, prop];
|
|
28173
28173
|
|
|
28174
28174
|
// Set the new value
|
|
28175
28175
|
obj[prop] = value;
|
|
@@ -28181,9 +28181,9 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
28181
28181
|
|
|
28182
28182
|
// Notify of change
|
|
28183
28183
|
if (oldValue !== value) {
|
|
28184
|
-
|
|
28184
|
+
currentPath.shift();
|
|
28185
28185
|
onChange({
|
|
28186
|
-
path:
|
|
28186
|
+
path: currentPath.join('.'),
|
|
28187
28187
|
oldValue,
|
|
28188
28188
|
newValue: value,
|
|
28189
28189
|
type: 'set',
|
|
@@ -42505,4 +42505,96 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
|
|
|
42505
42505
|
init_worker_session(worker_id);
|
|
42506
42506
|
return worker_id;
|
|
42507
42507
|
};
|
|
42508
|
+
|
|
42509
|
+
func.index.set_ds_0_proxy = function (SESSION_ID) {
|
|
42510
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
42511
|
+
let _ds = _session.DS_GLB[0];
|
|
42512
|
+
|
|
42513
|
+
// const _ds = func.utils.clean_returned_datasource(SESSION_ID, dsSessionP);
|
|
42514
|
+
|
|
42515
|
+
function createWatchedObject(obj, onChange) {
|
|
42516
|
+
const watchers = new WeakMap();
|
|
42517
|
+
|
|
42518
|
+
function createProxy(target, path = []) {
|
|
42519
|
+
if (watchers.has(target)) {
|
|
42520
|
+
return watchers.get(target);
|
|
42521
|
+
}
|
|
42522
|
+
|
|
42523
|
+
const proxy = new Proxy(target, {
|
|
42524
|
+
set(obj, prop, value) {
|
|
42525
|
+
const oldValue = obj[prop];
|
|
42526
|
+
let currentPath = [...path, prop];
|
|
42527
|
+
|
|
42528
|
+
// Set the new value
|
|
42529
|
+
obj[prop] = value;
|
|
42530
|
+
|
|
42531
|
+
// If the new value is an object, make it observable too
|
|
42532
|
+
if (typeof value === 'object' && value !== null) {
|
|
42533
|
+
obj[prop] = createProxy(value, currentPath);
|
|
42534
|
+
}
|
|
42535
|
+
|
|
42536
|
+
// Notify of change
|
|
42537
|
+
if (oldValue !== value) {
|
|
42538
|
+
currentPath.shift();
|
|
42539
|
+
onChange({
|
|
42540
|
+
path: currentPath.join('.'),
|
|
42541
|
+
oldValue,
|
|
42542
|
+
newValue: value,
|
|
42543
|
+
type: 'set',
|
|
42544
|
+
timestamp: Date.now(),
|
|
42545
|
+
});
|
|
42546
|
+
}
|
|
42547
|
+
|
|
42548
|
+
return true;
|
|
42549
|
+
},
|
|
42550
|
+
|
|
42551
|
+
deleteProperty(obj, prop) {
|
|
42552
|
+
const oldValue = obj[prop];
|
|
42553
|
+
const currentPath = [...path, prop];
|
|
42554
|
+
|
|
42555
|
+
delete obj[prop];
|
|
42556
|
+
|
|
42557
|
+
onChange({
|
|
42558
|
+
path: currentPath.join('.'),
|
|
42559
|
+
oldValue,
|
|
42560
|
+
newValue: undefined,
|
|
42561
|
+
type: 'delete',
|
|
42562
|
+
timestamp: Date.now(),
|
|
42563
|
+
});
|
|
42564
|
+
|
|
42565
|
+
return true;
|
|
42566
|
+
},
|
|
42567
|
+
});
|
|
42568
|
+
|
|
42569
|
+
// Make nested objects observable
|
|
42570
|
+
for (const [key, value] of Object.entries(target)) {
|
|
42571
|
+
if (typeof value === 'object' && value !== null) {
|
|
42572
|
+
target[key] = createProxy(value, [...path, key]);
|
|
42573
|
+
}
|
|
42574
|
+
}
|
|
42575
|
+
|
|
42576
|
+
watchers.set(target, proxy);
|
|
42577
|
+
return proxy;
|
|
42578
|
+
}
|
|
42579
|
+
|
|
42580
|
+
return createProxy(obj);
|
|
42581
|
+
}
|
|
42582
|
+
|
|
42583
|
+
const watchedDs = createWatchedObject({ _ref: _ds }, async (change) => {
|
|
42584
|
+
// console.log('Change detected:', change);
|
|
42585
|
+
const { path, newValue } = change;
|
|
42586
|
+
try {
|
|
42587
|
+
const datasource_changes = {
|
|
42588
|
+
[dsSessionP]: {
|
|
42589
|
+
['datasource_main']: {
|
|
42590
|
+
watcher: { path, newValue },
|
|
42591
|
+
},
|
|
42592
|
+
},
|
|
42593
|
+
};
|
|
42594
|
+
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
42595
|
+
} catch (error) {}
|
|
42596
|
+
});
|
|
42597
|
+
|
|
42598
|
+
_session.DS_GLB[0] = watchedDs._ref;
|
|
42599
|
+
};
|
|
42508
42600
|
glb.CODE_BUNDLE=1;
|