@amplifyup/sdk 0.1.72 → 0.1.74

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/react.mjs CHANGED
@@ -882,7 +882,8 @@ function mergeEventContext(properties, attached) {
882
882
  ...properties,
883
883
  ...attached.resource ? { resource: attached.resource } : {},
884
884
  page: attached.page,
885
- ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
885
+ ...attached.pageRoute ? { pageRoute: attached.pageRoute } : {},
886
+ ...attached.pageResource ? { pageResource: attached.pageResource } : {}
886
887
  };
887
888
  }
888
889
  var PAGE_RESOURCE_MARKER = "__amplifyupPageResource";
@@ -1182,7 +1183,8 @@ function mapResolvedToPageConfig(payload) {
1182
1183
  description: payload.meta?.degraded ? "degraded" : void 0
1183
1184
  },
1184
1185
  ...payload.eventTracking && payload.eventTracking.length > 0 ? { eventTracking: payload.eventTracking } : {},
1185
- ...payload.pageData ? { pageData: payload.pageData } : {}
1186
+ ...payload.pageData ? { pageData: payload.pageData } : {},
1187
+ ...payload.pageResources ? { pageResources: payload.pageResources } : {}
1186
1188
  };
1187
1189
  }
1188
1190
  function collectDegraded(payload) {
@@ -1484,6 +1486,7 @@ var AmplifyUpSDK = class {
1484
1486
  this.pendingPageContext = null;
1485
1487
  this.attachedPageContext = null;
1486
1488
  this.resolvedPageData = null;
1489
+ this.resolvedPageResource = null;
1487
1490
  this.resolvedPageRoute = "";
1488
1491
  this.resolvedRouteParams = {};
1489
1492
  this.historyHooksInstalled = false;
@@ -2016,28 +2019,38 @@ var AmplifyUpSDK = class {
2016
2019
  * Apply published pageData (from /v1/resolve) so field validation and
2017
2020
  * mapped page fields can run.
2018
2021
  */
2019
- applyResolvedPageData(pageData, pageRoute, routeParams) {
2022
+ applyResolvedPageData(pageData, pageRoute, routeParams, pageResources) {
2020
2023
  this.resolvedPageData = pageData || null;
2021
2024
  if (pageRoute) this.resolvedPageRoute = pageRoute;
2022
2025
  if (routeParams) this.resolvedRouteParams = routeParams;
2026
+ const firstResourceName = pageData?.resources?.[0]?.name;
2027
+ const resolvedForPage = (firstResourceName ? pageResources?.[firstResourceName] : void 0) || (pageResources ? Object.values(pageResources)[0] : void 0);
2028
+ this.resolvedPageResource = resolvedForPage || null;
2023
2029
  this.recomputeAttachedContext();
2024
2030
  }
2025
2031
  recomputeAttachedContext() {
2026
2032
  if (!this.pendingPageContext) {
2027
- this.attachedPageContext = attachStaticPageContext(
2028
- this.resolvedPageData,
2029
- this.resolvedPageRoute
2033
+ this.attachedPageContext = this.withPageResource(
2034
+ attachStaticPageContext(this.resolvedPageData, this.resolvedPageRoute)
2030
2035
  );
2031
2036
  setPageResourceFields(null);
2032
2037
  return;
2033
2038
  }
2034
- this.attachedPageContext = applyPageContext(this.pendingPageContext, {
2035
- pageData: this.resolvedPageData,
2036
- routeParams: this.resolvedRouteParams,
2037
- pageRoute: this.resolvedPageRoute
2038
- });
2039
+ this.attachedPageContext = this.withPageResource(
2040
+ applyPageContext(this.pendingPageContext, {
2041
+ pageData: this.resolvedPageData,
2042
+ routeParams: this.resolvedRouteParams,
2043
+ pageRoute: this.resolvedPageRoute
2044
+ })
2045
+ );
2039
2046
  setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
2040
2047
  }
2048
+ /** Stamp the resolved entry onto the context so events carry it. */
2049
+ withPageResource(context) {
2050
+ if (!context || !this.resolvedPageResource) return context;
2051
+ const { entity, providerId, docId } = this.resolvedPageResource;
2052
+ return { ...context, pageResource: { entity, providerId, docId } };
2053
+ }
2041
2054
  getAttachedPageContext() {
2042
2055
  return this.attachedPageContext;
2043
2056
  }
@@ -4886,6 +4899,9 @@ var lastRichTextRequestAt = 0;
4886
4899
  function requestCanvasRichTextEdit(opts) {
4887
4900
  if (typeof window === "undefined" || window.parent === window) return;
4888
4901
  if (!opts.name) return;
4902
+ if (opts.el.classList.contains("au-rte-active") || opts.el.querySelector(".ProseMirror")) {
4903
+ return;
4904
+ }
4889
4905
  const now = Date.now();
4890
4906
  if (now - lastRichTextRequestAt < 400) return;
4891
4907
  lastRichTextRequestAt = now;
@@ -5587,7 +5603,8 @@ function AmplifyUpProvider({
5587
5603
  sdk.applyResolvedPageData(
5588
5604
  result.pageConfig.pageData || null,
5589
5605
  result.pageConfig.route,
5590
- extractRouteParams(result.pageConfig.route, actualRoute)
5606
+ extractRouteParams(result.pageConfig.route, actualRoute),
5607
+ result.pageConfig.pageResources || null
5591
5608
  );
5592
5609
  }
5593
5610
  setInitialized(true);