@measured/puck 0.21.0-canary.bd7b613d → 0.21.0-canary.c0db75c1
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/{walk-tree-Cvtjzg9C.d.mts → actions-CaYAKtsG.d.mts} +63 -74
- package/dist/{walk-tree-Cvtjzg9C.d.ts → actions-CaYAKtsG.d.ts} +63 -74
- package/dist/{chunk-DBHXESEC.mjs → chunk-E4BOPJJV.mjs} +271 -998
- package/dist/chunk-J32NOAUF.mjs +524 -0
- package/dist/chunk-PJYARUPI.mjs +477 -0
- package/dist/chunk-S3RM5GHZ.mjs +503 -0
- package/dist/index-C6QwyW4B.d.ts +109 -0
- package/dist/index-IMRjDHZk.d.mts +109 -0
- package/dist/index.css +39 -37
- package/dist/index.d.mts +8 -109
- package/dist/index.d.ts +8 -109
- package/dist/index.js +279 -518
- package/dist/index.mjs +7 -4
- package/dist/internal.d.mts +12 -0
- package/dist/internal.d.ts +12 -0
- package/dist/internal.js +906 -0
- package/dist/internal.mjs +12 -0
- package/dist/no-external.css +39 -37
- package/dist/no-external.d.mts +3 -1
- package/dist/no-external.d.ts +3 -1
- package/dist/no-external.js +276 -515
- package/dist/no-external.mjs +7 -4
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +29 -33
- package/dist/rsc.mjs +7 -5
- package/dist/walk-tree-B-Q2gpMX.d.mts +29 -0
- package/dist/walk-tree-ksvZ7C4q.d.ts +29 -0
- package/package.json +7 -2
- package/dist/chunk-FPQ7BWRD.mjs +0 -971
package/dist/no-external.mjs
CHANGED
|
@@ -21,14 +21,17 @@ import {
|
|
|
21
21
|
setDeep,
|
|
22
22
|
useGetPuck,
|
|
23
23
|
usePuck
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-E4BOPJJV.mjs";
|
|
25
|
+
import "./chunk-J32NOAUF.mjs";
|
|
25
26
|
import {
|
|
26
|
-
init_react_import,
|
|
27
27
|
migrate,
|
|
28
28
|
resolveAllData,
|
|
29
|
-
transformProps
|
|
29
|
+
transformProps
|
|
30
|
+
} from "./chunk-PJYARUPI.mjs";
|
|
31
|
+
import {
|
|
32
|
+
init_react_import,
|
|
30
33
|
walkTree
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-S3RM5GHZ.mjs";
|
|
32
35
|
|
|
33
36
|
// bundle/no-external.ts
|
|
34
37
|
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 './
|
|
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 './actions-CaYAKtsG.mjs';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-B-Q2gpMX.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 './
|
|
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 './actions-CaYAKtsG.js';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-ksvZ7C4q.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,32 +130,27 @@ var walkField = ({
|
|
|
130
130
|
config,
|
|
131
131
|
recurseSlots = false
|
|
132
132
|
}) => {
|
|
133
|
-
var _a, _b, _c
|
|
133
|
+
var _a, _b, _c;
|
|
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
|
-
|
|
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
|
-
);
|
|
138
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
|
139
|
+
var _a2;
|
|
140
|
+
const componentConfig = config.components[el.type];
|
|
141
|
+
if (!componentConfig) {
|
|
142
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
|
157
143
|
}
|
|
158
|
-
|
|
144
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
|
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;
|
|
159
154
|
if (containsPromise(mappedContent)) {
|
|
160
155
|
return Promise.all(mappedContent);
|
|
161
156
|
}
|
|
@@ -177,7 +172,7 @@ var walkField = ({
|
|
|
177
172
|
}
|
|
178
173
|
if (value && typeof value === "object") {
|
|
179
174
|
if (Array.isArray(value)) {
|
|
180
|
-
const arrayFields = ((
|
|
175
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
|
181
176
|
if (!arrayFields) return value;
|
|
182
177
|
const newValue = value.map(
|
|
183
178
|
(el, idx) => walkField({
|
|
@@ -198,7 +193,7 @@ var walkField = ({
|
|
|
198
193
|
} else if ("$$typeof" in value) {
|
|
199
194
|
return value;
|
|
200
195
|
} else {
|
|
201
|
-
const objectFields = ((
|
|
196
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
|
202
197
|
return walkObject({
|
|
203
198
|
value,
|
|
204
199
|
fields: objectFields,
|
|
@@ -351,8 +346,9 @@ var Item = ({
|
|
|
351
346
|
);
|
|
352
347
|
};
|
|
353
348
|
var SlotRender = (0, import_react3.forwardRef)(
|
|
354
|
-
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
355
|
-
|
|
349
|
+
function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
|
|
350
|
+
const El = as != null ? as : "div";
|
|
351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(El, { className, style, ref, children: content.map((item) => {
|
|
356
352
|
if (!config.components[item.type]) {
|
|
357
353
|
return null;
|
|
358
354
|
}
|
|
@@ -479,7 +475,7 @@ var getChanged = (newItem, oldItem) => {
|
|
|
479
475
|
// lib/resolve-component-data.ts
|
|
480
476
|
var import_fast_equals2 = require("fast-equals");
|
|
481
477
|
var cache = { lastChange: {} };
|
|
482
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(
|
|
478
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
483
479
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
484
480
|
const resolvedItem = __spreadValues({}, item);
|
|
485
481
|
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
@@ -507,11 +503,11 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
507
503
|
let itemWithResolvedChildren = yield mapFields(
|
|
508
504
|
resolvedItem,
|
|
509
505
|
{
|
|
510
|
-
slot: (_02) => __async(
|
|
506
|
+
slot: (_02) => __async(null, [_02], function* ({ value }) {
|
|
511
507
|
const content = value;
|
|
512
508
|
return yield Promise.all(
|
|
513
509
|
content.map(
|
|
514
|
-
(childItem) => __async(
|
|
510
|
+
(childItem) => __async(null, null, function* () {
|
|
515
511
|
return (yield resolveComponentData(
|
|
516
512
|
childItem,
|
|
517
513
|
config,
|
|
@@ -559,7 +555,7 @@ function resolveAllData(_0, _1) {
|
|
|
559
555
|
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
560
556
|
var _a;
|
|
561
557
|
const defaultedData = defaultData(data);
|
|
562
|
-
const resolveNode = (_node) => __async(
|
|
558
|
+
const resolveNode = (_node) => __async(null, null, function* () {
|
|
563
559
|
const node = toComponent(_node);
|
|
564
560
|
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
565
561
|
const resolved = (yield resolveComponentData(
|
|
@@ -580,13 +576,13 @@ function resolveAllData(_0, _1) {
|
|
|
580
576
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
581
577
|
return resolvedDeep;
|
|
582
578
|
});
|
|
583
|
-
const processContent = (content) => __async(
|
|
579
|
+
const processContent = (content) => __async(null, null, function* () {
|
|
584
580
|
return Promise.all(content.map(resolveNode));
|
|
585
581
|
});
|
|
586
|
-
const processZones = () => __async(
|
|
582
|
+
const processZones = () => __async(null, null, function* () {
|
|
587
583
|
var _a2;
|
|
588
584
|
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
589
|
-
Object.entries(zones).forEach((_02) => __async(
|
|
585
|
+
Object.entries(zones).forEach((_02) => __async(null, [_02], function* ([zoneKey, content]) {
|
|
590
586
|
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
591
587
|
}));
|
|
592
588
|
return zones;
|
|
@@ -596,7 +592,7 @@ function resolveAllData(_0, _1) {
|
|
|
596
592
|
content: yield processContent(defaultedData.content),
|
|
597
593
|
zones: yield processZones()
|
|
598
594
|
};
|
|
599
|
-
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(
|
|
595
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(null, null, function* () {
|
|
600
596
|
const content = defaultedData.zones[zoneKey];
|
|
601
597
|
dynamic.zones[zoneKey] = yield processContent(content);
|
|
602
598
|
}), {});
|
package/dist/rsc.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SlotRenderPure,
|
|
3
|
+
migrate,
|
|
4
|
+
resolveAllData,
|
|
5
|
+
transformProps,
|
|
6
|
+
useSlots
|
|
7
|
+
} from "./chunk-PJYARUPI.mjs";
|
|
8
|
+
import {
|
|
3
9
|
__spreadProps,
|
|
4
10
|
__spreadValues,
|
|
5
11
|
init_react_import,
|
|
6
|
-
migrate,
|
|
7
|
-
resolveAllData,
|
|
8
12
|
rootAreaId,
|
|
9
13
|
rootDroppableId,
|
|
10
14
|
rootZone,
|
|
11
15
|
setupZone,
|
|
12
|
-
transformProps,
|
|
13
|
-
useSlots,
|
|
14
16
|
walkTree
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-S3RM5GHZ.mjs";
|
|
16
18
|
|
|
17
19
|
// bundle/rsc.tsx
|
|
18
20
|
init_react_import();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as Config, D as Data, W as WithId, U as UserGenerics, b as Content, c as ComponentData, d as DefaultComponents, e as DefaultComponentProps, f as DefaultRootFieldProps, M as Metadata, R as RootData } from './actions-CaYAKtsG.mjs';
|
|
2
|
+
|
|
3
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
4
|
+
migrateDynamicZonesForComponent?: {
|
|
5
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
9
|
+
|
|
10
|
+
type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
11
|
+
[ComponentName in keyof Components]: (props: Components[ComponentName] & {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}) => Components[ComponentName];
|
|
14
|
+
} & {
|
|
15
|
+
root: (props: RootProps & {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}) => RootProps;
|
|
18
|
+
}>;
|
|
19
|
+
declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
|
|
20
|
+
|
|
21
|
+
declare function resolveAllData<Components extends DefaultComponents = DefaultComponents, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Components, RootProps>>;
|
|
22
|
+
|
|
23
|
+
type WalkTreeOptions = {
|
|
24
|
+
parentId: string;
|
|
25
|
+
propName: string;
|
|
26
|
+
};
|
|
27
|
+
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
|
28
|
+
|
|
29
|
+
export { migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { C as Config, D as Data, W as WithId, U as UserGenerics, b as Content, c as ComponentData, d as DefaultComponents, e as DefaultComponentProps, f as DefaultRootFieldProps, M as Metadata, R as RootData } from './actions-CaYAKtsG.js';
|
|
2
|
+
|
|
3
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
4
|
+
migrateDynamicZonesForComponent?: {
|
|
5
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
9
|
+
|
|
10
|
+
type PropTransform<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
11
|
+
[ComponentName in keyof Components]: (props: Components[ComponentName] & {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}) => Components[ComponentName];
|
|
14
|
+
} & {
|
|
15
|
+
root: (props: RootProps & {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}) => RootProps;
|
|
18
|
+
}>;
|
|
19
|
+
declare function transformProps<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Components, RootProps>, config?: Config): Data;
|
|
20
|
+
|
|
21
|
+
declare function resolveAllData<Components extends DefaultComponents = DefaultComponents, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Components, RootProps>>;
|
|
22
|
+
|
|
23
|
+
type WalkTreeOptions = {
|
|
24
|
+
parentId: string;
|
|
25
|
+
propName: string;
|
|
26
|
+
};
|
|
27
|
+
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
|
28
|
+
|
|
29
|
+
export { migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
|
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.c0db75c1",
|
|
4
4
|
"description": "The open-source visual editor for React",
|
|
5
5
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
6
6
|
"repository": "measuredco/puck",
|
|
@@ -45,6 +45,11 @@
|
|
|
45
45
|
"import": "./dist/rsc.mjs",
|
|
46
46
|
"require": "./dist/rsc.js"
|
|
47
47
|
},
|
|
48
|
+
"./internal": {
|
|
49
|
+
"types": "./dist/internal.d.ts",
|
|
50
|
+
"import": "./dist/internal.mjs",
|
|
51
|
+
"require": "./dist/internal.js"
|
|
52
|
+
},
|
|
48
53
|
"./puck.css": "./dist/index.css",
|
|
49
54
|
"./no-external.css": "./dist/no-external.css",
|
|
50
55
|
"./dist/index.css": "./dist/index.css",
|
|
@@ -60,7 +65,7 @@
|
|
|
60
65
|
"license": "MIT",
|
|
61
66
|
"scripts": {
|
|
62
67
|
"lint": "eslint \"**/*.ts*\"",
|
|
63
|
-
"build": "rm -rf dist && tsup bundle/index.ts bundle/rsc.tsx bundle/no-external.ts",
|
|
68
|
+
"build": "rm -rf dist && tsup bundle/index.ts bundle/rsc.tsx bundle/no-external.ts bundle/internal.ts",
|
|
64
69
|
"test": "jest",
|
|
65
70
|
"prepare": "cp ../../README.md . && yarn build",
|
|
66
71
|
"postpublish": "rm README.md"
|