sibujs 1.2.0 → 1.4.0

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 (95) hide show
  1. package/README.md +29 -25
  2. package/dist/browser.cjs +804 -2
  3. package/dist/browser.d.cts +591 -1
  4. package/dist/browser.d.ts +591 -1
  5. package/dist/browser.js +50 -8
  6. package/dist/build.cjs +655 -237
  7. package/dist/build.js +15 -93
  8. package/dist/cdn.global.js +188 -7
  9. package/dist/chunk-2BYQDGN3.js +742 -0
  10. package/dist/chunk-32DY64NT.js +282 -0
  11. package/dist/chunk-3AIRKM3B.js +1263 -0
  12. package/dist/chunk-3X2YG6YM.js +505 -0
  13. package/dist/chunk-5X6PP2UK.js +28 -0
  14. package/dist/chunk-77L6NL3X.js +1097 -0
  15. package/dist/chunk-BGN5ZMP4.js +26 -0
  16. package/dist/chunk-BTU3TJDS.js +365 -0
  17. package/dist/chunk-CHF5OHIA.js +61 -0
  18. package/dist/chunk-CMBFNA7L.js +27 -0
  19. package/dist/chunk-CNZ35WI2.js +178 -0
  20. package/dist/chunk-DAHRH4ON.js +331 -0
  21. package/dist/chunk-EBGIRKQY.js +616 -0
  22. package/dist/chunk-EUZND3CB.js +27 -0
  23. package/dist/chunk-F3FA4F32.js +292 -0
  24. package/dist/chunk-JAKHTMQU.js +1000 -0
  25. package/dist/chunk-JCI5M6U6.js +956 -0
  26. package/dist/chunk-KQPDEVVS.js +398 -0
  27. package/dist/chunk-M4NLBH4I.js +725 -0
  28. package/dist/chunk-NEKUBFPT.js +60 -0
  29. package/dist/chunk-NYVAC6P5.js +37 -0
  30. package/dist/chunk-PTQJDMRT.js +146 -0
  31. package/dist/chunk-QWZG56ET.js +2744 -0
  32. package/dist/chunk-TSOKIX5Z.js +654 -0
  33. package/dist/chunk-UHNL42EF.js +2730 -0
  34. package/dist/chunk-VRW3FULF.js +725 -0
  35. package/dist/chunk-WZSPOOER.js +84 -0
  36. package/dist/chunk-YT6HQ6AM.js +14 -0
  37. package/dist/chunk-ZD6OAMTH.js +277 -0
  38. package/dist/chunk-ZWKZCBO6.js +317 -0
  39. package/dist/contracts-DDrwxvJ-.d.cts +245 -0
  40. package/dist/contracts-DDrwxvJ-.d.ts +245 -0
  41. package/dist/contracts-xo5ckdRP.d.cts +240 -0
  42. package/dist/contracts-xo5ckdRP.d.ts +240 -0
  43. package/dist/data.cjs +35 -2
  44. package/dist/data.d.cts +7 -0
  45. package/dist/data.d.ts +7 -0
  46. package/dist/data.js +9 -8
  47. package/dist/devtools.cjs +122 -0
  48. package/dist/devtools.d.cts +69 -461
  49. package/dist/devtools.d.ts +69 -461
  50. package/dist/devtools.js +127 -6
  51. package/dist/ecosystem.cjs +23 -6
  52. package/dist/ecosystem.d.cts +1 -1
  53. package/dist/ecosystem.d.ts +1 -1
  54. package/dist/ecosystem.js +10 -9
  55. package/dist/extras.cjs +1208 -88
  56. package/dist/extras.d.cts +6 -6
  57. package/dist/extras.d.ts +6 -6
  58. package/dist/extras.js +70 -33
  59. package/dist/index.cjs +663 -158
  60. package/dist/index.d.cts +398 -40
  61. package/dist/index.d.ts +398 -40
  62. package/dist/index.js +39 -21
  63. package/dist/introspect-BumjnBKr.d.cts +477 -0
  64. package/dist/introspect-CZrlcaYy.d.ts +477 -0
  65. package/dist/introspect-Cb0zgpi2.d.cts +477 -0
  66. package/dist/introspect-Y2xNXGSf.d.ts +477 -0
  67. package/dist/motion.js +4 -4
  68. package/dist/patterns.cjs +51 -24
  69. package/dist/patterns.d.cts +19 -57
  70. package/dist/patterns.d.ts +19 -57
  71. package/dist/patterns.js +8 -16
  72. package/dist/performance.js +4 -4
  73. package/dist/plugins.cjs +429 -82
  74. package/dist/plugins.d.cts +27 -4
  75. package/dist/plugins.d.ts +27 -4
  76. package/dist/plugins.js +156 -37
  77. package/dist/ssr-4PBXAOO3.js +40 -0
  78. package/dist/ssr-Do_SiVoL.d.cts +201 -0
  79. package/dist/ssr-Do_SiVoL.d.ts +201 -0
  80. package/dist/ssr.cjs +312 -60
  81. package/dist/ssr.d.cts +10 -1
  82. package/dist/ssr.d.ts +10 -1
  83. package/dist/ssr.js +13 -10
  84. package/dist/tagFactory-DaJ0YWX6.d.cts +47 -0
  85. package/dist/tagFactory-DaJ0YWX6.d.ts +47 -0
  86. package/dist/testing.cjs +233 -2
  87. package/dist/testing.d.cts +42 -1
  88. package/dist/testing.d.ts +42 -1
  89. package/dist/testing.js +129 -2
  90. package/dist/ui.cjs +374 -8
  91. package/dist/ui.d.cts +252 -2
  92. package/dist/ui.d.ts +252 -2
  93. package/dist/ui.js +329 -11
  94. package/dist/widgets.js +7 -7
  95. package/package.json +1 -1
