@myop/sdk 0.4.0-beta.4 → 0.4.0-beta.6

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.
Files changed (48) hide show
  1. package/README.md +13 -0
  2. package/dist/bundled-declarations.d.ts +87 -4
  3. package/dist/cjs/{_IframeSDK.3a412cd4.js → _IframeSDK.49662e01.js} +97 -18
  4. package/dist/cjs/_IframeSDK.49662e01.js.map +7 -0
  5. package/dist/cjs/_IframeSDK.d4a97876.min.js +1 -0
  6. package/dist/cjs/_MyopHelpers.12acc780.min.js +1 -0
  7. package/dist/cjs/{_MyopHelpers.efed13e4.js → _MyopHelpers.2c449e7a.js} +78 -15
  8. package/dist/cjs/_MyopHelpers.2c449e7a.js.map +7 -0
  9. package/dist/cjs/_WebComponentSDK.1addf28b.min.js +1 -0
  10. package/dist/cjs/{_WebComponentSDK.4b6ac803.js → _WebComponentSDK.d5f9105b.js} +97 -18
  11. package/dist/cjs/_WebComponentSDK.d5f9105b.js.map +7 -0
  12. package/dist/cjs/_hostSDK.6dab59cb.min.js +1 -0
  13. package/dist/cjs/{_hostSDK.e9b70e44.js → _hostSDK.8cf37510.js} +97 -18
  14. package/dist/cjs/_hostSDK.8cf37510.js.map +7 -0
  15. package/dist/cjs/myop_sdk.js +14 -14
  16. package/dist/cjs/myop_sdk.js.map +1 -1
  17. package/dist/cjs/myop_sdk.min.js +1 -1
  18. package/dist/cjs-bundled/myop_sdk.bundled.js +107 -21
  19. package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
  20. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  21. package/dist/module/Iframe/index.js +98 -19
  22. package/dist/module/Iframe/index.js.map +2 -2
  23. package/dist/module/SDK.js +107 -21
  24. package/dist/module/SDK.js.map +3 -3
  25. package/dist/module/common/index.d.ts +5 -0
  26. package/dist/module/common/index.js +1 -1
  27. package/dist/module/common/index.js.map +2 -2
  28. package/dist/module/embeddedSDK.js +1 -1
  29. package/dist/module/helpers/CloudRepository.d.ts +36 -1
  30. package/dist/module/helpers/cloudRepositoryHelpers.d.ts +42 -2
  31. package/dist/module/helpers/index.js +77 -16
  32. package/dist/module/helpers/index.js.map +2 -2
  33. package/dist/module/host/components/IMyopComponent.d.ts +3 -0
  34. package/dist/module/host/embeddedSDK.js +1 -1
  35. package/dist/module/host/hostSDK.d.ts +1 -1
  36. package/dist/module/host/index.js +98 -19
  37. package/dist/module/host/index.js.map +2 -2
  38. package/dist/module/webcomponent/index.js +98 -19
  39. package/dist/module/webcomponent/index.js.map +2 -2
  40. package/package.json +1 -1
  41. package/dist/cjs/_IframeSDK.3a412cd4.js.map +0 -7
  42. package/dist/cjs/_IframeSDK.9338575d.min.js +0 -1
  43. package/dist/cjs/_MyopHelpers.91004b19.min.js +0 -1
  44. package/dist/cjs/_MyopHelpers.efed13e4.js.map +0 -7
  45. package/dist/cjs/_WebComponentSDK.4b6ac803.js.map +0 -7
  46. package/dist/cjs/_WebComponentSDK.4e78d94a.min.js +0 -1
  47. package/dist/cjs/_hostSDK.34f770f6.min.js +0 -1
  48. package/dist/cjs/_hostSDK.e9b70e44.js.map +0 -7
