@measured/puck 0.18.3-canary.9e8e47b → 0.19.0-canary.b9add22

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.
@@ -111,19 +111,20 @@ var getChanged = (newItem, oldItem) => {
111
111
 
112
112
  // lib/resolve-component-data.ts
113
113
  var cache = { lastChange: {} };
114
- var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
114
+ var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
115
115
  return yield Promise.all(
116
116
  content.map((item) => __async(void 0, null, function* () {
117
117
  return yield resolveComponentData(
118
118
  item,
119
119
  config,
120
+ metadata,
120
121
  onResolveStart,
121
122
  onResolveEnd
122
123
  );
123
124
  }))
124
125
  );
125
126
  });
126
- var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
127
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
127
128
  const configForItem = config.components[item.type];
128
129
  if (configForItem.resolveData) {
129
130
  const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
@@ -134,7 +135,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
134
135
  if (onResolveStart) {
135
136
  onResolveStart(item);
136
137
  }
137
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
138
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
139
+ changed,
140
+ lastData: oldItem,
141
+ metadata
142
+ });
138
143
  const resolvedItem = __spreadProps(__spreadValues({}, item), {
139
144
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
140
145
  });
@@ -156,7 +161,7 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
156
161
  // lib/resolve-root-data.ts
157
162
  init_react_import();
158
163
  var cache2 = {};
159
- function resolveRootData(data, config) {
164
+ function resolveRootData(data, config, metadata) {
160
165
  return __async(this, null, function* () {
161
166
  var _a, _b, _c, _d, _e;
162
167
  if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
@@ -167,7 +172,8 @@ function resolveRootData(data, config) {
167
172
  const rootWithProps = data.root;
168
173
  const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
169
174
  changed,
170
- lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
175
+ lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
176
+ metadata: metadata || {}
171
177
  });
172
178
  cache2.lastChange = {
173
179
  original: data.root,
@@ -189,10 +195,14 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
189
195
  });
190
196
 
191
197
  // lib/resolve-all-data.ts
192
- function resolveAllData(data, config, onResolveStart, onResolveEnd) {
193
- return __async(this, null, function* () {
198
+ function resolveAllData(_0, _1) {
199
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
194
200
  const defaultedData = defaultData(data);
195
- const dynamicRoot = yield resolveRootData(defaultedData, config);
201
+ const dynamicRoot = yield resolveRootData(
202
+ defaultedData,
203
+ config,
204
+ metadata
205
+ );
196
206
  const { zones = {} } = data;
197
207
  const zoneKeys = Object.keys(zones);
198
208
  const resolvedZones = {};
@@ -201,6 +211,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
201
211
  resolvedZones[zoneKey] = yield resolveAllComponentData(
202
212
  zones[zoneKey],
203
213
  config,
214
+ metadata,
204
215
  onResolveStart,
205
216
  onResolveEnd
206
217
  );
@@ -210,6 +221,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
210
221
  content: yield resolveAllComponentData(
211
222
  defaultedData.content,
212
223
  config,
224
+ metadata,
213
225
  onResolveStart,
214
226
  onResolveEnd
215
227
  ),
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldProps, a as Field, D as DropZoneProps, C as Config, U as UserGenerics, b as Data, c as UiState, O as OnAction, P as Permissions, d as Plugin, e as Overrides, f as PuckAction, V as Viewports, I as IframeConfig, g as InitialHistory, h as DefaultComponentProps, i as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, j as ExtractRootPropsFromConfig, k as ComponentDataMap } from './resolve-all-data-ppm982Jh.mjs';
2
- export { Q as Adaptor, K as ArrayField, s as ArrayState, a3 as AsFieldProps, B as BaseData, z as BaseField, u as ComponentConfig, x as ComponentData, y as Content, Y as CustomField, a0 as DefaultRootProps, $ as DefaultRootRenderProps, l as Direction, m as DragAxis, X as ExternalField, W as ExternalFieldWithAdaptor, q as FieldRenderFunctions, Z as Fields, r as ItemWithId, M as MappedItem, N as NumberField, L as ObjectField, p as OverrideKey, t as PuckComponent, _ as PuckContext, J as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, G as TextareaField, n as Viewport, a4 as WithChildren, a1 as WithId, a2 as WithPuckProps, o as overrideKeys, a5 as resolveAllData } from './resolve-all-data-ppm982Jh.mjs';
1
+ import { F as FieldProps, a as Field, D as DropZoneProps, C as Config, U as UserGenerics, b as Data, c as UiState, O as OnAction, P as Permissions, d as Plugin, e as Overrides, f as PuckAction, V as Viewports, I as IframeConfig, g as InitialHistory, M as Metadata, h as DefaultComponentProps, i as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, j as ExtractRootPropsFromConfig, k as ComponentDataMap } from './resolve-all-data-DIpcwlzP.mjs';
2
+ export { W as Adaptor, L as ArrayField, s as ArrayState, a4 as AsFieldProps, B as BaseData, G as BaseField, u as ComponentConfig, x as ComponentData, z as Content, Z as CustomField, a1 as DefaultRootProps, a0 as DefaultRootRenderProps, l as Direction, m as DragAxis, Y as ExternalField, X as ExternalFieldWithAdaptor, q as FieldRenderFunctions, _ as Fields, r as ItemWithId, y as MappedItem, N as NumberField, Q as ObjectField, p as OverrideKey, t as PuckComponent, $ as PuckContext, K as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, J as TextareaField, n as Viewport, a5 as WithChildren, a2 as WithId, a3 as WithPuckProps, o as overrideKeys, a6 as resolveAllData } from './resolve-all-data-DIpcwlzP.mjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode, SyntheticEvent, ReactElement } from 'react';
@@ -93,7 +93,7 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
93
93
  title: string;
94
94
  }) => react_jsx_runtime.JSX.Element;
95
95
 
96
- declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe: _iframe, dnd, initialHistory: _initialHistory, }: {
96
+ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe: _iframe, dnd, initialHistory: _initialHistory, metadata, }: {
97
97
  children?: ReactNode;
98
98
  config: UserConfig;
99
99
  data: Partial<G["UserData"] | Data>;
@@ -121,6 +121,7 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
121
121
  disableAutoScroll?: boolean;
122
122
  };
123
123
  initialHistory?: InitialHistory;
124
+ metadata?: Metadata;
124
125
  }): react_jsx_runtime.JSX.Element;
