@reckona/mreact-compat 0.0.159 → 0.0.161

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 (102) hide show
  1. package/dist/class-component.d.ts +5 -0
  2. package/dist/class-component.d.ts.map +1 -1
  3. package/dist/class-component.js +36 -11
  4. package/dist/class-component.js.map +1 -1
  5. package/dist/context.d.ts +4 -0
  6. package/dist/context.d.ts.map +1 -1
  7. package/dist/context.js +4 -0
  8. package/dist/context.js.map +1 -1
  9. package/dist/element.d.ts +28 -0
  10. package/dist/element.d.ts.map +1 -1
  11. package/dist/element.js +21 -1
  12. package/dist/element.js.map +1 -1
  13. package/dist/event-priority.d.ts +1 -0
  14. package/dist/event-priority.d.ts.map +1 -1
  15. package/dist/event-priority.js +1 -0
  16. package/dist/event-priority.js.map +1 -1
  17. package/dist/event-replay.d.ts +6 -0
  18. package/dist/event-replay.d.ts.map +1 -1
  19. package/dist/event-replay.js +4 -0
  20. package/dist/event-replay.js.map +1 -1
  21. package/dist/flight-decoder.d.ts +1 -0
  22. package/dist/flight-decoder.d.ts.map +1 -1
  23. package/dist/flight-decoder.js.map +1 -1
  24. package/dist/flight-protocol.d.ts +2 -0
  25. package/dist/flight-protocol.d.ts.map +1 -1
  26. package/dist/flight-protocol.js +1 -0
  27. package/dist/flight-protocol.js.map +1 -1
  28. package/dist/flight-types.d.ts +21 -0
  29. package/dist/flight-types.d.ts.map +1 -1
  30. package/dist/flight-types.js.map +1 -1
  31. package/dist/flight.d.ts +7 -0
  32. package/dist/flight.d.ts.map +1 -1
  33. package/dist/flight.js +5 -0
  34. package/dist/flight.js.map +1 -1
  35. package/dist/hooks-entry.d.ts +2 -0
  36. package/dist/hooks-entry.d.ts.map +1 -1
  37. package/dist/hooks-entry.js +1 -0
  38. package/dist/hooks-entry.js.map +1 -1
  39. package/dist/hooks.d.ts +36 -0
  40. package/dist/hooks.d.ts.map +1 -1
  41. package/dist/hooks.js +42 -10
  42. package/dist/hooks.js.map +1 -1
  43. package/dist/host-reconciler.js +30 -30
  44. package/dist/host-reconciler.js.map +1 -1
  45. package/dist/hydration.d.ts +2 -0
  46. package/dist/hydration.d.ts.map +1 -1
  47. package/dist/hydration.js +1 -0
  48. package/dist/hydration.js.map +1 -1
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/internal.d.ts +1 -0
  54. package/dist/internal.d.ts.map +1 -1
  55. package/dist/internal.js +1 -0
  56. package/dist/internal.js.map +1 -1
  57. package/dist/jsx-dev-runtime.d.ts +5 -0
  58. package/dist/jsx-dev-runtime.d.ts.map +1 -1
  59. package/dist/jsx-dev-runtime.js +3 -0
  60. package/dist/jsx-dev-runtime.js.map +1 -1
  61. package/dist/jsx-runtime.d.ts +13 -0
  62. package/dist/jsx-runtime.d.ts.map +1 -1
  63. package/dist/jsx-runtime.js +4 -0
  64. package/dist/jsx-runtime.js.map +1 -1
  65. package/dist/react-default.d.ts +2 -0
  66. package/dist/react-default.d.ts.map +1 -1
  67. package/dist/react-default.js +2 -0
  68. package/dist/react-default.js.map +1 -1
  69. package/dist/root.d.ts +13 -0
  70. package/dist/root.d.ts.map +1 -1
  71. package/dist/root.js +6 -0
  72. package/dist/root.js.map +1 -1
  73. package/dist/scheduler.d.ts +23 -0
  74. package/dist/scheduler.d.ts.map +1 -1
  75. package/dist/scheduler.js +19 -0
  76. package/dist/scheduler.js.map +1 -1
  77. package/dist/server-render.d.ts +1 -0
  78. package/dist/server-render.d.ts.map +1 -1
  79. package/dist/server-render.js +1 -0
  80. package/dist/server-render.js.map +1 -1
  81. package/package.json +3 -3
  82. package/src/class-component.ts +47 -11
  83. package/src/context.ts +4 -0
  84. package/src/element.ts +33 -6
  85. package/src/event-priority.ts +1 -0
  86. package/src/event-replay.ts +6 -0
  87. package/src/flight-decoder.ts +1 -0
  88. package/src/flight-protocol.ts +2 -0
  89. package/src/flight-types.ts +21 -0
  90. package/src/flight.ts +7 -0
  91. package/src/hooks-entry.ts +2 -0
  92. package/src/hooks.ts +55 -15
  93. package/src/host-reconciler.ts +39 -38
  94. package/src/hydration.ts +2 -0
  95. package/src/index.ts +3 -0
  96. package/src/internal.ts +1 -0
  97. package/src/jsx-dev-runtime.ts +5 -0
  98. package/src/jsx-runtime.ts +13 -0
  99. package/src/react-default.ts +2 -0
  100. package/src/root.ts +13 -0
  101. package/src/scheduler.ts +23 -0
  102. package/src/server-render.ts +1 -0
package/src/scheduler.ts CHANGED
@@ -14,29 +14,41 @@ import {
14
14
  type SchedulerTask,
15
15
  } from "./fiber-scheduler.js";
16
16
 
