mtrl-addons 0.2.2 → 0.2.3

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 (128) hide show
  1. package/{src/components/index.ts → dist/components/index.d.ts} +0 -2
  2. package/dist/components/vlist/config.d.ts +86 -0
  3. package/{src/components/vlist/constants.ts → dist/components/vlist/constants.d.ts} +10 -11
  4. package/dist/components/vlist/features/api.d.ts +7 -0
  5. package/{src/components/vlist/features/index.ts → dist/components/vlist/features/index.d.ts} +0 -2
  6. package/dist/components/vlist/features/selection.d.ts +6 -0
  7. package/dist/components/vlist/features/viewport.d.ts +9 -0
  8. package/dist/components/vlist/features.d.ts +31 -0
  9. package/{src/components/vlist/index.ts → dist/components/vlist/index.d.ts} +1 -10
  10. package/dist/components/vlist/types.d.ts +596 -0
  11. package/dist/components/vlist/vlist.d.ts +29 -0
  12. package/dist/core/compose/features/gestures/index.d.ts +86 -0
  13. package/dist/core/compose/features/gestures/longpress.d.ts +85 -0
  14. package/dist/core/compose/features/gestures/pan.d.ts +108 -0
  15. package/dist/core/compose/features/gestures/pinch.d.ts +111 -0
  16. package/dist/core/compose/features/gestures/rotate.d.ts +111 -0
  17. package/dist/core/compose/features/gestures/swipe.d.ts +149 -0
  18. package/dist/core/compose/features/gestures/tap.d.ts +79 -0
  19. package/{src/core/compose/features/index.ts → dist/core/compose/features/index.d.ts} +1 -2
  20. package/{src/core/compose/index.ts → dist/core/compose/index.d.ts} +2 -11
  21. package/{src/core/gestures/index.ts → dist/core/gestures/index.d.ts} +1 -20
  22. package/dist/core/gestures/longpress.d.ts +23 -0
  23. package/dist/core/gestures/manager.d.ts +14 -0
  24. package/dist/core/gestures/pan.d.ts +12 -0
  25. package/dist/core/gestures/pinch.d.ts +14 -0
  26. package/dist/core/gestures/rotate.d.ts +14 -0
  27. package/dist/core/gestures/swipe.d.ts +20 -0
  28. package/dist/core/gestures/tap.d.ts +12 -0
  29. package/dist/core/gestures/types.d.ts +320 -0
  30. package/dist/core/gestures/utils.d.ts +57 -0
  31. package/dist/core/index.d.ts +13 -0
  32. package/dist/core/layout/config.d.ts +33 -0
  33. package/dist/core/layout/index.d.ts +51 -0
  34. package/dist/core/layout/jsx.d.ts +65 -0
  35. package/dist/core/layout/schema.d.ts +112 -0
  36. package/dist/core/layout/types.d.ts +69 -0
  37. package/dist/core/viewport/constants.d.ts +105 -0
  38. package/dist/core/viewport/features/base.d.ts +14 -0
  39. package/dist/core/viewport/features/collection.d.ts +41 -0
  40. package/dist/core/viewport/features/events.d.ts +13 -0
  41. package/{src/core/viewport/features/index.ts → dist/core/viewport/features/index.d.ts} +0 -7
  42. package/dist/core/viewport/features/item-size.d.ts +30 -0
  43. package/dist/core/viewport/features/loading.d.ts +34 -0
  44. package/dist/core/viewport/features/momentum.d.ts +17 -0
  45. package/dist/core/viewport/features/performance.d.ts +53 -0
  46. package/dist/core/viewport/features/placeholders.d.ts +38 -0
  47. package/dist/core/viewport/features/rendering.d.ts +16 -0
  48. package/dist/core/viewport/features/scrollbar.d.ts +26 -0
  49. package/dist/core/viewport/features/scrolling.d.ts +16 -0
  50. package/dist/core/viewport/features/utils.d.ts +43 -0
  51. package/dist/core/viewport/features/virtual.d.ts +18 -0
  52. package/{src/core/viewport/index.ts → dist/core/viewport/index.d.ts} +1 -17
  53. package/dist/core/viewport/types.d.ts +96 -0
  54. package/dist/core/viewport/utils/speed-tracker.d.ts +22 -0
  55. package/dist/core/viewport/viewport.d.ts +11 -0
  56. package/{src/index.ts → dist/index.d.ts} +0 -4
  57. package/dist/index.js +5143 -0
  58. package/dist/index.mjs +5111 -0
  59. package/dist/styles.css +254 -0
  60. package/dist/styles.css.map +1 -0
  61. package/package.json +5 -1
  62. package/.cursorrules +0 -117
  63. package/AI.md +0 -39
  64. package/CLAUDE.md +0 -882
  65. package/build.js +0 -377
  66. package/scripts/analyze-orphaned-functions.ts +0 -387
  67. package/scripts/debug/vlist-selection.ts +0 -121
  68. package/src/components/vlist/config.ts +0 -323
  69. package/src/components/vlist/features/api.ts +0 -626
  70. package/src/components/vlist/features/selection.ts +0 -436
  71. package/src/components/vlist/features/viewport.ts +0 -59
  72. package/src/components/vlist/features.ts +0 -112
  73. package/src/components/vlist/types.ts +0 -723
  74. package/src/components/vlist/vlist.ts +0 -92
  75. package/src/core/compose/features/gestures/index.ts +0 -227
  76. package/src/core/compose/features/gestures/longpress.ts +0 -383
  77. package/src/core/compose/features/gestures/pan.ts +0 -424
  78. package/src/core/compose/features/gestures/pinch.ts +0 -475
  79. package/src/core/compose/features/gestures/rotate.ts +0 -485
  80. package/src/core/compose/features/gestures/swipe.ts +0 -492
  81. package/src/core/compose/features/gestures/tap.ts +0 -334
  82. package/src/core/gestures/longpress.ts +0 -68
  83. package/src/core/gestures/manager.ts +0 -418
  84. package/src/core/gestures/pan.ts +0 -48
  85. package/src/core/gestures/pinch.ts +0 -58
  86. package/src/core/gestures/rotate.ts +0 -58
  87. package/src/core/gestures/swipe.ts +0 -66
  88. package/src/core/gestures/tap.ts +0 -45
  89. package/src/core/gestures/types.ts +0 -387
  90. package/src/core/gestures/utils.ts +0 -128
  91. package/src/core/index.ts +0 -43
  92. package/src/core/layout/config.ts +0 -102
  93. package/src/core/layout/index.ts +0 -168
  94. package/src/core/layout/jsx.ts +0 -174
  95. package/src/core/layout/schema.ts +0 -1044
  96. package/src/core/layout/types.ts +0 -95
  97. package/src/core/viewport/constants.ts +0 -145
  98. package/src/core/viewport/features/base.ts +0 -73
  99. package/src/core/viewport/features/collection.ts +0 -1182
  100. package/src/core/viewport/features/events.ts +0 -130
  101. package/src/core/viewport/features/item-size.ts +0 -271
  102. package/src/core/viewport/features/loading.ts +0 -263
  103. package/src/core/viewport/features/momentum.ts +0 -269
  104. package/src/core/viewport/features/performance.ts +0 -161
  105. package/src/core/viewport/features/placeholders.ts +0 -335
  106. package/src/core/viewport/features/rendering.ts +0 -962
  107. package/src/core/viewport/features/scrollbar.ts +0 -434
  108. package/src/core/viewport/features/scrolling.ts +0 -634
  109. package/src/core/viewport/features/utils.ts +0 -94
  110. package/src/core/viewport/features/virtual.ts +0 -525
  111. package/src/core/viewport/types.ts +0 -133
  112. package/src/core/viewport/utils/speed-tracker.ts +0 -79
  113. package/src/core/viewport/viewport.ts +0 -265
  114. package/test/benchmarks/layout/advanced.test.ts +0 -656
  115. package/test/benchmarks/layout/comparison.test.ts +0 -519
  116. package/test/benchmarks/layout/performance-comparison.test.ts +0 -274
  117. package/test/benchmarks/layout/real-components.test.ts +0 -733
  118. package/test/benchmarks/layout/simple.test.ts +0 -321
  119. package/test/benchmarks/layout/stress.test.ts +0 -990
  120. package/test/collection/basic.test.ts +0 -304
  121. package/test/components/vlist-selection.test.ts +0 -240
  122. package/test/components/vlist.test.ts +0 -63
  123. package/test/core/collection/adapter.test.ts +0 -161
  124. package/test/core/collection/collection.test.ts +0 -394
  125. package/test/core/layout/layout.test.ts +0 -201
  126. package/test/utils/dom-helpers.ts +0 -275
  127. package/test/utils/performance-helpers.ts +0 -392
  128. package/tsconfig.json +0 -20