125
126
  declare namespace Puck {
126
127
  var Components: () => react_jsx_runtime.JSX.Element;
@@ -133,9 +134,10 @@ declare namespace Puck {
133
134
  }) => react_jsx_runtime.JSX.Element;
134
135
  }
135
136
 
136
- declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, }: {
137
+ declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
137
138
  config: UserConfig;
138
139
  data: Partial<G["UserData"] | Data>;
140
+ metadata?: Metadata;
139
141
  }): react_jsx_runtime.JSX.Element;
140
142
 
141
143
  declare function migrate(data: Data): Data;
@@ -194,4 +196,4 @@ declare const usePuck: <UserConfig extends Config = Config>() => {
194
196
  selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
195
197
  };
196
198
 
197
- export { Action, ActionBar, AppState, AutoField, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldProps, Group, History, IconButton, IframeConfig, InitialHistory, Label, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, migrate, transformProps, usePuck };
199
+ export { Action, ActionBar, AppState, AutoField, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldProps, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, migrate, transformProps, usePuck };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldProps, a as Field, D as DropZoneProps, C as Config, U as UserGenerics, b as Data, c as UiState, O as OnAction, P as Permissions, d as Plugin, e as Overrides, f as PuckAction, V as Viewports, I as IframeConfig, g as InitialHistory, h as DefaultComponentProps, i as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, j as ExtractRootPropsFromConfig, k as ComponentDataMap } from './resolve-all-data-ppm982Jh.js';
2
- export { Q as Adaptor, K as ArrayField, s as ArrayState, a3 as AsFieldProps, B as BaseData, z as BaseField, u as ComponentConfig, x as ComponentData, y as Content, Y as CustomField, a0 as DefaultRootProps, $ as DefaultRootRenderProps, l as Direction, m as DragAxis, X as ExternalField, W as ExternalFieldWithAdaptor, q as FieldRenderFunctions, Z as Fields, r as ItemWithId, M as MappedItem, N as NumberField, L as ObjectField, p as OverrideKey, t as PuckComponent, _ as PuckContext, J as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, G as TextareaField, n as Viewport, a4 as WithChildren, a1 as WithId, a2 as WithPuckProps, o as overrideKeys, a5 as resolveAllData } from './resolve-all-data-ppm982Jh.js';
1
+ import { F as FieldProps, a as Field, D as DropZoneProps, C as Config, U as UserGenerics, b as Data, c as UiState, O as OnAction, P as Permissions, d as Plugin, e as Overrides, f as PuckAction, V as Viewports, I as IframeConfig, g as InitialHistory, M as Metadata, h as DefaultComponentProps, i as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, j as ExtractRootPropsFromConfig, k as ComponentDataMap } from './resolve-all-data-DIpcwlzP.js';
2
+ export { W as Adaptor, L as ArrayField, s as ArrayState, a4 as AsFieldProps, B as BaseData, G as BaseField, u as ComponentConfig, x as ComponentData, z as Content, Z as CustomField, a1 as DefaultRootProps, a0 as DefaultRootRenderProps, l as Direction, m as DragAxis, Y as ExternalField, X as ExternalFieldWithAdaptor, q as FieldRenderFunctions, _ as Fields, r as ItemWithId, y as MappedItem, N as NumberField, Q as ObjectField, p as OverrideKey, t as PuckComponent, $ as PuckContext, K as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, J as TextareaField, n as Viewport, a5 as WithChildren, a2 as WithId, a3 as WithPuckProps, o as overrideKeys, a6 as resolveAllData } from './resolve-all-data-DIpcwlzP.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode, SyntheticEvent, ReactElement } from 'react';
@@ -93,7 +93,7 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
93
93
  title: string;
94
94
  }) => react_jsx_runtime.JSX.Element;
95
95
 
96
- declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe: _iframe, dnd, initialHistory: _initialHistory, }: {
96
+ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe: _iframe, dnd, initialHistory: _initialHistory, metadata, }: {
97
97
  children?: ReactNode;
98
98
  config: UserConfig;
99
99
  data: Partial<G["UserData"] | Data>;
@@ -121,6 +121,7 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
121
121
  disableAutoScroll?: boolean;
122
122
  };
123
123
  initialHistory?: InitialHistory;
124
+ metadata?: Metadata;
124
125
  }): react_jsx_runtime.JSX.Element;
125
126
  declare namespace Puck {
126
127
  var Components: () => react_jsx_runtime.JSX.Element;
@@ -133,9 +134,10 @@ declare namespace Puck {
133
134
  }) => react_jsx_runtime.JSX.Element;
134
135
  }
135
136
 
