@myop/sdk 0.3.36 → 0.4.0-beta.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/dist/bundled-declarations.d.ts +406 -166
- package/dist/cjs/{_IframeSDK.3283252f.js → _IframeSDK.158994c9.js} +1325 -915
- package/dist/cjs/_IframeSDK.158994c9.js.map +7 -0
- package/dist/cjs/_IframeSDK.941e9a62.min.js +1 -0
- package/dist/cjs/_MyopHelpers.91004b19.min.js +1 -0
- package/dist/cjs/{_MyopHelpers.08d1cf5d.js → _MyopHelpers.efed13e4.js} +362 -2
- package/dist/cjs/_MyopHelpers.efed13e4.js.map +7 -0
- package/dist/cjs/_WebComponentSDK.5f41b3b7.min.js +1 -0
- package/dist/cjs/{_WebComponentSDK.e84be6ea.js → _WebComponentSDK.ca9d238e.js} +893 -486
- package/dist/cjs/_WebComponentSDK.ca9d238e.js.map +7 -0
- package/dist/cjs/_hostSDK.23c64e1b.min.js +1 -0
- package/dist/cjs/{_hostSDK.fa5b3ccf.js → _hostSDK.3c04ba71.js} +1348 -941
- package/dist/cjs/_hostSDK.3c04ba71.js.map +7 -0
- package/dist/cjs/myop_sdk.js +35 -24
- package/dist/cjs/myop_sdk.js.map +2 -2
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +1820 -1379
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +4 -4
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/index.js +1501 -1079
- package/dist/module/Iframe/index.js.map +4 -4
- package/dist/module/SDK.d.ts +5 -1
- package/dist/module/SDK.js +1974 -1523
- package/dist/module/SDK.js.map +4 -4
- package/dist/module/embeddedSDK.js +1 -1
- package/dist/module/helpers/CloudRepository.d.ts +96 -0
- package/dist/module/helpers/cloudRepositoryHelpers.d.ts +99 -0
- package/dist/module/helpers/deliveryStore.d.ts +51 -0
- package/dist/module/helpers/index.js +370 -3
- package/dist/module/helpers/index.js.map +4 -4
- package/dist/module/host/components/myopIframeComponent.d.ts +6 -0
- package/dist/module/host/embeddedSDK.js +1 -1
- package/dist/module/host/hostSDK.d.ts +2 -0
- package/dist/module/host/index.js +1516 -1097
- package/dist/module/host/index.js.map +4 -4
- package/dist/module/webcomponent/index.js +1202 -783
- package/dist/module/webcomponent/index.js.map +4 -4
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.3283252f.js.map +0 -7
- package/dist/cjs/_IframeSDK.652f4774.min.js +0 -1
- package/dist/cjs/_MyopHelpers.08d1cf5d.js.map +0 -7
- package/dist/cjs/_MyopHelpers.59521d8f.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.8fe7c9bf.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.e84be6ea.js.map +0 -7
- package/dist/cjs/_hostSDK.de2d767e.min.js +0 -1
- package/dist/cjs/_hostSDK.fa5b3ccf.js.map +0 -7
|
@@ -14,6 +14,105 @@ export declare const setCloudRepositoryUrl: (url: string) => void;
|
|
|
14
14
|
* `${cdnUrl}/components/${componentId}/${environment}.json`
|
|
15
15
|
*/
|
|
16
16
|
export declare const enableSelfHosted: (cdnUrl: string, queryParams?: Record<string, string>) => void;
|
|
17
|
+
/**
|
|
18
|
+
* THE OPT-IN. One call, and nothing changes for anyone who does not make it.
|
|
19
|
+
*
|
|
20
|
+
* myop.delivery({ minify: true });
|
|
21
|
+
*
|
|
22
|
+
* Opting in IS choosing the delivery lane: a second, complete Myop stack (its own server
|
|
23
|
+
* and CDN) reading the same component data. So this call does two things at once — it
|
|
24
|
+
* points `/consume` at that stack and asks it for the minified artifact — which is why
|
|
25
|
+
* turning the feature off is a config value on our side or one line on yours, and never
|
|
26
|
+
* a DNS change.
|
|
27
|
+
*
|
|
28
|
+
* Safety properties, all deliberate:
|
|
29
|
+
* - If the lane fails (transport error or 5xx), the SDK retries ONCE against
|
|
30
|
+
* cloud.myop.dev and the page renders anyway. `delivery.stats().fellBack` counts it.
|
|
31
|
+
* - `cache: true` adds the client window: a component this browser already holds, still
|
|
32
|
+
* inside the freshness the server promised, is rendered with NO request. Once the
|
|
33
|
+
* window ends the browser sends back the version it holds instead of re-downloading.
|
|
34
|
+
* - A preview is never minified and never cached.
|
|
35
|
+
* - Only /consume moves. Everything else keeps the host it has today.
|
|
36
|
+
* - Asking for `minify` does not force it: the server decides per component, and a
|
|
37
|
+
* component that is not enabled is served raw, which is not an error.
|
|
38
|
+
*
|
|
39
|
+
* `host` is for us (a staging lane, a local server); leave it out.
|
|
40
|
+
*/
|
|
41
|
+
export declare const DELIVERY_HOST = "https://delivery.myop.dev";
|
|
42
|
+
export declare const delivery: (opts?: {
|
|
43
|
+
minify?: boolean;
|
|
44
|
+
cache?: boolean;
|
|
45
|
+
host?: string | null;
|
|
46
|
+
}) => {
|
|
47
|
+
host: string;
|
|
48
|
+
minify: boolean;
|
|
49
|
+
cache: boolean;
|
|
50
|
+
requests: number;
|
|
51
|
+
viaDelivery: number;
|
|
52
|
+
fellBack: number;
|
|
53
|
+
lastError: string | null;
|
|
54
|
+
fromMemory: number;
|
|
55
|
+
fromStorage: number;
|
|
56
|
+
fromNetwork: number;
|
|
57
|
+
revalidations: number;
|
|
58
|
+
unchanged: number;
|
|
59
|
+
bytesSaved: number;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Forget what this browser holds, so the next load asks the server. Use it when a change
|
|
63
|
+
* has to be visible on THIS load — right after someone publishes — rather than within the
|
|
64
|
+
* freshness window.
|
|
65
|
+
*/
|
|
66
|
+
export declare const deliveryRefresh: () => Promise<{
|
|
67
|
+
host: string;
|
|
68
|
+
minify: boolean;
|
|
69
|
+
cache: boolean;
|
|
70
|
+
requests: number;
|
|
71
|
+
viaDelivery: number;
|
|
72
|
+
fellBack: number;
|
|
73
|
+
lastError: string | null;
|
|
74
|
+
fromMemory: number;
|
|
75
|
+
fromStorage: number;
|
|
76
|
+
fromNetwork: number;
|
|
77
|
+
revalidations: number;
|
|
78
|
+
unchanged: number;
|
|
79
|
+
bytesSaved: number;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* What answered the last requests, and — the number worth watching — how many times the
|
|
83
|
+
* SDK had to fall back to the default host because the lane did not answer.
|
|
84
|
+
*/
|
|
85
|
+
export declare const deliveryStats: () => {
|
|
86
|
+
host: string;
|
|
87
|
+
minify: boolean;
|
|
88
|
+
cache: boolean;
|
|
89
|
+
requests: number;
|
|
90
|
+
viaDelivery: number;
|
|
91
|
+
fellBack: number;
|
|
92
|
+
lastError: string | null;
|
|
93
|
+
fromMemory: number;
|
|
94
|
+
fromStorage: number;
|
|
95
|
+
fromNetwork: number;
|
|
96
|
+
revalidations: number;
|
|
97
|
+
unchanged: number;
|
|
98
|
+
bytesSaved: number;
|
|
99
|
+
};
|
|
100
|
+
/** Undo delivery(): back to the default host and raw bytes, with no reload. */
|
|
101
|
+
export declare const deliveryOff: () => {
|
|
102
|
+
host: string;
|
|
103
|
+
minify: boolean;
|
|
104
|
+
cache: boolean;
|
|
105
|
+
requests: number;
|
|
106
|
+
viaDelivery: number;
|
|
107
|
+
fellBack: number;
|
|
108
|
+
lastError: string | null;
|
|
109
|
+
fromMemory: number;
|
|
110
|
+
fromStorage: number;
|
|
111
|
+
fromNetwork: number;
|
|
112
|
+
revalidations: number;
|
|
113
|
+
unchanged: number;
|
|
114
|
+
bytesSaved: number;
|
|
115
|
+
};
|
|
17
116
|
export declare const setCloudRepository: (repository: CloudRepository) => void;
|
|
18
117
|
export declare const setEnvironment: (env: string) => void;
|
|
19
118
|
export declare const getResolvedConfig: (componentId: string, env?: string, preview?: boolean) => IComponentConfig;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The client window: what a returning visitor does NOT ask for.
|
|
3
|
+
*
|
|
4
|
+
* A component the browser already holds, still inside its freshness window, is rendered
|
|
5
|
+
* with no network at all. Once the window ends the browser does not re-download it either
|
|
6
|
+
* — it sends back the version it holds and is usually told "unchanged" in a few hundred
|
|
7
|
+
* bytes.
|
|
8
|
+
*
|
|
9
|
+
* THE WINDOW IS THE SERVER'S, NOT OURS. It comes from the response: `s-maxage` is the
|
|
10
|
+
* freshness the server promised, and `Age` is how much of it a CDN already spent before
|
|
11
|
+
* the bytes reached us. The window we may keep is therefore `s-maxage - Age`, never
|
|
12
|
+
* `s-maxage` — otherwise a copy that sat at the edge for 55 of its 60 seconds would be
|
|
13
|
+
* held for another 60 here, and a publish would take twice as long to be seen as promised.
|
|
14
|
+
* This is the single easiest thing to get wrong in a client cache, and it is invisible in
|
|
15
|
+
* testing because it only shows up as "sometimes stale".
|
|
16
|
+
*
|
|
17
|
+
* IndexedDB, not localStorage: components run to hundreds of KB, localStorage caps around
|
|
18
|
+
* 5 MB and blocks the main thread. Every path degrades to the network — a browser in
|
|
19
|
+
* private mode, with storage disabled or over quota, must render the page, not fail it.
|
|
20
|
+
*/
|
|
21
|
+
export interface StoredEntry {
|
|
22
|
+
key: string;
|
|
23
|
+
/** the resolved component config, exactly as the network path produces it */
|
|
24
|
+
config: any;
|
|
25
|
+
/** the server's version token for these bytes: `<rev>~<opt>` */
|
|
26
|
+
tag: string | null;
|
|
27
|
+
/** when this browser stored it */
|
|
28
|
+
storedAt: number;
|
|
29
|
+
/** how long it may be used without asking, in ms (already Age-adjusted) */
|
|
30
|
+
windowMs: number;
|
|
31
|
+
/** which host produced it — a key from another host is never reused */
|
|
32
|
+
host: string;
|
|
33
|
+
/** wire size of the response it came from, so stats can say what the window saved */
|
|
34
|
+
bytes?: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const deliveryStore: {
|
|
37
|
+
key(host: string, componentId: string, env: string, preview: boolean, opt: string): string;
|
|
38
|
+
get(key: string): Promise<StoredEntry | null>;
|
|
39
|
+
put(entry: StoredEntry): Promise<void>;
|
|
40
|
+
drop(key: string): Promise<void>;
|
|
41
|
+
/** Still usable without asking the server? */
|
|
42
|
+
fresh(e: StoredEntry | null): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The window this response licenses: the server's freshness minus what a CDN already
|
|
45
|
+
* spent. Returns 0 when the server said nothing about caching, which means "do not
|
|
46
|
+
* hold this" — the safe reading, and what production sends today.
|
|
47
|
+
*/
|
|
48
|
+
windowFrom(headers: Headers): number;
|
|
49
|
+
/** For tests and for `refresh()`: forget everything this browser holds. */
|
|
50
|
+
clear(): Promise<void>;
|
|
51
|
+
};
|