slopkit 0.3.0 → 0.4.0-rc.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/DEPS.md +5 -3
- package/README.md +93 -1
- package/RULES.md +26 -6
- package/dist/api.d.ts +93 -0
- package/dist/api.js +111 -0
- package/dist/client.d.ts +5 -1
- package/dist/conformance/agent-access.test.d.ts +1 -0
- package/dist/conformance/agent-access.test.js +74 -0
- package/dist/conformance/paging-state.test.js +1 -0
- package/dist/conformance/states.test.js +19 -8
- package/dist/server/auth.d.ts +4 -3
- package/dist/server/auth.js +14 -6
- package/dist/server/cli.d.ts +117 -0
- package/dist/server/cli.js +1534 -0
- package/dist/server/config.d.ts +4 -1
- package/dist/server/config.js +2 -2
- package/dist/server/keys.d.ts +17 -0
- package/dist/server/keys.js +127 -0
- package/dist/server/store.d.ts +101 -0
- package/dist/server/store.js +347 -0
- package/dist/server/sync.d.ts +158 -0
- package/dist/server/sync.js +293 -0
- package/dist/server/web.d.ts +54 -5
- package/dist/server/web.js +236 -28
- package/dist/states.d.ts +52 -4
- package/dist/states.js +20 -0
- package/dist/sync.d.ts +2 -0
- package/dist/sync.js +1 -0
- package/dist/test/agents.d.ts +19 -0
- package/dist/test/agents.js +62 -0
- package/dist/test/page.d.ts +91 -0
- package/dist/test/page.js +763 -0
- package/dist/test/states.d.ts +44 -7
- package/dist/test/states.js +152 -0
- package/dist/web/replica.d.ts +7 -0
- package/dist/web/replica.js +214 -43
- package/dist/web/runtime.d.ts +102 -0
- package/dist/web/runtime.js +335 -0
- package/package.json +39 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { WebConfig } from "../server/config.ts";
|
|
2
|
+
import type { Logger } from "../server/log.ts";
|
|
3
|
+
import type { Line, Meaning } from "../states.ts";
|
|
4
|
+
import type { Model } from "../sync.ts";
|
|
5
|
+
import type { World } from "./states.ts";
|
|
6
|
+
/** What the app's server gives the driver: where it listens, how it stops, its due jobs run, its open jobs listed. */
|
|
7
|
+
export type PageServer = {
|
|
8
|
+
url: string;
|
|
9
|
+
close: () => Promise<void>;
|
|
10
|
+
/** Runs the server's jobs due by now (the driver's clock). */
|
|
11
|
+
due?: () => unknown;
|
|
12
|
+
/** The server's jobs, for the honest check (`World.jobs`). */
|
|
13
|
+
jobs?: () => World["jobs"];
|
|
14
|
+
};
|
|
15
|
+
/** What the page shows and its sync model, read from the loaded page entry. */
|
|
16
|
+
export type PageRead = {
|
|
17
|
+
shown: unknown;
|
|
18
|
+
model?: Model<any, any, any, any>;
|
|
19
|
+
};
|
|
20
|
+
export type PageOptions<E> = {
|
|
21
|
+
/** The app's server in this process, on the driver's web config, reading time from `now`. */
|
|
22
|
+
server: (context: {
|
|
23
|
+
home: string;
|
|
24
|
+
web: WebConfig;
|
|
25
|
+
now: () => number;
|
|
26
|
+
log: Logger;
|
|
27
|
+
}) => Promise<PageServer>;
|
|
28
|
+
/** Imports the app's page entry, which renders into `#app`; modules are fresh on each load. */
|
|
29
|
+
page: () => Promise<E>;
|
|
30
|
+
/** What the page shows and its sync model, from the loaded entry. */
|
|
31
|
+
read?: (entry: E) => PageRead;
|
|
32
|
+
/** When the clock starts: an instant or ms since the epoch. */
|
|
33
|
+
at: string | number;
|
|
34
|
+
/** Where the page first loads, on the server: a deep link (default `/`). */
|
|
35
|
+
path?: string;
|
|
36
|
+
/** The app's severity order, for the honest checks. */
|
|
37
|
+
order?: readonly Meaning[];
|
|
38
|
+
/** How far a settle waits for pending timeouts, in ms of the clock. */
|
|
39
|
+
idle?: number;
|
|
40
|
+
viewport?: {
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/** A line the page's view holds now. */
|
|
46
|
+
export type ReadLine = {
|
|
47
|
+
subject: string;
|
|
48
|
+
kind: string;
|
|
49
|
+
meaning: Meaning;
|
|
50
|
+
text: string;
|
|
51
|
+
owed: Line<unknown>["owed"];
|
|
52
|
+
};
|
|
53
|
+
export type Page = {
|
|
54
|
+
/** Types into the text field with this accessible name (replacing its value), then settles. */
|
|
55
|
+
type: (name: string | RegExp, text: string) => Promise<void>;
|
|
56
|
+
/** Presses the button or link with this accessible name, then settles. */
|
|
57
|
+
press: (name: string | RegExp) => Promise<void>;
|
|
58
|
+
/** Picks an option (by value or label) in the select with this accessible name, then settles. */
|
|
59
|
+
select: (name: string | RegExp, option: string) => Promise<void>;
|
|
60
|
+
/** Moves the clock by `ms`, running what falls in it, then settles. */
|
|
61
|
+
advance: (ms: number) => Promise<void>;
|
|
62
|
+
/** Waits until quiet, then checks the view; throws on its problems unless `lenient`. */
|
|
63
|
+
settle: (options?: {
|
|
64
|
+
lenient?: boolean;
|
|
65
|
+
}) => Promise<{
|
|
66
|
+
lines: ReadLine[];
|
|
67
|
+
problems: string[];
|
|
68
|
+
}>;
|
|
69
|
+
/** The text of the element named by aria-label or aria-labelledby, or of the whole page. */
|
|
70
|
+
text: (name?: string | RegExp) => string;
|
|
71
|
+
/** The lines the view holds now. */
|
|
72
|
+
lines: () => ReadLine[];
|
|
73
|
+
/**
|
|
74
|
+
* A new page load at the address the page is on: fresh modules and DOM; this device's storage (IndexedDB,
|
|
75
|
+
* localStorage, sessionStorage), or a new device's, empty.
|
|
76
|
+
*/
|
|
77
|
+
reload: (options?: {
|
|
78
|
+
device?: "same" | "new";
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
/** The page's address, absolute. */
|
|
81
|
+
location: () => string;
|
|
82
|
+
/** History back within the page (an entry it pushed): the address moves and the page hears popstate; then settles. */
|
|
83
|
+
back: () => Promise<void>;
|
|
84
|
+
/** Drops the session: the server then answers this page as no one. */
|
|
85
|
+
signOut: () => Promise<void>;
|
|
86
|
+
/** Signs in again through the stand-in. */
|
|
87
|
+
signIn: () => Promise<void>;
|
|
88
|
+
readonly now: number;
|
|
89
|
+
close: () => Promise<void>;
|
|
90
|
+
};
|
|
91
|
+
export declare function openPage<E>(options: PageOptions<E>): Promise<Page>;
|