clickgo 6.4.0 → 6.4.2
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/app/demo.cga +0 -0
- package/dist/app/task.cga +0 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/objviewer.cgc +0 -0
- package/dist/index.js +1 -1
- package/dist/lib/dom.d.ts +24 -3
- package/dist/lib/task.d.ts +9 -2
- package/dist/lib/tool.d.ts +1 -0
- package/doc/clickgo-rag.md +409 -265
- package/package.json +1 -1
- package/test/dock-lifecycle.mjs +93 -0
- package/test/tool-clone.mjs +42 -0
package/package.json
CHANGED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Run after TypeScript compilation: node --experimental-vm-modules test/dock-lifecycle.mjs
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { SourceTextModule, SyntheticModule } from 'node:vm';
|
|
5
|
+
|
|
6
|
+
const sizeWatches = [];
|
|
7
|
+
const sizeUnwatches = [];
|
|
8
|
+
|
|
9
|
+
class AbstractControl {
|
|
10
|
+
constructor(rootForm, height) {
|
|
11
|
+
this.rootForm = rootForm;
|
|
12
|
+
this.refs = {
|
|
13
|
+
'body': { 'clientHeight': height }
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
watch(name, callback, options) {
|
|
18
|
+
if ((name === 'expanded') && options?.immediate) {
|
|
19
|
+
callback();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async nextTick() {}
|
|
24
|
+
|
|
25
|
+
propBoolean(name) {
|
|
26
|
+
return Boolean(this.props[name]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
emit() {}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const clickgo = new SyntheticModule(['control', 'dom'], function() {
|
|
33
|
+
this.setExport('control', { AbstractControl });
|
|
34
|
+
this.setExport('dom', {
|
|
35
|
+
watchSizeMulti(current, element, handler, immediate) {
|
|
36
|
+
sizeWatches.push({ current, element, handler });
|
|
37
|
+
if (immediate) {
|
|
38
|
+
handler();
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
},
|
|
42
|
+
unwatchSizeMulti(current, element, handler) {
|
|
43
|
+
sizeUnwatches.push({ current, element, handler });
|
|
44
|
+
},
|
|
45
|
+
watchSize(current, element, handler, immediate) {
|
|
46
|
+
if (immediate) {
|
|
47
|
+
handler();
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
const mod = new SourceTextModule(await readFile(new URL('../dist/sources/control/dock/code.js', import.meta.url), 'utf8'));
|
|
54
|
+
await mod.link(() => clickgo);
|
|
55
|
+
await mod.evaluate();
|
|
56
|
+
const Dock = mod.namespace.default;
|
|
57
|
+
|
|
58
|
+
const formA = { 'element': { 'isConnected': true, 'offsetWidth': 500 } };
|
|
59
|
+
const formB = { 'element': { 'isConnected': true, 'offsetWidth': 800 } };
|
|
60
|
+
const dockA1 = new Dock(formA, 300);
|
|
61
|
+
const dockA2 = new Dock(formA, 400);
|
|
62
|
+
const dockB = new Dock(formB, 500);
|
|
63
|
+
|
|
64
|
+
await dockA1.onMounted();
|
|
65
|
+
await dockA2.onMounted();
|
|
66
|
+
await dockB.onMounted();
|
|
67
|
+
|
|
68
|
+
assert.notEqual(dockA1.access, dockA2.access);
|
|
69
|
+
assert.notEqual(dockA1.access.formSizeWatch, dockA2.access.formSizeWatch);
|
|
70
|
+
assert.equal(dockA1.narrow, true);
|
|
71
|
+
assert.equal(dockA2.narrow, true);
|
|
72
|
+
assert.equal(dockB.narrow, false);
|
|
73
|
+
assert.equal(dockA1.floatAreaHeight, 300);
|
|
74
|
+
assert.equal(dockA2.floatAreaHeight, 400);
|
|
75
|
+
assert.equal(dockB.floatAreaHeight, 500);
|
|
76
|
+
|
|
77
|
+
dockB.toggleFloat(1);
|
|
78
|
+
dockA1.toggleFloat(2);
|
|
79
|
+
dockA2.toggleFloat(3);
|
|
80
|
+
assert.equal(dockA1.floatGroup, -1);
|
|
81
|
+
assert.equal(dockA2.floatGroup, 3);
|
|
82
|
+
assert.equal(dockB.floatGroup, 1);
|
|
83
|
+
|
|
84
|
+
const dockA1Watch = dockA1.access.formSizeWatch;
|
|
85
|
+
dockA1.onUnmounted();
|
|
86
|
+
assert.equal(dockA1.access.formSizeWatch, null);
|
|
87
|
+
assert.equal(sizeUnwatches.length, 1);
|
|
88
|
+
assert.equal(sizeUnwatches[0].current, dockA1);
|
|
89
|
+
assert.equal(sizeUnwatches[0].element, formA.element);
|
|
90
|
+
assert.equal(sizeUnwatches[0].handler, dockA1Watch.handler);
|
|
91
|
+
assert.equal(sizeWatches.length, 3);
|
|
92
|
+
|
|
93
|
+
console.log('Dock access state, Form isolation and size-watch cleanup checks passed.');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Run after TypeScript compilation: node test/tool-clone.mjs
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { clone } from '../dist/lib/tool.js';
|
|
4
|
+
|
|
5
|
+
const shared = { 'value': 1 };
|
|
6
|
+
const source = {
|
|
7
|
+
'map': new Map(),
|
|
8
|
+
'set': new Set(),
|
|
9
|
+
shared,
|
|
10
|
+
'alias': shared,
|
|
11
|
+
'date': new Date('2026-09-20T00:00:00.000Z'),
|
|
12
|
+
};
|
|
13
|
+
source.self = source;
|
|
14
|
+
source.map.set(shared, source);
|
|
15
|
+
source.set.add(shared);
|
|
16
|
+
source.set.add(source);
|
|
17
|
+
|
|
18
|
+
const first = clone(source);
|
|
19
|
+
const second = clone(source);
|
|
20
|
+
|
|
21
|
+
assert.notEqual(first, source);
|
|
22
|
+
assert.notEqual(first, second);
|
|
23
|
+
assert(first.map instanceof Map);
|
|
24
|
+
assert(first.set instanceof Set);
|
|
25
|
+
assert.notEqual(first.map, source.map);
|
|
26
|
+
assert.notEqual(first.map, second.map);
|
|
27
|
+
assert.notEqual(first.set, source.set);
|
|
28
|
+
assert.notEqual(first.set, second.set);
|
|
29
|
+
assert.equal(first.self, first);
|
|
30
|
+
assert.equal(first.shared, first.alias);
|
|
31
|
+
assert.notEqual(first.shared, shared);
|
|
32
|
+
assert.equal(first.map.get(first.shared), first);
|
|
33
|
+
assert(first.set.has(first.shared));
|
|
34
|
+
assert(first.set.has(first));
|
|
35
|
+
assert(first.date instanceof Date);
|
|
36
|
+
assert.notEqual(first.date, source.date);
|
|
37
|
+
assert.equal(first.date.getTime(), source.date.getTime());
|
|
38
|
+
|
|
39
|
+
first.map.set('only-first', true);
|
|
40
|
+
assert.equal(second.map.has('only-first'), false);
|
|
41
|
+
|
|
42
|
+
console.log('Tool clone Map/Set, circular-reference and instance-isolation checks passed.');
|