akanjs 3.3.0-rc.5 → 3.3.0-rc.6
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/CHANGELOG.md +1 -0
- package/client/appOpenedTab.ts +12 -0
- package/client/router.ts +2 -0
- package/package.json +1 -1
- package/types/client/appOpenedTab.d.ts +1 -0
- package/types/ui/Link/Action.d.ts +2 -1
- package/ui/Link/Action.tsx +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
### Patch Changes
|
|
20
20
|
|
|
21
21
|
- c44d068: A coding agent reads less to build its first app: the `akanjs` README keeps the path to a first app and links the rest on akanjs.com (17 KB to 7 KB), the `akan-page` and `akan-service` skills ship the API reference one section at a time with every entry named in the skill's index (`Link` now lists the anchor attributes it takes and `Link.Back`, `Link.Close` and `Link.Lang`), the `akan-page` skill holds what a first page looks up while `pageRule` keeps the deeper contract, and each rule is stated once across AGENTS.md, the path rules and the skills. Run `akan agent install` in a workspace to pick up the new files.
|
|
22
|
+
- af09c4f: `router.backOrFallback()` and `Link.Back` with a `fallback` close a browser tab the app itself opened instead of replacing to the fallback, when there is nothing to go back to. The tab counts as opened by the app when it holds one history entry and has an opener or a same-origin referrer, so a `window.open(href, "_blank", "noopener")` or `target="_blank"` link qualifies. A tab the person opened (a bookmark, a typed URL), one another site opened, and an iOS, Android or desktop shell keep going to the fallback, as does a tab the browser refuses to close.
|
|
22
23
|
- 24315d1: A page asks for its stylesheet before its client chunks. The preload tags for the chunks a page's first screen imports are written at the end of `<head>` instead of at its top, so the stylesheet link comes first; the bootstrap module, the dictionary and the import map stay at the top. On a throttled mobile connection (Lighthouse's slow 4G applied in the browser, over HTTP/2) a 56-chunk page first paints about 160 ms sooner (1.83 s to 1.67 s), and a page whose largest element is a small image shows it about 140 ms sooner; a large image still shares the connection with the chunks and arrives when it did. Every chunk still starts loading with the document, so the page hydrates when it did.
|
|
23
24
|
- bf582c1: A page stored in the HTML cache is kept as the bytes it streamed, instead of being decoded to text and encoded again before compression. Storing a 600 KB page takes about a fifth of the main-thread time it did, and the stored page and every response from it are unchanged.
|
|
24
25
|
- c10f7cf: A loader sends its store at most 500 distinct keys per query and splits a larger batch into several queries that run together. A `load<Model>Many` or a nested list with more ids than a database takes in one statement now loads instead of failing: Postgres refused more than 65,534 values, and SQLite refused a `byQuery` batch of about 1,000 keys.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Href } from "./href";
|
|
2
|
+
import { isNativeShell } from "./nativeHost";
|
|
3
|
+
|
|
4
|
+
export const closeAppOpenedTab = (): boolean => {
|
|
5
|
+
const win = globalThis.window;
|
|
6
|
+
if (!win || isNativeShell() || win.history?.length !== 1 || typeof win.close !== "function") return false;
|
|
7
|
+
|
|
8
|
+
const referrer = globalThis.document?.referrer ?? "";
|
|
9
|
+
if (!win.opener && (!referrer || Href.leavesOrigin(referrer, win.location.href))) return false;
|
|
10
|
+
win.close();
|
|
11
|
+
return win.closed === true;
|
|
12
|
+
};
|
package/client/router.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
parseBasePaths,
|
|
10
10
|
trimSlashes,
|
|
11
11
|
} from "akanjs/common";
|
|
12
|
+
import { closeAppOpenedTab } from "./appOpenedTab";
|
|
12
13
|
import { CsrLocation, csrLocation } from "./csrLocation";
|
|
13
14
|
import { Href } from "./href";
|
|
14
15
|
import { isMcpView } from "./mcpView";
|
|
@@ -654,6 +655,7 @@ class Router {
|
|
|
654
655
|
this.back(routeOptions);
|
|
655
656
|
return undefined as never;
|
|
656
657
|
}
|
|
658
|
+
if (closeAppOpenedTab()) return undefined as never;
|
|
657
659
|
this.replace(fallbackHref, routeOptions);
|
|
658
660
|
return undefined as never;
|
|
659
661
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const closeAppOpenedTab: () => boolean;
|
|
@@ -4,7 +4,8 @@ export interface ActionProps {
|
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
}
|
|
6
6
|
export interface BackProps extends ActionProps {
|
|
7
|
-
/** Where to go when there is no history to go back to, as on a deep link or a freshly opened app
|
|
7
|
+
/** Where to go when there is no history to go back to, as on a deep link or a freshly opened app; a browser tab this
|
|
8
|
+
* app opened closes instead. */
|
|
8
9
|
fallback?: string;
|
|
9
10
|
}
|
|
10
11
|
export declare const Back: ({ className, children, fallback }: BackProps) => import("react").JSX.Element;
|
package/ui/Link/Action.tsx
CHANGED
|
@@ -8,7 +8,8 @@ export interface ActionProps {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface BackProps extends ActionProps {
|
|
11
|
-
/** Where to go when there is no history to go back to, as on a deep link or a freshly opened app
|
|
11
|
+
/** Where to go when there is no history to go back to, as on a deep link or a freshly opened app; a browser tab this
|
|
12
|
+
* app opened closes instead. */
|
|
12
13
|
fallback?: string;
|
|
13
14
|
}
|
|
14
15
|
|