@alchemy.run/sigil 0.0.0-alpha.10 → 0.0.0-alpha.11

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.
@@ -0,0 +1,2 @@
1
+ import react_default, { Activity, Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, ViewTransition, act, addTransitionType, cache, cacheSignal, captureOwnerStack, cloneElement, createContext, createElement, createRef, forwardRef, isValidElement, lazy, memo, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useEffectEvent, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version } from "react";
2
+ export { Activity, Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, ViewTransition, act, addTransitionType, cache, cacheSignal, captureOwnerStack, cloneElement, createContext, createElement, createRef, react_default as default, forwardRef, isValidElement, lazy, memo, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useEffectEvent, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
package/dist/react.js ADDED
@@ -0,0 +1,49 @@
1
+ import { r as __toESM, t as require_react } from "./react-CTZ_8dwh.js";
2
+ //#region src/react.ts
3
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
4
+ //#endregion
5
+ var Activity = import_react.Activity;
6
+ var Children = import_react.Children;
7
+ var Component = import_react.Component;
8
+ var Fragment = import_react.Fragment;
9
+ var Profiler = import_react.Profiler;
10
+ var PureComponent = import_react.PureComponent;
11
+ var StrictMode = import_react.StrictMode;
12
+ var Suspense = import_react.Suspense;
13
+ var ViewTransition = import_react.ViewTransition;
14
+ var act = import_react.act;
15
+ var addTransitionType = import_react.addTransitionType;
16
+ var cache = import_react.cache;
17
+ var cacheSignal = import_react.cacheSignal;
18
+ var captureOwnerStack = import_react.captureOwnerStack;
19
+ var cloneElement = import_react.cloneElement;
20
+ var createContext = import_react.createContext;
21
+ var createElement = import_react.createElement;
22
+ var createRef = import_react.createRef;
23
+ var react_default = import_react.default;
24
+ var forwardRef = import_react.forwardRef;
25
+ var isValidElement = import_react.isValidElement;
26
+ var lazy = import_react.lazy;
27
+ var memo = import_react.memo;
28
+ var startTransition = import_react.startTransition;
29
+ var use = import_react.use;
30
+ var useActionState = import_react.useActionState;
31
+ var useCallback = import_react.useCallback;
32
+ var useContext = import_react.useContext;
33
+ var useDebugValue = import_react.useDebugValue;
34
+ var useDeferredValue = import_react.useDeferredValue;
35
+ var useEffect = import_react.useEffect;
36
+ var useEffectEvent = import_react.useEffectEvent;
37
+ var useId = import_react.useId;
38
+ var useImperativeHandle = import_react.useImperativeHandle;
39
+ var useInsertionEffect = import_react.useInsertionEffect;
40
+ var useLayoutEffect = import_react.useLayoutEffect;
41
+ var useMemo = import_react.useMemo;
42
+ var useOptimistic = import_react.useOptimistic;
43
+ var useReducer = import_react.useReducer;
44
+ var useRef = import_react.useRef;
45
+ var useState = import_react.useState;
46
+ var useSyncExternalStore = import_react.useSyncExternalStore;
47
+ var useTransition = import_react.useTransition;
48
+ var version = import_react.version;
49
+ export { Activity, Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, ViewTransition, act, addTransitionType, cache, cacheSignal, captureOwnerStack, cloneElement, createContext, createElement, createRef, react_default as default, forwardRef, isValidElement, lazy, memo, startTransition, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useEffectEvent, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
package/dist/router.js CHANGED
@@ -1,6 +1,6 @@
1
- import { f as Text, n as useInput, t as useFocus } from "./use-focus-CcCIdCWA.js";
2
- import { Children, Fragment, createContext, isValidElement, startTransition, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
- import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
1
+ import { r as __toESM, t as require_react } from "./react-CTZ_8dwh.js";
2
+ import { f as Text, n as useInput, t as useFocus } from "./use-focus-B5npZrJU.js";
3
+ import { t as require_jsx_runtime } from "./jsx-runtime-XtwIVFsg.js";
4
4
  //#region src/router/history.ts
5
5
  /**
6
6
  Splits a path string into its pathname and search parts.
@@ -98,6 +98,7 @@ const createMemoryHistory = ({ initialEntries = ["/"], initialIndex } = {}) => {
98
98
  };
99
99
  //#endregion
100
100
  //#region src/router/matcher.ts
101
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
101
102
  const joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
102
103
  const normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
103
104
  const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : `?${search}`;
@@ -327,16 +328,17 @@ function resolveTo(toArg, routePathnames, locationPathname) {
327
328
  }
328
329
  //#endregion
329
330
  //#region src/router/context.ts
330
- const NavigationContext = createContext(null);
331
- const LocationContext = createContext(null);
332
- const RouteContext = createContext({
331
+ const NavigationContext = (0, import_react.createContext)(null);
332
+ const LocationContext = (0, import_react.createContext)(null);
333
+ const RouteContext = (0, import_react.createContext)({
333
334
  outlet: null,
334
335
  matches: []
335
336
  });
336
- const OutletContext = createContext(null);
337
+ const OutletContext = (0, import_react.createContext)(null);
337
338
  //#endregion
338
339
  //#region src/router/hooks.tsx
339
340
  /** @jsxImportSource react */
341
+ var import_jsx_runtime = require_jsx_runtime();
340
342
  const warned = /* @__PURE__ */ new Set();
341
343
  const warnOnce = (key, message) => {
342
344
  if (!warned.has(key)) {
@@ -348,12 +350,12 @@ const warnOnce = (key, message) => {
348
350
  Returns `true` when rendered inside a `<MemoryRouter>`. Useful for components
349
351
  that optionally integrate with routing.
350
352
  */
351
- const useInRouterContext = () => useContext(LocationContext) != null;
353
+ const useInRouterContext = () => (0, import_react.useContext)(LocationContext) != null;
352
354
  /**
353
355
  Returns the current `Location`.
354
356
  */
355
357
  const useLocation = () => {
356
- const locationContext = useContext(LocationContext);
358
+ const locationContext = (0, import_react.useContext)(LocationContext);
357
359
  if (!locationContext) throw new Error("useLocation() may be used only in the context of a <MemoryRouter> component.");
358
360
  return locationContext.location;
359
361
  };
@@ -362,12 +364,12 @@ Returns the type of navigation that produced the current location: `"POP"`,
362
364
  `"PUSH"`, or `"REPLACE"`.
363
365
  */
364
366
  const useNavigationType = () => {
365
- const locationContext = useContext(LocationContext);
367
+ const locationContext = (0, import_react.useContext)(LocationContext);
366
368
  if (!locationContext) throw new Error("useNavigationType() may be used only in the context of a <MemoryRouter> component.");
367
369
  return locationContext.navigationType;
368
370
  };
369
371
  const useNavigationContext = (hookName) => {
370
- const navigationContext = useContext(NavigationContext);
372
+ const navigationContext = (0, import_react.useContext)(NavigationContext);
371
373
  if (!navigationContext) throw new Error(`${hookName} may be used only in the context of a <MemoryRouter> component.`);
372
374
  return navigationContext;
373
375
  };
@@ -376,14 +378,14 @@ Returns a stable function for imperative navigation.
376
378
  */
377
379
  const useNavigate = () => {
378
380
  const { navigator } = useNavigationContext("useNavigate()");
379
- const { matches } = useContext(RouteContext);
381
+ const { matches } = (0, import_react.useContext)(RouteContext);
380
382
  const { pathname: locationPathname } = useLocation();
381
383
  const routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
382
- const activeRef = useRef(false);
383
- useLayoutEffect(() => {
384
+ const activeRef = (0, import_react.useRef)(false);
385
+ (0, import_react.useLayoutEffect)(() => {
384
386
  activeRef.current = true;
385
387
  });
386
- return useCallback((to, options = {}) => {
388
+ return (0, import_react.useCallback)((to, options = {}) => {
387
389
  if (!activeRef.current) return;
388
390
  if (typeof to === "number") {
389
391
  navigator.go(to);
@@ -415,7 +417,7 @@ Returns the params from all dynamic segments matched by the current route and
415
417
  its ancestors.
416
418
  */
417
419
  const useParams = () => {
418
- const { matches } = useContext(RouteContext);
420
+ const { matches } = (0, import_react.useContext)(RouteContext);
419
421
  const routeMatch = matches[matches.length - 1];
420
422
  return routeMatch ? routeMatch.params : {};
421
423
  };
@@ -432,7 +434,7 @@ Resolves a `To` value against the current route, exactly as `useNavigate`
432
434
  would. Useful for building navigation UI.
433
435
  */
434
436
  const useResolvedPath = (to) => {
435
- const { matches } = useContext(RouteContext);
437
+ const { matches } = (0, import_react.useContext)(RouteContext);
436
438
  const { pathname: locationPathname } = useLocation();
437
439
  return resolveTo(to, getResolveToMatches(matches), locationPathname);
438
440
  };
@@ -441,8 +443,8 @@ Returns the element for the child route at this level of the route hierarchy,
441
443
  or `null` if there is none. Used internally by `<Outlet>`.
442
444
  */
443
445
  const useOutlet = (context) => {
444
- const { outlet } = useContext(RouteContext);
445
- if (outlet) return /* @__PURE__ */ jsx(OutletContext.Provider, {
446
+ const { outlet } = (0, import_react.useContext)(RouteContext);
447
+ if (outlet) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutletContext.Provider, {
446
448
  value: context,
447
449
  children: outlet
448
450
  });
@@ -451,7 +453,7 @@ const useOutlet = (context) => {
451
453
  /**
452
454
  Returns the value passed to the nearest parent `<Outlet context={...}>`.
453
455
  */
454
- const useOutletContext = () => useContext(OutletContext);
456
+ const useOutletContext = () => (0, import_react.useContext)(OutletContext);
455
457
  /**
456
458
  Creates a `URLSearchParams` from common initializer shapes, including
457
459
  `{ key: ["a", "b"] }` for repeated keys.
@@ -465,10 +467,10 @@ Returns the current location's search params and a setter that navigates to
465
467
  the same pathname with the new params.
466
468
  */
467
469
  const useSearchParams = (defaultInit) => {
468
- const defaultSearchParamsRef = useRef(createSearchParams(defaultInit));
469
- const hasSetSearchParamsRef = useRef(false);
470
+ const defaultSearchParamsRef = (0, import_react.useRef)(createSearchParams(defaultInit));
471
+ const hasSetSearchParamsRef = (0, import_react.useRef)(false);
470
472
  const location = useLocation();
471
- const searchParams = useMemo(() => {
473
+ const searchParams = (0, import_react.useMemo)(() => {
472
474
  const params = createSearchParams(location.search);
473
475
  if (!hasSetSearchParamsRef.current) {
474
476
  for (const key of defaultSearchParamsRef.current.keys()) if (!params.has(key)) for (const value of defaultSearchParamsRef.current.getAll(key)) params.append(key, value);
@@ -476,7 +478,7 @@ const useSearchParams = (defaultInit) => {
476
478
  return params;
477
479
  }, [location.search]);
478
480
  const navigate = useNavigate();
479
- return [searchParams, useCallback((nextInit, navigateOptions) => {
481
+ return [searchParams, (0, import_react.useCallback)((nextInit, navigateOptions) => {
480
482
  const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit);
481
483
  hasSetSearchParamsRef.current = true;
482
484
  navigate(`?${newSearchParams.toString()}`, navigateOptions);
@@ -489,7 +491,7 @@ and returns the rendered element tree. The plain-object alternative to
489
491
  */
490
492
  const useRoutes = (routes, locationArg) => {
491
493
  if (!useInRouterContext()) throw new Error("useRoutes() may be used only in the context of a <MemoryRouter> component.");
492
- const { matches: parentMatches } = useContext(RouteContext);
494
+ const { matches: parentMatches } = (0, import_react.useContext)(RouteContext);
493
495
  const routeMatch = parentMatches[parentMatches.length - 1];
494
496
  const parentParams = routeMatch ? routeMatch.params : {};
495
497
  const parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
@@ -525,7 +527,7 @@ function renderMatches(matches, parentMatches) {
525
527
  if (matches == null) return null;
526
528
  return matches.reduceRight((outlet, match, index) => {
527
529
  const matchesUpToHere = parentMatches.concat(matches.slice(0, index + 1));
528
- return /* @__PURE__ */ jsx(RouteContext.Provider, {
530
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteContext.Provider, {
529
531
  value: {
530
532
  outlet,
531
533
  matches: matchesUpToHere
@@ -551,39 +553,39 @@ routes aren't URLs, they're screen states.
551
553
  ```
552
554
  */
553
555
  function MemoryRouter({ initialEntries, initialIndex, children }) {
554
- const historyRef = useRef(null);
556
+ const historyRef = (0, import_react.useRef)(null);
555
557
  historyRef.current ??= createMemoryHistory({
556
558
  initialEntries,
557
559
  initialIndex
558
560
  });
559
561
  const history = historyRef.current;
560
- const [state, setState] = useState({
562
+ const [state, setState] = (0, import_react.useState)({
561
563
  action: history.action,
562
564
  location: history.location
563
565
  });
564
- useLayoutEffect(() => history.listen(({ action, location }) => {
565
- startTransition(() => {
566
+ (0, import_react.useLayoutEffect)(() => history.listen(({ action, location }) => {
567
+ (0, import_react.startTransition)(() => {
566
568
  setState({
567
569
  action,
568
570
  location
569
571
  });
570
572
  });
571
573
  }), [history]);
572
- const navigator = useMemo(() => ({
574
+ const navigator = (0, import_react.useMemo)(() => ({
573
575
  push: (to, historyState) => history.push(to, historyState),
574
576
  replace: (to, historyState) => history.replace(to, historyState),
575
577
  go: (delta) => history.go(delta),
576
578
  canGoBack: () => history.canGoBack,
577
579
  canGoForward: () => history.canGoForward
578
580
  }), [history]);
579
- const navigationContext = useMemo(() => ({ navigator }), [navigator]);
580
- const locationContext = useMemo(() => ({
581
+ const navigationContext = (0, import_react.useMemo)(() => ({ navigator }), [navigator]);
582
+ const locationContext = (0, import_react.useMemo)(() => ({
581
583
  location: state.location,
582
584
  navigationType: state.action
583
585
  }), [state]);
584
- return /* @__PURE__ */ jsx(NavigationContext.Provider, {
586
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NavigationContext.Provider, {
585
587
  value: navigationContext,
586
- children: /* @__PURE__ */ jsx(LocationContext.Provider, {
588
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LocationContext.Provider, {
587
589
  value: locationContext,
588
590
  children
589
591
  })
@@ -597,9 +599,9 @@ function Route(_props) {
597
599
  }
598
600
  function createRoutesFromChildren(children) {
599
601
  const routes = [];
600
- Children.forEach(children, (element) => {
601
- if (!isValidElement(element)) return;
602
- if (element.type === Fragment) {
602
+ import_react.Children.forEach(children, (element) => {
603
+ if (!(0, import_react.isValidElement)(element)) return;
604
+ if (element.type === import_react.Fragment) {
603
605
  routes.push(...createRoutesFromChildren(element.props.children));
604
606
  return;
605
607
  }
@@ -640,7 +642,7 @@ declarative redirects:
640
642
  function Navigate({ to, replace, state }) {
641
643
  const navigate = useNavigate();
642
644
  const { pathname, search } = useResolvedPath(to);
643
- useEffect(() => {
645
+ (0, import_react.useEffect)(() => {
644
646
  navigate({
645
647
  pathname,
646
648
  search
@@ -677,7 +679,7 @@ function Link({ to, replace = false, state, autoFocus = false, id, children, ...
677
679
  });
678
680
  const toPathname = normalizePathname(path.pathname);
679
681
  const isActive = locationPathname === toPathname || locationPathname.startsWith(toPathname) && locationPathname.charAt(toPathname.length) === "/";
680
- const activate = useCallback(() => {
682
+ const activate = (0, import_react.useCallback)(() => {
681
683
  navigate({
682
684
  pathname: path.pathname,
683
685
  search: path.search
@@ -695,11 +697,11 @@ function Link({ to, replace = false, state, autoFocus = false, id, children, ...
695
697
  useInput((_input, key) => {
696
698
  if (key.return) activate();
697
699
  }, { isActive: isFocused });
698
- if (typeof children === "function") return /* @__PURE__ */ jsx(Fragment$1, { children: children({
700
+ if (typeof children === "function") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: children({
699
701
  isFocused,
700
702
  isActive
701
703
  }) });
702
- return /* @__PURE__ */ jsx(Text, {
704
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
703
705
  inverse: isFocused,
704
706
  ...textProps,
705
707
  children