@braidlabs/core 0.6.0 → 0.7.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/package.json +1 -1
- package/src/adapters/adapter.d.ts +11 -0
- package/src/adapters/adapter.js.map +1 -1
- package/src/adapters/compat-adapter.js +2 -2
- package/src/adapters/compat-adapter.js.map +1 -1
- package/src/compat/born-inert-scripts.d.ts +2 -0
- package/src/compat/born-inert-scripts.js +39 -0
- package/src/compat/born-inert-scripts.js.map +1 -1
- package/src/compat/cookie-partition.d.ts +25 -0
- package/src/compat/cookie-partition.js +79 -0
- package/src/compat/cookie-partition.js.map +1 -0
- package/src/compat/document-member-classification.js +3 -2
- package/src/compat/document-member-classification.js.map +1 -1
- package/src/compat/document-overrides.d.ts +6 -6
- package/src/compat/document-overrides.js +23 -0
- package/src/compat/document-overrides.js.map +1 -1
- package/src/compat/fragment-boundary.d.ts +5 -0
- package/src/compat/fragment-boundary.js +291 -36
- package/src/compat/fragment-boundary.js.map +1 -1
- package/src/compat/html-policy.d.ts +50 -0
- package/src/compat/html-policy.js +155 -0
- package/src/compat/html-policy.js.map +1 -0
- package/src/compat/realm-patches.d.ts +2 -1
- package/src/compat/realm-patches.js +117 -3
- package/src/compat/realm-patches.js.map +1 -1
- package/src/compat/script-execution.d.ts +24 -0
- package/src/compat/script-execution.js +177 -10
- package/src/compat/script-execution.js.map +1 -1
- package/src/compat/storage-partition.d.ts +47 -0
- package/src/compat/storage-partition.js +291 -0
- package/src/compat/storage-partition.js.map +1 -0
- package/src/compat/subresource-urls.d.ts +41 -0
- package/src/compat/subresource-urls.js +133 -0
- package/src/compat/subresource-urls.js.map +1 -0
- package/src/config.d.ts +28 -0
- package/src/config.js +24 -0
- package/src/config.js.map +1 -1
- package/src/elements/boot-gate.d.ts +47 -0
- package/src/elements/boot-gate.js +207 -0
- package/src/elements/boot-gate.js.map +1 -0
- package/src/elements/fragment-slot.d.ts +62 -15
- package/src/elements/fragment-slot.js +388 -26
- package/src/elements/fragment-slot.js.map +1 -1
- package/src/elements/late-content.d.ts +44 -0
- package/src/elements/late-content.js +107 -0
- package/src/elements/late-content.js.map +1 -0
- package/src/elements/prefetch.d.ts +27 -0
- package/src/elements/prefetch.js +100 -0
- package/src/elements/prefetch.js.map +1 -0
- package/src/elements/prerequisites.d.ts +42 -0
- package/src/elements/prerequisites.js +133 -0
- package/src/elements/prerequisites.js.map +1 -0
- package/src/elements/recovery.d.ts +46 -0
- package/src/elements/recovery.js +59 -0
- package/src/elements/recovery.js.map +1 -0
- package/src/env/create-env.js +2 -1
- package/src/env/create-env.js.map +1 -1
- package/src/env/fragment-env.d.ts +6 -0
- package/src/errors.d.ts +4 -1
- package/src/errors.js +2 -0
- package/src/errors.js.map +1 -1
- package/src/index.d.ts +5 -1
- package/src/index.js +11 -1
- package/src/index.js.map +1 -1
- package/src/realm/realm-manager.js +23 -0
- package/src/realm/realm-manager.js.map +1 -1
- package/src/weave/capabilities.d.ts +35 -7
- package/src/weave/capabilities.js +17 -0
- package/src/weave/capabilities.js.map +1 -1
- package/src/weave/guest.d.ts +2 -0
- package/src/weave/guest.js +2 -1
- package/src/weave/guest.js.map +1 -1
- package/src/weave/messages.d.ts +24 -0
- package/src/weave/messages.js +22 -0
- package/src/weave/messages.js.map +1 -1
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import { BraidError } from '../errors.js';
|
|
2
2
|
import { LivenessState } from '../weave/liveness.js';
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* The original four are all still here and still mean what they meant — `ready` in particular is
|
|
7
|
-
* kept as the name for "mounted, first beat not yet observed", which the liveness machine calls
|
|
8
|
-
* `connecting`. Renaming it would have broken every host checking `slot.state === 'ready'` in
|
|
9
|
-
* exchange for a word.
|
|
10
|
-
*
|
|
11
|
-
* The new three are the ones `ready` used to have to cover on its own:
|
|
12
|
-
*
|
|
13
|
-
* - `healthy` — beating.
|
|
14
|
-
* - `unobservable` — the tab is hidden, so the host has stopped being able to tell. Not a fault.
|
|
15
|
-
* - `suspect` → `gone` — beats stopped while the fragment should have been running.
|
|
16
|
-
*/
|
|
3
|
+
/** The `settle-timeout` attribute as a delay: the default when absent, empty or not a number. */
|
|
4
|
+
export declare function settleTimeoutMs(attribute: string | null): number;
|
|
17
5
|
export type FragmentSlotState = 'idle' | 'loading' | 'ready' | 'error' | 'closing' | 'healthy' | 'unobservable' | 'suspect' | 'gone';
|
|
18
6
|
/** `connecting` is reported as `ready`; every other liveness state carries its own name. */
|
|
19
7
|
export declare function slotStateFor(liveness: LivenessState): FragmentSlotState;
|
|
8
|
+
/**
|
|
9
|
+
* Whether a slot sits in another fragment's DOM: some shadow root above it belongs to a slot. A
|
|
10
|
+
* host's own components may keep slots in their shadow roots; those are the host's.
|
|
11
|
+
*/
|
|
12
|
+
export declare function insideAnotherFragment(slot: Element): boolean;
|
|
20
13
|
/**
|
|
21
14
|
* Finds server-rendered fragment content the gateway pierced into a slot.
|
|
22
15
|
*
|
|
@@ -35,6 +28,12 @@ export declare function findPiercedContentRoot(shadowRoot: ShadowRoot | null): H
|
|
|
35
28
|
* than a moment of unresponsiveness — and suspicion is designed to be recoverable.
|
|
36
29
|
*/
|
|
37
30
|
export declare const SLOT_STYLES: string;
|
|
31
|
+
/**
|
|
32
|
+
* Adds the slot a host's `slot="loading"` child projects into. Only on roots the client builds: a
|
|
33
|
+
* pierced fragment already has its content on screen. (After `reload()` a pierced slot's root is
|
|
34
|
+
* rebuilt by the client, and can show its loading state like any other.)
|
|
35
|
+
*/
|
|
36
|
+
export declare function ensureLoadingSlot(shadowRoot: ShadowRoot): void;
|
|
38
37
|
/**
|
|
39
38
|
* Ensures the shadow root can present host-provided fallback content:
|
|
40
39
|
*
|
|
@@ -59,9 +58,14 @@ export declare function ensureFallbackSlot(shadowRoot: ShadowRoot): void;
|
|
|
59
58
|
* - `src` — optional route url for the fragment. When absent, the fragment is *bound*: it
|
|
60
59
|
* follows the host page's location and participates in host navigation.
|
|
61
60
|
* - `props` — JSON attribute (or the `props` property) passed to the fragment instance.
|
|
61
|
+
* - `boot` — `eager` (default), `idle`, `visible`, or `interaction`: when to boot. Read when the
|
|
62
|
+
* slot connects, or when a deferred slot's late markup arrives. See `boot-gate.ts`.
|
|
63
|
+
*
|
|
64
|
+
* - `settle-timeout` — milliseconds after `ready` before the slot reports `settled` on its own, for a
|
|
65
|
+
* fragment that never says it has (default 10000). See {@link FragmentSlot.settled}.
|
|
62
66
|
*
|
|
63
67
|
* Events: `braid:ready`, `braid:error` (detail includes stage + fix hint), `braid:event`
|
|
64
|
-
* (fragment → host).
|
|
68
|
+
* (fragment → host), `braid:settled` (detail: `{ fragmentId, timedOut }`).
|
|
65
69
|
*
|
|
66
70
|
* The slot uses only its own shadow root and its own elements — the host page is never patched.
|
|
67
71
|
*/
|
|
@@ -70,6 +74,28 @@ export declare class FragmentSlot extends HTMLElement {
|
|
|
70
74
|
static get observedAttributes(): string[];
|
|
71
75
|
get state(): FragmentSlotState;
|
|
72
76
|
get name(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the fragment's first content has settled, reflected as the `settled` attribute.
|
|
79
|
+
*
|
|
80
|
+
* Not a slot state, because it answers a different question. `healthy` says the fragment's realm
|
|
81
|
+
* is running, which is true from its first beat — while the application inside may still be
|
|
82
|
+
* showing its own spinner. `settled` says the fragment has finished its own initial loading,
|
|
83
|
+
* which only the fragment can know: it reports it (`env.settled()`, `provideBraidFragment()` in
|
|
84
|
+
* Angular), and a host keeps its skeleton up until then. Not through `slot="loading"`, which is
|
|
85
|
+
* the slot's own boot-time state and gives way at first paint, but as a sibling the host styles:
|
|
86
|
+
*
|
|
87
|
+
* ```html
|
|
88
|
+
* <fragment-slot name="contact"></fragment-slot><div class="skeleton" hidden></div>
|
|
89
|
+
* ```
|
|
90
|
+
* ```css
|
|
91
|
+
* fragment-slot:not([settled], [state="error"]) + .skeleton { display: block; }
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* A fragment that never reports is settled anyway `settle-timeout` milliseconds after `ready`, with
|
|
95
|
+
* `timedOut: true` on the event, so a skeleton cannot stick forever. One that fails never settles —
|
|
96
|
+
* it has nothing to show — so a skeleton keyed on `settled` gives way to `[state="error"]`, as above.
|
|
97
|
+
*/
|
|
98
|
+
get settled(): boolean;
|
|
73
99
|
/**
|
|
74
100
|
* The fragment's unsaved-work declaration, or null.
|
|
75
101
|
*
|
|
@@ -90,6 +116,27 @@ export declare class FragmentSlot extends HTMLElement {
|
|
|
90
116
|
disconnectedCallback(): void;
|
|
91
117
|
reload(): Promise<void>;
|
|
92
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Starts loading a fragment before its slot exists — from a link's hover, or a router's preload
|
|
121
|
+
* hook — so a navigation that is about to mount it finds the work already in flight.
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* link.addEventListener('pointerenter', () => prefetchFragment('billing', '/billing/invoices'));
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* `route` is what the slot will render: the destination page's path for a routed fragment, or the
|
|
128
|
+
* slot's `src` for a widget. Two things start:
|
|
129
|
+
*
|
|
130
|
+
* - the fragment's document, held for the next slot of that fragment and route to mount within
|
|
131
|
+
* ten seconds (`PREFETCH_TTL_MS`) — so that slot makes no document request of its own;
|
|
132
|
+
* - the scripts the document names, in its own namespace, as `<link rel="prefetch">` the realm
|
|
133
|
+
* then loads from the HTTP cache.
|
|
134
|
+
*
|
|
135
|
+
* Compat fragments only: contract and untrusted fragments load no Braid document. Calling it again
|
|
136
|
+
* for the same fragment and route while a prefetch is held does nothing. Call
|
|
137
|
+
* `clearPrefetchedFragments()` when the user signs out.
|
|
138
|
+
*/
|
|
139
|
+
export declare function prefetchFragment(fragmentId: string, route: string): void;
|
|
93
140
|
/**
|
|
94
141
|
* Fetches the fragment's document from the gateway's document namespace.
|
|
95
142
|
*
|