@measured/puck 0.21.0-canary.b6ed9789 → 0.21.0-canary.bd7b613d
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/{chunk-VVS2EUKT.mjs → chunk-DBHXESEC.mjs} +277 -146
- package/dist/{chunk-XYKLHT4R.mjs → chunk-FPQ7BWRD.mjs} +29 -24
- package/dist/index.css +4 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +327 -191
- package/dist/index.mjs +2 -2
- package/dist/no-external.css +4 -3
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +327 -191
- package/dist/no-external.mjs +2 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +29 -24
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-C0rGZzWO.d.mts → walk-tree-Cvtjzg9C.d.mts} +3 -2
- package/dist/{walk-tree-C0rGZzWO.d.ts → walk-tree-Cvtjzg9C.d.ts} +3 -2
- package/package.json +2 -2
package/dist/no-external.mjs
CHANGED
|
@@ -21,14 +21,14 @@ import {
|
|
|
21
21
|
setDeep,
|
|
22
22
|
useGetPuck,
|
|
23
23
|
usePuck
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-DBHXESEC.mjs";
|
|
25
25
|
import {
|
|
26
26
|
init_react_import,
|
|
27
27
|
migrate,
|
|
28
28
|
resolveAllData,
|
|
29
29
|
transformProps,
|
|
30
30
|
walkTree
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-FPQ7BWRD.mjs";
|
|
32
32
|
|
|
33
33
|
// bundle/no-external.ts
|
|
34
34
|
init_react_import();
|
package/dist/rsc.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-Cvtjzg9C.mjs';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Cvtjzg9C.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-Cvtjzg9C.js';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Cvtjzg9C.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.js
CHANGED
|
@@ -130,34 +130,39 @@ var walkField = ({
|
|
|
130
130
|
config,
|
|
131
131
|
recurseSlots = false
|
|
132
132
|
}) => {
|
|
133
|
-
var _a, _b, _c;
|
|
133
|
+
var _a, _b, _c, _d;
|
|
134
134
|
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
135
135
|
const map = mappers[fieldType];
|
|
136
136
|
if (map && fieldType === "slot") {
|
|
137
137
|
const content = value || [];
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
let mappedContent = content;
|
|
139
|
+
if (recurseSlots) {
|
|
140
|
+
for (let i = 0; i < content.length; i++) {
|
|
141
|
+
const el = content[i];
|
|
142
|
+
const componentConfig = config.components[el.type];
|
|
143
|
+
if (!componentConfig) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const fields2 = (_b = componentConfig.fields) != null ? _b : {};
|
|
147
|
+
mappedContent.push(
|
|
148
|
+
walkField({
|
|
149
|
+
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
150
|
+
fields: fields2,
|
|
151
|
+
mappers,
|
|
152
|
+
id: el.props.id,
|
|
153
|
+
config,
|
|
154
|
+
recurseSlots
|
|
155
|
+
})
|
|
156
|
+
);
|
|
143
157
|
}
|
|
144
|
-
|
|
145
|
-
return walkField({
|
|
146
|
-
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
147
|
-
fields: fields2,
|
|
148
|
-
mappers,
|
|
149
|
-
id: el.props.id,
|
|
150
|
-
config,
|
|
151
|
-
recurseSlots
|
|
152
|
-
});
|
|
153
|
-
}) : content;
|
|
158
|
+
}
|
|
154
159
|
if (containsPromise(mappedContent)) {
|
|
155
160
|
return Promise.all(mappedContent);
|
|
156
161
|
}
|
|
157
162
|
return map({
|
|
158
163
|
value: mappedContent,
|
|
159
164
|
parentId: id,
|
|
160
|
-
propName:
|
|
165
|
+
propName: propPath,
|
|
161
166
|
field: fields[propKey],
|
|
162
167
|
propPath
|
|
163
168
|
});
|
|
@@ -172,7 +177,7 @@ var walkField = ({
|
|
|
172
177
|
}
|
|
173
178
|
if (value && typeof value === "object") {
|
|
174
179
|
if (Array.isArray(value)) {
|
|
175
|
-
const arrayFields = ((
|
|
180
|
+
const arrayFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "array" ? fields[propKey].arrayFields : null;
|
|
176
181
|
if (!arrayFields) return value;
|
|
177
182
|
const newValue = value.map(
|
|
178
183
|
(el, idx) => walkField({
|
|
@@ -193,7 +198,7 @@ var walkField = ({
|
|
|
193
198
|
} else if ("$$typeof" in value) {
|
|
194
199
|
return value;
|
|
195
200
|
} else {
|
|
196
|
-
const objectFields = ((
|
|
201
|
+
const objectFields = ((_d = fields[propKey]) == null ? void 0 : _d.type) === "object" ? fields[propKey].objectFields : fields;
|
|
197
202
|
return walkObject({
|
|
198
203
|
value,
|
|
199
204
|
fields: objectFields,
|
|
@@ -460,19 +465,19 @@ function Render({
|
|
|
460
465
|
}
|
|
461
466
|
|
|
462
467
|
// lib/get-changed.ts
|
|
463
|
-
var
|
|
468
|
+
var import_fast_equals = require("fast-equals");
|
|
464
469
|
var getChanged = (newItem, oldItem) => {
|
|
465
470
|
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
466
471
|
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
467
472
|
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
468
473
|
return __spreadProps(__spreadValues({}, acc), {
|
|
469
|
-
[item]: !(0,
|
|
474
|
+
[item]: !(0, import_fast_equals.deepEqual)(oldItemProps[item], newItemProps[item])
|
|
470
475
|
});
|
|
471
476
|
}, {}) : {};
|
|
472
477
|
};
|
|
473
478
|
|
|
474
479
|
// lib/resolve-component-data.ts
|
|
475
|
-
var
|
|
480
|
+
var import_fast_equals2 = require("fast-equals");
|
|
476
481
|
var cache = { lastChange: {} };
|
|
477
482
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
478
483
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
@@ -481,7 +486,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
481
486
|
const id = "id" in item.props ? item.props.id : "root";
|
|
482
487
|
if (shouldRunResolver) {
|
|
483
488
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
484
|
-
if (item && (0,
|
|
489
|
+
if (trigger !== "force" && item && (0, import_fast_equals2.deepEqual)(item, oldItem)) {
|
|
485
490
|
return { node: resolved, didChange: false };
|
|
486
491
|
}
|
|
487
492
|
const changed = getChanged(item, oldItem);
|
|
@@ -531,7 +536,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
531
536
|
};
|
|
532
537
|
return {
|
|
533
538
|
node: itemWithResolvedChildren,
|
|
534
|
-
didChange: !(0,
|
|
539
|
+
didChange: !(0, import_fast_equals2.deepEqual)(item, itemWithResolvedChildren)
|
|
535
540
|
};
|
|
536
541
|
});
|
|
537
542
|
|
package/dist/rsc.mjs
CHANGED
|
@@ -212,6 +212,7 @@ UserField extends BaseField = {}> = {
|
|
|
212
212
|
fields: Fields<FieldProps>;
|
|
213
213
|
lastFields: Fields<FieldProps>;
|
|
214
214
|
lastData: DataShape | null;
|
|
215
|
+
metadata: Metadata;
|
|
215
216
|
appState: AppState;
|
|
216
217
|
parent: ComponentData | null;
|
|
217
218
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -255,7 +256,7 @@ type ConfigInternal<Props extends DefaultComponents = DefaultComponents, RootPro
|
|
|
255
256
|
root?: RootConfigInternal<RootProps, UserField>;
|
|
256
257
|
};
|
|
257
258
|
type DefaultComponents = Record<string, any>;
|
|
258
|
-
type Config<PropsOrParams extends LeftOrExactRight<PropsOrParams, DefaultComponents, ConfigParams> = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps =
|
|
259
|
+
type Config<PropsOrParams extends LeftOrExactRight<PropsOrParams, DefaultComponents, ConfigParams> = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps = any, CategoryName extends string = string> = PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, never> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number]> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, infer ParamFields> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], ParamFields[keyof ParamFields] & BaseField> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, any> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], {}> : ConfigInternal<PropsOrParams, RootProps, CategoryName>;
|
|
259
260
|
type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends ConfigInternal<infer PropsOrParams, infer RootProps, infer CategoryName, infer UserField> ? {
|
|
260
261
|
props: PropsOrParams;
|
|
261
262
|
rootProps: RootProps & DefaultRootFieldProps;
|
|
@@ -377,7 +378,7 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
377
378
|
type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
|
|
378
379
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
379
380
|
} : T;
|
|
380
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps =
|
|
381
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
381
382
|
components?: Components;
|
|
382
383
|
root?: RootProps;
|
|
383
384
|
categories?: CategoryNames;
|
|
@@ -212,6 +212,7 @@ UserField extends BaseField = {}> = {
|
|
|
212
212
|
fields: Fields<FieldProps>;
|
|
213
213
|
lastFields: Fields<FieldProps>;
|
|
214
214
|
lastData: DataShape | null;
|
|
215
|
+
metadata: Metadata;
|
|
215
216
|
appState: AppState;
|
|
216
217
|
parent: ComponentData | null;
|
|
217
218
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -255,7 +256,7 @@ type ConfigInternal<Props extends DefaultComponents = DefaultComponents, RootPro
|
|
|
255
256
|
root?: RootConfigInternal<RootProps, UserField>;
|
|
256
257
|
};
|
|
257
258
|
type DefaultComponents = Record<string, any>;
|
|
258
|
-
type Config<PropsOrParams extends LeftOrExactRight<PropsOrParams, DefaultComponents, ConfigParams> = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps =
|
|
259
|
+
type Config<PropsOrParams extends LeftOrExactRight<PropsOrParams, DefaultComponents, ConfigParams> = DefaultComponents | ConfigParams, RootProps extends DefaultComponentProps = any, CategoryName extends string = string> = PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, never> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number]> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, infer ParamFields> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], ParamFields[keyof ParamFields] & BaseField> : PropsOrParams extends ConfigParams<infer ParamComponents, infer ParamRoot, infer ParamCategoryName, any> ? ConfigInternal<ParamComponents, ParamRoot, ParamCategoryName[number], {}> : ConfigInternal<PropsOrParams, RootProps, CategoryName>;
|
|
259
260
|
type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends ConfigInternal<infer PropsOrParams, infer RootProps, infer CategoryName, infer UserField> ? {
|
|
260
261
|
props: PropsOrParams;
|
|
261
262
|
rootProps: RootProps & DefaultRootFieldProps;
|
|
@@ -377,7 +378,7 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
377
378
|
type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
|
|
378
379
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
379
380
|
} : T;
|
|
380
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps =
|
|
381
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
381
382
|
components?: Components;
|
|
382
383
|
root?: RootProps;
|
|
383
384
|
categories?: CategoryNames;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck",
|
|
3
|
-
"version": "0.21.0-canary.
|
|
3
|
+
"version": "0.21.0-canary.bd7b613d",
|
|
4
4
|
"description": "The open-source visual editor for React",
|
|
5
5
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
6
6
|
"repository": "measuredco/puck",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@dnd-kit/helpers": "0.1.18",
|
|
97
97
|
"@dnd-kit/react": "0.1.18",
|
|
98
98
|
"deep-diff": "^1.0.2",
|
|
99
|
-
"fast-
|
|
99
|
+
"fast-equals": "5.2.2",
|
|
100
100
|
"flat": "^5.0.2",
|
|
101
101
|
"object-hash": "^3.0.0",
|
|
102
102
|
"react-hotkeys-hook": "^4.6.1",
|