@getforma/core 0.1.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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -0
  3. package/dist/chunk-27QSSN4E.cjs +1773 -0
  4. package/dist/chunk-27QSSN4E.cjs.map +1 -0
  5. package/dist/chunk-DB2ULMOM.js +1750 -0
  6. package/dist/chunk-DB2ULMOM.js.map +1 -0
  7. package/dist/chunk-FPSLC62A.cjs +31 -0
  8. package/dist/chunk-FPSLC62A.cjs.map +1 -0
  9. package/dist/chunk-KX5WRZH7.js +27 -0
  10. package/dist/chunk-KX5WRZH7.js.map +1 -0
  11. package/dist/formajs-runtime-hardened.global.js +2 -0
  12. package/dist/formajs-runtime-hardened.global.js.map +1 -0
  13. package/dist/formajs-runtime.global.js +2 -0
  14. package/dist/formajs-runtime.global.js.map +1 -0
  15. package/dist/formajs.global.js +2 -0
  16. package/dist/formajs.global.js.map +1 -0
  17. package/dist/index.cjs +1626 -0
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.cts +1382 -0
  20. package/dist/index.d.ts +1382 -0
  21. package/dist/index.js +1482 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/runtime-hardened.cjs +2805 -0
  24. package/dist/runtime-hardened.cjs.map +1 -0
  25. package/dist/runtime-hardened.js +2786 -0
  26. package/dist/runtime-hardened.js.map +1 -0
  27. package/dist/runtime.cjs +2531 -0
  28. package/dist/runtime.cjs.map +1 -0
  29. package/dist/runtime.d.cts +86 -0
  30. package/dist/runtime.d.ts +86 -0
  31. package/dist/runtime.js +2512 -0
  32. package/dist/runtime.js.map +1 -0
  33. package/dist/signal-CfLDwMyg.d.cts +29 -0
  34. package/dist/signal-CfLDwMyg.d.ts +29 -0
  35. package/dist/ssr/index.cjs +381 -0
  36. package/dist/ssr/index.cjs.map +1 -0
  37. package/dist/ssr/index.d.cts +154 -0
  38. package/dist/ssr/index.d.ts +154 -0
  39. package/dist/ssr/index.js +371 -0
  40. package/dist/ssr/index.js.map +1 -0
  41. package/dist/tc39-compat.cjs +45 -0
  42. package/dist/tc39-compat.cjs.map +1 -0
  43. package/dist/tc39-compat.d.cts +50 -0
  44. package/dist/tc39-compat.d.ts +50 -0
  45. package/dist/tc39-compat.js +42 -0
  46. package/dist/tc39-compat.js.map +1 -0
  47. package/package.json +122 -0
@@ -0,0 +1,86 @@
1
+ type UnsafeEvalMode = 'mutable' | 'locked-off' | 'locked-on';
2
+ interface RuntimeDiagnostic {
3
+ kind: 'handler-unsupported' | 'expression-unsupported';
4
+ expr: string;
5
+ reason: string;
6
+ count: number;
7
+ firstSeenAt: number;
8
+ lastSeenAt: number;
9
+ }
10
+ /** Yield control to keep the main thread responsive during large batches. */
11
+ declare function yieldToMain(): Promise<void>;
12
+ interface ContainmentHintsOptions {
13
+ selector?: string;
14
+ contain?: string;
15
+ contentVisibility?: string;
16
+ containIntrinsicSize?: string;
17
+ skipIfAlreadySet?: boolean;
18
+ }
19
+ /** Apply CSS containment hints to opt-in containers for lower layout/paint cost. */
20
+ declare function applyContainmentHints(root?: ParentNode, options?: ContainmentHintsOptions): number;
21
+ /**
22
+ * Load a pre-compiled directive map from the server.
23
+ * Keys are data-forma-id values, values are arrays of directive attribute names.
24
+ */
25
+ declare function setDirectiveMap(map: Record<string, string[]> | null): void;
26
+ declare function initRuntime(): void;
27
+ /** Dispose all FormaJS scopes — clears effects, intervals, event listeners, and stops the observer. */
28
+ declare function destroyRuntime(): void;
29
+ /**
30
+ * Mount a specific element or subtree — scans for `data-forma-state`
31
+ * elements and initializes their reactive bindings.
32
+ *
33
+ * Use this for manual control when injecting HTML dynamically.
34
+ * With the MutationObserver active, this is usually not needed.
35
+ *
36
+ * @param el - The root element to scan (checks itself and all descendants).
37
+ */
38
+ declare function mount(el: Element): void;
39
+ /**
40
+ * Unmount a specific element or subtree — disposes all reactive bindings
41
+ * for `data-forma-state` elements within.
42
+ *
43
+ * @param el - The root element to clean up (checks itself and all descendants).
44
+ */
45
+ declare function unmount(el: Element): void;
46
+ /** Enable/disable debug logging. Also toggleable via window.__FORMA_DEBUG = true */
47
+ declare function setDebug(on: boolean): void;
48
+ /** Set unsafe-eval mode. `locked-off` is hardened and non-toggleable via setUnsafeEval. */
49
+ declare function setUnsafeEvalMode(mode: UnsafeEvalMode): void;
50
+ /** Enable/disable unsafe `new Function` fallback for complex expressions. */
51
+ declare function setUnsafeEval(on: boolean): void;
52
+ /** Get current unsafe-eval policy mode. */
53
+ declare function getUnsafeEvalMode(): UnsafeEvalMode;
54
+ /** Enable/disable runtime diagnostics for unsupported expressions/handlers. */
55
+ declare function setDiagnostics(on: boolean): void;
56
+ /** Runtime diagnostics captured while parsing/binding templates. */
57
+ declare function getDiagnostics(): RuntimeDiagnostic[];
58
+ /** Clear runtime diagnostics collected so far. */
59
+ declare function clearDiagnostics(): void;
60
+ interface ScopeDescriptor {
61
+ element: Element;
62
+ id: string;
63
+ values: Record<string, {
64
+ value: unknown;
65
+ type: string;
66
+ }>;
67
+ initialJSON: string;
68
+ }
69
+ /**
70
+ * DevTools: enumerate all active scopes and their current signal values.
71
+ * Only called when the State Inspector panel is open — zero overhead otherwise.
72
+ */
73
+ declare function getScopes(): ScopeDescriptor[];
74
+ /**
75
+ * DevTools: set a state value on a specific scope element.
76
+ * Triggers normal reactive effects (data-show, data-text, etc.).
77
+ */
78
+ declare function setScopeValue(element: Element, key: string, value: unknown): void;
79
+ /**
80
+ * DevTools: reset all values on a scope to their initial JSON state.
81
+ */
82
+ declare function resetScope(element: Element): void;
83
+ /** Reconcile a container's DOM against a new HTML string. */
84
+ declare function reconcile(container: Element, html: string): void;
85
+
86
+ export { applyContainmentHints, clearDiagnostics, destroyRuntime, getDiagnostics, getScopes, getUnsafeEvalMode, initRuntime, mount, reconcile, resetScope, setDebug, setDiagnostics, setDirectiveMap, setScopeValue, setUnsafeEval, setUnsafeEvalMode, unmount, yieldToMain };