@@ -32,21 +32,28 @@ export declare const enableSelfHosted: (cdnUrl: string, queryParams?: Record<str
32
32
  * inside the freshness the server promised, is rendered with NO request. Once the
33
33
  * window ends the browser sends back the version it holds instead of re-downloading.
34
34
  * - A preview is never minified and never cached.
35
- * - Only /consume moves. Everything else keeps the host it has today.
35
+ * - Only /consume moves. Everything else keeps the host it has today -- unless
36
+ * `flow: true`, which also moves v1 component configs (`/flow?auto=true`), with the
37
+ * same fallback.
36
38
  * - Asking for `minify` does not force it: the server decides per component, and a
37
39
  * component that is not enabled is served raw, which is not an error.
38
40
  *
39
41
  * `host` is for us (a staging lane, a local server); leave it out.
42
+ *
43
+ * @internal Delivery lane: kept out of the public API reference until it is released.
40
44
  */
41
45
  export declare const DELIVERY_HOST = "https://delivery.myop.dev";
46
+ /** @internal */
42
47
  export declare const delivery: (opts?: {
43
48
  minify?: boolean;
44
49
  cache?: boolean;
50
+ flow?: boolean;
45
51
  host?: string | null;
46
52
  }) => {
47
53
  host: string;
48
54
  minify: boolean;
49
55
  cache: boolean;
56
+ flow: boolean;
50
57
  requests: number;
51
58
  viaDelivery: number;
52
59
  fellBack: number;
@@ -62,11 +69,14 @@ export declare const delivery: (opts?: {
62
69
  * Forget what this browser holds, so the next load asks the server. Use it when a change
63
70
  * has to be visible on THIS load — right after someone publishes — rather than within the
64
71
  * freshness window.
72
+ *
73
+ * @internal
65
74
  */
66
75
  export declare const deliveryRefresh: () => Promise<{
67
76
  host: string;
68
77
  minify: boolean;
69
78
  cache: boolean;
79
+ flow: boolean;
70
80
  requests: number;
71
81
  viaDelivery: number;
72
82
  fellBack: number;
@@ -81,11 +91,14 @@ export declare const deliveryRefresh: () => Promise<{
81
91
  /**
82
92
  * What answered the last requests, and — the number worth watching — how many times the
83
93
  * SDK had to fall back to the default host because the lane did not answer.
94
+ *
95
+ * @internal
84
96
  */
85
97
  export declare const deliveryStats: () => {
86
98
  host: string;
87
99
  minify: boolean;
88
100
  cache: boolean;
101
+ flow: boolean;
89
102
  requests: number;
90
103
  viaDelivery: number;
91
104
  fellBack: number;
@@ -97,11 +110,12 @@ export declare const deliveryStats: () => {
97
110
  unchanged: number;
98
111
  bytesSaved: number;
99
112
  };
100
- /** Undo delivery(): back to the default host and raw bytes, with no reload. */
113
+ /** Undo delivery(): back to the default host and raw bytes, with no reload. @internal */
101
114
  export declare const deliveryOff: () => {
102
115
  host: string;
103
116
  minify: boolean;
104
117
  cache: boolean;
118
+ flow: boolean;
105
119
  requests: number;
106
120
  viaDelivery: number;
107
121
  fellBack: number;
@@ -116,6 +130,16 @@ export declare const deliveryOff: () => {
116
130
  export declare const setCloudRepository: (repository: CloudRepository) => void;
117
131
  export declare const setEnvironment: (env: string) => void;
118
132
  export declare const getResolvedConfig: (componentId: string, env?: string, preview?: boolean) => IComponentConfig;
133
+ /**
134
+ * The runtime tags of a loaded/preloaded component: only tags named `ui:...` (e.g.
135
+ * `ui:beta`). Returns `[]` when it has none or has not been fetched yet.
136
+ *
137
+ * ```ts
138
+ * await preloadComponents([id]);
139
+ * getComponentTags(id); // ['ui:beta']
140
+ * ```
141
+ */
142
+ export declare const getComponentTags: (componentId: string, env?: string, preview?: boolean) => string[];
119
143
  export declare const preloadComponents: (ids: string[], env?: string, preview?: boolean) => Promise<PromiseSettledResult<IComponentConfig>[]>;
120
144
  /**
121
145
  * Seed already-resolved component configs into the SDK cache, with no network
@@ -135,3 +159,19 @@ export declare const preloadComponents: (ids: string[], env?: string, preview?:
135
159
  * match what a plain `preloadComponents([id])` would have used.
136
160
  */
137
161
  export declare const hydrateComponents: (configs: Record<string, IComponentConfig>, env?: string, preview?: boolean) => void;
162
+ /**
163
+ * The v1 (iframe component) counterpart of {@link hydrateComponents}: seed configs that a
164
+ * server already fetched, so `loadComponent` needs no `/flow` request at all.
165
+ *
166
+ * ```ts
167
+ * // server (cache it ~60 s; `prefetch=1` keeps this fetch out of the view count, `for` says which
168
+ * // page it is for, so the prefetch is attributed to your site — its query string is not stored):
169
+ * const flow = await (await fetch(`https://cloud.myop.dev/flow?id=${id}&auto=true&prefetch=1&for=${encodeURIComponent(pageUrl)}`)).json();
170
+ * // embed JSON.stringify(flow) in the page, then on the client:
171
+ * hydrateV1Components({ [id]: flow });
172
+ * const cfg = await CloudRepository.Main.fetchComponentV1(id); // no request
173
+ * ```
174
+ *
175
+ * Each seeded config is counted as a view the first time it is used (via /clientUsage).
176
+ */
177
+ export declare const hydrateV1Components: (flows: Record<string, any>) => void;