@preprio/toolkit 0.5.0-rc.4 → 0.5.0-rc.5

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.
@@ -2,7 +2,7 @@
2
2
  import { NextResponse } from "next/server";
3
3
 
4
4
  // src/version.ts
5
- var VERSION = "0.5.0-rc.4";
5
+ var VERSION = "0.5.0-rc.5";
6
6
 
7
7
  // src/core/constants.ts
8
8
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,8 +1,8 @@
1
1
  "use server";
2
2
  import {
3
3
  isPreviewFromHeaders
4
- } from "../chunk-AHBN6FQP.js";
5
- import "../chunk-46ISDRHT.js";
4
+ } from "../chunk-3X55JL52.js";
5
+ import "../chunk-CMUFTCG3.js";
6
6
  import {
7
7
  parsePatchLog
8
8
  } from "../chunk-74KY5EAM.js";
@@ -1722,12 +1722,15 @@ function useLive(data, opts) {
1722
1722
  }
1723
1723
  function PreprRefresh({
1724
1724
  enabled = false,
1725
+ allowedEditorOrigins: origins,
1725
1726
  strictMode: strict = false
1726
1727
  }) {
1727
1728
  const router = (0, import_navigation.useRouter)();
1729
+ const originsKey = origins?.join(" ");
1728
1730
  (0, import_react.useEffect)(() => {
1729
1731
  if (!enabled || !isFramed()) return;
1730
1732
  if (strict) strictMode = true;
1733
+ if (originsKey) allowedEditorOrigins = originsKey.split(" ");
1731
1734
  const sync = createLogSync();
1732
1735
  let unsubscribe = null;
1733
1736
  let active = true;
@@ -1748,7 +1751,7 @@ function PreprRefresh({
1748
1751
  unsubscribe?.();
1749
1752
  sync.cancel();
1750
1753
  };
1751
- }, [enabled, strict, router]);
1754
+ }, [enabled, originsKey, strict, router]);
1752
1755
  return null;
1753
1756
  }
1754
1757
  var STEGA_CHARS = /[\u200b-\u200d\u2060-\u2064\ufeff]/;
@@ -19,6 +19,8 @@ interface LivePreviewConfig {
19
19
  interface PreprRefreshProps {
20
20
  /** Pass your preview flag; never `true` on a production deployment. */
21
21
  enabled?: boolean;
22
+ /** Exact editor origins, replacing the `*.prepr.io` default. */
23
+ allowedEditorOrigins?: string[];
22
24
  /** Your preview token uses GraphQL strict mode; see the toolbar option. */
23
25
  strictMode?: boolean;
24
26
  }
@@ -47,6 +49,6 @@ declare function useLive<T>(data: T, opts?: UseLiveOptions): T;
47
49
  * Use this or `useLive` with a `query`, not both: a save would refetch and
48
50
  * refresh.
49
51
  */
50
- declare function PreprRefresh({ enabled, strictMode: strict, }: PreprRefreshProps): null;
52
+ declare function PreprRefresh({ enabled, allowedEditorOrigins: origins, strictMode: strict, }: PreprRefreshProps): null;
51
53
 
52
54
  export { type LivePreviewConfig, PreprRefresh, type PreprRefreshProps, type UseLiveOptions, initLivePreview, useLive };
@@ -19,6 +19,8 @@ interface LivePreviewConfig {
19
19
  interface PreprRefreshProps {
20
20
  /** Pass your preview flag; never `true` on a production deployment. */
21
21
  enabled?: boolean;
22
+ /** Exact editor origins, replacing the `*.prepr.io` default. */
23
+ allowedEditorOrigins?: string[];
22
24
  /** Your preview token uses GraphQL strict mode; see the toolbar option. */
23
25
  strictMode?: boolean;
24
26
  }
@@ -47,6 +49,6 @@ declare function useLive<T>(data: T, opts?: UseLiveOptions): T;
47
49
  * Use this or `useLive` with a `query`, not both: a save would refetch and
48
50
  * refresh.
49
51
  */
50
- declare function PreprRefresh({ enabled, strictMode: strict, }: PreprRefreshProps): null;
52
+ declare function PreprRefresh({ enabled, allowedEditorOrigins: origins, strictMode: strict, }: PreprRefreshProps): null;
51
53
 
52
54
  export { type LivePreviewConfig, PreprRefresh, type PreprRefreshProps, type UseLiveOptions, initLivePreview, useLive };
@@ -92,12 +92,15 @@ function useLive(data, opts) {
92
92
  }
93
93
  function PreprRefresh({
94
94
  enabled = false,
95
+ allowedEditorOrigins: origins,
95
96
  strictMode: strict = false
96
97
  }) {
97
98
  const router = useRouter();
99
+ const originsKey = origins?.join(" ");
98
100
  useEffect(() => {
99
101
  if (!enabled || !isFramed()) return;
100
102
  if (strict) strictMode = true;
103
+ if (originsKey) allowedEditorOrigins = originsKey.split(" ");
101
104
  const sync = createLogSync();
102
105
  let unsubscribe = null;
103
106
  let active = true;
@@ -118,7 +121,7 @@ function PreprRefresh({
118
121
  unsubscribe?.();
119
122
  sync.cancel();
120
123
  };
121
- }, [enabled, strict, router]);
124
+ }, [enabled, originsKey, strict, router]);
122
125
  return null;
123
126
  }
124
127
  var STEGA_CHARS = /[\u200b-\u200d\u2060-\u2064\ufeff]/;
@@ -35,7 +35,7 @@ __export(nuxt_exports, {
35
35
  module.exports = __toCommonJS(nuxt_exports);
36
36
 
37
37
  // src/version.ts
38
- var VERSION = "0.5.0-rc.4";
38
+ var VERSION = "0.5.0-rc.5";
39
39
 
40
40
  // src/core/constants.ts
41
41
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.5.0-rc.4";
2
+ var VERSION = "0.5.0-rc.5";
3
3
 
4
4
  // src/core/constants.ts
5
5
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -3513,7 +3513,7 @@ function createPreprPreview(opts = {}) {
3513
3513
  }
3514
3514
 
3515
3515
  // src/version.ts
3516
- var VERSION = "0.5.0-rc.4";
3516
+ var VERSION = "0.5.0-rc.5";
3517
3517
 
3518
3518
  // src/core/pixel.ts
3519
3519
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -3489,7 +3489,7 @@ function createPreprPreview(opts = {}) {
3489
3489
  }
3490
3490
 
3491
3491
  // src/version.ts
3492
- var VERSION = "0.5.0-rc.4";
3492
+ var VERSION = "0.5.0-rc.5";
3493
3493
 
3494
3494
  // src/core/pixel.ts
3495
3495
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -35,7 +35,7 @@ __export(sveltekit_exports, {
35
35
  module.exports = __toCommonJS(sveltekit_exports);
36
36
 
37
37
  // src/version.ts
38
- var VERSION = "0.5.0-rc.4";
38
+ var VERSION = "0.5.0-rc.5";
39
39
 
40
40
  // src/core/constants.ts
41
41
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.5.0-rc.4";
2
+ var VERSION = "0.5.0-rc.5";
3
3
 
4
4
  // src/core/constants.ts
5
5
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";