clickgo 6.1.3 → 6.1.4
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/form.cgc +0 -0
- package/dist/index.js +1 -1
- package/dist/lib/control.d.ts +1 -1
- package/dist/lib/native.d.ts +7 -0
- package/doc/clickgo-rag.md +363 -321
- package/package.json +1 -1
- package/test/form-native.mjs +68 -0
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Run after TypeScript compilation: node --experimental-vm-modules test/form-native.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 listeners = {};
|
|
7
|
+
const minimums = [];
|
|
8
|
+
let ended = 0;
|
|
9
|
+
let cancelled = true;
|
|
10
|
+
class AbstractControl {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.parent = { controlName: 'root', isNativeNoFrameFirst: true };
|
|
13
|
+
this.formId = 'form';
|
|
14
|
+
this.element = {};
|
|
15
|
+
this.watches = {};
|
|
16
|
+
}
|
|
17
|
+
watch(name, callback, options) {
|
|
18
|
+
this.watches[name] = callback;
|
|
19
|
+
if (options?.immediate) { callback(); }
|
|
20
|
+
}
|
|
21
|
+
propInt(name) { return parseInt(this.props[name]); }
|
|
22
|
+
propBoolean(name) { return Boolean(this.props[name]); }
|
|
23
|
+
emit(name, event) {
|
|
24
|
+
if (name === 'close') {
|
|
25
|
+
assert.equal(event.detail.event, null);
|
|
26
|
+
if (cancelled) { event.preventDefault(); }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const clickgo = new SyntheticModule(['control', 'native', 'dom', 'tool', 'task'], function() {
|
|
31
|
+
this.setExport('control', { AbstractControl });
|
|
32
|
+
this.setExport('native', {
|
|
33
|
+
on(current, name, handler) { listeners[name] = handler; },
|
|
34
|
+
async minSize(current, w, h) { minimums.push([w, h]); },
|
|
35
|
+
async maximizable() {},
|
|
36
|
+
});
|
|
37
|
+
this.setExport('dom', { watchSize() {} });
|
|
38
|
+
this.setExport('tool', { getBoolean: Boolean });
|
|
39
|
+
this.setExport('task', { async end() { ++ended; } });
|
|
40
|
+
});
|
|
41
|
+
const mod = new SourceTextModule(await readFile(new URL('../dist/sources/control/form/code.js', import.meta.url), 'utf8'));
|
|
42
|
+
await mod.link(() => clickgo);
|
|
43
|
+
await mod.evaluate();
|
|
44
|
+
const Form = mod.namespace.default;
|
|
45
|
+
const form = new Form();
|
|
46
|
+
form.onMounted();
|
|
47
|
+
assert.deepEqual(minimums.at(-1), [200, 100]);
|
|
48
|
+
form.props.minWidth = '360';
|
|
49
|
+
form.watches.minWidth();
|
|
50
|
+
assert.deepEqual(minimums.at(-1), [360, 100]);
|
|
51
|
+
form.props.minHeight = 240;
|
|
52
|
+
form.watches.minHeight();
|
|
53
|
+
assert.deepEqual(minimums.at(-1), [360, 240]);
|
|
54
|
+
listeners['close-request']();
|
|
55
|
+
assert.equal(ended, 0);
|
|
56
|
+
cancelled = false;
|
|
57
|
+
listeners['close-request']();
|
|
58
|
+
assert.equal(ended, 1);
|
|
59
|
+
form.props.close = false;
|
|
60
|
+
listeners['close-request']();
|
|
61
|
+
assert.equal(ended, 1);
|
|
62
|
+
|
|
63
|
+
const web = new Form();
|
|
64
|
+
web.parent.isNativeNoFrameFirst = false;
|
|
65
|
+
const before = minimums.length;
|
|
66
|
+
web.onMounted();
|
|
67
|
+
assert.equal(minimums.length, before);
|
|
68
|
+
console.log('Form native minimum-size and cancellable close-event checks passed.');
|