@planningcenter/topbar 12.2.4-qa-881.0 → 12.2.4-qa-881.2

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/topbar.js CHANGED
@@ -3732,6 +3732,16 @@ let hasTriggeredObserve = false;
3732
3732
  function observe() {
3733
3733
  if (hasTriggeredObserve) return;
3734
3734
  hasTriggeredObserve = true;
3735
+ // The module-load snapshot above can predate meta tags that appear later
3736
+ // in <head> (e.g. pco:resource, yielded right before </head>) if this
3737
+ // module's own script tag isn't deferred and runs mid-parse. Those tags
3738
+ // never mutate afterward, so the observer alone would never catch them.
3739
+ // Re-read once now, since observe() is only called once a consumer is
3740
+ // actually mounting, which is always after the document has fully parsed.
3741
+ const freshState = getAllPcoMeta();
3742
+ if (!shallowCompare(store.getState(), freshState)) {
3743
+ store.setState(freshState);
3744
+ }
3735
3745
  observer.observe(document.head, {
3736
3746
  attributes: true,
3737
3747
  childList: true,
@@ -3745,10 +3755,13 @@ function usePcoMeta() {
3745
3755
 
3746
3756
  var styles$4 = {"debug-pco-resource":"debug-pco-resource-sLteM","debug-pco-resource-label":"debug-pco-resource-label-59ELk","debug-pco-resource-value":"debug-pco-resource-value-8IHn8","debug-pco-resource-json":"debug-pco-resource-json-Rx-JI"};
3747
3757
 
3748
- function describeResource(resource) {
3749
- if (resource === undefined) return "No pco:resource meta tag found on this page";
3750
- if (resource.trim() === "") return "pco:resource meta tag is present but malformed (empty)";
3751
- return resource;
3758
+ function isPresent(value) {
3759
+ return value !== undefined && value.trim() !== "";
3760
+ }
3761
+ function describeTag(tagName, value) {
3762
+ if (value === undefined) return `No pco:${tagName} meta tag found on this page`;
3763
+ if (value.trim() === "") return `pco:${tagName} meta tag is present but malformed (empty)`;
3764
+ return value;
3752
3765
  }
3753
3766
  // A `pco:resource` value looks like `<product>/v2/<resource_type>/<id>`. The
3754
3767
  // product segment doubles as the API subdomain/path, so a lookup only needs it.
@@ -3768,13 +3781,18 @@ function DebugPcoResource({
3768
3781
  env
3769
3782
  }) {
3770
3783
  const {
3784
+ recently_visitable: recentlyVisitable,
3771
3785
  resource
3772
3786
  } = usePcoMeta();
3773
3787
  const [lookup, setLookup] = React.useState({
3774
3788
  status: "idle"
3775
3789
  });
3790
+ const hasResource = isPresent(resource);
3791
+ const hasRecentlyVisitable = isPresent(recentlyVisitable);
3776
3792
  React.useEffect(() => {
3777
- const url = resource && resource.trim() !== "" ? pcrlLookupUrl(resource, env) : null;
3793
+ // pco:resource is the more specific signal, so it always wins when both
3794
+ // tags are present.
3795
+ const url = hasResource ? pcrlLookupUrl(resource, env) : null;
3778
3796
  if (!url) {
3779
3797
  setLookup({
3780
3798
  status: "idle"
@@ -3806,20 +3824,28 @@ function DebugPcoResource({
3806
3824
  return () => {
3807
3825
  cancelled = true;
3808
3826
  };
3809
- }, [resource, env]);
3827
+ }, [resource, env, hasResource]);
3810
3828
  return /*#__PURE__*/React.createElement("div", {
3811
3829
  className: styles$4["debug-pco-resource"]
3812
3830
  }, /*#__PURE__*/React.createElement("span", {
3813
3831
  className: styles$4["debug-pco-resource-label"]
3814
- }, "Debug: pco:resource"), /*#__PURE__*/React.createElement("span", {
3832
+ }, "Debug: Recently Visited"), /*#__PURE__*/React.createElement("span", {
3833
+ className: styles$4["debug-pco-resource-value"]
3834
+ }, "pco:resource: ", describeTag("resource", resource)), /*#__PURE__*/React.createElement("span", {
3815
3835
  className: styles$4["debug-pco-resource-value"]
3816
- }, describeResource(resource)), lookup.status === "loading" && (/*#__PURE__*/React.createElement("span", {
3836
+ }, "pco:recently_visitable:", " ", describeTag("recently_visitable", recentlyVisitable)), !hasResource && !hasRecentlyVisitable && (/*#__PURE__*/React.createElement("span", {
3817
3837
  className: styles$4["debug-pco-resource-value"]
3818
- }, "Looking up resource\u2026")), lookup.status === "error" && (/*#__PURE__*/React.createElement("span", {
3838
+ }, "This page is not eligible for Recently Visited")), hasResource && hasRecentlyVisitable && (/*#__PURE__*/React.createElement("span", {
3819
3839
  className: styles$4["debug-pco-resource-value"]
3820
- }, lookup.message)), lookup.status === "loaded" && (/*#__PURE__*/React.createElement("pre", {
3840
+ }, "Both tags are present \u2014 pco:resource takes precedence for the Recently Visited entry.")), hasResource && lookup.status === "loading" && (/*#__PURE__*/React.createElement("span", {
3841
+ className: styles$4["debug-pco-resource-value"]
3842
+ }, "Looking up resource\u2026")), hasResource && lookup.status === "error" && (/*#__PURE__*/React.createElement("span", {
3843
+ className: styles$4["debug-pco-resource-value"]
3844
+ }, lookup.message)), hasResource && lookup.status === "loaded" && (/*#__PURE__*/React.createElement("pre", {
3821
3845
  className: styles$4["debug-pco-resource-json"]
3822
- }, JSON.stringify(lookup.json, null, 2))));
3846
+ }, JSON.stringify(lookup.json, null, 2))), !hasResource && hasRecentlyVisitable && (/*#__PURE__*/React.createElement("span", {
3847
+ className: styles$4["debug-pco-resource-value"]
3848
+ }, "Recently Visited title: ", recentlyVisitable)));
3823
3849
  }
3824
3850
 
3825
3851
  var styles$3 = {"drawer-wrap":"drawer-wrap-J0rSL","is-visible":"is-visible-KTME8","drawer":"drawer-j7f4l"};