@alchemy.run/sigil 0.0.0-alpha.9 → 0.1.0-alpha.1
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/THIRD_PARTY_NOTICES.md +28 -0
- package/dist/ansi.d.ts +53 -53
- package/dist/capabilities.js +1 -1
- package/dist/{color-policy-DlrZXC0f.js → color-policy-BAC9-TZX.js} +15 -1
- package/dist/color.d.ts +8 -8
- package/dist/{devtools-DbthxoD1.js → devtools-B_2SDRaO.js} +3 -0
- package/dist/index.d.ts +39 -37
- package/dist/index.js +189 -181
- package/dist/jsx-dev-runtime.d.ts +3 -0
- package/dist/jsx-dev-runtime.js +7 -0
- package/dist/jsx-runtime-BS_OosoY.js +42 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.js +8 -0
- package/dist/react-CeO3oT_g.js +394 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +50 -0
- package/dist/rolldown-runtime-BPOCksWG.js +24 -0
- package/dist/router.d.ts +26 -26
- package/dist/router.js +45 -42
- package/dist/{session-Cg6STjFV.js → session-DDQ5V300.js} +34 -11
- package/dist/terminal.d.ts +9 -10
- package/dist/terminal.js +1 -1
- package/dist/use-focus-B1WVNBQm.js +8383 -0
- package/package.json +27 -15
- package/src/ansi/strip.ts +2 -2
- package/src/capabilities/query.ts +22 -0
- package/src/devtools.ts +5 -0
- package/src/hooks/use-window-size.ts +10 -3
- package/src/input-parser.ts +31 -11
- package/src/jsx-dev-runtime.ts +3 -0
- package/src/jsx-runtime.ts +6 -0
- package/src/react.ts +53 -0
- package/src/reconciler.ts +51 -0
- package/src/terminal/input.ts +11 -5
- package/dist/use-focus-Basd0ksv.js +0 -1337
package/dist/router.d.ts
CHANGED
|
@@ -46,11 +46,11 @@ type To = string | Partial<Path>;
|
|
|
46
46
|
/**
|
|
47
47
|
Splits a path string into its pathname and search parts.
|
|
48
48
|
*/
|
|
49
|
-
declare const parsePath: (path: string) => Partial<Path>;
|
|
49
|
+
export declare const parsePath: (path: string) => Partial<Path>;
|
|
50
50
|
/**
|
|
51
51
|
Joins a `Path` back into a single string.
|
|
52
52
|
*/
|
|
53
|
-
declare const createPath: ({ pathname, search }: Partial<Path>) => string;
|
|
53
|
+
export declare const createPath: ({ pathname, search }: Partial<Path>) => string;
|
|
54
54
|
/**
|
|
55
55
|
An entry to seed the navigation stack with: a path string or a partial
|
|
56
56
|
`Location` (which may carry `state`).
|
|
@@ -126,12 +126,12 @@ Matches a set of (possibly nested) routes against a location and returns the
|
|
|
126
126
|
chain of matches from the root route down to the leaf, or `null` if nothing
|
|
127
127
|
matches.
|
|
128
128
|
*/
|
|
129
|
-
declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string): RouteMatch<RouteObjectType>[] | null;
|
|
129
|
+
export declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string): RouteMatch<RouteObjectType>[] | null;
|
|
130
130
|
/**
|
|
131
131
|
Matches a single path pattern against a pathname. Returns the match with
|
|
132
132
|
extracted params, or `null` if the pattern does not match.
|
|
133
133
|
*/
|
|
134
|
-
declare function matchPath<ParamKey extends string = string>(pattern: PathPattern | string, pathname: string): PathMatch<ParamKey> | null;
|
|
134
|
+
export declare function matchPath<ParamKey extends string = string>(pattern: PathPattern | string, pathname: string): PathMatch<ParamKey> | null;
|
|
135
135
|
/**
|
|
136
136
|
Interpolates params into a route path pattern.
|
|
137
137
|
|
|
@@ -139,12 +139,12 @@ Interpolates params into a route path pattern.
|
|
|
139
139
|
generatePath("/users/:id", { id: "42" }); // "/users/42"
|
|
140
140
|
```
|
|
141
141
|
*/
|
|
142
|
-
declare function generatePath(originalPath: string, params?: Record<string, string | null>): string;
|
|
142
|
+
export declare function generatePath(originalPath: string, params?: Record<string, string | null>): string;
|
|
143
143
|
/**
|
|
144
144
|
Resolves a `To` value against a starting pathname, handling `.` and `..`
|
|
145
145
|
segments.
|
|
146
146
|
*/
|
|
147
|
-
declare function resolvePath(to: To, fromPathname?: string): Path;
|
|
147
|
+
export declare function resolvePath(to: To, fromPathname?: string): Path;
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/router/context.d.ts
|
|
150
150
|
/**
|
|
@@ -164,16 +164,16 @@ type Navigator = {
|
|
|
164
164
|
Returns `true` when rendered inside a `<MemoryRouter>`. Useful for components
|
|
165
165
|
that optionally integrate with routing.
|
|
166
166
|
*/
|
|
167
|
-
declare const useInRouterContext: () => boolean;
|
|
167
|
+
export declare const useInRouterContext: () => boolean;
|
|
168
168
|
/**
|
|
169
169
|
Returns the current `Location`.
|
|
170
170
|
*/
|
|
171
|
-
declare const useLocation: () => Location;
|
|
171
|
+
export declare const useLocation: () => Location;
|
|
172
172
|
/**
|
|
173
173
|
Returns the type of navigation that produced the current location: `"POP"`,
|
|
174
174
|
`"PUSH"`, or `"REPLACE"`.
|
|
175
175
|
*/
|
|
176
|
-
declare const useNavigationType: () => NavigationType;
|
|
176
|
+
export declare const useNavigationType: () => NavigationType;
|
|
177
177
|
type NavigateOptions = {
|
|
178
178
|
/**
|
|
179
179
|
Replace the current entry in the navigation stack instead of pushing a new
|
|
@@ -197,13 +197,13 @@ type NavigateFunction = {
|
|
|
197
197
|
/**
|
|
198
198
|
Returns a stable function for imperative navigation.
|
|
199
199
|
*/
|
|
200
|
-
declare const useNavigate: () => NavigateFunction;
|
|
200
|
+
export declare const useNavigate: () => NavigateFunction;
|
|
201
201
|
/**
|
|
202
202
|
Returns whether the navigation stack has entries behind/ahead of the current
|
|
203
203
|
one — i.e. whether `navigate(-1)` / `navigate(1)` will move anywhere. Handy
|
|
204
204
|
for "Esc goes back, unless at root" bindings.
|
|
205
205
|
*/
|
|
206
|
-
declare const useNavigationStack: () => {
|
|
206
|
+
export declare const useNavigationStack: () => {
|
|
207
207
|
canGoBack: boolean;
|
|
208
208
|
canGoForward: boolean;
|
|
209
209
|
};
|
|
@@ -211,44 +211,44 @@ declare const useNavigationStack: () => {
|
|
|
211
211
|
Returns the params from all dynamic segments matched by the current route and
|
|
212
212
|
its ancestors.
|
|
213
213
|
*/
|
|
214
|
-
declare const useParams: <ParamsOrKey extends Record<string, string | undefined> | string = string>() => Readonly<[ParamsOrKey] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
|
|
214
|
+
export declare const useParams: <ParamsOrKey extends Record<string, string | undefined> | string = string>() => Readonly<[ParamsOrKey] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
|
|
215
215
|
/**
|
|
216
216
|
Matches a path pattern against the current location's pathname. Returns the
|
|
217
217
|
match (with params) or `null`.
|
|
218
218
|
*/
|
|
219
|
-
declare const useMatch: <ParamKey extends string = string>(pattern: PathPattern | string) => PathMatch<ParamKey> | null;
|
|
219
|
+
export declare const useMatch: <ParamKey extends string = string>(pattern: PathPattern | string) => PathMatch<ParamKey> | null;
|
|
220
220
|
/**
|
|
221
221
|
Resolves a `To` value against the current route, exactly as `useNavigate`
|
|
222
222
|
would. Useful for building navigation UI.
|
|
223
223
|
*/
|
|
224
|
-
declare const useResolvedPath: (to: To) => Path;
|
|
224
|
+
export declare const useResolvedPath: (to: To) => Path;
|
|
225
225
|
/**
|
|
226
226
|
Returns the element for the child route at this level of the route hierarchy,
|
|
227
227
|
or `null` if there is none. Used internally by `<Outlet>`.
|
|
228
228
|
*/
|
|
229
|
-
declare const useOutlet: (context?: unknown) => ReactElement | null;
|
|
229
|
+
export declare const useOutlet: (context?: unknown) => ReactElement | null;
|
|
230
230
|
/**
|
|
231
231
|
Returns the value passed to the nearest parent `<Outlet context={...}>`.
|
|
232
232
|
*/
|
|
233
|
-
declare const useOutletContext: <Context = unknown>() => Context;
|
|
233
|
+
export declare const useOutletContext: <Context = unknown>() => Context;
|
|
234
234
|
type SearchParamsInit = string | string[][] | Record<string, string | string[]> | URLSearchParams;
|
|
235
235
|
/**
|
|
236
236
|
Creates a `URLSearchParams` from common initializer shapes, including
|
|
237
237
|
`{ key: ["a", "b"] }` for repeated keys.
|
|
238
238
|
*/
|
|
239
|
-
declare const createSearchParams: (init?: SearchParamsInit) => URLSearchParams;
|
|
239
|
+
export declare const createSearchParams: (init?: SearchParamsInit) => URLSearchParams;
|
|
240
240
|
type SetSearchParams = (nextInit: SearchParamsInit | ((prev: URLSearchParams) => SearchParamsInit), navigateOptions?: NavigateOptions) => void;
|
|
241
241
|
/**
|
|
242
242
|
Returns the current location's search params and a setter that navigates to
|
|
243
243
|
the same pathname with the new params.
|
|
244
244
|
*/
|
|
245
|
-
declare const useSearchParams: (defaultInit?: SearchParamsInit) => [URLSearchParams, SetSearchParams];
|
|
245
|
+
export declare const useSearchParams: (defaultInit?: SearchParamsInit) => [URLSearchParams, SetSearchParams];
|
|
246
246
|
/**
|
|
247
247
|
Matches a set of route objects against the current location (or an override)
|
|
248
248
|
and returns the rendered element tree. The plain-object alternative to
|
|
249
249
|
`<Routes>`.
|
|
250
250
|
*/
|
|
251
|
-
declare const useRoutes: (routes: RouteObject[], locationArg?: Partial<Location> | string) => ReactElement | null;
|
|
251
|
+
export declare const useRoutes: (routes: RouteObject[], locationArg?: Partial<Location> | string) => ReactElement | null;
|
|
252
252
|
//#endregion
|
|
253
253
|
//#region src/router/components.d.ts
|
|
254
254
|
type MemoryRouterProps = {
|
|
@@ -275,7 +275,7 @@ routes aren't URLs, they're screen states.
|
|
|
275
275
|
</MemoryRouter>
|
|
276
276
|
```
|
|
277
277
|
*/
|
|
278
|
-
declare function MemoryRouter({ initialEntries, initialIndex, children }: MemoryRouterProps): import("react").JSX.Element;
|
|
278
|
+
export declare function MemoryRouter({ initialEntries, initialIndex, children }: MemoryRouterProps): import("react").JSX.Element;
|
|
279
279
|
type RouteProps = {
|
|
280
280
|
/**
|
|
281
281
|
The path pattern to match, relative to the parent route. Supports `:param`
|
|
@@ -300,7 +300,7 @@ type RouteProps = {
|
|
|
300
300
|
/**
|
|
301
301
|
Declares a route. Only valid as a child of `<Routes>` or another `<Route>`.
|
|
302
302
|
*/
|
|
303
|
-
declare function Route(_props: RouteProps): ReactElement | null;
|
|
303
|
+
export declare function Route(_props: RouteProps): ReactElement | null;
|
|
304
304
|
type RoutesProps = {
|
|
305
305
|
children?: ReactNode;
|
|
306
306
|
/**
|
|
@@ -313,7 +313,7 @@ type RoutesProps = {
|
|
|
313
313
|
Renders the branch of child `<Route>` elements that best matches the current
|
|
314
314
|
location.
|
|
315
315
|
*/
|
|
316
|
-
declare function Routes({ children, location }: RoutesProps): ReactElement | null;
|
|
316
|
+
export declare function Routes({ children, location }: RoutesProps): ReactElement | null;
|
|
317
317
|
type OutletProps = {
|
|
318
318
|
/**
|
|
319
319
|
A value to make available to descendant routes via `useOutletContext()`.
|
|
@@ -324,7 +324,7 @@ type OutletProps = {
|
|
|
324
324
|
Renders the matching child route of a parent route, or nothing if no child
|
|
325
325
|
matches.
|
|
326
326
|
*/
|
|
327
|
-
declare function Outlet(props: OutletProps): ReactElement | null;
|
|
327
|
+
export declare function Outlet(props: OutletProps): ReactElement | null;
|
|
328
328
|
type NavigateProps = {
|
|
329
329
|
to: To;
|
|
330
330
|
replace?: boolean;
|
|
@@ -338,7 +338,7 @@ declarative redirects:
|
|
|
338
338
|
<Route path="/" element={<Navigate to="/home" replace />} />
|
|
339
339
|
```
|
|
340
340
|
*/
|
|
341
|
-
declare function Navigate({ to, replace, state }: NavigateProps): null;
|
|
341
|
+
export declare function Navigate({ to, replace, state }: NavigateProps): null;
|
|
342
342
|
type LinkRenderState = {
|
|
343
343
|
/**
|
|
344
344
|
Whether this link currently has focus.
|
|
@@ -387,6 +387,6 @@ customize.
|
|
|
387
387
|
<Link to="/settings">Settings</Link>
|
|
388
388
|
```
|
|
389
389
|
*/
|
|
390
|
-
declare function Link({ to, replace, state, autoFocus, id, children, ...textProps }: LinkProps): import("react").JSX.Element;
|
|
390
|
+
export declare function Link({ to, replace, state, autoFocus, id, children, ...textProps }: LinkProps): import("react").JSX.Element;
|
|
391
391
|
//#endregion
|
|
392
|
-
export {
|
|
392
|
+
export type { InitialEntry, LinkProps, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, NavigationType, Navigator, OutletProps, Params, Path, PathMatch, PathPattern, RouteMatch, RouteObject, RouteProps, RoutesProps, To };
|
package/dist/router.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { n as __toESM } from "./rolldown-runtime-BPOCksWG.js";
|
|
2
|
+
import { t as require_react } from "./react-CeO3oT_g.js";
|
|
3
|
+
import { f as Text, n as useInput, t as useFocus } from "./use-focus-B1WVNBQm.js";
|
|
4
|
+
import { t as require_jsx_runtime } from "./jsx-runtime-BS_OosoY.js";
|
|
4
5
|
//#region src/router/history.ts
|
|
5
6
|
/**
|
|
6
7
|
Splits a path string into its pathname and search parts.
|
|
@@ -98,6 +99,7 @@ const createMemoryHistory = ({ initialEntries = ["/"], initialIndex } = {}) => {
|
|
|
98
99
|
};
|
|
99
100
|
//#endregion
|
|
100
101
|
//#region src/router/matcher.ts
|
|
102
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
101
103
|
const joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
|
|
102
104
|
const normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
|
|
103
105
|
const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : `?${search}`;
|
|
@@ -327,16 +329,17 @@ function resolveTo(toArg, routePathnames, locationPathname) {
|
|
|
327
329
|
}
|
|
328
330
|
//#endregion
|
|
329
331
|
//#region src/router/context.ts
|
|
330
|
-
const NavigationContext = createContext(null);
|
|
331
|
-
const LocationContext = createContext(null);
|
|
332
|
-
const RouteContext = createContext({
|
|
332
|
+
const NavigationContext = (0, import_react.createContext)(null);
|
|
333
|
+
const LocationContext = (0, import_react.createContext)(null);
|
|
334
|
+
const RouteContext = (0, import_react.createContext)({
|
|
333
335
|
outlet: null,
|
|
334
336
|
matches: []
|
|
335
337
|
});
|
|
336
|
-
const OutletContext = createContext(null);
|
|
338
|
+
const OutletContext = (0, import_react.createContext)(null);
|
|
337
339
|
//#endregion
|
|
338
340
|
//#region src/router/hooks.tsx
|
|
339
341
|
/** @jsxImportSource react */
|
|
342
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
340
343
|
const warned = /* @__PURE__ */ new Set();
|
|
341
344
|
const warnOnce = (key, message) => {
|
|
342
345
|
if (!warned.has(key)) {
|
|
@@ -348,12 +351,12 @@ const warnOnce = (key, message) => {
|
|
|
348
351
|
Returns `true` when rendered inside a `<MemoryRouter>`. Useful for components
|
|
349
352
|
that optionally integrate with routing.
|
|
350
353
|
*/
|
|
351
|
-
const useInRouterContext = () => useContext(LocationContext) != null;
|
|
354
|
+
const useInRouterContext = () => (0, import_react.useContext)(LocationContext) != null;
|
|
352
355
|
/**
|
|
353
356
|
Returns the current `Location`.
|
|
354
357
|
*/
|
|
355
358
|
const useLocation = () => {
|
|
356
|
-
const locationContext = useContext(LocationContext);
|
|
359
|
+
const locationContext = (0, import_react.useContext)(LocationContext);
|
|
357
360
|
if (!locationContext) throw new Error("useLocation() may be used only in the context of a <MemoryRouter> component.");
|
|
358
361
|
return locationContext.location;
|
|
359
362
|
};
|
|
@@ -362,12 +365,12 @@ Returns the type of navigation that produced the current location: `"POP"`,
|
|
|
362
365
|
`"PUSH"`, or `"REPLACE"`.
|
|
363
366
|
*/
|
|
364
367
|
const useNavigationType = () => {
|
|
365
|
-
const locationContext = useContext(LocationContext);
|
|
368
|
+
const locationContext = (0, import_react.useContext)(LocationContext);
|
|
366
369
|
if (!locationContext) throw new Error("useNavigationType() may be used only in the context of a <MemoryRouter> component.");
|
|
367
370
|
return locationContext.navigationType;
|
|
368
371
|
};
|
|
369
372
|
const useNavigationContext = (hookName) => {
|
|
370
|
-
const navigationContext = useContext(NavigationContext);
|
|
373
|
+
const navigationContext = (0, import_react.useContext)(NavigationContext);
|
|
371
374
|
if (!navigationContext) throw new Error(`${hookName} may be used only in the context of a <MemoryRouter> component.`);
|
|
372
375
|
return navigationContext;
|
|
373
376
|
};
|
|
@@ -376,14 +379,14 @@ Returns a stable function for imperative navigation.
|
|
|
376
379
|
*/
|
|
377
380
|
const useNavigate = () => {
|
|
378
381
|
const { navigator } = useNavigationContext("useNavigate()");
|
|
379
|
-
const { matches } = useContext(RouteContext);
|
|
382
|
+
const { matches } = (0, import_react.useContext)(RouteContext);
|
|
380
383
|
const { pathname: locationPathname } = useLocation();
|
|
381
384
|
const routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
382
|
-
const activeRef = useRef(false);
|
|
383
|
-
useLayoutEffect(() => {
|
|
385
|
+
const activeRef = (0, import_react.useRef)(false);
|
|
386
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
384
387
|
activeRef.current = true;
|
|
385
388
|
});
|
|
386
|
-
return useCallback((to, options = {}) => {
|
|
389
|
+
return (0, import_react.useCallback)((to, options = {}) => {
|
|
387
390
|
if (!activeRef.current) return;
|
|
388
391
|
if (typeof to === "number") {
|
|
389
392
|
navigator.go(to);
|
|
@@ -415,7 +418,7 @@ Returns the params from all dynamic segments matched by the current route and
|
|
|
415
418
|
its ancestors.
|
|
416
419
|
*/
|
|
417
420
|
const useParams = () => {
|
|
418
|
-
const { matches } = useContext(RouteContext);
|
|
421
|
+
const { matches } = (0, import_react.useContext)(RouteContext);
|
|
419
422
|
const routeMatch = matches[matches.length - 1];
|
|
420
423
|
return routeMatch ? routeMatch.params : {};
|
|
421
424
|
};
|
|
@@ -432,7 +435,7 @@ Resolves a `To` value against the current route, exactly as `useNavigate`
|
|
|
432
435
|
would. Useful for building navigation UI.
|
|
433
436
|
*/
|
|
434
437
|
const useResolvedPath = (to) => {
|
|
435
|
-
const { matches } = useContext(RouteContext);
|
|
438
|
+
const { matches } = (0, import_react.useContext)(RouteContext);
|
|
436
439
|
const { pathname: locationPathname } = useLocation();
|
|
437
440
|
return resolveTo(to, getResolveToMatches(matches), locationPathname);
|
|
438
441
|
};
|
|
@@ -441,8 +444,8 @@ Returns the element for the child route at this level of the route hierarchy,
|
|
|
441
444
|
or `null` if there is none. Used internally by `<Outlet>`.
|
|
442
445
|
*/
|
|
443
446
|
const useOutlet = (context) => {
|
|
444
|
-
const { outlet } = useContext(RouteContext);
|
|
445
|
-
if (outlet) return /* @__PURE__ */ jsx(OutletContext.Provider, {
|
|
447
|
+
const { outlet } = (0, import_react.useContext)(RouteContext);
|
|
448
|
+
if (outlet) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutletContext.Provider, {
|
|
446
449
|
value: context,
|
|
447
450
|
children: outlet
|
|
448
451
|
});
|
|
@@ -451,7 +454,7 @@ const useOutlet = (context) => {
|
|
|
451
454
|
/**
|
|
452
455
|
Returns the value passed to the nearest parent `<Outlet context={...}>`.
|
|
453
456
|
*/
|
|
454
|
-
const useOutletContext = () => useContext(OutletContext);
|
|
457
|
+
const useOutletContext = () => (0, import_react.useContext)(OutletContext);
|
|
455
458
|
/**
|
|
456
459
|
Creates a `URLSearchParams` from common initializer shapes, including
|
|
457
460
|
`{ key: ["a", "b"] }` for repeated keys.
|
|
@@ -465,10 +468,10 @@ Returns the current location's search params and a setter that navigates to
|
|
|
465
468
|
the same pathname with the new params.
|
|
466
469
|
*/
|
|
467
470
|
const useSearchParams = (defaultInit) => {
|
|
468
|
-
const defaultSearchParamsRef = useRef(createSearchParams(defaultInit));
|
|
469
|
-
const hasSetSearchParamsRef = useRef(false);
|
|
471
|
+
const defaultSearchParamsRef = (0, import_react.useRef)(createSearchParams(defaultInit));
|
|
472
|
+
const hasSetSearchParamsRef = (0, import_react.useRef)(false);
|
|
470
473
|
const location = useLocation();
|
|
471
|
-
const searchParams = useMemo(() => {
|
|
474
|
+
const searchParams = (0, import_react.useMemo)(() => {
|
|
472
475
|
const params = createSearchParams(location.search);
|
|
473
476
|
if (!hasSetSearchParamsRef.current) {
|
|
474
477
|
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 +479,7 @@ const useSearchParams = (defaultInit) => {
|
|
|
476
479
|
return params;
|
|
477
480
|
}, [location.search]);
|
|
478
481
|
const navigate = useNavigate();
|
|
479
|
-
return [searchParams, useCallback((nextInit, navigateOptions) => {
|
|
482
|
+
return [searchParams, (0, import_react.useCallback)((nextInit, navigateOptions) => {
|
|
480
483
|
const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit);
|
|
481
484
|
hasSetSearchParamsRef.current = true;
|
|
482
485
|
navigate(`?${newSearchParams.toString()}`, navigateOptions);
|
|
@@ -489,7 +492,7 @@ and returns the rendered element tree. The plain-object alternative to
|
|
|
489
492
|
*/
|
|
490
493
|
const useRoutes = (routes, locationArg) => {
|
|
491
494
|
if (!useInRouterContext()) throw new Error("useRoutes() may be used only in the context of a <MemoryRouter> component.");
|
|
492
|
-
const { matches: parentMatches } = useContext(RouteContext);
|
|
495
|
+
const { matches: parentMatches } = (0, import_react.useContext)(RouteContext);
|
|
493
496
|
const routeMatch = parentMatches[parentMatches.length - 1];
|
|
494
497
|
const parentParams = routeMatch ? routeMatch.params : {};
|
|
495
498
|
const parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
|
|
@@ -525,7 +528,7 @@ function renderMatches(matches, parentMatches) {
|
|
|
525
528
|
if (matches == null) return null;
|
|
526
529
|
return matches.reduceRight((outlet, match, index) => {
|
|
527
530
|
const matchesUpToHere = parentMatches.concat(matches.slice(0, index + 1));
|
|
528
|
-
return /* @__PURE__ */ jsx(RouteContext.Provider, {
|
|
531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteContext.Provider, {
|
|
529
532
|
value: {
|
|
530
533
|
outlet,
|
|
531
534
|
matches: matchesUpToHere
|
|
@@ -551,39 +554,39 @@ routes aren't URLs, they're screen states.
|
|
|
551
554
|
```
|
|
552
555
|
*/
|
|
553
556
|
function MemoryRouter({ initialEntries, initialIndex, children }) {
|
|
554
|
-
const historyRef = useRef(null);
|
|
557
|
+
const historyRef = (0, import_react.useRef)(null);
|
|
555
558
|
historyRef.current ??= createMemoryHistory({
|
|
556
559
|
initialEntries,
|
|
557
560
|
initialIndex
|
|
558
561
|
});
|
|
559
562
|
const history = historyRef.current;
|
|
560
|
-
const [state, setState] = useState({
|
|
563
|
+
const [state, setState] = (0, import_react.useState)({
|
|
561
564
|
action: history.action,
|
|
562
565
|
location: history.location
|
|
563
566
|
});
|
|
564
|
-
useLayoutEffect(() => history.listen(({ action, location }) => {
|
|
565
|
-
startTransition(() => {
|
|
567
|
+
(0, import_react.useLayoutEffect)(() => history.listen(({ action, location }) => {
|
|
568
|
+
(0, import_react.startTransition)(() => {
|
|
566
569
|
setState({
|
|
567
570
|
action,
|
|
568
571
|
location
|
|
569
572
|
});
|
|
570
573
|
});
|
|
571
574
|
}), [history]);
|
|
572
|
-
const navigator = useMemo(() => ({
|
|
575
|
+
const navigator = (0, import_react.useMemo)(() => ({
|
|
573
576
|
push: (to, historyState) => history.push(to, historyState),
|
|
574
577
|
replace: (to, historyState) => history.replace(to, historyState),
|
|
575
578
|
go: (delta) => history.go(delta),
|
|
576
579
|
canGoBack: () => history.canGoBack,
|
|
577
580
|
canGoForward: () => history.canGoForward
|
|
578
581
|
}), [history]);
|
|
579
|
-
const navigationContext = useMemo(() => ({ navigator }), [navigator]);
|
|
580
|
-
const locationContext = useMemo(() => ({
|
|
582
|
+
const navigationContext = (0, import_react.useMemo)(() => ({ navigator }), [navigator]);
|
|
583
|
+
const locationContext = (0, import_react.useMemo)(() => ({
|
|
581
584
|
location: state.location,
|
|
582
585
|
navigationType: state.action
|
|
583
586
|
}), [state]);
|
|
584
|
-
return /* @__PURE__ */ jsx(NavigationContext.Provider, {
|
|
587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NavigationContext.Provider, {
|
|
585
588
|
value: navigationContext,
|
|
586
|
-
children: /* @__PURE__ */ jsx(LocationContext.Provider, {
|
|
589
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LocationContext.Provider, {
|
|
587
590
|
value: locationContext,
|
|
588
591
|
children
|
|
589
592
|
})
|
|
@@ -597,9 +600,9 @@ function Route(_props) {
|
|
|
597
600
|
}
|
|
598
601
|
function createRoutesFromChildren(children) {
|
|
599
602
|
const routes = [];
|
|
600
|
-
Children.forEach(children, (element) => {
|
|
601
|
-
if (!isValidElement(element)) return;
|
|
602
|
-
if (element.type === Fragment) {
|
|
603
|
+
import_react.Children.forEach(children, (element) => {
|
|
604
|
+
if (!(0, import_react.isValidElement)(element)) return;
|
|
605
|
+
if (element.type === import_react.Fragment) {
|
|
603
606
|
routes.push(...createRoutesFromChildren(element.props.children));
|
|
604
607
|
return;
|
|
605
608
|
}
|
|
@@ -640,7 +643,7 @@ declarative redirects:
|
|
|
640
643
|
function Navigate({ to, replace, state }) {
|
|
641
644
|
const navigate = useNavigate();
|
|
642
645
|
const { pathname, search } = useResolvedPath(to);
|
|
643
|
-
useEffect(() => {
|
|
646
|
+
(0, import_react.useEffect)(() => {
|
|
644
647
|
navigate({
|
|
645
648
|
pathname,
|
|
646
649
|
search
|
|
@@ -677,7 +680,7 @@ function Link({ to, replace = false, state, autoFocus = false, id, children, ...
|
|
|
677
680
|
});
|
|
678
681
|
const toPathname = normalizePathname(path.pathname);
|
|
679
682
|
const isActive = locationPathname === toPathname || locationPathname.startsWith(toPathname) && locationPathname.charAt(toPathname.length) === "/";
|
|
680
|
-
const activate = useCallback(() => {
|
|
683
|
+
const activate = (0, import_react.useCallback)(() => {
|
|
681
684
|
navigate({
|
|
682
685
|
pathname: path.pathname,
|
|
683
686
|
search: path.search
|
|
@@ -695,11 +698,11 @@ function Link({ to, replace = false, state, autoFocus = false, id, children, ...
|
|
|
695
698
|
useInput((_input, key) => {
|
|
696
699
|
if (key.return) activate();
|
|
697
700
|
}, { isActive: isFocused });
|
|
698
|
-
if (typeof children === "function") return /* @__PURE__ */ jsx(Fragment
|
|
701
|
+
if (typeof children === "function") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: children({
|
|
699
702
|
isFocused,
|
|
700
703
|
isActive
|
|
701
704
|
}) });
|
|
702
|
-
return /* @__PURE__ */ jsx(Text, {
|
|
705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
703
706
|
inverse: isFocused,
|
|
704
707
|
...textProps,
|
|
705
708
|
children
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { G as pasteEnd, K as pasteStart, S as ansiEscapes } from "./sgr-BhwaWAJB.js";
|
|
2
2
|
import { a as setPointerShape, c as setWorkingDirectory, i as setClipboard, l as tmuxPassthrough, n as notify, o as setTerminalProgress, s as setWindowTitle, u as cliCursor } from "./osc-BFKKSqpg.js";
|
|
3
|
-
import { i as getCapabilities, t as colorState } from "./color-policy-
|
|
3
|
+
import { d as isTerminalQueryResponse, i as getCapabilities, t as colorState } from "./color-policy-BAC9-TZX.js";
|
|
4
4
|
import { n as cellsEqual, t as cellAttributes } from "./cell-_ZVhbfl0.js";
|
|
5
5
|
import { n as serializeScreen, t as serializeLine } from "./serialize-BTkAZgw1.js";
|
|
6
6
|
//#region src/cursor-position.ts
|
|
@@ -77,6 +77,10 @@ const parseCsiSequence = (input, startIndex, prefixLength) => {
|
|
|
77
77
|
for (; index < input.length; index++) {
|
|
78
78
|
const byte = input.codePointAt(index);
|
|
79
79
|
if (byte === void 0) return "pending";
|
|
80
|
+
if (byte === 27 || byte === 3) return {
|
|
81
|
+
sequence: "",
|
|
82
|
+
nextIndex: index
|
|
83
|
+
};
|
|
80
84
|
if (isCsiParameterByte(byte) || isCsiIntermediateByte(byte)) continue;
|
|
81
85
|
if (byte === 91 && index === csiPayloadStart) continue;
|
|
82
86
|
if (isCsiFinalByte(byte)) return {
|
|
@@ -101,6 +105,24 @@ const parseControlSequence = (input, startIndex, prefixLength) => {
|
|
|
101
105
|
const sequenceType = input[startIndex + prefixLength];
|
|
102
106
|
if (sequenceType === void 0) return "pending";
|
|
103
107
|
if (sequenceType === "[") return parseCsiSequence(input, startIndex, prefixLength);
|
|
108
|
+
if (sequenceType === "]" || sequenceType === "P" || sequenceType === "_") {
|
|
109
|
+
for (let index = startIndex + prefixLength + 1; index < input.length; index++) {
|
|
110
|
+
if (input[index] === "" || input[index] === escape && index + 1 < input.length && input[index + 1] !== "\\") return {
|
|
111
|
+
sequence: "",
|
|
112
|
+
nextIndex: index
|
|
113
|
+
};
|
|
114
|
+
const bel = sequenceType === "]" && input[index] === "\x07";
|
|
115
|
+
const st = input[index] === escape && input[index + 1] === "\\";
|
|
116
|
+
if (bel || st) {
|
|
117
|
+
const nextIndex = index + (st ? 2 : 1);
|
|
118
|
+
return {
|
|
119
|
+
sequence: input.slice(startIndex, nextIndex),
|
|
120
|
+
nextIndex
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return "pending";
|
|
125
|
+
}
|
|
104
126
|
if (sequenceType === "O") return parseSs3Sequence(input, startIndex, prefixLength);
|
|
105
127
|
};
|
|
106
128
|
const parseEscapedCodePoint = (input, escapeIndex) => {
|
|
@@ -173,7 +195,7 @@ const parseKeypresses = (input) => {
|
|
|
173
195
|
index = endIndex + pasteEnd.length;
|
|
174
196
|
continue;
|
|
175
197
|
}
|
|
176
|
-
events.push(parsedEscapeSequence.sequence);
|
|
198
|
+
if (parsedEscapeSequence.sequence.length > 0) events.push(parsedEscapeSequence.sequence);
|
|
177
199
|
index = parsedEscapeSequence.nextIndex;
|
|
178
200
|
}
|
|
179
201
|
return {
|
|
@@ -183,17 +205,16 @@ const parseKeypresses = (input) => {
|
|
|
183
205
|
};
|
|
184
206
|
const createInputParser = () => {
|
|
185
207
|
let pending = "";
|
|
208
|
+
const hasPendingEscape = () => pending.startsWith(escape) && !/^\u001B{1,2}[[\]P_]/.test(pending);
|
|
186
209
|
return {
|
|
187
210
|
push(chunk) {
|
|
188
211
|
const parsedInput = parseKeypresses(pending + chunk);
|
|
189
212
|
pending = parsedInput.pending;
|
|
190
213
|
return parsedInput.events;
|
|
191
214
|
},
|
|
192
|
-
hasPendingEscape
|
|
193
|
-
return pending.startsWith(escape) && !pending.startsWith(pasteStart) && pending !== pasteStart.slice(0, -1);
|
|
194
|
-
},
|
|
215
|
+
hasPendingEscape,
|
|
195
216
|
flushPendingEscape() {
|
|
196
|
-
if (!
|
|
217
|
+
if (!hasPendingEscape()) return;
|
|
197
218
|
const pendingEscape = pending;
|
|
198
219
|
pending = "";
|
|
199
220
|
return pendingEscape;
|
|
@@ -215,13 +236,15 @@ var TerminalInput = class {
|
|
|
215
236
|
this.#capabilities = capabilities;
|
|
216
237
|
}
|
|
217
238
|
push(chunk) {
|
|
218
|
-
return this.#parser.push(chunk).
|
|
219
|
-
if (typeof event !== "string") return
|
|
220
|
-
if (
|
|
239
|
+
return this.#parser.push(chunk).flatMap((event) => {
|
|
240
|
+
if (typeof event !== "string") return [event];
|
|
241
|
+
if (event.startsWith("\x1B\x1B") && isTerminalQueryResponse(event.slice(1))) return ["\x1B"];
|
|
242
|
+
if (this.#capabilities.ingest(event)) return [];
|
|
243
|
+
if (isTerminalQueryResponse(event)) return [];
|
|
221
244
|
const mouse = parseMouseEvent(event);
|
|
222
|
-
if (!mouse) return
|
|
245
|
+
if (!mouse) return [event];
|
|
223
246
|
for (const listener of this.#mouseListeners) listener(mouse);
|
|
224
|
-
return
|
|
247
|
+
return [];
|
|
225
248
|
});
|
|
226
249
|
}
|
|
227
250
|
subscribeMouse(listener) {
|
package/dist/terminal.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ type InputEvent = string | {
|
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/terminal/input.d.ts
|
|
14
|
-
type MouseButton = "left" | "middle" | "right" | "none" | "wheel-up" | "wheel-down";
|
|
15
|
-
type TerminalMouseEvent = {
|
|
14
|
+
export type MouseButton = "left" | "middle" | "right" | "none" | "wheel-up" | "wheel-down";
|
|
15
|
+
export type TerminalMouseEvent = {
|
|
16
16
|
readonly type: "press" | "release" | "move" | "wheel";
|
|
17
17
|
readonly x: number;
|
|
18
18
|
readonly y: number;
|
|
@@ -22,7 +22,7 @@ type TerminalMouseEvent = {
|
|
|
22
22
|
readonly ctrl: boolean;
|
|
23
23
|
};
|
|
24
24
|
/** Stateful stdin decoder that separates terminal reports from application input. */
|
|
25
|
-
declare class TerminalInput {
|
|
25
|
+
export declare class TerminalInput {
|
|
26
26
|
#private;
|
|
27
27
|
constructor(capabilities: CapabilitiesStore);
|
|
28
28
|
push(chunk: string): InputEvent[];
|
|
@@ -31,22 +31,22 @@ declare class TerminalInput {
|
|
|
31
31
|
flushPendingEscape(): string | undefined;
|
|
32
32
|
reset(): void;
|
|
33
33
|
}
|
|
34
|
-
declare function parseMouseEvent(sequence: string): TerminalMouseEvent | undefined;
|
|
34
|
+
export declare function parseMouseEvent(sequence: string): TerminalMouseEvent | undefined;
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/terminal/session.d.ts
|
|
37
|
-
type TerminalSessionOptions = {
|
|
37
|
+
export type TerminalSessionOptions = {
|
|
38
38
|
readonly stdin: NodeJS.ReadableStream;
|
|
39
39
|
readonly stdout: OutputStream;
|
|
40
40
|
readonly stderr: OutputStream;
|
|
41
41
|
readonly colorPolicy?: ColorPolicy;
|
|
42
42
|
readonly onCapabilitiesChange?: () => void;
|
|
43
43
|
};
|
|
44
|
-
type TerminalMode = {
|
|
44
|
+
export type TerminalMode = {
|
|
45
45
|
readonly id: string;
|
|
46
46
|
readonly enable: string;
|
|
47
47
|
readonly disable: string;
|
|
48
48
|
};
|
|
49
|
-
type TerminalCursor = {
|
|
49
|
+
export type TerminalCursor = {
|
|
50
50
|
readonly position?: CursorPosition;
|
|
51
51
|
readonly visible: boolean;
|
|
52
52
|
readonly shape: CursorShape;
|
|
@@ -54,7 +54,7 @@ type TerminalCursor = {
|
|
|
54
54
|
readonly color?: string;
|
|
55
55
|
};
|
|
56
56
|
/** Instance-scoped terminal state and lifecycle ownership. */
|
|
57
|
-
declare class TerminalSession {
|
|
57
|
+
export declare class TerminalSession {
|
|
58
58
|
#private;
|
|
59
59
|
readonly stdin: NodeJS.ReadableStream;
|
|
60
60
|
readonly stdout: OutputStream;
|
|
@@ -117,5 +117,4 @@ declare class TerminalSession {
|
|
|
117
117
|
resume(): void;
|
|
118
118
|
cleanup(): void;
|
|
119
119
|
}
|
|
120
|
-
//#endregion
|
|
121
|
-
export { MouseButton, TerminalCursor, TerminalInput, TerminalMode, TerminalMouseEvent, TerminalSession, TerminalSessionOptions, parseMouseEvent };
|
|
120
|
+
//#endregion
|
package/dist/terminal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TerminalInput, r as parseMouseEvent, t as TerminalSession } from "./session-
|
|
1
|
+
import { n as TerminalInput, r as parseMouseEvent, t as TerminalSession } from "./session-DDQ5V300.js";
|
|
2
2
|
export { TerminalInput, TerminalSession, parseMouseEvent };
|