-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild-seed-map.js
More file actions
219 lines (188 loc) · 6.6 KB
/
build-seed-map.js
File metadata and controls
219 lines (188 loc) · 6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
const MacRecorder = require('./index.js');
const recorder = new MacRecorder();
const fs = require('fs');
console.log('\n🎯 SEED MAPPING BUILDER\n');
console.log('═'.repeat(100));
console.log('\n📋 Bu tool tüm cursor tiplerinin seed mapping\'ini oluşturur.\n');
// Tüm CSS cursor tipleri (HTML'deki sırayla)
const cursorTypes = [
"auto",
"default",
"none",
"context-menu",
"help",
"pointer",
"progress",
"wait",
"cell",
"crosshair",
"text",
"vertical-text",
"alias",
"copy",
"move",
"no-drop",
"not-allowed",
"grab",
"grabbing",
"all-scroll",
"col-resize",
"row-resize",
"n-resize",
"e-resize",
"s-resize",
"w-resize",
"ne-resize",
"nw-resize",
"se-resize",
"sw-resize",
"ew-resize",
"ns-resize",
"nesw-resize",
"nwse-resize",
"zoom-in",
"zoom-out"
];
let currentIndex = 0;
let seedMapping = {}; // cursorType -> seed
let isWaitingForClick = false;
console.log(`\n📝 ${cursorTypes.length} cursor tipi için seed toplanacak:\n`);
cursorTypes.forEach((cursor, index) => {
console.log(` ${(index + 1).toString().padStart(2)}. ${cursor}`);
});
console.log('\n' + '═'.repeat(100));
console.log('\n💡 Nasıl Kullanılır:');
console.log(' 1. test-all-cursors.html dosyası tarayıcıda açık olmalı');
console.log(' 2. Bu script size hangi cursor\'a tıklamanız gerektiğini söyleyecek');
console.log(' 3. HTML\'deki o cursor kutusuna TIKLAYIN');
console.log(' 4. Seed otomatik kaydedilecek ve bir sonrakine geçilecek');
console.log(' 5. Tüm cursor\'lar bitince seed-mapping.json oluşturulacak\n');
console.log('═'.repeat(100));
function showNextCursor() {
if (currentIndex >= cursorTypes.length) {
finishMapping();
return;
}
const cursorType = cursorTypes[currentIndex];
console.log(`\n\n🎯 [${currentIndex + 1}/${cursorTypes.length}] "${cursorType}" cursor'una tıkla`);
console.log('👆 HTML\'de bu cursor kutusunu bul ve TIKLA...\n');
isWaitingForClick = true;
}
function recordSeedOnClick(pos) {
if (!isWaitingForClick) return;
isWaitingForClick = false;
const cursorType = cursorTypes[currentIndex];
const seed = pos.seed || -1;
console.log(`✅ Kaydedildi: ${cursorType.padEnd(20)} → seed: ${seed}`);
// Mapping'e ekle
seedMapping[cursorType] = seed;
currentIndex++;
// 200ms bekle sonraki cursor'a geç
setTimeout(() => {
showNextCursor();
}, 200);
}
function finishMapping() {
console.log('\n\n🎉 TÜM CURSOR TİPLERİ İÇİN SEED TOPLANDI!\n');
console.log('═'.repeat(100));
console.log(`\n✅ ${Object.keys(seedMapping).length} cursor tipi kaydedildi.\n`);
console.log('═'.repeat(100));
// Reverse mapping oluştur: seed -> cursorType
const seedToType = {};
Object.keys(seedMapping).forEach(cursorType => {
const seed = seedMapping[cursorType];
if (seed > 0) {
// Eğer bu seed zaten başka bir cursor'a atanmışsa, not ekle
if (seedToType[seed]) {
console.log(`⚠️ Seed collision: ${seed} both ${seedToType[seed]} and ${cursorType}`);
// İlk gördüğümüzü tut, ama not ekle
if (!seedToType[seed].includes('/')) {
seedToType[seed] = `${seedToType[seed]}/${cursorType}`;
} else {
seedToType[seed] += `/${cursorType}`;
}
} else {
seedToType[seed] = cursorType;
}
}
});
console.log('\n📊 SEED MAPPING ÖZET:\n');
console.log('Cursor Type -> Seed');
console.log('─'.repeat(100));
Object.keys(seedMapping).sort().forEach(cursorType => {
const seed = seedMapping[cursorType];
console.log(`${cursorType.padEnd(20)} → ${seed}`);
});
console.log('\n\n📊 REVERSE MAPPING (Seed -> Cursor):\n');
console.log('Seed -> Cursor Type');
console.log('─'.repeat(100));
Object.keys(seedToType).sort((a, b) => parseInt(a) - parseInt(b)).forEach(seed => {
console.log(`${seed.padEnd(10)} → ${seedToType[seed]}`);
});
// Dosyaya kaydet
const output = {
metadata: {
timestamp: new Date().toISOString(),
totalCursorTypes: Object.keys(seedMapping).length,
uniqueSeeds: Object.keys(seedToType).length
},
cursorToSeed: seedMapping,
seedToCursor: seedToType
};
fs.writeFileSync('seed-mapping.json', JSON.stringify(output, null, 2));
console.log('\n✅ Mapping "seed-mapping.json" dosyasına kaydedildi!\n');
// C++ için kod üret
console.log('\n═'.repeat(100));
console.log('\n📝 C++ KODU (cursor_tracker.mm için):\n');
console.log('static NSString* cursorTypeFromSeed(int seed) {');
console.log(' switch(seed) {');
Object.keys(seedToType).sort((a, b) => parseInt(a) - parseInt(b)).forEach(seed => {
const cursorType = seedToType[seed];
// Eğer collision varsa (örn: "auto/default"), ilkini al
const primaryType = cursorType.split('/')[0];
console.log(` case ${seed}: return @"${primaryType}";`);
});
console.log(' default: return nil;');
console.log(' }');
console.log('}\n');
console.log('═'.repeat(100));
process.exit(0);
}
// Mouse click monitoring
let lastClickTime = 0;
let monitoringInterval = null;
console.log('\n⏳ test-all-cursors.html açık mı? 3 saniye sonra başlıyoruz...\n');
setTimeout(() => {
console.log('🚀 TEST BAŞLADI! HTML\'deki cursor kutularına tıklayın!\n');
console.log('═'.repeat(100));
showNextCursor();
// Mouse click'i sürekli kontrol et
monitoringInterval = setInterval(() => {
try {
const pos = recorder.getCursorPosition();
// Mouse down eventi
if (pos && pos.eventType === 'mousedown') {
const now = Date.now();
// Debounce - 300ms
if (now - lastClickTime > 300) {
lastClickTime = now;
recordSeedOnClick(pos);
}
}
} catch (err) {
// Sessizce devam et
}
}, 50);
}, 3000);
// Ctrl+C handler
process.on('SIGINT', () => {
if (monitoringInterval) {
clearInterval(monitoringInterval);
}
console.log('\n\n⚠️ Yarıda kesildi. Şimdiye kadar toplanan data:\n');
Object.keys(seedMapping).forEach(cursorType => {
console.log(`${cursorType.padEnd(20)} → ${seedMapping[cursorType]}`);
});
console.log('\n');
process.exit(0);
});