136
- declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, }: {
137
+ declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
137
138
  config: UserConfig;
138
139
  data: Partial<G["UserData"] | Data>;
140
+ metadata?: Metadata;
139
141
  }): react_jsx_runtime.JSX.Element;
140
142
 
141
143
  declare function migrate(data: Data): Data;
@@ -194,4 +196,4 @@ declare const usePuck: <UserConfig extends Config = Config>() => {
194
196
  selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
195
197
  };
196
198
 
197
- export { Action, ActionBar, AppState, AutoField, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldProps, Group, History, IconButton, IframeConfig, InitialHistory, Label, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, migrate, transformProps, usePuck };
199
+ export { Action, ActionBar, AppState, AutoField, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldProps, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, migrate, transformProps, usePuck };
package/dist/index.js CHANGED
@@ -962,19 +962,20 @@ var import_react6 = require("react");
962
962
  // lib/resolve-component-data.ts
963
963
  init_react_import();
964
964
  var cache = { lastChange: {} };
965
- var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
965
+ var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
966
966
  return yield Promise.all(
967
967
  content.map((item) => __async(void 0, null, function* () {
968
968
  return yield resolveComponentData(
969
969
  item,
970
970
  config,
971
+ metadata,
971
972
  onResolveStart,
972
973
  onResolveEnd
973
974
  );
974
975
  }))
975
976
  );
976
977
  });
977
- var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
978
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
978
979
  const configForItem = config.components[item.type];
979
980
  if (configForItem.resolveData) {
980
981
  const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
@@ -985,7 +986,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
985
986
  if (onResolveStart) {
986
987
  onResolveStart(item);
987
988
  }
988
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
989
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
990
+ changed,
991
+ lastData: oldItem,
992
+ metadata
993
+ });
989
994
  const resolvedItem = __spreadProps(__spreadValues({}, item), {
990
995
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
991
996
  });
