sdc_client 0.57.14 → 0.57.16
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/dist/index.js +26 -26
- package/dist/ugly.index.js +1 -1
- package/gulp/gulp.jsx +85 -78
- package/package.json +3 -5
- package/src/simpleDomControl/AbstractSDC.js +2 -2
- package/src/simpleDomControl/sdc_dom_events.js +17 -1
- package/src/simpleDomControl/sdc_params.js +67 -52
- package/src/simpleDomControl/sdc_socket.js +744 -716
- package/src/simpleDomControl/sdc_utils.js +1 -1
- package/src/simpleDomControl/sdc_view.js +55 -43
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
runControlFlowFunctions,
|
|
5
5
|
updateEventAndTriggerOnRefresh
|
|
6
6
|
} from "./sdc_controller.js";
|
|
7
|
-
import {getUrlParam} from "./sdc_params.js";
|
|
7
|
+
import {getUrlParam, prepareData} from "./sdc_params.js";
|
|
8
8
|
import {app} from "./sdc_main.js";
|
|
9
9
|
import {trigger} from "./sdc_events.js";
|
|
10
10
|
|
|
@@ -89,7 +89,7 @@ function replacePlaceholderController(controller, url, urlValues) {
|
|
|
89
89
|
* @param {object} args - get args.
|
|
90
90
|
* @param tag - a normalized tag-name as string.
|
|
91
91
|
* @param hardReload - true if the file has to be reloaded every time.
|
|
92
|
-
* @returns {Promise<Boolean>} - waits for the file to be loaded.
|
|
92
|
+
* @returns {Promise<jQuery|Boolean>} - waits for the file to be loaded.
|
|
93
93
|
*/
|
|
94
94
|
function loadHTMLFile(path, args, tag, hardReload) {
|
|
95
95
|
if (!path) {
|
|
@@ -136,7 +136,7 @@ function replaceAllTagElementsInContainer($container, parentController, process
|
|
|
136
136
|
* correct URL. Also parses the url parameter
|
|
137
137
|
*
|
|
138
138
|
* @param {AbstractSDC} controller - controller object
|
|
139
|
-
* @returns {
|
|
139
|
+
* @returns {{url: String, args: Array}} - the correct URL with prefix.
|
|
140
140
|
*/
|
|
141
141
|
function parseContentUrl(controller) {
|
|
142
142
|
let url = controller.contentUrl;
|
|
@@ -187,7 +187,7 @@ export function getController($elem) {
|
|
|
187
187
|
export function loadFilesFromController(controller) {
|
|
188
188
|
let getElements = {args: {}};
|
|
189
189
|
if (controller.contentUrl) {
|
|
190
|
-
getElements = parseContentUrl(controller
|
|
190
|
+
getElements = parseContentUrl(controller);
|
|
191
191
|
controller.contentUrl = getElements.url;
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -219,7 +219,7 @@ export function loadFilesFromController(controller) {
|
|
|
219
219
|
*/
|
|
220
220
|
export function reloadHTMLController(controller) {
|
|
221
221
|
if (controller.contentUrl) {
|
|
222
|
-
let getElements = parseContentUrl(controller
|
|
222
|
+
let getElements = parseContentUrl(controller);
|
|
223
223
|
controller.contentUrl = getElements.url;
|
|
224
224
|
return loadHTMLFile(controller.contentUrl, getElements.args, controller._tagName, controller.contentReload);
|
|
225
225
|
}
|
|
@@ -330,14 +330,19 @@ function _reloadMethodHTML(controller, $dom, process) {
|
|
|
330
330
|
|
|
331
331
|
|
|
332
332
|
if (typeof result === 'function') {
|
|
333
|
-
|
|
333
|
+
const newData = prepareData($this.data());
|
|
334
|
+
result = result.bind(controller)(newData);
|
|
334
335
|
}
|
|
335
|
-
if (result
|
|
336
|
+
if (result) {
|
|
336
337
|
plist.push(Promise.resolve(result).then((x) => {
|
|
337
338
|
let $newContent = $(`<div></div>`);
|
|
338
339
|
$newContent.append(x);
|
|
339
|
-
|
|
340
|
-
|
|
340
|
+
|
|
341
|
+
if ($this.html() === '') {
|
|
342
|
+
$this.append('<div></div>');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return app.reconcile(controller, $newContent, $this.children(), process);
|
|
341
346
|
}));
|
|
342
347
|
}
|
|
343
348
|
|
|
@@ -363,7 +368,7 @@ function getNodeKey(node) {
|
|
|
363
368
|
return res.join('__');
|
|
364
369
|
}
|
|
365
370
|
|
|
366
|
-
function reconcileTree($element, id = [], parent = null) {
|
|
371
|
+
function reconcileTree({$element, id = [], parent = null}) {
|
|
367
372
|
id.push(getNodeKey($element));
|
|
368
373
|
const obj = {
|
|
369
374
|
$element,
|
|
@@ -372,21 +377,26 @@ function reconcileTree($element, id = [], parent = null) {
|
|
|
372
377
|
idx: 0,
|
|
373
378
|
getRealParent: () => parent,
|
|
374
379
|
getIdx: function () {
|
|
375
|
-
this.idx = (this.getRealParent()?.getIdx() ?? -1) + $element.index() + 1;
|
|
380
|
+
this.idx = Math.max(0, (this.getRealParent()?.getIdx() ?? -1) + $element.index() + 1);
|
|
376
381
|
return this.idx;
|
|
377
382
|
},
|
|
378
383
|
op: null,
|
|
379
384
|
parent
|
|
380
385
|
};
|
|
381
386
|
obj.getIdx.bind(obj);
|
|
382
|
-
return [obj].concat($element.contents().toArray().map((x) => reconcileTree(
|
|
387
|
+
return [obj].concat($element.contents().toArray().map((x) => reconcileTree({
|
|
388
|
+
$element: $(x),
|
|
389
|
+
id: id.slice(),
|
|
390
|
+
parent: obj
|
|
391
|
+
})).flat());
|
|
383
392
|
|
|
384
393
|
}
|
|
385
394
|
|
|
386
395
|
|
|
387
396
|
export function reconcile($virtualNode, $realNode) {
|
|
388
|
-
|
|
389
|
-
const $
|
|
397
|
+
|
|
398
|
+
const $old = reconcileTree({$element: $realNode});
|
|
399
|
+
const $new = reconcileTree({$element: $virtualNode});
|
|
390
400
|
$old.map((x, i) => x.idx = i);
|
|
391
401
|
$new.map((x, i) => x.idx = i);
|
|
392
402
|
const depth = Math.max(...$new.concat($old).map(x => x.depth));
|
|
@@ -396,38 +406,40 @@ export function reconcile($virtualNode, $realNode) {
|
|
|
396
406
|
window.OPS = op_steps;
|
|
397
407
|
|
|
398
408
|
op_steps.forEach((op_step, i) => {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
+
const {op, $element, idx} = op_step;
|
|
410
|
+
|
|
411
|
+
if (op.type === 'keep_counterpart') {
|
|
412
|
+
let cIdx = op.counterpart.getIdx();
|
|
413
|
+
if (cIdx !== idx) {
|
|
414
|
+
const elemBefore = op_step.getBefore();
|
|
415
|
+
if (!elemBefore) {
|
|
416
|
+
op_step.getRealParent().$element.prepend(op.counterpart.$element);
|
|
417
|
+
} else {
|
|
418
|
+
op.counterpart.$element.insertAfter(elemBefore.$element);
|
|
419
|
+
}
|
|
409
420
|
}
|
|
410
|
-
}
|
|
411
421
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
422
|
+
syncAttributes(op.counterpart.$element, $element);
|
|
423
|
+
if ($element.hasClass(CONTROLLER_CLASS)) {
|
|
424
|
+
$element.data(DATA_CONTROLLER_KEY).$container = op.counterpart.$element;
|
|
425
|
+
$element.data(DATA_CONTROLLER_KEY, null);
|
|
426
|
+
}
|
|
417
427
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
+
toRemove.push($element);
|
|
429
|
+
} else if (op.type === 'delete') {
|
|
430
|
+
$element.safeRemove();
|
|
431
|
+
} else if (op.type === 'insert') {
|
|
432
|
+
const {after, target} = op_step.op;
|
|
433
|
+
if (after) {
|
|
434
|
+
$element.insertAfter(after.$element);
|
|
435
|
+
} else if (target) {
|
|
436
|
+
target.$element.prepend($element);
|
|
437
|
+
}
|
|
428
438
|
|
|
439
|
+
}
|
|
429
440
|
}
|
|
430
|
-
|
|
441
|
+
)
|
|
442
|
+
;
|
|
431
443
|
|
|
432
444
|
toRemove.forEach(($element) => $element.safeRemove());
|
|
433
445
|
}
|
|
@@ -504,7 +516,7 @@ function lcbDiff(oldNodes, newNodes, depth) {
|
|
|
504
516
|
|
|
505
517
|
function getBefore(element, idx) {
|
|
506
518
|
const startDepth = element.depth;
|
|
507
|
-
while (idx >=
|
|
519
|
+
while (idx >= 1 && element.depth >= startDepth) {
|
|
508
520
|
idx -= 1;
|
|
509
521
|
element = newNodes[idx];
|
|
510
522
|
if (element.depth === startDepth) {
|
|
@@ -563,7 +575,7 @@ export function refresh($dom, leafController, process = null) {
|
|
|
563
575
|
$dom ??= leafController.$container;
|
|
564
576
|
|
|
565
577
|
return replaceTagElementsInContainer(app.tagNames, $dom, leafController, process).then(() => {
|
|
566
|
-
reloadMethodHTML(leafController, $dom, refreshProcess).then(() => {
|
|
578
|
+
return reloadMethodHTML(leafController, $dom, refreshProcess).then(() => {
|
|
567
579
|
if (!isRunningProcess) {
|
|
568
580
|
updateEventAndTriggerOnRefresh(refreshProcess);
|
|
569
581
|
}
|