ignotum 0.0.13 → 0.0.15
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/README.md +6 -6
- package/dist/cli/bin.mjs +6111 -4448
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/cli/emscripten-module-D5GzfUNv.mjs +533 -0
- package/dist/cli/emscripten-module-D5GzfUNv.mjs.map +1 -0
- package/dist/cli/ffi-7IElU4Co.mjs +148 -0
- package/dist/cli/ffi-7IElU4Co.mjs.map +1 -0
- package/dist/cli/managed-release-WHYLZwaS.mjs +10902 -0
- package/dist/cli/managed-release-WHYLZwaS.mjs.map +1 -0
- package/dist/cli/managed-release.d.mts +1 -0
- package/dist/cli/managed-release.mjs +14 -0
- package/dist/cli/managed-release.mjs.map +1 -0
- package/dist/cli/module-ES6BEMUI-D36I4NVn.mjs +1289 -0
- package/dist/cli/module-ES6BEMUI-D36I4NVn.mjs.map +1 -0
- package/dist/runtime/{api-Cv3hMbzo.d.ts → api-B4fwp5a2.d.ts} +4 -4
- package/dist/runtime/bootstrap-BISQSn_O.js +916 -0
- package/dist/runtime/bootstrap-BISQSn_O.js.map +1 -0
- package/dist/runtime/bootstrap-BTFScKAc.d.ts +545 -0
- package/dist/runtime/client.d.ts +50 -15
- package/dist/runtime/client.js +7 -1138
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/descriptor-CTY4mtwS-cS43EbwS.js +269 -0
- package/dist/runtime/descriptor-CTY4mtwS-cS43EbwS.js.map +1 -0
- package/dist/runtime/{id-Bt9XWRGL.js → id--1m0NuUL.js} +4 -4
- package/dist/runtime/id--1m0NuUL.js.map +1 -0
- package/dist/runtime/{id-BzFHf3Wo-DGPCjgrf.d.ts → id-7an3nxTu-DZJSM5xh.d.ts} +2 -2
- package/dist/runtime/id-CBOt2kDo.d.ts +1 -0
- package/dist/runtime/identity-QjtJRxBD.d.ts +2 -0
- package/dist/runtime/image-Djtjy4Z8.js +19 -0
- package/dist/runtime/image-Djtjy4Z8.js.map +1 -0
- package/dist/runtime/index-D4seNHlX.d.ts +184 -0
- package/dist/runtime/internal/api.d.ts +1 -1
- package/dist/runtime/internal/api.js +30 -1
- package/dist/runtime/internal/api.js.map +1 -0
- package/dist/runtime/internal/bootstrap.d.ts +2 -0
- package/dist/runtime/internal/bootstrap.js +2 -0
- package/dist/runtime/internal/client.d.ts +2 -0
- package/dist/runtime/internal/client.js +75 -0
- package/dist/runtime/internal/client.js.map +1 -0
- package/dist/runtime/internal/host.d.ts +25 -8
- package/dist/runtime/internal/host.js +27 -6
- package/dist/runtime/internal/host.js.map +1 -1
- package/dist/runtime/internal/routes.d.ts +2 -0
- package/dist/runtime/internal/routes.js +2 -0
- package/dist/runtime/internal/server.d.ts +1 -1
- package/dist/runtime/internal/server.js +1 -1
- package/dist/runtime/internal/types.d.ts +2 -1
- package/dist/runtime/internal/types.js +1 -1
- package/dist/runtime/pagination-CBOt2kDo.d.ts +1 -0
- package/dist/runtime/pagination-D3qd6s9N.js +33 -0
- package/dist/runtime/pagination-D3qd6s9N.js.map +1 -0
- package/dist/runtime/result-BkziOG1L.d.ts +1 -0
- package/dist/runtime/router-BSBI1oN1.js +2377 -0
- package/dist/runtime/router-BSBI1oN1.js.map +1 -0
- package/dist/runtime/routes-Ce8TVP-T.js +690 -0
- package/dist/runtime/routes-Ce8TVP-T.js.map +1 -0
- package/dist/runtime/{schema-1Zs03-iS.js → schema-D1wOqiNH.js} +40 -12
- package/dist/runtime/schema-D1wOqiNH.js.map +1 -0
- package/dist/runtime/server.d.ts +5 -5
- package/dist/runtime/server.js +2 -2
- package/dist/runtime/{sync-Bs8J3fIr.d.ts → sync-D-GK2sv9.d.ts} +3 -2
- package/dist/runtime/{api-CAgKDij7.js → sync-DzUwA8W9.js} +22 -41
- package/dist/runtime/sync-DzUwA8W9.js.map +1 -0
- package/dist/runtime/types-DeCCyqLU-BIm7rU-0.d.ts +341 -0
- package/package.json +29 -4
- package/src/cli/agent-files.ts +14 -8
- package/src/cli/build/managed-client.ts +411 -0
- package/src/cli/build/managed-server.ts +294 -0
- package/src/cli/build/managed.ts +67 -0
- package/src/cli/build/output.ts +47 -0
- package/src/cli/build/server.ts +51 -220
- package/src/cli/client-config.ts +1 -140
- package/src/cli/client-styles.ts +1 -0
- package/src/cli/codegen.ts +9 -4
- package/src/cli/command.ts +28 -5
- package/src/cli/control-client.ts +84 -101
- package/src/cli/deploy.ts +133 -177
- package/src/cli/dev.ts +506 -107
- package/src/cli/image-assets.ts +499 -0
- package/src/cli/managed-client-boundaries.ts +103 -0
- package/src/cli/managed-dev-platform.ts +118 -0
- package/src/cli/managed-exports.ts +219 -0
- package/src/cli/managed-release-bin.ts +13 -0
- package/src/cli/managed-release.ts +260 -0
- package/src/cli/module-boundaries.ts +11 -1
- package/src/cli/new-app.ts +111 -87
- package/src/cli/route-codegen.ts +311 -0
- package/src/cli/route-static.ts +710 -0
- package/src/client/bootstrap.ts +110 -0
- package/src/client/errors.ts +13 -7
- package/src/client/files.ts +64 -0
- package/src/client/id.ts +9 -5
- package/src/client/image.ts +28 -0
- package/src/client/index.ts +25 -2
- package/src/client/managed-client.ts +729 -0
- package/src/client/managed-upgrade.ts +283 -0
- package/src/client/recovery-journal.ts +195 -0
- package/src/client/route-boundaries.ts +184 -0
- package/src/client/router-history.ts +152 -0
- package/src/client/router-store.ts +644 -0
- package/src/client/router.ts +324 -0
- package/src/client/routes.ts +28 -0
- package/src/client/sync.ts +66 -592
- package/src/dev-runtime/database.ts +77 -2
- package/src/dev-runtime/functions.ts +3 -3
- package/src/dev-runtime/id.ts +19 -4
- package/src/dev-runtime/managed-functions.ts +255 -0
- package/src/dev-runtime/managed-sync.ts +263 -0
- package/src/dev-runtime/managed-websocket.ts +71 -0
- package/src/dev-runtime/migrations.ts +20 -0
- package/src/dev-runtime/sync.ts +236 -236
- package/src/image-assets.d.ts +36 -0
- package/src/internal/client.ts +186 -0
- package/src/internal/host.ts +1 -1
- package/src/internal/http-paths.ts +0 -3
- package/src/internal/routes.ts +45 -0
- package/dist/runtime/api-CAgKDij7.js.map +0 -1
- package/dist/runtime/descriptor-Cyo9FP9n-C0SRVXNW.js +0 -154
- package/dist/runtime/descriptor-Cyo9FP9n-C0SRVXNW.js.map +0 -1
- package/dist/runtime/id-Bt9XWRGL.js.map +0 -1
- package/dist/runtime/id-Dz0apuB3.d.ts +0 -1
- package/dist/runtime/index-D54flWtH.d.ts +0 -402
- package/dist/runtime/pagination-DnKg3dkI-r5ZUxBBx.d.ts +0 -112
- package/dist/runtime/pagination-Dz0apuB3.d.ts +0 -1
- package/dist/runtime/result-DKAA4gpS.d.ts +0 -1
- package/dist/runtime/schema-1Zs03-iS.js.map +0 -1
- package/src/cli/build/client.ts +0 -119
- package/src/cli/build/public.ts +0 -186
- package/src/cli/client-entry.ts +0 -152
- package/src/cli/client-plugin.ts +0 -136
- package/src/client/app.ts +0 -15
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import * as Versioned from "@ignotum/contracts/versioned";
|
|
2
|
+
import { Deferred, Effect, Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
const HistoryEntryV1 = Schema.Struct({ formatVersion: Schema.Literal(1), key: Schema.String });
|
|
5
|
+
const HistoryEntryV2 = Schema.Struct({
|
|
6
|
+
formatVersion: Schema.Literal(2),
|
|
7
|
+
key: Schema.String,
|
|
8
|
+
index: Schema.NullOr(Schema.Int),
|
|
9
|
+
});
|
|
10
|
+
const HistoryEntry = Versioned.upgrade(
|
|
11
|
+
Versioned.initial(HistoryEntryV1),
|
|
12
|
+
HistoryEntryV2,
|
|
13
|
+
(old) => ({
|
|
14
|
+
formatVersion: 2 as const,
|
|
15
|
+
key: old.key,
|
|
16
|
+
index: null,
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
const HistoryState = Schema.Struct({ __ignotumRouter: HistoryEntry });
|
|
20
|
+
const StateObject = Schema.Record(Schema.String, Schema.Unknown);
|
|
21
|
+
export interface HistoryPosition {
|
|
22
|
+
readonly key: string;
|
|
23
|
+
readonly index: number;
|
|
24
|
+
readonly href: string;
|
|
25
|
+
}
|
|
26
|
+
const hrefOf = (browser: Window) =>
|
|
27
|
+
`${browser.location.pathname}${browser.location.search}${browser.location.hash}`;
|
|
28
|
+
|
|
29
|
+
/** Serializes router corrections to native traversal without adding duplicate entries. */
|
|
30
|
+
export class RouterHistory {
|
|
31
|
+
committed: HistoryPosition;
|
|
32
|
+
private actual: HistoryPosition;
|
|
33
|
+
private readonly positions = new Map<string, number>();
|
|
34
|
+
private seeking: { position: HistoryPosition; done: Deferred.Deferred<boolean> } | undefined;
|
|
35
|
+
private readonly originalScrollRestoration;
|
|
36
|
+
private direction = -1;
|
|
37
|
+
private scrollPending = false;
|
|
38
|
+
private expectedKey: string | undefined;
|
|
39
|
+
readonly scroll = new Map<string, { x: number; y: number }>();
|
|
40
|
+
constructor(
|
|
41
|
+
private readonly browser: Window,
|
|
42
|
+
private readonly onTraversal: (position: HistoryPosition) => void,
|
|
43
|
+
) {
|
|
44
|
+
const parsed = Schema.decodeUnknownOption(HistoryState)(browser.history.state);
|
|
45
|
+
const entry = parsed._tag === "Some" ? parsed.value.__ignotumRouter : undefined;
|
|
46
|
+
this.actual = this.committed = {
|
|
47
|
+
key: entry?.key ?? browser.crypto.randomUUID(),
|
|
48
|
+
index: entry?.index ?? 0,
|
|
49
|
+
href: hrefOf(browser),
|
|
50
|
+
};
|
|
51
|
+
this.write(this.actual, false);
|
|
52
|
+
this.originalScrollRestoration = browser.history.scrollRestoration;
|
|
53
|
+
browser.history.scrollRestoration = "manual";
|
|
54
|
+
browser.addEventListener("popstate", this.onPop);
|
|
55
|
+
browser.addEventListener("scroll", this.saveScroll);
|
|
56
|
+
}
|
|
57
|
+
private write(position: HistoryPosition, push: boolean): void {
|
|
58
|
+
const parsed = Schema.decodeUnknownOption(StateObject)(this.browser.history.state);
|
|
59
|
+
const owned = {
|
|
60
|
+
__ignotumRouter: Schema.encodeSync(HistoryEntry)({
|
|
61
|
+
formatVersion: 2,
|
|
62
|
+
key: position.key,
|
|
63
|
+
index: position.index,
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
const state = parsed._tag === "Some" ? { ...parsed.value, ...owned } : owned;
|
|
67
|
+
if (push) this.browser.history.pushState(state, "", position.href);
|
|
68
|
+
else this.browser.history.replaceState(state, "", position.href);
|
|
69
|
+
this.positions.set(position.key, position.index);
|
|
70
|
+
}
|
|
71
|
+
saveScroll = (): void => {
|
|
72
|
+
if (this.scrollPending) return;
|
|
73
|
+
this.scroll.set(this.committed.key, { x: this.browser.scrollX, y: this.browser.scrollY });
|
|
74
|
+
};
|
|
75
|
+
captureScroll(): { x: number; y: number } {
|
|
76
|
+
this.saveScroll();
|
|
77
|
+
this.scrollPending = true;
|
|
78
|
+
return (
|
|
79
|
+
this.scroll.get(this.committed.key) ?? { x: this.browser.scrollX, y: this.browser.scrollY }
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
finishScroll(): void {
|
|
83
|
+
this.scrollPending = false;
|
|
84
|
+
this.saveScroll();
|
|
85
|
+
}
|
|
86
|
+
restoreSourceScroll(): void {
|
|
87
|
+
if (!this.scrollPending) return;
|
|
88
|
+
const saved = this.scroll.get(this.committed.key);
|
|
89
|
+
if (saved !== undefined) this.browser.scrollTo(saved.x, saved.y);
|
|
90
|
+
this.finishScroll();
|
|
91
|
+
}
|
|
92
|
+
private onPop = (): void => {
|
|
93
|
+
const parsed = Schema.decodeUnknownOption(HistoryState)(this.browser.history.state);
|
|
94
|
+
const entry = parsed._tag === "Some" ? parsed.value.__ignotumRouter : undefined;
|
|
95
|
+
const key = entry?.key ?? this.browser.crypto.randomUUID();
|
|
96
|
+
const index = entry?.index ?? this.positions.get(key) ?? this.actual.index + this.direction;
|
|
97
|
+
this.actual = { key, index, href: hrefOf(this.browser) };
|
|
98
|
+
this.write(this.actual, false);
|
|
99
|
+
const expected = this.expectedKey;
|
|
100
|
+
this.expectedKey = undefined;
|
|
101
|
+
const seeking = this.seeking;
|
|
102
|
+
if (seeking !== undefined && (expected === key || seeking.position.key === key)) {
|
|
103
|
+
this.advanceSeek();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (seeking !== undefined) {
|
|
107
|
+
this.seeking = undefined;
|
|
108
|
+
Effect.runSync(Deferred.succeed(seeking.done, false));
|
|
109
|
+
}
|
|
110
|
+
this.onTraversal(this.actual);
|
|
111
|
+
};
|
|
112
|
+
private advanceSeek(): void {
|
|
113
|
+
const seeking = this.seeking;
|
|
114
|
+
if (seeking === undefined || this.expectedKey !== undefined) return;
|
|
115
|
+
if (this.actual.key === seeking.position.key) {
|
|
116
|
+
this.seeking = undefined;
|
|
117
|
+
Effect.runSync(Deferred.succeed(seeking.done, true));
|
|
118
|
+
} else {
|
|
119
|
+
this.expectedKey = seeking.position.key;
|
|
120
|
+
this.browser.history.go(seeking.position.index - this.actual.index);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
seek(position: HistoryPosition): Promise<boolean> {
|
|
124
|
+
if (this.seeking !== undefined) {
|
|
125
|
+
if (this.seeking.position.key === position.key)
|
|
126
|
+
return Effect.runPromise(Deferred.await(this.seeking.done));
|
|
127
|
+
Effect.runSync(Deferred.succeed(this.seeking.done, false));
|
|
128
|
+
}
|
|
129
|
+
const done = Deferred.makeUnsafe<boolean>();
|
|
130
|
+
this.seeking = { position, done };
|
|
131
|
+
this.advanceSeek();
|
|
132
|
+
return Effect.runPromise(Deferred.await(done));
|
|
133
|
+
}
|
|
134
|
+
commit(position: HistoryPosition, kind: "initial" | "push" | "replace" | "traverse"): void {
|
|
135
|
+
if (kind === "push" || kind === "replace") this.write(position, kind === "push");
|
|
136
|
+
this.actual = this.committed = position;
|
|
137
|
+
}
|
|
138
|
+
back = (): void => {
|
|
139
|
+
this.direction = -1;
|
|
140
|
+
this.browser.history.back();
|
|
141
|
+
};
|
|
142
|
+
forward = (): void => {
|
|
143
|
+
this.direction = 1;
|
|
144
|
+
this.browser.history.forward();
|
|
145
|
+
};
|
|
146
|
+
dispose(): void {
|
|
147
|
+
this.browser.removeEventListener("popstate", this.onPop);
|
|
148
|
+
this.browser.removeEventListener("scroll", this.saveScroll);
|
|
149
|
+
this.browser.history.scrollRestoration = this.originalScrollRestoration;
|
|
150
|
+
if (this.seeking !== undefined) Effect.runSync(Deferred.succeed(this.seeking.done, false));
|
|
151
|
+
}
|
|
152
|
+
}
|