@@ -1025,7 +1030,7 @@ var applyDynamicProps = (data, dynamicProps, rootData) => {
1025
1030
  // lib/resolve-root-data.ts
1026
1031
  init_react_import();
1027
1032
  var cache2 = {};
1028
- function resolveRootData(data, config) {
1033
+ function resolveRootData(data, config, metadata) {
1029
1034
  return __async(this, null, function* () {
1030
1035
  var _a, _b, _c, _d, _e;
1031
1036
  if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
@@ -1036,7 +1041,8 @@ function resolveRootData(data, config) {
1036
1041
  const rootWithProps = data.root;
1037
1042
  const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
1038
1043
  changed,
1039
- lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
1044
+ lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
1045
+ metadata: metadata || {}
1040
1046
  });
1041
1047
  cache2.lastChange = {
1042
1048
  original: data.root,
@@ -1051,7 +1057,7 @@ function resolveRootData(data, config) {
1051
1057
  }
1052
1058
 
1053
1059
  // lib/use-resolved-data.ts
1054
- var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions) => {
1060
+ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions, metadata) => {
1055
1061
  const [{ resolverKey, newAppState }, setResolverState] = (0, import_react6.useState)({
1056
1062
  resolverKey: 0,
1057
1063
  newAppState: appState
@@ -1105,7 +1111,7 @@ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetCom
1105
1111
  promises.push(
1106
1112
  (() => __async(void 0, null, function* () {
1107
1113
  _setComponentLoading("puck-root", true, 50);
1108
- const dynamicRoot = yield resolveRootData(newData, config);
1114
+ const dynamicRoot = yield resolveRootData(newData, config, metadata);
1109
1115
  applyIfChange({}, dynamicRoot);
1110
1116
  _setComponentLoading("puck-root", false);
1111
1117
  }))()
@@ -1117,6 +1123,7 @@ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetCom
1117
1123
  const dynamicData = yield resolveComponentData(
1118
1124
  item,
1119
1125
  config,
1126
+ metadata,
1120
1127
  (item2) => {
1121
1128
  _setComponentLoading(item2.props.id, true, 50);
1122
1129
  },
@@ -1193,7 +1200,8 @@ var defaultContext = {
1193
1200
  iframe: {},
1194
1201
  globalPermissions: {},
1195
1202
  getPermissions: () => ({}),
1196
- refreshPermissions: () => null
1203
+ refreshPermissions: () => null,
1204
+ metadata: {}
1197
1205
  };
1198
1206
  var appContext = (0, import_react7.createContext)(defaultContext);
1199
1207
  var AppProvider = ({
@@ -1240,7 +1248,8 @@ var AppProvider = ({
1240
1248
  value.dispatch,
1241
1249
  setComponentLoading,
1242
1250
  unsetComponentLoading,
1243
- refreshPermissions
1251
+ refreshPermissions,
1252
+ value.metadata
1244
1253
  );
1245
1254
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1246
1255
  appContext.Provider,
@@ -4188,6 +4197,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
4188
4197
  const componentId = item.props.id;
4189
4198
  const puckProps = {
4190
4199
  renderDropZone: DropZoneEditPure,
4200
+ metadata: appContext2.metadata,
4191
4201
  isEditing: true,
4192
4202
  dragRef: null
4193
4203
  };
@@ -4285,13 +4295,15 @@ var DropZoneRender = (0, import_react30.forwardRef)(
4285
4295
  config,
4286
4296
  areaId: item.props.id,
4287
4297
  depth: 1,
4288
- path: []
4298
+ path: [],
4299
+ metadata: (ctx == null ? void 0 : ctx.metadata) || {}
4289
4300
  },
4290
4301
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4291
4302
  Component.render,
4292
4303
  __spreadProps(__spreadValues({}, item.props), {
4293
4304
  puck: {
4294
- renderDropZone: DropZoneRenderPure
4305
+ renderDropZone: DropZoneRenderPure,
4306
+ metadata: (ctx == null ? void 0 : ctx.metadata) || {}
4295
4307
  }
4296
4308
  })
4297
4309
  )
@@ -5033,7 +5045,7 @@ var DragDropContextClient = ({
5033
5045
  children,
5034
5046
  disableAutoScroll
5035
5047
  }) => {
5036
- const { state, config, dispatch, resolveData } = useAppContext();
5048
+ const { state, config, dispatch, resolveData, metadata } = useAppContext();
5037
5049
  const id = (0, import_react32.useId)();
5038
5050
  const { data } = state;
5039
5051
  const debouncedParamsRef = (0, import_react32.useRef)(null);
@@ -5392,7 +5404,8 @@ var DragDropContextClient = ({
5392
5404
  registerPath,
5393
5405
  unregisterPath,
5394
5406
  pathData,
5395
- path: []
5407
+ path: [],
5408
+ metadata
5396
5409
  },
5397
5410
  children
5398
5411
  }
@@ -6467,7 +6480,8 @@ init_react_import();
6467
6480
  var import_jsx_runtime32 = require("react/jsx-runtime");
6468
6481
  function Render({
6469
6482
  config,
6470
- data
6483
+ data,
6484
+ metadata = {}
6471
6485
  }) {
6472
6486
  var _a;
6473
6487
  const defaultedData = __spreadProps(__spreadValues({}, data), {
@@ -6485,7 +6499,8 @@ function Render({
6485
6499
  config,
6486
6500
  mode: "render",
6487
6501
  depth: 0,
6488
- path: []
6502
+ path: [],
6503
+ metadata
6489
6504
  },
6490
6505
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6491
6506
  config.root.render,
@@ -6512,7 +6527,8 @@ function Render({
6512
6527
  config,
6513
6528
  mode: "render",
6514
6529
  depth: 0,
6515
- path: []
6530
+ path: [],
6531
+ metadata
6516
6532
  },
6517
6533
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
6518
6534
  }
@@ -6576,7 +6592,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
6576
6592
  puck: {
6577
6593
  renderDropZone: DropZonePure,
6578
6594
  isEditing: true,
6579
- dragRef: null
6595
+ dragRef: null,
6596
+ metadata: {}
6580
6597
  },
6581
6598
  editMode: true,
6582
6599
  children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZonePure, { zone: rootDroppableId })
@@ -7571,7 +7588,8 @@ function Puck({
7571
7588
  viewports = defaultViewports,
7572
7589
  iframe: _iframe,
7573
7590
  dnd,
7574
- initialHistory: _initialHistory
7591
+ initialHistory: _initialHistory,
7592
+ metadata
7575
7593
  }) {
7576
7594
  var _a, _b;
7577
7595
  const iframe = __spreadValues({
@@ -7784,7 +7802,8 @@ function Puck({
7784
7802
  edit: true
7785
7803
  }, permissions),
7786
7804
  getPermissions: () => ({}),
7787
- refreshPermissions: () => null
7805
+ refreshPermissions: () => null,
7806
+ metadata: metadata || {}
7788
7807
  },
7789
7808
  children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7790
7809
  "div",
@@ -7988,10 +8007,14 @@ function transformProps(data, propTransforms) {
7988
8007
 
7989
8008
  // lib/resolve-all-data.ts
7990
8009
  init_react_import();
7991
- function resolveAllData(data, config, onResolveStart, onResolveEnd) {
7992
- return __async(this, null, function* () {
8010
+ function resolveAllData(_0, _1) {
8011
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
7993
8012
  const defaultedData = defaultData(data);
7994
- const dynamicRoot = yield resolveRootData(defaultedData, config);
8013
+ const dynamicRoot = yield resolveRootData(
8014
+ defaultedData,
8015
+ config,
8016
+ metadata
8017
+ );
7995
8018
  const { zones = {} } = data;
7996
8019
  const zoneKeys = Object.keys(zones);
7997
8020
  const resolvedZones = {};
@@ -8000,6 +8023,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
8000
8023
  resolvedZones[zoneKey] = yield resolveAllComponentData(
8001
8024
  zones[zoneKey],
8002
8025
  config,
8026
+ metadata,
8003
8027
  onResolveStart,
8004
8028
  onResolveEnd
8005
8029
  );
@@ -8009,6 +8033,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
8009
8033
  content: yield resolveAllComponentData(
8010
8034
  defaultedData.content,
8011
8035
  config,
8036
+ metadata,
8012
8037
  onResolveStart,
8013
8038
  onResolveEnd
8014
8039
  ),
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  resolveRootData,
17
17
  rootDroppableId,
18
18
  setupZone
19
- } from "./chunk-CHWFBYEM.mjs";
19
+ } from "./chunk-FNRHXUGA.mjs";
20
20
 
21
21
  // ../../node_modules/classnames/index.js
22
22
  var require_classnames = __commonJS({
@@ -857,7 +857,7 @@ var applyDynamicProps = (data, dynamicProps, rootData) => {
857
857
  };
858
858
 
859
859
  // lib/use-resolved-data.ts
860
- var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions) => {
860
+ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions, metadata) => {
861
861
  const [{ resolverKey, newAppState }, setResolverState] = useState3({
862
862
  resolverKey: 0,
863
863
  newAppState: appState
@@ -911,7 +911,7 @@ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetCom
911
911
  promises.push(
912
912
  (() => __async(void 0, null, function* () {
913
913
  _setComponentLoading("puck-root", true, 50);
914
- const dynamicRoot = yield resolveRootData(newData, config);
914
+ const dynamicRoot = yield resolveRootData(newData, config, metadata);
915
915
  applyIfChange({}, dynamicRoot);
916
916
  _setComponentLoading("puck-root", false);
917
917
  }))()
@@ -923,6 +923,7 @@ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetCom
923
923
  const dynamicData = yield resolveComponentData(
924
924
  item,
925
925
  config,
926
+ metadata,
926
927
  (item2) => {
927
928
  _setComponentLoading(item2.props.id, true, 50);
928
929
  },
@@ -999,7 +1000,8 @@ var defaultContext = {
999
1000
  iframe: {},
1000
1001
  globalPermissions: {},
1001
1002
  getPermissions: () => ({}),
1002
- refreshPermissions: () => null
1003
+ refreshPermissions: () => null,
1004
+ metadata: {}
1003
1005
  };
1004
1006
  var appContext = createContext(defaultContext);
1005
1007
  var AppProvider = ({
@@ -1046,7 +1048,8 @@ var AppProvider = ({
1046
1048
  value.dispatch,
1047
1049
  setComponentLoading,
1048
1050
  unsetComponentLoading,
1049
- refreshPermissions
1051
+ refreshPermissions,
1052
+ value.metadata
1050
1053
  );
1051
1054
  return /* @__PURE__ */ jsx5(
1052
1055
  appContext.Provider,
@@ -4042,6 +4045,7 @@ var DropZoneEdit = forwardRef3(
4042
4045
  const componentId = item.props.id;
4043
4046
  const puckProps = {
4044
4047
  renderDropZone: DropZoneEditPure,
4048
+ metadata: appContext2.metadata,
4045
4049
  isEditing: true,
4046
4050
  dragRef: null
4047
4051
  };
@@ -4139,13 +4143,15 @@ var DropZoneRender = forwardRef3(
4139
4143
  config,
4140
4144
  areaId: item.props.id,
4141
4145
  depth: 1,
4142
- path: []
4146
+ path: [],
4147
+ metadata: (ctx == null ? void 0 : ctx.metadata) || {}
4143
4148
  },
4144
4149
  children: /* @__PURE__ */ jsx22(
4145
4150
  Component.render,
4146
4151
  __spreadProps(__spreadValues({}, item.props), {
4147
4152
  puck: {
4148
- renderDropZone: DropZoneRenderPure
4153
+ renderDropZone: DropZoneRenderPure,
4154
+ metadata: (ctx == null ? void 0 : ctx.metadata) || {}
4149
4155
  }
4150
4156
  })
4151
4157
  )
@@ -4887,7 +4893,7 @@ var DragDropContextClient = ({
4887
4893
  children,
4888
4894
  disableAutoScroll
4889
4895
  }) => {
4890
- const { state, config, dispatch, resolveData } = useAppContext();
4896
+ const { state, config, dispatch, resolveData, metadata } = useAppContext();
4891
4897
  const id = useId();
4892
4898
  const { data } = state;
4893
4899
  const debouncedParamsRef = useRef3(null);
@@ -5246,7 +5252,8 @@ var DragDropContextClient = ({
5246
5252
  registerPath,
5247
5253
  unregisterPath,
5248
5254
  pathData,
5249
- path: []
5255
+ path: [],
5256
+ metadata
5250
5257
  },
5251
5258
  children
5252
5259
  }
@@ -6332,7 +6339,8 @@ init_react_import();
6332
6339
  import { jsx as jsx32 } from "react/jsx-runtime";
6333
6340
  function Render({
6334
6341
  config,
6335
- data
6342
+ data,
6343
+ metadata = {}
6336
6344
  }) {
6337
6345
  var _a;
6338
6346
  const defaultedData = __spreadProps(__spreadValues({}, data), {
@@ -6350,7 +6358,8 @@ function Render({
6350
6358
  config,
6351
6359
  mode: "render",
6352
6360
  depth: 0,
6353
- path: []
6361
+ path: [],
6362
+ metadata
6354
6363
  },
6355
6364
  children: /* @__PURE__ */ jsx32(
6356
6365
  config.root.render,
@@ -6377,7 +6386,8 @@ function Render({
6377
6386
  config,
6378
6387
  mode: "render",
6379
6388
  depth: 0,
6380
- path: []
6389
+ path: [],
6390
+ metadata
6381
6391
  },
6382
6392
  children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
6383
6393
  }
@@ -6441,7 +6451,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
6441
6451
  puck: {
6442
6452
  renderDropZone: DropZonePure,
6443
6453
  isEditing: true,
6444
- dragRef: null
6454
+ dragRef: null,
6455
+ metadata: {}
6445
6456
  },
6446
6457
  editMode: true,
6447
6458
  children: /* @__PURE__ */ jsx33(DropZonePure, { zone: rootDroppableId })
@@ -7442,7 +7453,8 @@ function Puck({
7442
7453
  viewports = defaultViewports,
7443
7454
  iframe: _iframe,
7444
7455
  dnd,
7445
- initialHistory: _initialHistory
7456
+ initialHistory: _initialHistory,
7457
+ metadata
7446
7458
  }) {
7447
7459
  var _a, _b;
7448
7460
  const iframe = __spreadValues({
@@ -7655,7 +7667,8 @@ function Puck({
7655
7667
  edit: true
7656
7668
  }, permissions),
7657
7669
  getPermissions: () => ({}),
7658
- refreshPermissions: () => null
7670
+ refreshPermissions: () => null,
7671
+ metadata: metadata || {}
7659
7672
  },
7660
7673
  children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
7661
7674
  "div",
@@ -154,6 +154,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
154
154
  resolveData?: (data: DataShape, params: {
155
155
  changed: Partial<Record<keyof FieldProps, boolean>>;
156
156
  lastData: DataShape | null;
157
+ metadata: Metadata;
157
158
  }) => Promise<{
158
159
  props?: Partial<FieldProps>;
159
160
  readOnly?: Partial<Record<keyof FieldProps, boolean>>;
@@ -209,6 +210,7 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
209
210
 
210
211
  type PuckContext = {
211
212
  renderDropZone: React.FC<DropZoneProps>;
213
+ metadata: Metadata;
212
214
  isEditing: boolean;
213
215
  dragRef: ((element: Element | null) => void) | null;
214
216
  };
@@ -251,6 +253,9 @@ type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps
251
253
  content: Content<Props>;
252
254
  zones?: Record<string, Content<Props>>;
253
255
  };
256
+ type Metadata = {
257
+ [key: string]: any;
258
+ };
254
259
 
255
260
  type ItemWithId = {
256
261
  _arrayId: string;
@@ -457,6 +462,6 @@ type PuckAction = {
457
462
  recordHistory?: boolean;
458
463
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
459
464
 
460
- declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
465
+ declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
461
466
 
462
- export { type DefaultRootRenderProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type ExtractPropsFromConfig as E, type FieldProps as F, type TextareaField as G, type History as H, type IframeConfig as I, type RadioField as J, type ArrayField as K, type ObjectField as L, type MappedItem as M, type NumberField as N, type OnAction as O, type Permissions as P, type Adaptor as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ExternalFieldWithAdaptor as W, type ExternalField as X, type CustomField as Y, type Fields as Z, type PuckContext as _, type Field as a, type DefaultRootProps as a0, type WithId as a1, type WithPuckProps as a2, type AsFieldProps as a3, type WithChildren as a4, resolveAllData as a5, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type DefaultComponentProps as h, type DefaultRootFieldProps as i, type ExtractRootPropsFromConfig as j, type ComponentDataMap as k, type Direction as l, type DragAxis as m, type Viewport as n, overrideKeys as o, type OverrideKey as p, type FieldRenderFunctions as q, type ItemWithId as r, type ArrayState as s, type PuckComponent as t, type ComponentConfig as u, type RootDataWithoutProps as v, type RootData as w, type ComponentData as x, type Content as y, type BaseField as z };
467
+ export { type PuckContext as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type ExtractPropsFromConfig as E, type FieldProps as F, type BaseField as G, type History as H, type IframeConfig as I, type TextareaField as J, type RadioField as K, type ArrayField as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ObjectField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type Adaptor as W, type ExternalFieldWithAdaptor as X, type ExternalField as Y, type CustomField as Z, type Fields as _, type Field as a, type DefaultRootRenderProps as a0, type DefaultRootProps as a1, type WithId as a2, type WithPuckProps as a3, type AsFieldProps as a4, type WithChildren as a5, resolveAllData as a6, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type DefaultComponentProps as h, type DefaultRootFieldProps as i, type ExtractRootPropsFromConfig as j, type ComponentDataMap as k, type Direction as l, type DragAxis as m, type Viewport as n, overrideKeys as o, type OverrideKey as p, type FieldRenderFunctions as q, type ItemWithId as r, type ArrayState as s, type PuckComponent as t, type ComponentConfig as u, type RootDataWithoutProps as v, type RootData as w, type ComponentData as x, type MappedItem as y, type Content as z };
@@ -154,6 +154,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
154
154
  resolveData?: (data: DataShape, params: {
155
155
  changed: Partial<Record<keyof FieldProps, boolean>>;
156
156
  lastData: DataShape | null;
157
+ metadata: Metadata;
157
158
  }) => Promise<{
158
159
  props?: Partial<FieldProps>;
159
160
  readOnly?: Partial<Record<keyof FieldProps, boolean>>;
@@ -209,6 +210,7 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
209
210
 
210
211
  type PuckContext = {
211
212
  renderDropZone: React.FC<DropZoneProps>;
213
+ metadata: Metadata;
212
214
  isEditing: boolean;
213
215
  dragRef: ((element: Element | null) => void) | null;
214
216
  };
@@ -251,6 +253,9 @@ type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps
251
253
  content: Content<Props>;
252
254
  zones?: Record<string, Content<Props>>;
253
255
  };
256
+ type Metadata = {
257
+ [key: string]: any;
258
+ };
254
259
 
255
260
  type ItemWithId = {
256
261
  _arrayId: string;
@@ -457,6 +462,6 @@ type PuckAction = {
457
462
  recordHistory?: boolean;
458
463
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
459
464
 
460
- declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
465
+ declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
461
466
 
462
- export { type DefaultRootRenderProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type ExtractPropsFromConfig as E, type FieldProps as F, type TextareaField as G, type History as H, type IframeConfig as I, type RadioField as J, type ArrayField as K, type ObjectField as L, type MappedItem as M, type NumberField as N, type OnAction as O, type Permissions as P, type Adaptor as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ExternalFieldWithAdaptor as W, type ExternalField as X, type CustomField as Y, type Fields as Z, type PuckContext as _, type Field as a, type DefaultRootProps as a0, type WithId as a1, type WithPuckProps as a2, type AsFieldProps as a3, type WithChildren as a4, resolveAllData as a5, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type DefaultComponentProps as h, type DefaultRootFieldProps as i, type ExtractRootPropsFromConfig as j, type ComponentDataMap as k, type Direction as l, type DragAxis as m, type Viewport as n, overrideKeys as o, type OverrideKey as p, type FieldRenderFunctions as q, type ItemWithId as r, type ArrayState as s, type PuckComponent as t, type ComponentConfig as u, type RootDataWithoutProps as v, type RootData as w, type ComponentData as x, type Content as y, type BaseField as z };
467
+ export { type PuckContext as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type ExtractPropsFromConfig as E, type FieldProps as F, type BaseField as G, type History as H, type IframeConfig as I, type TextareaField as J, type RadioField as K, type ArrayField as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ObjectField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type Adaptor as W, type ExternalFieldWithAdaptor as X, type ExternalField as Y, type CustomField as Z, type Fields as _, type Field as a, type DefaultRootRenderProps as a0, type DefaultRootProps as a1, type WithId as a2, type WithPuckProps as a3, type AsFieldProps as a4, type WithChildren as a5, resolveAllData as a6, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type DefaultComponentProps as h, type DefaultRootFieldProps as i, type ExtractRootPropsFromConfig as j, type ComponentDataMap as k, type Direction as l, type DragAxis as m, type Viewport as n, overrideKeys as o, type OverrideKey as p, type FieldRenderFunctions as q, type ItemWithId as r, type ArrayState as s, type PuckComponent as t, type ComponentConfig as u, type RootDataWithoutProps as v, type RootData as w, type ComponentData as x, type MappedItem as y, type Content as z };
package/dist/rsc.d.mts CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics } from './resolve-all-data-ppm982Jh.mjs';
3
- export { a5 as resolveAllData } from './resolve-all-data-ppm982Jh.mjs';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-DIpcwlzP.mjs';
3
+ export { a6 as resolveAllData } from './resolve-all-data-DIpcwlzP.mjs';
4
4
  import 'react';
5
5
 
6
- declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data }: {
6
+ declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
7
7
  config: UserConfig;
8
8
  data: G["UserData"];
9
+ metadata: Metadata;
9
10
  }): react_jsx_runtime.JSX.Element;
10
11
 
11
12
  export { Render };
package/dist/rsc.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics } from './resolve-all-data-ppm982Jh.js';
3
- export { a5 as resolveAllData } from './resolve-all-data-ppm982Jh.js';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-DIpcwlzP.js';
3
+ export { a6 as resolveAllData } from './resolve-all-data-DIpcwlzP.js';
4
4
  import 'react';
5
5
 
6
- declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data }: {
6
+ declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
7
7
  config: UserConfig;
8
8
  data: G["UserData"];
9
+ metadata: Metadata;
9
10
  }): react_jsx_runtime.JSX.Element;
10
11
 
11
12
  export { Render };
package/dist/rsc.js CHANGED
@@ -96,7 +96,8 @@ function DropZoneRender({
96
96
  zone,
97
97
  data,
98
98
  areaId = "root",
99
- config
99
+ config,
100
+ metadata = {}
100
101
  }) {
101
102
  let zoneCompound = rootDroppableId;
102
103
  let content = (data == null ? void 0 : data.content) || [];
@@ -120,9 +121,11 @@ function DropZoneRender({
120
121
  zone: zone2,
121
122
  data,
122
123
  areaId: item.props.id,
123
- config
124
+ config,
125
+ metadata
124
126
  }
125
- )
127
+ ),
128
+ metadata
126
129
  }
127
130
  }),
128
131
  item.props.id
@@ -131,7 +134,11 @@ function DropZoneRender({
131
134
  return null;
132
135
  }) });
133
136
  }
134
- function Render({ config, data }) {
137
+ function Render({
138
+ config,
139
+ data,
140
+ metadata
141
+ }) {
135
142
  var _a;
136
143
  if ((_a = config.root) == null ? void 0 : _a.render) {
137
144
  const rootProps = data.root.props || data.root;
@@ -140,18 +147,42 @@ function Render({ config, data }) {
140
147
  config.root.render,
141
148
  __spreadProps(__spreadValues({}, rootProps), {
142
149
  puck: {
143
- renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropZoneRender, { zone, data, config }),
150
+ renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
+ DropZoneRender,
152
+ {
153
+ zone,
154
+ data,
155
+ config,
156
+ metadata
157
+ }
158
+ ),
144
159
  isEditing: false,
145
160
  dragRef: null
146
161
  },
147
162
  title,
148
163
  editMode: false,
149
164
  id: "puck-root",
150
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropZoneRender, { config, data, zone: rootDroppableId })
165
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
166
+ DropZoneRender,
167
+ {
168
+ config,
169
+ data,
170
+ zone: rootDroppableId,
171
+ metadata
172
+ }
173
+ )
151
174
  })
152
175
  );
153
176
  }
154
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropZoneRender, { config, data, zone: rootDroppableId });
177
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
+ DropZoneRender,
179
+ {
180
+ config,
181
+ data,
182
+ zone: rootDroppableId,
183
+ metadata
184
+ }
185
+ );
155
186
  }
156
187
 
157
188
  // lib/get-changed.ts
@@ -167,19 +198,20 @@ var getChanged = (newItem, oldItem) => {
167
198
 
168
199
  // lib/resolve-component-data.ts
169
200
  var cache = { lastChange: {} };
170
- var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
201
+ var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
171
202
  return yield Promise.all(
172
203
  content.map((item) => __async(void 0, null, function* () {
173
204
  return yield resolveComponentData(
174
205
  item,
175
206
  config,
207
+ metadata,
176
208
  onResolveStart,
177
209
  onResolveEnd
178
210
  );
179
211
  }))
180
212
  );
181
213
  });
182
- var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
214
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
183
215
  const configForItem = config.components[item.type];
184
216
  if (configForItem.resolveData) {
185
217
  const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
@@ -190,7 +222,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
190
222
  if (onResolveStart) {
191
223
  onResolveStart(item);
192
224
  }
193
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
225
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
226
+ changed,
227
+ lastData: oldItem,
228
+ metadata
229
+ });
194
230
  const resolvedItem = __spreadProps(__spreadValues({}, item), {
195
231
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
196
232
  });
@@ -211,7 +247,7 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
211
247
 
212
248
  // lib/resolve-root-data.ts
213
249
  var cache2 = {};
214
- function resolveRootData(data, config) {
250
+ function resolveRootData(data, config, metadata) {
215
251
  return __async(this, null, function* () {
216
252
  var _a, _b, _c, _d, _e;
217
253
  if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
@@ -222,7 +258,8 @@ function resolveRootData(data, config) {
222
258
  const rootWithProps = data.root;
223
259
  const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
224
260
  changed,
225
- lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
261
+ lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
262
+ metadata: metadata || {}
226
263
  });
227
264
  cache2.lastChange = {
228
265
  original: data.root,
@@ -243,10 +280,14 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
243
280
  });
244
281
 
245
282
  // lib/resolve-all-data.ts
246
- function resolveAllData(data, config, onResolveStart, onResolveEnd) {
247
- return __async(this, null, function* () {
283
+ function resolveAllData(_0, _1) {
284
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
248
285
  const defaultedData = defaultData(data);
249
- const dynamicRoot = yield resolveRootData(defaultedData, config);
286
+ const dynamicRoot = yield resolveRootData(
287
+ defaultedData,
288
+ config,
289
+ metadata
290
+ );
250
291
  const { zones = {} } = data;
251
292
  const zoneKeys = Object.keys(zones);
252
293
  const resolvedZones = {};
@@ -255,6 +296,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
255
296
  resolvedZones[zoneKey] = yield resolveAllComponentData(
256
297
  zones[zoneKey],
257
298
  config,
299
+ metadata,
258
300
  onResolveStart,
259
301
  onResolveEnd
260
302
  );
@@ -264,6 +306,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
264
306
  content: yield resolveAllComponentData(
265
307
  defaultedData.content,
266
308
  config,
309
+ metadata,
267
310
  onResolveStart,
268
311
  onResolveEnd
269
312
  ),
package/dist/rsc.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  resolveAllData,
6
6
  rootDroppableId,
7
7
  setupZone
8
- } from "./chunk-CHWFBYEM.mjs";
8
+ } from "./chunk-FNRHXUGA.mjs";
9
9
 
10
10
  // rsc.tsx
11
11
  init_react_import();
@@ -17,7 +17,8 @@ function DropZoneRender({
17
17
  zone,
18
18
  data,
19
19
  areaId = "root",
20
- config
20
+ config,
21
+ metadata = {}
21
22
  }) {
22
23
  let zoneCompound = rootDroppableId;
23
24
  let content = (data == null ? void 0 : data.content) || [];
@@ -41,9 +42,11 @@ function DropZoneRender({
41
42
  zone: zone2,
42
43
  data,
43
44
  areaId: item.props.id,
44
- config
45
+ config,
46
+ metadata
45
47
  }
46
- )
48
+ ),
49
+ metadata
47
50
  }
48
51
  }),
49
52
  item.props.id
@@ -52,7 +55,11 @@ function DropZoneRender({
52
55
  return null;
53
56
  }) });
54
57
  }
55
- function Render({ config, data }) {
58
+ function Render({
59
+ config,
60
+ data,
61
+ metadata
62
+ }) {
56
63
  var _a;
57
64
  if ((_a = config.root) == null ? void 0 : _a.render) {
58
65
  const rootProps = data.root.props || data.root;
@@ -61,18 +68,42 @@ function Render({ config, data }) {
61
68
  config.root.render,
62
69
  __spreadProps(__spreadValues({}, rootProps), {
63
70
  puck: {
64
- renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(DropZoneRender, { zone, data, config }),
71
+ renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
72
+ DropZoneRender,
73
+ {
74
+ zone,
75
+ data,
76
+ config,
77
+ metadata
78
+ }
79
+ ),
65
80
  isEditing: false,
66
81
  dragRef: null
67
82
  },
68
83
  title,
69
84
  editMode: false,
70
85
  id: "puck-root",
71
- children: /* @__PURE__ */ jsx(DropZoneRender, { config, data, zone: rootDroppableId })
86
+ children: /* @__PURE__ */ jsx(
87
+ DropZoneRender,
88
+ {
89
+ config,
90
+ data,
91
+ zone: rootDroppableId,
92
+ metadata
93
+ }
94
+ )
72
95
  })
73
96
  );
74
97
  }
75
- return /* @__PURE__ */ jsx(DropZoneRender, { config, data, zone: rootDroppableId });
98
+ return /* @__PURE__ */ jsx(
99
+ DropZoneRender,
100
+ {
101
+ config,
102
+ data,
103
+ zone: rootDroppableId,
104
+ metadata
105
+ }
106
+ );
76
107
  }
77
108
  export {
78
109
  Render,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.18.3-canary.9e8e47b",
3
+ "version": "0.19.0-canary.b9add22",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",