package/dist/devtools.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var devtools_exports = {};
22
22
  __export(devtools_exports, {
23
23
  SibuError: () => SibuError,
24
+ captureSignalGraph: () => captureSignalGraph,
24
25
  checkLeaks: () => checkLeaks,
25
26
  clearDebugValues: () => clearDebugValues,
26
27
  clearHMRState: () => clearHMRState,
@@ -29,9 +30,11 @@ __export(devtools_exports, {
29
30
  createErrorReporter: () => createErrorReporter,
30
31
  createHMRBoundary: () => createHMRBoundary,
31
32
  createProfiler: () => createProfiler,
33
+ createTraceProfiler: () => createTraceProfiler,
32
34
  debugLog: () => debugLog,
33
35
  debugValue: () => debugValue,
34
36
  devState: () => devState,
37
+ diffSignalGraphs: () => diffSignalGraphs,
35
38
  disableDebug: () => disableDebug,
36
39
  enableDebug: () => enableDebug,
37
40
  formatError: () => formatError,
@@ -1411,9 +1414,126 @@ function walkDependencyGraph(getter, maxDepth = 10) {
1411
1414
  downstream
1412
1415
  };
1413
1416
  }
1417
+
1418
+ // src/devtools/signalGraph.ts
1419
+ function getHook() {
1420
+ if (!isDev()) return null;
1421
+ const g = globalThis;
1422
+ return g.__SIBU_DEVTOOLS_GLOBAL_HOOK__ ?? null;
1423
+ }
1424
+ function captureSignalGraph() {
1425
+ const hook = getHook();
1426
+ if (!hook || typeof hook.getSignalNodes !== "function") {
1427
+ return { capturedAt: Date.now(), nodes: [], edgeCount: 0 };
1428
+ }
1429
+ const nodes = [];
1430
+ let edgeCount = 0;
1431
+ for (const n of hook.getSignalNodes()) {
1432
+ nodes.push({
1433
+ id: n.id,
1434
+ name: n.name,
1435
+ kind: n.kind,
1436
+ value: n.value,
1437
+ subscribers: [...n.subscribers],
1438
+ dependencies: [...n.dependencies],
1439
+ evalCount: n.evalCount
1440
+ });
1441
+ edgeCount += n.dependencies.length;
1442
+ }
1443
+ return { capturedAt: Date.now(), nodes, edgeCount };
1444
+ }
1445
+ function diffSignalGraphs(before, after) {
1446
+ const beforeById = new Map(before.nodes.map((n) => [n.id, n]));
1447
+ const afterById = new Map(after.nodes.map((n) => [n.id, n]));
1448
+ const added = [];
1449
+ const removed = [];
1450
+ const reevaluated = [];
1451
+ for (const [id, node] of afterById) {
1452
+ if (!beforeById.has(id)) {
1453
+ added.push(node);
1454
+ continue;
1455
+ }
1456
+ const prev = beforeById.get(id);
1457
+ if (prev && prev.evalCount !== node.evalCount) reevaluated.push(node);
1458
+ }
1459
+ for (const [id, node] of beforeById) {
1460
+ if (!afterById.has(id)) removed.push(node);
1461
+ }
1462
+ return { added, removed, reevaluated };
1463
+ }
1464
+ function createTraceProfiler() {
1465
+ const events = [];
1466
+ const hook = getHook();
1467
+ if (!hook) {
1468
+ return {
1469
+ stop: () => events,
1470
+ stopTrace: () => JSON.stringify({ traceEvents: events }),
1471
+ isRecording: () => false
1472
+ };
1473
+ }
1474
+ const start = typeof performance !== "undefined" ? performance.now() : Date.now();
1475
+ let recording = true;
1476
+ const onEffectStart = (payload) => {
1477
+ if (!recording) return;
1478
+ const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
1479
+ const label = payload.name ?? "effect";
1480
+ events.push({
1481
+ name: label,
1482
+ cat: "effect",
1483
+ ph: "B",
1484
+ ts: Math.floor(now * 1e3),
1485
+ tid: 0,
1486
+ pid: 0
1487
+ });
1488
+ };
1489
+ const onEffectEnd = (payload) => {
1490
+ if (!recording) return;
1491
+ const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
1492
+ const label = payload.name ?? "effect";
1493
+ events.push({
1494
+ name: label,
1495
+ cat: "effect",
1496
+ ph: "E",
1497
+ ts: Math.floor(now * 1e3),
1498
+ tid: 0,
1499
+ pid: 0
1500
+ });
1501
+ };
1502
+ const onSignalSet = (payload) => {
1503
+ if (!recording) return;
1504
+ const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
1505
+ const label = payload.name ?? "signal";
1506
+ events.push({
1507
+ name: label,
1508
+ cat: "signal",
1509
+ ph: "I",
1510
+ ts: Math.floor(now * 1e3),
1511
+ tid: 0,
1512
+ pid: 0,
1513
+ args: payload.args
1514
+ });
1515
+ };
1516
+ const offStart = hook.on("effect:start", onEffectStart);
1517
+ const offEnd = hook.on("effect:end", onEffectEnd);
1518
+ const offSet = hook.on("signal:set", onSignalSet);
1519
+ function stop() {
1520
+ if (!recording) return events;
1521
+ recording = false;
1522
+ offStart();
1523
+ offEnd();
1524
+ offSet();
1525
+ return events;
1526
+ }
1527
+ function stopTrace() {
1528
+ stop();
1529
+ return JSON.stringify({ traceEvents: events, displayTimeUnit: "ms" });
1530
+ }
1531
+ return { stop, stopTrace, isRecording: () => recording };
1532
+ }
1414
1533
  // Annotate the CommonJS export names for ESM import in node:
1415
1534
  0 && (module.exports = {
1416
1535
  SibuError,
1536
+ captureSignalGraph,
1417
1537
  checkLeaks,
1418
1538
  clearDebugValues,
1419
1539
  clearHMRState,
@@ -1422,9 +1542,11 @@ function walkDependencyGraph(getter, maxDepth = 10) {
1422
1542
  createErrorReporter,
1423
1543
  createHMRBoundary,
1424
1544
  createProfiler,
1545
+ createTraceProfiler,
1425
1546
  debugLog,
1426
1547
  debugValue,
1427
1548
  devState,
1549
+ diffSignalGraphs,
1428
1550
  disableDebug,
1429
1551
  enableDebug,
1430
1552
  formatError,