@getforma/core 1.1.0 → 1.3.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.
- package/dist/{chunk-MIOMT2CB.js → chunk-AJP4OVCN.js} +29 -9
- package/dist/chunk-AJP4OVCN.js.map +1 -0
- package/dist/{chunk-XLVBYXOU.js → chunk-ETPJTPYD.js} +6 -3
- package/dist/chunk-ETPJTPYD.js.map +1 -0
- package/dist/{chunk-JRQNDXX7.cjs → chunk-FBM7V4NE.cjs} +68 -47
- package/dist/chunk-FBM7V4NE.cjs.map +1 -0
- package/dist/{chunk-W7OUWVRA.cjs → chunk-H7MDUHS5.cjs} +6 -2
- package/dist/chunk-H7MDUHS5.cjs.map +1 -0
- package/dist/{chunk-2Y5US35K.cjs → chunk-KUXNZ5MG.cjs} +12 -12
- package/dist/{chunk-2Y5US35K.cjs.map → chunk-KUXNZ5MG.cjs.map} +1 -1
- package/dist/{chunk-INNOI6TG.js → chunk-Y3A2EVVS.js} +3 -3
- package/dist/{chunk-INNOI6TG.js.map → chunk-Y3A2EVVS.js.map} +1 -1
- package/dist/forma-runtime-csp.js +178 -79
- package/dist/forma-runtime.js +178 -79
- package/dist/formajs-runtime-hardened.global.js +178 -79
- package/dist/formajs-runtime-hardened.global.js.map +1 -1
- package/dist/formajs-runtime.global.js +178 -79
- package/dist/formajs-runtime.global.js.map +1 -1
- package/dist/formajs.global.js +245 -61
- package/dist/formajs.global.js.map +1 -1
- package/dist/http.cjs +11 -11
- package/dist/http.js +2 -2
- package/dist/index.cjs +307 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.js +248 -88
- package/dist/index.js.map +1 -1
- package/dist/runtime-hardened.cjs +178 -79
- package/dist/runtime-hardened.cjs.map +1 -1
- package/dist/runtime-hardened.js +178 -79
- package/dist/runtime-hardened.js.map +1 -1
- package/dist/runtime.cjs +198 -103
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +174 -79
- package/dist/runtime.js.map +1 -1
- package/dist/server.cjs +7 -7
- package/dist/server.js +2 -2
- package/dist/tc39-compat.cjs +3 -3
- package/dist/tc39-compat.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-JRQNDXX7.cjs.map +0 -1
- package/dist/chunk-MIOMT2CB.js.map +0 -1
- package/dist/chunk-W7OUWVRA.cjs.map +0 -1
- package/dist/chunk-XLVBYXOU.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -334,6 +334,19 @@ declare function onError(handler: ErrorHandler): () => void;
|
|
|
334
334
|
declare const Fragment: (props: {
|
|
335
335
|
children?: unknown;
|
|
336
336
|
}) => DocumentFragment;
|
|
337
|
+
/**
|
|
338
|
+
* Run `build()` with the SVG namespace active so nested `h()` calls create
|
|
339
|
+
* SVG-namespaced elements — including dual-use tags like `<a>` that `h()` would
|
|
340
|
+
* otherwise create as HTML. `h()` resolves tags by this explicit context (there
|
|
341
|
+
* is no automatic parent-walk); a `foreignObject` creates the SVG element but
|
|
342
|
+
* does not auto-switch its descendants back to HTML (author those with plain
|
|
343
|
+
* `h()` outside `svg()`). MathML is not supported.
|
|
344
|
+
*
|
|
345
|
+
* ```ts
|
|
346
|
+
* const icon = svg(() => h('svg', { viewBox: '0 0 10 10' }, h('a', { href: '#' })));
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function svg<T extends Node>(build: () => T): T;
|
|
337
350
|
/**
|
|
338
351
|
* Remove all event listeners previously attached via `h()` on the given element.
|
|
339
352
|
*
|
|
@@ -943,6 +956,8 @@ interface HistoryControls<T> {
|
|
|
943
956
|
cursor: () => number;
|
|
944
957
|
/** Clear all history, keeping only the current value. */
|
|
945
958
|
clear: () => void;
|
|
959
|
+
/** Stop tracking the source signal and release the history stack. */
|
|
960
|
+
destroy: () => void;
|
|
946
961
|
}
|
|
947
962
|
/**
|
|
948
963
|
* Create undo/redo history tracking for a signal.
|
|
@@ -957,6 +972,13 @@ interface HistoryControls<T> {
|
|
|
957
972
|
* h.redo(); // count() === 2
|
|
958
973
|
* h.canUndo(); // true (reactive)
|
|
959
974
|
* ```
|
|
975
|
+
*
|
|
976
|
+
* **Limitation:** the source must be a signal whose getter returns a stable
|
|
977
|
+
* value (a primitive or a stable object reference). A `createStore` slice whose
|
|
978
|
+
* getter returns a *fresh proxy on every read* is not supported: the undo/redo
|
|
979
|
+
* echo guard compares by identity, so a new proxy each read makes every
|
|
980
|
+
* undo/redo look like an external change and clears the redo history. Track
|
|
981
|
+
* store state with `setState`/direct mutation, not `createHistory`.
|
|
960
982
|
*/
|
|
961
983
|
declare function createHistory<T>(source: [get: () => T, set: (v: T) => void], options?: {
|
|
962
984
|
maxLength?: number;
|
|
@@ -969,6 +991,8 @@ declare function createHistory<T>(source: [get: () => T, set: (v: T) => void], o
|
|
|
969
991
|
* Reads stored value on creation; writes on every signal change.
|
|
970
992
|
* Zero dependencies -- native browser APIs only.
|
|
971
993
|
*/
|
|
994
|
+
/** The phase in which a persist operation failed, passed to {@link PersistOptions.onError}. */
|
|
995
|
+
type PersistErrorPhase = 'hydrate' | 'serialize' | 'write' | 'migrate';
|
|
972
996
|
/** Options for {@link persist} — storage backend, serialization, and validation. */
|
|
973
997
|
interface PersistOptions<T> {
|
|
974
998
|
/** Storage backend. Defaults to localStorage. */
|
|
@@ -979,6 +1003,14 @@ interface PersistOptions<T> {
|
|
|
979
1003
|
deserialize?: (s: string) => T;
|
|
980
1004
|
/** Optional validator — return true if the deserialized value is valid. Rejects corrupt/tampered data. */
|
|
981
1005
|
validate?: (v: unknown) => v is T;
|
|
1006
|
+
/** Current schema version. When set, values are stored in a versioned envelope. */
|
|
1007
|
+
version?: number;
|
|
1008
|
+
/** Migrate stored data whose version is older than {@link version}. Runs before validate. */
|
|
1009
|
+
migrate?: (oldValue: unknown, oldVersion: number) => T;
|
|
1010
|
+
/** Re-hydrate when another tab writes this key. Defaults to true for localStorage. */
|
|
1011
|
+
syncTabs?: boolean;
|
|
1012
|
+
/** Report hydrate/serialize/write/migrate failures instead of swallowing them. */
|
|
1013
|
+
onError?: (err: unknown, phase: PersistErrorPhase) => void;
|
|
982
1014
|
}
|
|
983
1015
|
/**
|
|
984
1016
|
* Persist a signal's value to storage.
|
|
@@ -993,7 +1025,7 @@ interface PersistOptions<T> {
|
|
|
993
1025
|
* setTheme('dark'); // auto-saved to localStorage under key 'app:theme'
|
|
994
1026
|
* ```
|
|
995
1027
|
*/
|
|
996
|
-
declare function persist<T>(source: [get: () => T, set: (v: T) => void], key: string, options?: PersistOptions<T>): void;
|
|
1028
|
+
declare function persist<T>(source: [get: () => T, set: (v: T) => void], key: string, options?: PersistOptions<T>): () => void;
|
|
997
1029
|
|
|
998
1030
|
/**
|
|
999
1031
|
* A typed publish/subscribe event bus.
|
|
@@ -1156,4 +1188,4 @@ declare function onIntersect(el: HTMLElement, handler: (entry: IntersectionObser
|
|
|
1156
1188
|
*/
|
|
1157
1189
|
declare function onMutation(el: HTMLElement, handler: (mutations: MutationRecord[]) => void, options?: MutationObserverInit): () => void;
|
|
1158
1190
|
|
|
1159
|
-
export { $, $$, type CleanupFn, type ComponentDef, type Context, type CreateListOptions, type Dispatch, type ErrorHandler, type EventBus, Fragment, type HistoryControls, type IslandHydrateFn, type KeyOptions, type ListTransitionHooks, type PersistOptions, type ReconcileResult, type Ref, type SetupFn, SignalGetter, type StoreSetter, type SwitchCase, activateIslands, addClass, batch, children, cleanup, closest, createBus, createComputed, createContext, createEffect, createErrorBoundary, createHistory, createList, createMemo, createPortal, createReducer, createRef, createRoot, createShow, createStore, createSuspense, createSwitch, createText, createUnownedRoot, deactivateAllIslands, deactivateIsland, defineComponent, delegate, disposeComponent, fragment, h, hydrateIsland, inject, mount, nextSibling, on, onCleanup, onError, onIntersect, onKey, onMount, onMutation, onResize, onUnmount, parent, persist, prevSibling, provide, reconcileList, removeClass, setAttr, setHTMLUnsafe, setStyle, setText, siblings, template, templateMany, toggleClass, trackDisposer, unprovide, untrack };
|
|
1191
|
+
export { $, $$, type CleanupFn, type ComponentDef, type Context, type CreateListOptions, type Dispatch, type ErrorHandler, type EventBus, Fragment, type HistoryControls, type IslandHydrateFn, type KeyOptions, type ListTransitionHooks, type PersistErrorPhase, type PersistOptions, type ReconcileResult, type Ref, type SetupFn, SignalGetter, type StoreSetter, type SwitchCase, activateIslands, addClass, batch, children, cleanup, closest, createBus, createComputed, createContext, createEffect, createErrorBoundary, createHistory, createList, createMemo, createPortal, createReducer, createRef, createRoot, createShow, createStore, createSuspense, createSwitch, createText, createUnownedRoot, deactivateAllIslands, deactivateIsland, defineComponent, delegate, disposeComponent, fragment, h, hydrateIsland, inject, mount, nextSibling, on, onCleanup, onError, onIntersect, onKey, onMount, onMutation, onResize, onUnmount, parent, persist, prevSibling, provide, reconcileList, removeClass, setAttr, setHTMLUnsafe, setStyle, setText, siblings, svg, template, templateMany, toggleClass, trackDisposer, unprovide, untrack };
|
package/dist/index.d.ts
CHANGED
|
@@ -334,6 +334,19 @@ declare function onError(handler: ErrorHandler): () => void;
|
|
|
334
334
|
declare const Fragment: (props: {
|
|
335
335
|
children?: unknown;
|
|
336
336
|
}) => DocumentFragment;
|
|
337
|
+
/**
|
|
338
|
+
* Run `build()` with the SVG namespace active so nested `h()` calls create
|
|
339
|
+
* SVG-namespaced elements — including dual-use tags like `<a>` that `h()` would
|
|
340
|
+
* otherwise create as HTML. `h()` resolves tags by this explicit context (there
|
|
341
|
+
* is no automatic parent-walk); a `foreignObject` creates the SVG element but
|
|
342
|
+
* does not auto-switch its descendants back to HTML (author those with plain
|
|
343
|
+
* `h()` outside `svg()`). MathML is not supported.
|
|
344
|
+
*
|
|
345
|
+
* ```ts
|
|
346
|
+
* const icon = svg(() => h('svg', { viewBox: '0 0 10 10' }, h('a', { href: '#' })));
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function svg<T extends Node>(build: () => T): T;
|
|
337
350
|
/**
|
|
338
351
|
* Remove all event listeners previously attached via `h()` on the given element.
|
|
339
352
|
*
|
|
@@ -943,6 +956,8 @@ interface HistoryControls<T> {
|
|
|
943
956
|
cursor: () => number;
|
|
944
957
|
/** Clear all history, keeping only the current value. */
|
|
945
958
|
clear: () => void;
|
|
959
|
+
/** Stop tracking the source signal and release the history stack. */
|
|
960
|
+
destroy: () => void;
|
|
946
961
|
}
|
|
947
962
|
/**
|
|
948
963
|
* Create undo/redo history tracking for a signal.
|
|
@@ -957,6 +972,13 @@ interface HistoryControls<T> {
|
|
|
957
972
|
* h.redo(); // count() === 2
|
|
958
973
|
* h.canUndo(); // true (reactive)
|
|
959
974
|
* ```
|
|
975
|
+
*
|
|
976
|
+
* **Limitation:** the source must be a signal whose getter returns a stable
|
|
977
|
+
* value (a primitive or a stable object reference). A `createStore` slice whose
|
|
978
|
+
* getter returns a *fresh proxy on every read* is not supported: the undo/redo
|
|
979
|
+
* echo guard compares by identity, so a new proxy each read makes every
|
|
980
|
+
* undo/redo look like an external change and clears the redo history. Track
|
|
981
|
+
* store state with `setState`/direct mutation, not `createHistory`.
|
|
960
982
|
*/
|
|
961
983
|
declare function createHistory<T>(source: [get: () => T, set: (v: T) => void], options?: {
|
|
962
984
|
maxLength?: number;
|
|
@@ -969,6 +991,8 @@ declare function createHistory<T>(source: [get: () => T, set: (v: T) => void], o
|
|
|
969
991
|
* Reads stored value on creation; writes on every signal change.
|
|
970
992
|
* Zero dependencies -- native browser APIs only.
|
|
971
993
|
*/
|
|
994
|
+
/** The phase in which a persist operation failed, passed to {@link PersistOptions.onError}. */
|
|
995
|
+
type PersistErrorPhase = 'hydrate' | 'serialize' | 'write' | 'migrate';
|
|
972
996
|
/** Options for {@link persist} — storage backend, serialization, and validation. */
|
|
973
997
|
interface PersistOptions<T> {
|
|
974
998
|
/** Storage backend. Defaults to localStorage. */
|
|
@@ -979,6 +1003,14 @@ interface PersistOptions<T> {
|
|
|
979
1003
|
deserialize?: (s: string) => T;
|
|
980
1004
|
/** Optional validator — return true if the deserialized value is valid. Rejects corrupt/tampered data. */
|
|
981
1005
|
validate?: (v: unknown) => v is T;
|
|
1006
|
+
/** Current schema version. When set, values are stored in a versioned envelope. */
|
|
1007
|
+
version?: number;
|
|
1008
|
+
/** Migrate stored data whose version is older than {@link version}. Runs before validate. */
|
|
1009
|
+
migrate?: (oldValue: unknown, oldVersion: number) => T;
|
|
1010
|
+
/** Re-hydrate when another tab writes this key. Defaults to true for localStorage. */
|
|
1011
|
+
syncTabs?: boolean;
|
|
1012
|
+
/** Report hydrate/serialize/write/migrate failures instead of swallowing them. */
|
|
1013
|
+
onError?: (err: unknown, phase: PersistErrorPhase) => void;
|
|
982
1014
|
}
|
|
983
1015
|
/**
|
|
984
1016
|
* Persist a signal's value to storage.
|
|
@@ -993,7 +1025,7 @@ interface PersistOptions<T> {
|
|
|
993
1025
|
* setTheme('dark'); // auto-saved to localStorage under key 'app:theme'
|
|
994
1026
|
* ```
|
|
995
1027
|
*/
|
|
996
|
-
declare function persist<T>(source: [get: () => T, set: (v: T) => void], key: string, options?: PersistOptions<T>): void;
|
|
1028
|
+
declare function persist<T>(source: [get: () => T, set: (v: T) => void], key: string, options?: PersistOptions<T>): () => void;
|
|
997
1029
|
|
|
998
1030
|
/**
|
|
999
1031
|
* A typed publish/subscribe event bus.
|
|
@@ -1156,4 +1188,4 @@ declare function onIntersect(el: HTMLElement, handler: (entry: IntersectionObser
|
|
|
1156
1188
|
*/
|
|
1157
1189
|
declare function onMutation(el: HTMLElement, handler: (mutations: MutationRecord[]) => void, options?: MutationObserverInit): () => void;
|
|
1158
1190
|
|
|
1159
|
-
export { $, $$, type CleanupFn, type ComponentDef, type Context, type CreateListOptions, type Dispatch, type ErrorHandler, type EventBus, Fragment, type HistoryControls, type IslandHydrateFn, type KeyOptions, type ListTransitionHooks, type PersistOptions, type ReconcileResult, type Ref, type SetupFn, SignalGetter, type StoreSetter, type SwitchCase, activateIslands, addClass, batch, children, cleanup, closest, createBus, createComputed, createContext, createEffect, createErrorBoundary, createHistory, createList, createMemo, createPortal, createReducer, createRef, createRoot, createShow, createStore, createSuspense, createSwitch, createText, createUnownedRoot, deactivateAllIslands, deactivateIsland, defineComponent, delegate, disposeComponent, fragment, h, hydrateIsland, inject, mount, nextSibling, on, onCleanup, onError, onIntersect, onKey, onMount, onMutation, onResize, onUnmount, parent, persist, prevSibling, provide, reconcileList, removeClass, setAttr, setHTMLUnsafe, setStyle, setText, siblings, template, templateMany, toggleClass, trackDisposer, unprovide, untrack };
|
|
1191
|
+
export { $, $$, type CleanupFn, type ComponentDef, type Context, type CreateListOptions, type Dispatch, type ErrorHandler, type EventBus, Fragment, type HistoryControls, type IslandHydrateFn, type KeyOptions, type ListTransitionHooks, type PersistErrorPhase, type PersistOptions, type ReconcileResult, type Ref, type SetupFn, SignalGetter, type StoreSetter, type SwitchCase, activateIslands, addClass, batch, children, cleanup, closest, createBus, createComputed, createContext, createEffect, createErrorBoundary, createHistory, createList, createMemo, createPortal, createReducer, createRef, createRoot, createShow, createStore, createSuspense, createSwitch, createText, createUnownedRoot, deactivateAllIslands, deactivateIsland, defineComponent, delegate, disposeComponent, fragment, h, hydrateIsland, inject, mount, nextSibling, on, onCleanup, onError, onIntersect, onKey, onMount, onMutation, onResize, onUnmount, parent, persist, prevSibling, provide, reconcileList, removeClass, setAttr, setHTMLUnsafe, setStyle, setText, siblings, svg, template, templateMany, toggleClass, trackDisposer, unprovide, untrack };
|