@askrjs/askr 0.0.29 → 0.0.31

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 (68) hide show
  1. package/README.md +21 -3
  2. package/dist/benchmark.js +2 -2
  3. package/dist/common/vnode.d.ts +1 -0
  4. package/dist/common/vnode.d.ts.map +1 -1
  5. package/dist/common/vnode.js +2 -1
  6. package/dist/common/vnode.js.map +1 -1
  7. package/dist/components/error-boundary.d.ts +25 -0
  8. package/dist/components/error-boundary.d.ts.map +1 -0
  9. package/dist/components/error-boundary.js +114 -0
  10. package/dist/components/error-boundary.js.map +1 -0
  11. package/dist/foundations/core.d.ts +15 -0
  12. package/dist/foundations/core.js +13 -0
  13. package/dist/foundations/index.d.ts +16 -3
  14. package/dist/foundations/index.js +14 -1
  15. package/dist/foundations/interactions/dismissable.d.ts +66 -0
  16. package/dist/foundations/interactions/dismissable.d.ts.map +1 -0
  17. package/dist/foundations/interactions/dismissable.js +26 -0
  18. package/dist/foundations/interactions/dismissable.js.map +1 -0
  19. package/dist/foundations/interactions/focusable.d.ts +22 -0
  20. package/dist/foundations/interactions/focusable.d.ts.map +1 -0
  21. package/dist/foundations/interactions/focusable.js +18 -0
  22. package/dist/foundations/interactions/focusable.js.map +1 -0
  23. package/dist/foundations/interactions/hoverable.d.ts +26 -0
  24. package/dist/foundations/interactions/hoverable.d.ts.map +1 -0
  25. package/dist/foundations/interactions/hoverable.js +15 -0
  26. package/dist/foundations/interactions/hoverable.js.map +1 -0
  27. package/dist/foundations/interactions/interaction-policy.d.ts +50 -0
  28. package/dist/foundations/interactions/interaction-policy.d.ts.map +1 -0
  29. package/dist/foundations/interactions/interaction-policy.js +33 -4
  30. package/dist/foundations/interactions/interaction-policy.js.map +1 -1
  31. package/dist/foundations/interactions/pressable.d.ts +61 -0
  32. package/dist/foundations/interactions/pressable.d.ts.map +1 -0
  33. package/dist/foundations/interactions/roving-focus.d.ts +52 -0
  34. package/dist/foundations/interactions/roving-focus.d.ts.map +1 -0
  35. package/dist/foundations/interactions/roving-focus.js +71 -0
  36. package/dist/foundations/interactions/roving-focus.js.map +1 -0
  37. package/dist/foundations/state/controllable.d.ts +34 -0
  38. package/dist/foundations/state/controllable.d.ts.map +1 -0
  39. package/dist/foundations/state/controllable.js +81 -0
  40. package/dist/foundations/state/controllable.js.map +1 -0
  41. package/dist/foundations/utilities/aria.d.ts +16 -0
  42. package/dist/foundations/utilities/aria.d.ts.map +1 -0
  43. package/dist/foundations/utilities/aria.js +7 -1
  44. package/dist/foundations/utilities/aria.js.map +1 -1
  45. package/dist/foundations/utilities/compose-handlers.d.ts +37 -0
  46. package/dist/foundations/utilities/compose-handlers.d.ts.map +1 -0
  47. package/dist/foundations/utilities/compose-ref.d.ts +1 -1
  48. package/dist/foundations/utilities/compose-ref.js +1 -1
  49. package/dist/foundations/utilities/event-types.d.ts +20 -0
  50. package/dist/foundations/utilities/event-types.d.ts.map +1 -0
  51. package/dist/foundations/utilities/merge-props.d.ts +5 -0
  52. package/dist/foundations/utilities/merge-props.d.ts.map +1 -0
  53. package/dist/foundations/utilities/use-id.d.ts +32 -0
  54. package/dist/foundations/utilities/use-id.d.ts.map +1 -0
  55. package/dist/foundations/utilities/use-id.js +29 -0
  56. package/dist/foundations/utilities/use-id.js.map +1 -0
  57. package/dist/index.d.ts +3 -2
  58. package/dist/index.js +2 -1
  59. package/dist/index.js.map +1 -1
  60. package/dist/renderer/dom.js +23 -1
  61. package/dist/renderer/dom.js.map +1 -1
  62. package/dist/runtime/component.d.ts +5 -0
  63. package/dist/runtime/component.d.ts.map +1 -1
  64. package/dist/runtime/component.js.map +1 -1
  65. package/dist/ssr/index.d.ts.map +1 -1
  66. package/dist/ssr/index.js +166 -0
  67. package/dist/ssr/index.js.map +1 -1
  68. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -9,13 +9,14 @@ import { HistoryScrollBehavior, NavigateOptions, NavigationScrollBehavior, Scrol
9
9
  import { HydrateSPAConfig, IslandConfig, IslandsConfig, SPAConfig, cleanupApp, createIsland, createIslands, createSPA, hasApp, hydrateSPA } from "./boot/index.js";
10
10
  import { Show, ShowProps } from "./control/show.js";
11
11
  import { Case, CaseProps, Match, MatchProps } from "./control/case.js";
12
+ import { jsx, jsxs } from "./jsx-runtime.js";
12
13
  import { Slot, SlotProps } from "./foundations/structures/slot.js";
13
14
  import { DefaultPortal, Portal, PortalProps, definePortal } from "./foundations/structures/portal.js";
14
- import { jsx, jsxs } from "./jsx-runtime.js";
15
15
  import { Derived, derive } from "./runtime/derive.js";
16
16
  import { Selector, selector } from "./runtime/selector.js";
17
17
  import { ResourceResult, resource } from "./runtime/operations.js";
18
18
  import { currentRoute, fallback, group, lazy, registerRoutes, resolveRouteRequest, route } from "./router/route.js";
19
19
  import { allow, deny, forbidden, notFound, redirect, requireAuth, requirePermission, requireRole, unauthorized } from "./router/policy.js";
20
20
  import { Link, LinkProps } from "./components/link.js";
21
- export { type AccessDecision, type AccessDenyDecision, type AccessRedirectDecision, Case, type CaseProps, type Context, DefaultPortal, type Derived, For, type ForProps, Fragment, type GroupHelperOptions, type HistoryScrollBehavior, type HydrateSPAConfig, type IslandConfig, type IslandsConfig, Link, type LinkProps, Match, type MatchProps, type NavigateOptions, type NavigationScrollBehavior, Portal, type PortalProps, type Props, type RegisterRoutesOptions, type ResourceResult, type RouteAuthMode, type RouteAuthOptions, type RouteAuthResolver, type RouteAuthState, type RouteComponent, type RouteContext, type RouteDefinition, type RouteManifest, type RouteMatch, type RouteMode, type RouteOptions, type RoutePolicy, type RouteRecord, type RouteRenderResult, type RouteRequestOptions, type RouteRequestResult, type RouteSnapshot, type SPAConfig, type ScrollRestorationOptions, type Selector, Show, type ShowProps, Slot, type SlotProps, type State, allow, cleanupApp, createIsland, createIslands, createSPA, currentRoute, defineContext, definePortal, deny, derive, fallback, forbidden, getSignal, group, hasApp, hydrateSPA, jsx, jsxs, lazy, navigate, notFound, readContext, redirect, registerRoutes, requireAuth, requirePermission, requireRole, resolveRouteRequest, resource, route, selector, state, unauthorized };
21
+ import { ErrorBoundary, ErrorBoundaryFallbackRender, ErrorBoundaryProps } from "./components/error-boundary.js";
22
+ export { type AccessDecision, type AccessDenyDecision, type AccessRedirectDecision, Case, type CaseProps, type Context, DefaultPortal, type Derived, ErrorBoundary, type ErrorBoundaryFallbackRender, type ErrorBoundaryProps, For, type ForProps, Fragment, type GroupHelperOptions, type HistoryScrollBehavior, type HydrateSPAConfig, type IslandConfig, type IslandsConfig, Link, type LinkProps, Match, type MatchProps, type NavigateOptions, type NavigationScrollBehavior, Portal, type PortalProps, type Props, type RegisterRoutesOptions, type ResourceResult, type RouteAuthMode, type RouteAuthOptions, type RouteAuthResolver, type RouteAuthState, type RouteComponent, type RouteContext, type RouteDefinition, type RouteManifest, type RouteMatch, type RouteMode, type RouteOptions, type RoutePolicy, type RouteRecord, type RouteRenderResult, type RouteRequestOptions, type RouteRequestResult, type RouteSnapshot, type SPAConfig, type ScrollRestorationOptions, type Selector, Show, type ShowProps, Slot, type SlotProps, type State, allow, cleanupApp, createIsland, createIslands, createSPA, currentRoute, defineContext, definePortal, deny, derive, fallback, forbidden, getSignal, group, hasApp, hydrateSPA, jsx, jsxs, lazy, navigate, notFound, readContext, redirect, registerRoutes, requireAuth, requirePermission, requireRole, resolveRouteRequest, resource, route, selector, state, unauthorized };
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { Fragment } from "./common/jsx.js";
2
2
  import { defineContext, readContext } from "./runtime/context.js";
3
3
  import { getSignal } from "./runtime/component.js";
4
4
  import { jsx, jsxs } from "./jsx-runtime.js";
5
+ import { ErrorBoundary } from "./components/error-boundary.js";
5
6
  import { installRendererBridge } from "./renderer/index.js";
6
7
  import { state } from "./runtime/state.js";
7
8
  import { derive } from "./runtime/derive.js";
@@ -29,6 +30,6 @@ import "./foundations/structures.js";
29
30
  */
30
31
  installRendererBridge();
31
32
  //#endregion
32
- export { Case, DefaultPortal, For, Fragment, Link, Match, Portal, Show, Slot, allow, cleanupApp, createIsland, createIslands, createSPA, currentRoute, defineContext, definePortal, deny, derive, fallback, forbidden, getSignal, group, hasApp, hydrateSPA, jsx, jsxs, lazy, navigate, notFound, readContext, redirect, registerRoutes, requireAuth, requirePermission, requireRole, resolveRouteRequest, resource, route, selector, state, unauthorized };
33
+ export { Case, DefaultPortal, ErrorBoundary, For, Fragment, Link, Match, Portal, Show, Slot, allow, cleanupApp, createIsland, createIslands, createSPA, currentRoute, defineContext, definePortal, deny, derive, fallback, forbidden, getSignal, group, hasApp, hydrateSPA, jsx, jsxs, lazy, navigate, notFound, readContext, redirect, registerRoutes, requireAuth, requirePermission, requireRole, resolveRouteRequest, resource, route, selector, state, unauthorized };
33
34
 
34
35
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Askr: Actor-backed deterministic UI framework\n *\n * Public API surface — only users should import from here\n */\n\nimport { installRendererBridge } from './renderer';\n\ninstallRendererBridge();\n\n// Runtime primitives\nexport { state } from './runtime/state';\nexport type { State } from './runtime/state';\nexport { derive } from './runtime/derive';\nexport type { Derived } from './runtime/derive';\nexport { getSignal } from './runtime/component';\nexport { selector } from './runtime/selector';\nexport type { Selector } from './runtime/selector';\n\n// Context\nexport { defineContext, readContext } from './runtime/context';\nexport type { Context } from './runtime/context';\n\n// Resources\nexport { resource } from './runtime/operations';\nexport type { ResourceResult } from './runtime/operations';\n\n// App bootstrap\nexport {\n createIsland,\n createIslands,\n createSPA,\n hydrateSPA,\n cleanupApp,\n hasApp,\n} from './boot';\nexport type {\n IslandConfig,\n IslandsConfig,\n SPAConfig,\n HydrateSPAConfig,\n} from './boot';\n\n// Routing\nexport {\n registerRoutes,\n route,\n currentRoute,\n group,\n fallback,\n lazy,\n allow,\n redirect,\n deny,\n unauthorized,\n forbidden,\n notFound,\n requireAuth,\n requireRole,\n requirePermission,\n resolveRouteRequest,\n type RouteSnapshot,\n type RouteMatch,\n type RouteComponent,\n type RouteMode,\n type RouteAuthMode,\n type RouteContext,\n type RoutePolicy,\n type RouteOptions,\n type RouteRecord,\n type RouteManifest,\n type AccessDecision,\n type AccessDenyDecision,\n type AccessRedirectDecision,\n type GroupHelperOptions,\n type RegisterRoutesOptions,\n type RouteDefinition,\n type RouteAuthOptions,\n type RouteAuthResolver,\n type RouteAuthState,\n type RouteRenderResult,\n type RouteRequestOptions,\n type RouteRequestResult,\n} from './router';\nexport { navigate } from './router/navigate';\nexport type {\n NavigateOptions,\n NavigationScrollBehavior,\n HistoryScrollBehavior,\n ScrollRestorationOptions,\n} from './router/navigate';\n\n// Components\nexport { Link } from './components/link';\nexport type { LinkProps } from './components/link';\nexport { Case, For, Match, Show } from './control';\nexport type { CaseProps, ForProps, MatchProps, ShowProps } from './control';\nexport {\n Slot,\n definePortal,\n DefaultPortal,\n Portal,\n} from './foundations/structures';\nexport type { SlotProps, PortalProps } from './foundations/structures';\n\n// Re-export JSX runtime for tsconfig jsxImportSource\nexport { jsx, jsxs, Fragment } from './jsx-runtime';\n\n// Public types\nexport type { Props } from './common/props';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,uBAAuB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Askr: Actor-backed deterministic UI framework\n *\n * Public API surface — only users should import from here\n */\n\nimport { installRendererBridge } from './renderer';\n\ninstallRendererBridge();\n\n// Runtime primitives\nexport { state } from './runtime/state';\nexport type { State } from './runtime/state';\nexport { derive } from './runtime/derive';\nexport type { Derived } from './runtime/derive';\nexport { getSignal } from './runtime/component';\nexport { selector } from './runtime/selector';\nexport type { Selector } from './runtime/selector';\n\n// Context\nexport { defineContext, readContext } from './runtime/context';\nexport type { Context } from './runtime/context';\n\n// Resources\nexport { resource } from './runtime/operations';\nexport type { ResourceResult } from './runtime/operations';\n\n// App bootstrap\nexport {\n createIsland,\n createIslands,\n createSPA,\n hydrateSPA,\n cleanupApp,\n hasApp,\n} from './boot';\nexport type {\n IslandConfig,\n IslandsConfig,\n SPAConfig,\n HydrateSPAConfig,\n} from './boot';\n\n// Routing\nexport {\n registerRoutes,\n route,\n currentRoute,\n group,\n fallback,\n lazy,\n allow,\n redirect,\n deny,\n unauthorized,\n forbidden,\n notFound,\n requireAuth,\n requireRole,\n requirePermission,\n resolveRouteRequest,\n type RouteSnapshot,\n type RouteMatch,\n type RouteComponent,\n type RouteMode,\n type RouteAuthMode,\n type RouteContext,\n type RoutePolicy,\n type RouteOptions,\n type RouteRecord,\n type RouteManifest,\n type AccessDecision,\n type AccessDenyDecision,\n type AccessRedirectDecision,\n type GroupHelperOptions,\n type RegisterRoutesOptions,\n type RouteDefinition,\n type RouteAuthOptions,\n type RouteAuthResolver,\n type RouteAuthState,\n type RouteRenderResult,\n type RouteRequestOptions,\n type RouteRequestResult,\n} from './router';\nexport { navigate } from './router/navigate';\nexport type {\n NavigateOptions,\n NavigationScrollBehavior,\n HistoryScrollBehavior,\n ScrollRestorationOptions,\n} from './router/navigate';\n\n// Components\nexport { Link } from './components/link';\nexport type { LinkProps } from './components/link';\nexport { ErrorBoundary } from './components/error-boundary';\nexport type {\n ErrorBoundaryProps,\n ErrorBoundaryFallbackRender,\n} from './components/error-boundary';\nexport { Case, For, Match, Show } from './control';\nexport type { CaseProps, ForProps, MatchProps, ShowProps } from './control';\nexport {\n Slot,\n definePortal,\n DefaultPortal,\n Portal,\n} from './foundations/structures';\nexport type { SlotProps, PortalProps } from './foundations/structures';\n\n// Re-export JSX runtime for tsconfig jsxImportSource\nexport { jsx, jsxs, Fragment } from './jsx-runtime';\n\n// Public types\nexport type { Props } from './common/props';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,uBAAuB"}
@@ -1,4 +1,4 @@
1
- import { __FOR_BOUNDARY__, _isDOMElement } from "../common/vnode.js";
1
+ import { __ERROR_BOUNDARY__, __FOR_BOUNDARY__, _isDOMElement } from "../common/vnode.js";
2
2
  import "./types.js";
3
3
  import { getRuntimeEnv } from "../common/env.js";
4
4
  import { logger } from "../dev/logger.js";
@@ -21,6 +21,7 @@ import { clearCaseDomUpdateState, clearShowDomUpdateState, evaluateCaseState, ev
21
21
  import { reconcileKeyedChildren } from "./reconcile.js";
22
22
  import { isBulkTextFastPathEligible, performBulkTextReplace } from "./children.js";
23
23
  import { createFineGrainedEffect, markFineGrainedEffectsDirtySource } from "../runtime/effect.js";
24
+ import { createBoundaryReset, reportBoundaryError, resolveErrorBoundaryFallback } from "../components/error-boundary.js";
24
25
  //#region src/renderer/dom.ts
25
26
  const reactivePropRegistry = /* @__PURE__ */ new Set();
26
27
  const controlBoundaryOwners = /* @__PURE__ */ new WeakMap();
@@ -1085,6 +1086,7 @@ function createDOMNode(node, parentNamespace) {
1085
1086
  if (typeof type === "string") return createIntrinsicElement(node, type, props, parentNamespace);
1086
1087
  if (typeof type === "function") return createComponentElement(node, type, props, parentNamespace);
1087
1088
  if (type === __FOR_BOUNDARY__) return createForBoundary(node, props, parentNamespace);
1089
+ if (type === __ERROR_BOUNDARY__) return createErrorBoundaryElement(node, props, parentNamespace);
1088
1090
  if (typeof type === "symbol" && (type === Fragment || String(type) === "Symbol(Fragment)")) return createFragmentElement(node, props, parentNamespace);
1089
1091
  }
1090
1092
  return null;
@@ -1486,6 +1488,26 @@ function createForBoundary(node, props, parentNamespace) {
1486
1488
  clearControlBoundaryDomUpdateState(controlState);
1487
1489
  return fragment;
1488
1490
  }
1491
+ function createErrorBoundaryElement(node, props, parentNamespace) {
1492
+ const boundaryState = node.__instance?.errorBoundaryState ?? null;
1493
+ const reset = node.__instance ? createBoundaryReset(node.__instance) : () => {};
1494
+ const fallback = props.fallback;
1495
+ const children = props.children;
1496
+ if (boundaryState?.error != null) {
1497
+ const fallbackValue = resolveErrorBoundaryFallback(fallback, boundaryState.error, reset);
1498
+ if (fallbackValue instanceof Node) return fallbackValue;
1499
+ return createDOMNode(fallbackValue, parentNamespace) ?? document.createComment("");
1500
+ }
1501
+ try {
1502
+ return createDOMNode(children, parentNamespace) ?? document.createComment("");
1503
+ } catch (error) {
1504
+ if (node.__instance) reportBoundaryError(node.__instance, error, props.onError);
1505
+ else logger.error("[Askr] ErrorBoundary caught render error:", error);
1506
+ const fallbackValue = resolveErrorBoundaryFallback(fallback, error, reset);
1507
+ if (fallbackValue instanceof Node) return fallbackValue;
1508
+ return createDOMNode(fallbackValue, parentNamespace) ?? document.createComment("");
1509
+ }
1510
+ }
1489
1511
  function syncForItemDom(parent, scope, vnode) {
1490
1512
  let dom = scope.dom ?? null;
1491
1513
  const parentNamespace = parent.namespaceURI === SVG_NAMESPACE ? SVG_NAMESPACE : void 0;