@fluxfast/core 0.0.0-oidc-bootstrap.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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/cache.d.ts +18 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +50 -0
- package/dist/cache.js.map +1 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +75 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +62 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +45 -0
- package/dist/events.js.map +1 -0
- package/dist/history.d.ts +19 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +55 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/mutation.d.ts +6 -0
- package/dist/mutation.d.ts.map +1 -0
- package/dist/mutation.js +62 -0
- package/dist/mutation.js.map +1 -0
- package/dist/prefetch.d.ts +20 -0
- package/dist/prefetch.d.ts.map +1 -0
- package/dist/prefetch.js +78 -0
- package/dist/prefetch.js.map +1 -0
- package/dist/protocol.d.ts +49 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +10 -0
- package/dist/protocol.js.map +1 -0
- package/dist/router.d.ts +67 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +242 -0
- package/dist/router.js.map +1 -0
- package/dist/store.d.ts +93 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +277 -0
- package/dist/store.js.map +1 -0
- package/dist/transport.d.ts +38 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +218 -0
- package/dist/transport.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FluxFast Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @fluxfast/core
|
|
2
|
+
|
|
3
|
+
Framework-neutral browser runtime for the FluxFast protocol. It provides the
|
|
4
|
+
resource store, router, transport, cache, mutation, history, event, and
|
|
5
|
+
prefetch primitives shared by frontend adapters.
|
|
6
|
+
|
|
7
|
+
Most applications should install an adapter such as `@fluxfast/next`, which
|
|
8
|
+
installs a compatible version of this package automatically. Install the core
|
|
9
|
+
package directly when building an adapter or using its framework-neutral APIs:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @fluxfast/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { FluxRouter, ResourceStore } from "@fluxfast/core";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`@fluxfast/core` has no React, Next.js, Vue, Svelte, or Solid dependency. It
|
|
20
|
+
supports Node.js 22 and 24, while the browser-facing APIs target modern web
|
|
21
|
+
runtimes.
|
|
22
|
+
|
|
23
|
+
See the [FluxFast architecture](https://github.com/El37628/FluxFast/blob/main/docs/architecture.md),
|
|
24
|
+
[wire protocol](https://github.com/El37628/FluxFast/blob/main/docs/protocol.md),
|
|
25
|
+
and [versioning policy](https://github.com/El37628/FluxFast/blob/main/docs/versioning.md)
|
|
26
|
+
for the public contracts.
|
|
27
|
+
|
|
28
|
+
FluxFast is licensed under the [MIT License](https://github.com/El37628/FluxFast/blob/main/LICENSE).
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PageDescriptor } from "./protocol";
|
|
2
|
+
import { ResourceStore } from "./store";
|
|
3
|
+
export interface CachedPage {
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly component: string;
|
|
6
|
+
readonly meta: Record<string, unknown>;
|
|
7
|
+
readonly resources: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/** Lightweight LRU page cache. Resource values remain in ResourceStore. */
|
|
10
|
+
export declare class PageCache {
|
|
11
|
+
private readonly maxPages;
|
|
12
|
+
private readonly entries;
|
|
13
|
+
constructor(maxPages?: number);
|
|
14
|
+
set(page: PageDescriptor, resources: Record<string, string>): void;
|
|
15
|
+
getValid(url: string, resources: ResourceStore): CachedPage | undefined;
|
|
16
|
+
clear(): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED,2EAA2E;AAC3E,qBAAa,SAAS;IAGR,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IAEzD,YAA6B,QAAQ,GAAE,MAAW,EAIjD;IAED,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAejE;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,UAAU,GAAG,SAAS,CAetE;IAED,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageCache = void 0;
|
|
4
|
+
/** Lightweight LRU page cache. Resource values remain in ResourceStore. */
|
|
5
|
+
class PageCache {
|
|
6
|
+
maxPages;
|
|
7
|
+
entries = new Map();
|
|
8
|
+
constructor(maxPages = 32) {
|
|
9
|
+
this.maxPages = maxPages;
|
|
10
|
+
if (!Number.isInteger(maxPages) || maxPages <= 0) {
|
|
11
|
+
throw new RangeError("maxPages must be a positive integer");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
set(page, resources) {
|
|
15
|
+
const entry = {
|
|
16
|
+
url: page.url,
|
|
17
|
+
component: page.component,
|
|
18
|
+
meta: { ...(page.meta ?? {}) },
|
|
19
|
+
resources: { ...resources },
|
|
20
|
+
};
|
|
21
|
+
this.entries.delete(page.url);
|
|
22
|
+
this.entries.set(page.url, entry);
|
|
23
|
+
while (this.entries.size > this.maxPages) {
|
|
24
|
+
const oldest = this.entries.keys().next().value;
|
|
25
|
+
if (oldest === undefined)
|
|
26
|
+
break;
|
|
27
|
+
this.entries.delete(oldest);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
getValid(url, resources) {
|
|
31
|
+
const entry = this.entries.get(url);
|
|
32
|
+
if (!entry)
|
|
33
|
+
return undefined;
|
|
34
|
+
for (const [key, version] of Object.entries(entry.resources)) {
|
|
35
|
+
const record = resources.getRecord(key);
|
|
36
|
+
if (!record || record.version !== version || resources.isStale(key)) {
|
|
37
|
+
this.entries.delete(url);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
this.entries.delete(url);
|
|
42
|
+
this.entries.set(url, entry);
|
|
43
|
+
return entry;
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
this.entries.clear();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.PageCache = PageCache;
|
|
50
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":";;;AAUA,2EAA2E;AAC3E;IAG+B,QAAQ;IAFpB,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEzD,YAA6B,QAAQ,GAAW,EAAE;wBAArB,QAAQ;QACnC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,UAAU,CAAC,qCAAqC,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,GAAG,CAAC,IAAoB,EAAE,SAAiC;QACzD,MAAM,KAAK,GAAe;YACxB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAA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G,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FluxFast error classes for core client runtime.
|
|
3
|
+
*/
|
|
4
|
+
export declare class FluxFastError extends Error {
|
|
5
|
+
readonly details?: unknown;
|
|
6
|
+
constructor(message: string, details?: unknown);
|
|
7
|
+
}
|
|
8
|
+
export declare class ProtocolError extends FluxFastError {
|
|
9
|
+
constructor(message: string, details?: unknown);
|
|
10
|
+
}
|
|
11
|
+
export declare class TransportError extends FluxFastError {
|
|
12
|
+
readonly status?: number;
|
|
13
|
+
constructor(message: string, status?: number, details?: unknown);
|
|
14
|
+
}
|
|
15
|
+
export declare class PageNotFoundError extends FluxFastError {
|
|
16
|
+
constructor(message: string, details?: unknown);
|
|
17
|
+
}
|
|
18
|
+
export declare class ComponentResolutionError extends FluxFastError {
|
|
19
|
+
constructor(message: string, details?: unknown);
|
|
20
|
+
}
|
|
21
|
+
export declare class ValidationError extends FluxFastError {
|
|
22
|
+
constructor(message: string, details?: unknown);
|
|
23
|
+
}
|
|
24
|
+
export declare class MutationError extends FluxFastError {
|
|
25
|
+
constructor(message: string, details?: unknown);
|
|
26
|
+
}
|
|
27
|
+
export declare class ResourceError extends FluxFastError {
|
|
28
|
+
constructor(message: string, details?: unknown);
|
|
29
|
+
}
|
|
30
|
+
export declare class VersionMismatchError extends ProtocolError {
|
|
31
|
+
constructor(message: string, details?: unknown);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings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exports, "__esModule", { value: true });
|
|
6
|
+
exports.VersionMismatchError = exports.ResourceError = exports.MutationError = exports.ValidationError = exports.ComponentResolutionError = exports.PageNotFoundError = exports.TransportError = exports.ProtocolError = exports.FluxFastError = void 0;
|
|
7
|
+
class FluxFastError extends Error {
|
|
8
|
+
details;
|
|
9
|
+
constructor(message, details) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "FluxFastError";
|
|
12
|
+
this.details = details;
|
|
13
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.FluxFastError = FluxFastError;
|
|
17
|
+
class ProtocolError extends FluxFastError {
|
|
18
|
+
constructor(message, details) {
|
|
19
|
+
super(message, details);
|
|
20
|
+
this.name = "ProtocolError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ProtocolError = ProtocolError;
|
|
24
|
+
class TransportError extends FluxFastError {
|
|
25
|
+
status;
|
|
26
|
+
constructor(message, status, details) {
|
|
27
|
+
super(message, details);
|
|
28
|
+
this.name = "TransportError";
|
|
29
|
+
this.status = status;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.TransportError = TransportError;
|
|
33
|
+
class PageNotFoundError extends FluxFastError {
|
|
34
|
+
constructor(message, details) {
|
|
35
|
+
super(message, details);
|
|
36
|
+
this.name = "PageNotFoundError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.PageNotFoundError = PageNotFoundError;
|
|
40
|
+
class ComponentResolutionError extends FluxFastError {
|
|
41
|
+
constructor(message, details) {
|
|
42
|
+
super(message, details);
|
|
43
|
+
this.name = "ComponentResolutionError";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ComponentResolutionError = ComponentResolutionError;
|
|
47
|
+
class ValidationError extends FluxFastError {
|
|
48
|
+
constructor(message, details) {
|
|
49
|
+
super(message, details);
|
|
50
|
+
this.name = "ValidationError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ValidationError = ValidationError;
|
|
54
|
+
class MutationError extends FluxFastError {
|
|
55
|
+
constructor(message, details) {
|
|
56
|
+
super(message, details);
|
|
57
|
+
this.name = "MutationError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.MutationError = MutationError;
|
|
61
|
+
class ResourceError extends FluxFastError {
|
|
62
|
+
constructor(message, details) {
|
|
63
|
+
super(message, details);
|
|
64
|
+
this.name = "ResourceError";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ResourceError = ResourceError;
|
|
68
|
+
class VersionMismatchError extends ProtocolError {
|
|
69
|
+
constructor(message, details) {
|
|
70
|
+
super(message, details);
|
|
71
|
+
this.name = "VersionMismatchError";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.VersionMismatchError = VersionMismatchError;
|
|
75
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mBAA2B,SAAQ,KAAK;IACtB,OAAO,CAAW;IAElC,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;;AAED,mBAA2B,SAAQ,aAAa;IAC9C,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;;AAED,oBAA4B,SAAQ,aAAa;IAC/B,MAAM,CAAU;IAEhC,YAAY,OAAe,EAAE,MAAe,EAAE,OAAiB;QA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**
|
|
2
|
+
* Framework-neutral event emitter for FluxFast runtime events.
|
|
3
|
+
*/
|
|
4
|
+
export type FluxEventName = "visit:start" | "visit:success" | "visit:error" | "visit:cancel" | "resource:update" | "resource:invalidate" | "cache:hit" | "cache:miss" | "prefetch:start" | "prefetch:success" | "mutation:start" | "mutation:success" | "mutation:error";
|
|
5
|
+
export interface FluxEventPayloads {
|
|
6
|
+
"visit:start": {
|
|
7
|
+
visitId: string;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
"visit:success": {
|
|
11
|
+
visitId: string;
|
|
12
|
+
url: string;
|
|
13
|
+
component: string;
|
|
14
|
+
};
|
|
15
|
+
"visit:error": {
|
|
16
|
+
visitId: string;
|
|
17
|
+
url: string;
|
|
18
|
+
error: Error;
|
|
19
|
+
};
|
|
20
|
+
"visit:cancel": {
|
|
21
|
+
visitId: string;
|
|
22
|
+
url: string;
|
|
23
|
+
};
|
|
24
|
+
"resource:update": {
|
|
25
|
+
key: string;
|
|
26
|
+
version: string;
|
|
27
|
+
};
|
|
28
|
+
"resource:invalidate": {
|
|
29
|
+
key: string;
|
|
30
|
+
};
|
|
31
|
+
"cache:hit": {
|
|
32
|
+
key: string;
|
|
33
|
+
};
|
|
34
|
+
"cache:miss": {
|
|
35
|
+
key: string;
|
|
36
|
+
};
|
|
37
|
+
"prefetch:start": {
|
|
38
|
+
url: string;
|
|
39
|
+
};
|
|
40
|
+
"prefetch:success": {
|
|
41
|
+
url: string;
|
|
42
|
+
};
|
|
43
|
+
"mutation:start": {
|
|
44
|
+
url: string;
|
|
45
|
+
};
|
|
46
|
+
"mutation:success": {
|
|
47
|
+
url: string;
|
|
48
|
+
};
|
|
49
|
+
"mutation:error": {
|
|
50
|
+
url: string;
|
|
51
|
+
error: Error;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export type FluxEventListener<E extends FluxEventName> = (payload: FluxEventPayloads[E]) => void;
|
|
55
|
+
export declare class EventEmitter {
|
|
56
|
+
private listeners;
|
|
57
|
+
on<E extends FluxEventName>(event: E, listener: FluxEventListener<E>): () => void;
|
|
58
|
+
off<E extends FluxEventName>(event: E, listener: FluxEventListener<E>): void;
|
|
59
|
+
emit<E extends FluxEventName>(event: E, payload: FluxEventPayloads[E]): void;
|
|
60
|
+
removeAllListeners(): void;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,eAAe,GACf,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,qBAAqB,GACrB,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,CAAC;AAErB,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,aAAa,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC;IAC9D,cAAc,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,iBAAiB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,qBAAqB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7B,YAAY,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,kBAAkB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,kBAAkB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC;CACjD;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI,CACvD,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAC1B,IAAI,CAAC;AAEV,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAuD;IAExE,EAAE,CAAC,CAAC,SAAS,aAAa,EACxB,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,MAAM,IAAI,CASZ;IAED,GAAG,CAAC,CAAC,SAAS,aAAa,EACzB,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,IAAI,CAQN;IAED,IAAI,CAAC,CAAC,SAAS,aAAa,EAC1B,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,IAAI,CAWN;IAED,kBAAkB,IAAI,IAAI,CAEzB;CACF"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Framework-neutral event emitter for FluxFast runtime events.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EventEmitter = void 0;
|
|
7
|
+
class EventEmitter {
|
|
8
|
+
listeners = new Map();
|
|
9
|
+
on(event, listener) {
|
|
10
|
+
if (!this.listeners.has(event)) {
|
|
11
|
+
this.listeners.set(event, new Set());
|
|
12
|
+
}
|
|
13
|
+
this.listeners.get(event).add(listener);
|
|
14
|
+
return () => {
|
|
15
|
+
this.off(event, listener);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
off(event, listener) {
|
|
19
|
+
const set = this.listeners.get(event);
|
|
20
|
+
if (set) {
|
|
21
|
+
set.delete(listener);
|
|
22
|
+
if (set.size === 0) {
|
|
23
|
+
this.listeners.delete(event);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
emit(event, payload) {
|
|
28
|
+
const set = this.listeners.get(event);
|
|
29
|
+
if (set) {
|
|
30
|
+
for (const listener of Array.from(set)) {
|
|
31
|
+
try {
|
|
32
|
+
listener(payload);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error(`[fluxfast] Error in listener for event ${event}:`, e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
removeAllListeners() {
|
|
41
|
+
this.listeners.clear();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.EventEmitter = EventEmitter;
|
|
45
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAqCH;IACU,SAAS,GAA6C,IAAI,GAAG,EAAE,CAAC;IAExE,EAAE,CACA,KAAQ,EACR,QAA8B;QAE9B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEzC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;IAED,GAAG,CACD,KAAQ,EACR,QAA8B;QAE9B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACrB,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBACnB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,CACF,KAAQ,EACR,OAA6B;QAE7B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,GAAG,EAAE,CAAC;YACR,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvC,IAAI,CAAC;oBACH,QAAQ,CAAC,OAAO,CAAC,CAAC;gBACpB,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,CAAC,KAAK,CAAC,0CAA0C,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser history integration and popstate management.
|
|
3
|
+
*/
|
|
4
|
+
export interface HistoryOptions {
|
|
5
|
+
replace?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type PopStateCallback = (url: string) => void;
|
|
8
|
+
export declare class HistoryManager {
|
|
9
|
+
private popStateCallback?;
|
|
10
|
+
private isBrowser;
|
|
11
|
+
private isListening;
|
|
12
|
+
constructor();
|
|
13
|
+
onPopState(cb: PopStateCallback): () => void;
|
|
14
|
+
push(url: string): void;
|
|
15
|
+
replace(url: string): void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
private handlePopState;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAErD,qBAAa,cAAc;IACzB,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,WAAW,CAAS;IAE5B,cAEC;IAED,UAAU,CAAC,EAAE,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAe3C;IAED,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAItB;IAED,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAIzB;IAED,OAAO,IAAI,IAAI,CAMd;IAED,OAAO,CAAC,cAAc,CAKpB;CACH"}
|
package/dist/history.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Browser history integration and popstate management.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HistoryManager = void 0;
|
|
7
|
+
class HistoryManager {
|
|
8
|
+
popStateCallback;
|
|
9
|
+
isBrowser;
|
|
10
|
+
isListening = false;
|
|
11
|
+
constructor() {
|
|
12
|
+
this.isBrowser = typeof window !== "undefined" && typeof window.history !== "undefined";
|
|
13
|
+
}
|
|
14
|
+
onPopState(cb) {
|
|
15
|
+
this.popStateCallback = cb;
|
|
16
|
+
if (this.isBrowser && !this.isListening) {
|
|
17
|
+
window.addEventListener("popstate", this.handlePopState);
|
|
18
|
+
this.isListening = true;
|
|
19
|
+
}
|
|
20
|
+
return () => {
|
|
21
|
+
if (this.popStateCallback === cb) {
|
|
22
|
+
this.popStateCallback = undefined;
|
|
23
|
+
if (this.isBrowser && this.isListening) {
|
|
24
|
+
window.removeEventListener("popstate", this.handlePopState);
|
|
25
|
+
this.isListening = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
push(url) {
|
|
31
|
+
if (this.isBrowser) {
|
|
32
|
+
window.history.pushState({ fluxfast: true, url }, "", url);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
replace(url) {
|
|
36
|
+
if (this.isBrowser) {
|
|
37
|
+
window.history.replaceState({ fluxfast: true, url }, "", url);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
destroy() {
|
|
41
|
+
if (this.isBrowser && this.isListening) {
|
|
42
|
+
window.removeEventListener("popstate", this.handlePopState);
|
|
43
|
+
this.isListening = false;
|
|
44
|
+
}
|
|
45
|
+
this.popStateCallback = undefined;
|
|
46
|
+
}
|
|
47
|
+
handlePopState = (_event) => {
|
|
48
|
+
if (this.popStateCallback && typeof window !== "undefined") {
|
|
49
|
+
const url = window.location.pathname + window.location.search + window.location.hash;
|
|
50
|
+
this.popStateCallback(url);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.HistoryManager = HistoryManager;
|
|
55
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAQH;IACU,gBAAgB,CAAoB;IACpC,SAAS,CAAU;IACnB,WAAW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SAAS,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YAC5D,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACpC,CAAC;IAEO,cAAc,GAAG,CAAC,MAAqB,EAAQ,EAAE;QACvD,IAAI,IAAI,CAAC,gBAAgB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YACrF,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC;CACH"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fluxfast/core — Framework-neutral client runtime for FluxFast.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./protocol";
|
|
5
|
+
export * from "./errors";
|
|
6
|
+
export * from "./events";
|
|
7
|
+
export * from "./mutation";
|
|
8
|
+
export * from "./store";
|
|
9
|
+
export * from "./cache";
|
|
10
|
+
export * from "./transport";
|
|
11
|
+
export * from "./history";
|
|
12
|
+
export * from "./prefetch";
|
|
13
|
+
export * from "./router";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fluxfast/core — Framework-neutral client runtime for FluxFast.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./protocol"), exports);
|
|
21
|
+
__exportStar(require("./errors"), exports);
|
|
22
|
+
__exportStar(require("./events"), exports);
|
|
23
|
+
__exportStar(require("./mutation"), exports);
|
|
24
|
+
__exportStar(require("./store"), exports);
|
|
25
|
+
__exportStar(require("./cache"), exports);
|
|
26
|
+
__exportStar(require("./transport"), exports);
|
|
27
|
+
__exportStar(require("./history"), exports);
|
|
28
|
+
__exportStar(require("./prefetch"), exports);
|
|
29
|
+
__exportStar(require("./router"), exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,6CAA2B;AAC3B,0CAAwB;AACxB,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation.d.ts","sourceRoot":"","sources":["../src/mutation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA0B3C,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAuCtF"}
|
package/dist/mutation.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mutation patch processing algorithms.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.applyPatchToValue = applyPatchToValue;
|
|
7
|
+
function matchItem(item, patch) {
|
|
8
|
+
if (typeof item !== "object" || item === null) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const obj = item;
|
|
12
|
+
if (patch.id !== undefined) {
|
|
13
|
+
if (obj.id === patch.id || String(obj.id) === String(patch.id)) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (patch.match) {
|
|
18
|
+
for (const [k, v] of Object.entries(patch.match)) {
|
|
19
|
+
if (obj[k] !== v) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
function applyPatchToValue(currentValue, patch) {
|
|
28
|
+
switch (patch.op) {
|
|
29
|
+
case "replace-resource":
|
|
30
|
+
return patch.value;
|
|
31
|
+
case "merge-object": {
|
|
32
|
+
if (typeof currentValue === "object" && currentValue !== null && !Array.isArray(currentValue)) {
|
|
33
|
+
return {
|
|
34
|
+
...currentValue,
|
|
35
|
+
...(typeof patch.value === "object" && patch.value !== null ? patch.value : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return patch.value;
|
|
39
|
+
}
|
|
40
|
+
case "replace-item": {
|
|
41
|
+
if (Array.isArray(currentValue)) {
|
|
42
|
+
return currentValue.map(item => (matchItem(item, patch) ? patch.value : item));
|
|
43
|
+
}
|
|
44
|
+
return currentValue;
|
|
45
|
+
}
|
|
46
|
+
case "remove-item": {
|
|
47
|
+
if (Array.isArray(currentValue)) {
|
|
48
|
+
return currentValue.filter(item => !matchItem(item, patch));
|
|
49
|
+
}
|
|
50
|
+
return currentValue;
|
|
51
|
+
}
|
|
52
|
+
case "append-item": {
|
|
53
|
+
if (Array.isArray(currentValue)) {
|
|
54
|
+
return [...currentValue, patch.value];
|
|
55
|
+
}
|
|
56
|
+
return [patch.value];
|
|
57
|
+
}
|
|
58
|
+
default:
|
|
59
|
+
return currentValue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation.js","sourceRoot":"","sources":["../src/mutation.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH,SAAS,SAAS,CAAC,IAAa,EAAE,KAAoB;IACpD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,GAAG,GAAG,IAA+B,CAAC;IAE5C,IAAI,KAAK,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC3B,IAAI,GAAG,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC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AO,YAAY,CAAC;QACtB,CAAC;QAED,KAAK,aAAa,EAAE,CAAC;YACnB,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBAChC,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YAC9D,CAAC;YACD,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,KAAK,aAAa,EAAE,CAAC;YACnB,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAED;YACE,OAAO,YAAY,CAAC;IACxB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** In-flight request deduplication and version-safe prefetch caching. */
|
|
2
|
+
import { PageEnvelope } from "./protocol";
|
|
3
|
+
import { FluxTransport } from "./transport";
|
|
4
|
+
export interface PrefetchEntry {
|
|
5
|
+
readonly envelope: PageEnvelope;
|
|
6
|
+
readonly expiresAt: number;
|
|
7
|
+
readonly basedOnVersions: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export declare class PrefetchManager {
|
|
10
|
+
private readonly defaultTtlMs;
|
|
11
|
+
private readonly inFlight;
|
|
12
|
+
private readonly cache;
|
|
13
|
+
private generation;
|
|
14
|
+
constructor(defaultTtlMs?: number);
|
|
15
|
+
fetch(url: string, transport: FluxTransport, knownVersions: Record<string, string>, ttlMs?: number): Promise<PageEnvelope>;
|
|
16
|
+
getPending(url: string, knownVersions: Record<string, string>): Promise<PageEnvelope> | undefined;
|
|
17
|
+
getCached(url: string, currentVersions: Record<string, string>): PageEnvelope | undefined;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=prefetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefetch.d.ts","sourceRoot":"","sources":["../src/prefetch.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClD;AAkBD,qBAAa,eAAe;IAKd,OAAO,CAAC,QAAQ,CAAC,YAAY;IAJzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4C;IACrE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoC;IAC1D,OAAO,CAAC,UAAU,CAAK;IAEvB,YAA6B,YAAY,GAAE,MAAe,EAAI;IAExD,KAAK,CACT,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,aAAa,EACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,KAAK,GAAE,MAA0B,GAChC,OAAO,CAAC,YAAY,CAAC,CAkCvB;IAED,UAAU,CACR,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,CAEnC;IAED,SAAS,CACP,GAAG,EAAE,MAAM,EACX,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtC,YAAY,GAAG,SAAS,CAW1B;IAED,KAAK,IAAI,IAAI,CAIZ;CACF"}
|