17
+ /** Numeric priority level used by the scheduler-compatible API. */
17
18
  export type unstable_PriorityLevel = 1 | 2 | 3 | 4 | 5;
19
+ /** Handle returned by unstable_scheduleCallback. */
18
20
  export type unstable_CallbackNode = SchedulerTask;
21
+ /** Scheduled callback that may return a continuation. */
19
22
  export type unstable_Callback = (
20
23
  didTimeout: boolean,
21
24
  ) => unstable_Callback | null | void;
22
25
 
26
+ /** Highest-priority scheduler task for immediate work. */
23
27
  export const unstable_ImmediatePriority = 1;
28
+ /** Scheduler priority for user-blocking work. */
24
29
  export const unstable_UserBlockingPriority = 2;
30
+ /** Scheduler priority for normal work. */
25
31
  export const unstable_NormalPriority = 3;
32
+ /** Scheduler priority for low-priority work. */
26
33
  export const unstable_LowPriority = 4;
34
+ /** Scheduler priority for idle work. */
27
35
  export const unstable_IdlePriority = 5;
36
+ /** Profiling controls for scheduler-compatible tracing. */
28
37
  export const unstable_Profiling = {
29
38
  startLoggingProfilingEvents: startLoggingSchedulerProfilingEvents,
30
39
  stopLoggingProfilingEvents: stopLoggingSchedulerProfilingEvents,
31
40
  };
41
+ /** Profiling event emitted by scheduler-compatible tracing. */
32
42
  export type unstable_ProfilingEvent = SchedulerProfilingEvent;
33
43
 
34
44
  let currentPriorityLevel: unstable_PriorityLevel = unstable_NormalPriority;
35
45
 
46
+ /** Returns the scheduler clock time in milliseconds. */
36
47
  export function unstable_now(): number {
37
48
  return now();
38
49
  }
39
50
 
51
+ /** Schedules a callback at the requested scheduler priority. */
40
52
  export function unstable_scheduleCallback(
41
53
  priorityLevel: unstable_PriorityLevel,
42
54
  callback: unstable_Callback,
@@ -49,26 +61,32 @@ export function unstable_scheduleCallback(
49
61
  );
50
62
  }
51
63
 
64
+ /** Cancels a scheduled callback node. */
52
65
  export function unstable_cancelCallback(task: unstable_CallbackNode): void {
53
66
  cancelCallback(task);
54
67
  }
55
68
 
69
+ /** Returns true when the current scheduler task should yield to the host. */
56
70
  export function unstable_shouldYield(): boolean {
57
71
  return shouldYieldToHost();
58
72
  }
59
73
 
74
+ /** Requests a paint opportunity from the host scheduler. */
60
75
  export function unstable_requestPaint(): void {
61
76
  requestPaint();
62
77
  }
63
78
 
79
+ /** Sets the target frame rate for scheduler yielding. */
64
80
  export function unstable_forceFrameRate(fps: number): void {
65
81
  forceFrameRate(fps);
66
82
  }
67
83
 
84
+ /** Returns the priority currently active for scheduler-compatible callbacks. */
68
85
  export function unstable_getCurrentPriorityLevel(): unstable_PriorityLevel {
69
86
  return currentPriorityLevel;
70
87
  }
71
88
 
89
+ /** Runs a callback at the requested scheduler priority. */
72
90
  export function unstable_runWithPriority<T>(
73
91
  priorityLevel: unstable_PriorityLevel,
74
92
  callback: () => T,
@@ -76,6 +94,7 @@ export function unstable_runWithPriority<T>(
76
94
  return runWithPriorityLevel(priorityLevel, callback);
77
95
  }
78
96
 
97
+ /** Runs a callback at normal priority when the current priority is higher. */
79
98
  export function unstable_next<T>(callback: () => T): T {
80
99
  const nextPriority =
81
100
  currentPriorityLevel === unstable_ImmediatePriority ||
@@ -85,6 +104,7 @@ export function unstable_next<T>(callback: () => T): T {
85
104
  return runWithPriorityLevel(nextPriority, callback);
86
105
  }
87
106
 
107
+ /** Wraps a callback so it runs later with the current scheduler priority. */
88
108
  export function unstable_wrapCallback<TArgs extends unknown[], TResult>(
89
109
  callback: (...args: TArgs) => TResult,
90
110
  ): (...args: TArgs) => TResult {
@@ -92,14 +112,17 @@ export function unstable_wrapCallback<TArgs extends unknown[], TResult>(
92
112
  return (...args) => runWithPriorityLevel(capturedPriority, () => callback(...args));
93
113
  }
94
114
 
115
+ /** Returns the first pending scheduler callback node, if one exists. */
95
116
  export function unstable_getFirstCallbackNode(): unstable_CallbackNode | null {
96
117
  return getFirstCallbackNode();
97
118
  }
98
119
 
120
+ /** Compatibility no-op for pausing global scheduler execution. */
99
121
  export function unstable_pauseExecution(): void {
100
122
  // React exposes this as an unstable public hook; this scheduler has no global pause state.
101
123
  }
102
124
 
125
+ /** Compatibility no-op for resuming global scheduler execution. */
103
126
  export function unstable_continueExecution(): void {
104
127
  // Host callbacks are requested eagerly by scheduleCallback, so there is no paused queue to resume.
105
128
  }
@@ -34,6 +34,7 @@ import {
34
34
  import { escapeHtmlAttribute as escapeHtml } from "@reckona/mreact-shared/html-escape";
35
35
  import { isVoidHtmlElement } from "@reckona/mreact-shared";
36
36
 
37
+ /** Renders a React-compatible component to an HTML string. */
37
38
  export function renderToString<TProps>(
38
39
  component:
39
40
  | ((props: TProps) => ReactCompatNode)