package/build.js DELETED
@@ -1,377 +0,0 @@
1
- // build.js
2
- import { mkdir } from "fs/promises";
3
- import { existsSync } from "fs";
4
- import { join, dirname, extname } from "path";
5
- import { fileURLToPath } from "url";
6
- import { watch } from "fs";
7
-
8
- const __dirname = dirname(fileURLToPath(import.meta.url));
9
- const isWatch = process.argv.includes("--watch");
10
- const isProduction =
11
- process.argv.includes("--production") ||
12
- process.env.NODE_ENV === "production";
13
-
14
- // Define consistent output paths
15
- const DIST_DIR = join(__dirname, "dist");
16
- const JS_OUTPUT = join(DIST_DIR, "index.js");
17
- const MJS_OUTPUT = join(DIST_DIR, "index.mjs");
18
- const CSS_OUTPUT = join(DIST_DIR, "styles.css");
19
- const STYLES_ENTRY = join(__dirname, "src/styles/index.scss");
20
-
21
- // Log build mode
22
- console.log(`Building in ${isProduction ? "PRODUCTION" : "DEVELOPMENT"} mode`);
23
-
24
- const buildStyles = async () => {
25
- console.log("┌─────────────────────────────────────────");
26
- console.log("│ SCSS Build");
27
- console.log("│ Mode:", isProduction ? "PRODUCTION" : "DEVELOPMENT");
28
- console.log("└─────────────────────────────────────────");
29
-
30
- try {
31
- // Check if source file exists
32
- if (!existsSync(STYLES_ENTRY)) {
33
- console.log("⚠️ No SCSS entry found at", STYLES_ENTRY);
34
- return true; // Not an error, just no styles to build
35
- }
36
-
37
- // Build sass arguments
38
- const sassArgs = [
39
- "sass",
40
- STYLES_ENTRY,
41
- CSS_OUTPUT,
42
- isProduction ? "--style=compressed" : "--style=expanded",
43
- ];
44
-
45
- // Add source map in development
46
- if (!isProduction) {
47
- sassArgs.push("--source-map");
48
- } else {
49
- sassArgs.push("--no-source-map");
50
- }
51
-
52
- const sassProcess = Bun.spawn(["npx", ...sassArgs], {
53
- cwd: __dirname,
54
- stdio: ["inherit", "pipe", "pipe"],
55
- });
56
-
57
- const stdout = await new Response(sassProcess.stdout).text();
58
- const stderr = await new Response(sassProcess.stderr).text();
59
- const exitCode = await sassProcess.exited;
60
-
61
- if (exitCode !== 0) {
62
- console.error("❌ SCSS build failed");
63
- if (stdout.trim()) console.error("STDOUT:", stdout);
64
- if (stderr.trim()) console.error("STDERR:", stderr);
65
- return false;
66
- }
67
-
68
- // Get file size
69
- const cssSize = existsSync(CSS_OUTPUT)
70
- ? (await Bun.file(CSS_OUTPUT).size) / 1024
71
- : 0;
72
-
73
- console.log("✓ SCSS build successful");
74
- console.log(` CSS bundle: ${cssSize.toFixed(2)} KB`);
75
-
76
- return true;
77
- } catch (error) {
78
- console.error("❌ SCSS build error:", error.message);
79
-
80
- // Check if sass is available
81
- try {
82
- const checkSass = Bun.spawn(["npx", "sass", "--version"], {
83
- stdio: ["inherit", "pipe", "pipe"],
84
- });
85
- const versionExitCode = await checkSass.exited;
86
-
87
- if (versionExitCode !== 0) {
88
- console.error("💡 Sass compiler not found. Install it with:");
89
- console.error(" npm install -D sass");
90
- console.error(" or");
91
- console.error(" bun add -D sass");
92
- }
93
- } catch {
94
- console.error("💡 Sass compiler not found. Install it with:");
95
- console.error(" npm install -D sass");
96
- console.error(" or");
97
- console.error(" bun add -D sass");
98
- }
99
-
100
- return false;
101
- }
102
- };
103
-
104
- const buildApp = async () => {
105
- try {
106
- console.log("┌─────────────────────────────────────────");
107
- console.log("│ JavaScript Build");
108
- console.log("│ Mode:", isProduction ? "PRODUCTION" : "DEVELOPMENT");
109
- console.log("│ Minify:", isProduction ? "Yes" : "No");
110
- console.log("│ Sourcemaps:", isProduction ? "No" : "Yes (inline)");
111
- console.log("└─────────────────────────────────────────");
112
-
113
- // Create dist directory if it doesn't exist
114
- await mkdir(DIST_DIR, { recursive: true });
115
-
116
- // Build CJS version
117
- const cjsResult = await Bun.build({
118
- entrypoints: [join(__dirname, "src/index.ts")],
119
- outdir: DIST_DIR,
120
- minify: isProduction,
121
- sourcemap: isProduction ? "none" : "inline",
122
- format: "cjs",
123
- target: "node",
124
- external: ["mtrl"],
125
- });
126
-
127
- // Build ESM version
128
- const esmResult = await Bun.build({
129
- entrypoints: [join(__dirname, "src/index.ts")],
130
- outdir: DIST_DIR,
131
- minify: isProduction,
132
- sourcemap: isProduction ? "none" : "inline",
133
- format: "esm",
134
- target: "node",
135
- naming: {
136
- entry: "index.mjs",
137
- },
138
- external: ["mtrl"],
139
- });
140
-
141
- if (!cjsResult.success || !esmResult.success) {
142
- console.error("❌ JavaScript build failed");
143
- console.error(cjsResult.logs);
144
- console.error(esmResult.logs);
145
- return false;
146
- }
147
-
148
- console.log("✓ JavaScript build successful");
149
- console.log(
150
- ` CJS bundle: ${((await Bun.file(JS_OUTPUT).size) / 1024).toFixed(2)} KB`,
151
- );
152
- console.log(
153
- ` ESM bundle: ${((await Bun.file(MJS_OUTPUT).size) / 1024).toFixed(
154
- 2,
155
- )} KB`,
156
- );
157
-
158
- // Generate type definitions with better error handling
159
- console.log("Generating TypeScript declarations...");
160
-
161
- try {
162
- const tscProcess = Bun.spawn(
163
- ["tsc", "--emitDeclarationOnly", "--outDir", DIST_DIR],
164
- {
165
- cwd: __dirname,
166
- stdio: ["inherit", "pipe", "pipe"],
167
- },
168
- );
169
-
170
- // Capture stdout and stderr
171
- const stdout = await new Response(tscProcess.stdout).text();
172
- const stderr = await new Response(tscProcess.stderr).text();
173
-
174
- const tscExitCode = await tscProcess.exited;
175
-
176
- if (tscExitCode !== 0) {
177
- console.warn(
178
- "⚠️ TypeScript declaration generation had errors (non-blocking)",
179
- );
180
- if (stdout.trim()) {
181
- console.warn(
182
- "STDOUT:",
183
- stdout.slice(0, 500) + (stdout.length > 500 ? "..." : ""),
184
- );
185
- }
186
- if (stderr.trim()) {
187
- console.warn(
188
- "STDERR:",
189
- stderr.slice(0, 500) + (stderr.length > 500 ? "..." : ""),
190
- );
191
- }
192
-
193
- // Check if tsc is available
194
- const whichResult = Bun.spawn(["which", "tsc"], {
195
- stdio: ["inherit", "pipe", "pipe"],
196
- });
197
- const tscPath = await new Response(whichResult.stdout).text();
198
- if (!tscPath.trim()) {
199
- console.error(
200
- "💡 TypeScript compiler (tsc) not found. Install it with:",
201
- );
202
- console.error(" npm install -g typescript");
203
- console.error(" or");
204
- console.error(" bun add -g typescript");
205
- }
206
-
207
- // Continue build despite tsc errors (JS bundles are still valid)
208
- return true;
209
- }
210
-
211
- console.log("✓ TypeScript declarations generated");
212
- if (stdout.trim()) {
213
- console.log("TSC output:", stdout);
214
- }
215
-
216
- return true;
217
- } catch (tscError) {
218
- console.warn("⚠️ Error running TypeScript compiler:", tscError.message);
219
-
220
- // Check if TypeScript is installed
221
- try {
222
- const checkTsc = Bun.spawn(["tsc", "--version"], {
223
- stdio: ["inherit", "pipe", "pipe"],
224
- });
225
- const versionOutput = await new Response(checkTsc.stdout).text();
226
- const versionExitCode = await checkTsc.exited;
227
-
228
- if (versionExitCode === 0) {
229
- console.log("TypeScript version:", versionOutput.trim());
230
- } else {
231
- console.warn(
232
- "💡 TypeScript compiler not properly installed. Install with:",
233
- );
234
- console.warn(" npm install -g typescript");
235
- console.warn(" or");
236
- console.warn(" bun add -g typescript");
237
- }
238
- } catch (versionError) {
239
- console.warn("💡 TypeScript compiler not found. Install it with:");
240
- console.warn(" npm install -g typescript");
241
- console.warn(" or");
242
- console.warn(" bun add -g typescript");
243
- }
244
-
245
- // Continue build despite tsc errors (JS bundles are still valid)
246
- return true;
247
- }
248
- } catch (error) {
249
- console.error("❌ JavaScript build error:", error);
250
- console.error(error.stack);
251
- return false;
252
- }
253
- };
254
-
255
- const buildAll = async () => {
256
- const jsSuccess = await buildApp();
257
- const cssSuccess = await buildStyles();
258
- return jsSuccess && cssSuccess;
259
- };
260
-
261
- const build = async () => {
262
- try {
263
- const startTime = Date.now();
264
-
265
- console.log("┌───────────────────────────────────────────────");
266
- console.log("│ 🚀 MTRL-Addons Build Process");
267
- console.log("│ Mode:", isProduction ? "🏭 PRODUCTION" : "🔧 DEVELOPMENT");
268
- console.log("│ Watch:", isWatch ? "✓ Enabled" : "✗ Disabled");
269
- console.log("└───────────────────────────────────────────────");
270
- console.log("");
271
-
272
- // Create output directory
273
- await mkdir(DIST_DIR, { recursive: true });
274
-
275
- // Build JavaScript and CSS
276
- const buildSuccess = await buildAll();
277
-
278
- const buildTime = ((Date.now() - startTime) / 1000).toFixed(2);
279
-
280
- if (isWatch && !isProduction) {
281
- console.log("");
282
- console.log("┌───────────────────────────────────────────────");
283
- console.log("│ 👀 Watching for changes...");
284
- console.log("└───────────────────────────────────────────────");
285
-
286
- // Watch src directory for changes
287
- const srcDir = join(__dirname, "src");
288
- let debounceTimer = null;
289
- let isBuilding = false;
290
-
291
- const rebuild = async (changedFile) => {
292
- if (isBuilding) return;
293
- isBuilding = true;
294
-
295
- const ext = changedFile ? extname(changedFile) : "";
296
- const isStyleChange = [".scss", ".css"].includes(ext);
297
- const isJsChange = [".ts", ".tsx"].includes(ext);
298
-
299
- console.log("");
300
- console.log("┌───────────────────────────────────────────────");
301
- console.log(
302
- `│ 🔄 Change detected${changedFile ? ` (${changedFile})` : ""}, rebuilding...`,
303
- );
304
- console.log("└───────────────────────────────────────────────");
305
-
306
- const rebuildStart = Date.now();
307
- let success;
308
-
309
- // Selective rebuild based on file type
310
- if (isStyleChange) {
311
- success = await buildStyles();
312
- } else if (isJsChange) {
313
- success = await buildApp();
314
- } else {
315
- success = await buildAll();
316
- }
317
-
318
- const rebuildTime = ((Date.now() - rebuildStart) / 1000).toFixed(2);
319
-
320
- console.log("");
321
- console.log(
322
- `│ ${success ? "✅" : "⚠️"} Rebuild completed in ${rebuildTime}s`,
323
- );
324
- console.log("│ 👀 Watching for changes...");
325
- console.log("└───────────────────────────────────────────────");
326
-
327
- isBuilding = false;
328
- };
329
-
330
- const watchHandler = (eventType, filename) => {
331
- if (!filename) return;
332
-
333
- // Only watch .ts, .tsx, .scss and .css files
334
- const ext = extname(filename);
335
- if (![".ts", ".tsx", ".scss", ".css"].includes(ext)) return;
336
-
337
- // Debounce rapid changes
338
- if (debounceTimer) clearTimeout(debounceTimer);
339
- debounceTimer = setTimeout(() => {
340
- rebuild(filename);
341
- }, 100);
342
- };
343
-
344
- // Watch recursively using fs.watch
345
- const watchDir = (dir) => {
346
- watch(dir, { recursive: true }, watchHandler);
347
- };
348
-
349
- watchDir(srcDir);
350
- console.log(`│ Watching: ${srcDir}`);
351
-
352
- // Keep process alive
353
- process.on("SIGINT", () => {
354
- console.log("\n│ 👋 Stopping watch mode...");
355
- process.exit(0);
356
- });
357
- } else {
358
- console.log("");
359
- console.log("┌───────────────────────────────────────────────");
360
- console.log(`│ ✅ Build completed in ${buildTime}s`);
361
- if (!buildSuccess) {
362
- console.log("│ ⚠️ Build completed with some errors");
363
- }
364
- console.log("└───────────────────────────────────────────────");
365
-
366
- // Only exit with error code in non-watch mode if there were failures
367
- if (!isWatch && !buildSuccess) {
368
- process.exit(1);
369
- }
370
- }
371
- } catch (error) {
372
- console.error("❌ Build failed with error:", error);
373
- process.exit(1);
374
- }
375
- };
376
-
377
- build();