@bobfrankston/extractids 1.0.20 → 1.0.21

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.
Files changed (2) hide show
  1. package/index.js +15 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -65,6 +65,15 @@ function generateTypes(ids, classes) {
65
65
  return `${header}${idType}\n\n${queryType}\n\n${classType}`;
66
66
  }
67
67
  const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
68
+ /** Strip the auto-generated header (first 4 lines) so we compare only the type content */
69
+ function stripHeader(content) {
70
+ const lines = content.split('\n');
71
+ // Skip lines starting with "// " at the top, plus the blank line after
72
+ let i = 0;
73
+ while (i < lines.length && (lines[i].startsWith('//') || lines[i] === ''))
74
+ i++;
75
+ return lines.slice(i).join('\n');
76
+ }
68
77
  async function updateTypesFile(specifiedHtmlFile) {
69
78
  let htmlFile;
70
79
  if (specifiedHtmlFile) {
@@ -114,10 +123,13 @@ async function updateTypesFile(specifiedHtmlFile) {
114
123
  });
115
124
  const types = generateTypes(ids, Array.from(allClasses));
116
125
  const existing = fs.existsSync('generated-types.ts') ? fs.readFileSync('generated-types.ts', 'utf8') : '';
117
- if (types === existing)
126
+ // Compare only the type content, ignoring the timestamp header
127
+ if (stripHeader(types) === stripHeader(existing)) {
128
+ console.log(`[extractids ${timestamp()}] No type changes detected`);
118
129
  return;
130
+ }
119
131
  fs.writeFileSync('generated-types.ts', types);
120
- console.log(`[extractids ${timestamp()}] Updated generated-types.ts`);
132
+ console.log(`[extractids ${timestamp()}] ** Updated generated-types.ts **`);
121
133
  }
122
134
  // Parse CLI arguments for -w or --watch and optional HTML filename
123
135
  const args = process.argv.slice(2);
@@ -161,7 +173,7 @@ if (watchMode) {
161
173
  watcher.on('change', (path) => {
162
174
  console.log(`[extractids ${timestamp()}] Change detected: ${path}`);
163
175
  clearTimeout(debounceTimer);
164
- debounceTimer = setTimeout(() => updateTypesFile(specifiedHtmlFile), 100);
176
+ debounceTimer = setTimeout(() => updateTypesFile(specifiedHtmlFile), 500);
165
177
  });
166
178
  watcher.on('ready', () => {
167
179
  console.log(`[extractids ${timestamp()}] Watcher is ready and running.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/extractids",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Extracd html and css as types",
5
5
  "main": "index.js",
6
6
  "bin": {