@measured/puck-plugin-heading-analyzer 0.16.0-canary.cad95b8 → 0.16.0-canary.d08a794
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +4 -0
- package/dist/index.js +82 -29
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -74258,18 +74258,71 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
74258
74258
|
}, [plugins, overrides]);
|
74259
74259
|
};
|
74260
74260
|
init_react_import2();
|
74261
|
+
init_react_import2();
|
74262
|
+
var getChanged = (newItem, oldItem) => {
|
74263
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
74264
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
74265
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
74266
|
+
return __spreadProps2(__spreadValues2({}, acc), {
|
74267
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
74268
|
+
});
|
74269
|
+
}, {}) : {};
|
74270
|
+
};
|
74271
|
+
init_react_import2();
|
74272
|
+
var resolvePermissions = ({
|
74273
|
+
selectedItem,
|
74274
|
+
config,
|
74275
|
+
changed,
|
74276
|
+
lastPermissions,
|
74277
|
+
initialPermissions,
|
74278
|
+
appState
|
74279
|
+
}) => {
|
74280
|
+
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
74281
|
+
if (selectedItem && (componentConfig == null ? void 0 : componentConfig.resolvePermissions)) {
|
74282
|
+
return componentConfig.resolvePermissions(selectedItem, {
|
74283
|
+
changed,
|
74284
|
+
lastPermissions,
|
74285
|
+
initialPermissions,
|
74286
|
+
appState
|
74287
|
+
});
|
74288
|
+
}
|
74289
|
+
return {};
|
74290
|
+
};
|
74291
|
+
var cache = { lastPermissions: {}, lastSelected: {} };
|
74261
74292
|
var getPermissions = ({
|
74262
74293
|
selectedItem,
|
74263
74294
|
type,
|
74264
74295
|
globalPermissions,
|
74265
|
-
config
|
74296
|
+
config,
|
74297
|
+
appState
|
74266
74298
|
}) => {
|
74267
74299
|
const componentType = type || selectedItem && selectedItem.type || "";
|
74300
|
+
const componentId = selectedItem && selectedItem.props.id || "";
|
74268
74301
|
let componentPermissions = getInitialPermissions({
|
74269
74302
|
componentType,
|
74270
74303
|
config,
|
74271
74304
|
globalPermissions
|
74272
74305
|
});
|
74306
|
+
const changed = getChanged(selectedItem, cache.lastSelected);
|
74307
|
+
if (Object.values(changed).some((el) => el === true)) {
|
74308
|
+
const resolvedPermissions = resolvePermissions({
|
74309
|
+
selectedItem,
|
74310
|
+
config,
|
74311
|
+
changed,
|
74312
|
+
lastPermissions: cache.lastPermissions[componentId] || componentPermissions,
|
74313
|
+
initialPermissions: componentPermissions,
|
74314
|
+
appState
|
74315
|
+
});
|
74316
|
+
if (resolvedPermissions !== void 0) {
|
74317
|
+
componentPermissions = __spreadValues2(__spreadValues2({}, componentPermissions), resolvedPermissions);
|
74318
|
+
}
|
74319
|
+
cache.lastSelected = selectedItem;
|
74320
|
+
cache.lastPermissions[componentId] = componentPermissions;
|
74321
|
+
return componentPermissions;
|
74322
|
+
}
|
74323
|
+
if (Object.keys(componentId && cache.lastPermissions[componentId]).length !== 0) {
|
74324
|
+
componentPermissions = cache.lastPermissions[componentId];
|
74325
|
+
}
|
74273
74326
|
return componentPermissions;
|
74274
74327
|
};
|
74275
74328
|
var getInitialPermissions = ({
|
@@ -74319,7 +74372,8 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
74319
74372
|
plugins,
|
74320
74373
|
selectedItem,
|
74321
74374
|
config,
|
74322
|
-
globalPermissions
|
74375
|
+
globalPermissions,
|
74376
|
+
state
|
74323
74377
|
} = useAppContext2();
|
74324
74378
|
const isModifierHeld = useModifierHeld("Alt");
|
74325
74379
|
const El = status !== "LOADING" ? import_dnd4.Draggable : DefaultDraggable;
|
@@ -74341,7 +74395,8 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
74341
74395
|
const permissions = selectedItem && getPermissions({
|
74342
74396
|
selectedItem,
|
74343
74397
|
globalPermissions: globalPermissions || {},
|
74344
|
-
config
|
74398
|
+
config,
|
74399
|
+
appState: state
|
74345
74400
|
});
|
74346
74401
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
74347
74402
|
El,
|
@@ -74686,7 +74741,8 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
74686
74741
|
appContext22.state.data
|
74687
74742
|
),
|
74688
74743
|
config: appContext22.config,
|
74689
|
-
globalPermissions: appContext22.globalPermissions || {}
|
74744
|
+
globalPermissions: appContext22.globalPermissions || {},
|
74745
|
+
appState: appContext22.state
|
74690
74746
|
}).drag;
|
74691
74747
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
74692
74748
|
"div",
|
@@ -75356,17 +75412,7 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
75356
75412
|
init_react_import2();
|
75357
75413
|
var import_react20 = require("react");
|
75358
75414
|
init_react_import2();
|
75359
|
-
|
75360
|
-
var getChanged = (newItem, oldItem) => {
|
75361
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
75362
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
75363
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
75364
|
-
return __spreadProps2(__spreadValues2({}, acc), {
|
75365
|
-
[item]: oldItemProps[item] !== newItemProps[item]
|
75366
|
-
});
|
75367
|
-
}, {}) : {};
|
75368
|
-
};
|
75369
|
-
var cache = { lastChange: {} };
|
75415
|
+
var cache2 = { lastChange: {} };
|
75370
75416
|
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async2(void 0, null, function* () {
|
75371
75417
|
return yield Promise.all(
|
75372
75418
|
content.map((item) => __async2(void 0, null, function* () {
|
@@ -75382,7 +75428,7 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
75382
75428
|
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async2(void 0, null, function* () {
|
75383
75429
|
const configForItem = config.components[item.type];
|
75384
75430
|
if (configForItem.resolveData) {
|
75385
|
-
const { item: oldItem = {}, resolved = {} } =
|
75431
|
+
const { item: oldItem = {}, resolved = {} } = cache2.lastChange[item.props.id] || {};
|
75386
75432
|
if (item && item === oldItem) {
|
75387
75433
|
return resolved;
|
75388
75434
|
}
|
@@ -75399,7 +75445,7 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
75399
75445
|
if (Object.keys(newReadOnly).length) {
|
75400
75446
|
resolvedItem.readOnly = newReadOnly;
|
75401
75447
|
}
|
75402
|
-
|
75448
|
+
cache2.lastChange[item.props.id] = {
|
75403
75449
|
item,
|
75404
75450
|
resolved: resolvedItem
|
75405
75451
|
};
|
@@ -75427,20 +75473,20 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
75427
75473
|
});
|
75428
75474
|
};
|
75429
75475
|
init_react_import2();
|
75430
|
-
var
|
75476
|
+
var cache3 = {};
|
75431
75477
|
var resolveRootData = (data, config) => __async2(void 0, null, function* () {
|
75432
75478
|
var _a3, _b2, _c, _d, _e;
|
75433
75479
|
if (((_a3 = config.root) == null ? void 0 : _a3.resolveData) && data.root.props) {
|
75434
|
-
if (((_b2 =
|
75435
|
-
return
|
75480
|
+
if (((_b2 = cache3.lastChange) == null ? void 0 : _b2.original) === data.root) {
|
75481
|
+
return cache3.lastChange.resolved;
|
75436
75482
|
}
|
75437
|
-
const changed = getChanged(data.root, (_c =
|
75483
|
+
const changed = getChanged(data.root, (_c = cache3.lastChange) == null ? void 0 : _c.original);
|
75438
75484
|
const rootWithProps = data.root;
|
75439
75485
|
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
75440
75486
|
changed,
|
75441
|
-
lastData: ((_d =
|
75487
|
+
lastData: ((_d = cache3.lastChange) == null ? void 0 : _d.original) || {}
|
75442
75488
|
});
|
75443
|
-
|
75489
|
+
cache3.lastChange = {
|
75444
75490
|
original: data.root,
|
75445
75491
|
resolved: resolvedRoot
|
75446
75492
|
};
|
@@ -75759,7 +75805,8 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
75759
75805
|
const { edit } = getPermissions({
|
75760
75806
|
selectedItem,
|
75761
75807
|
config,
|
75762
|
-
globalPermissions: globalPermissions || {}
|
75808
|
+
globalPermissions: globalPermissions || {},
|
75809
|
+
appState: state
|
75763
75810
|
});
|
75764
75811
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
75765
75812
|
AutoFieldPrivate,
|
@@ -75807,11 +75854,12 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
75807
75854
|
label,
|
75808
75855
|
index
|
75809
75856
|
}) => {
|
75810
|
-
const { overrides, config, globalPermissions } = useAppContext2();
|
75857
|
+
const { overrides, config, globalPermissions, state } = useAppContext2();
|
75811
75858
|
const canInsert = getPermissions({
|
75812
75859
|
type: name,
|
75813
75860
|
config,
|
75814
|
-
globalPermissions: globalPermissions || {}
|
75861
|
+
globalPermissions: globalPermissions || {},
|
75862
|
+
appState: state
|
75815
75863
|
}).insert;
|
75816
75864
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
75817
75865
|
Drawer.Item,
|
@@ -76161,10 +76209,11 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
76161
76209
|
var AutoFrame_default = AutoFrameComponent;
|
76162
76210
|
init_react_import2();
|
76163
76211
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
76212
|
+
var import_react_frame_component2 = require_lib();
|
76164
76213
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
76165
76214
|
var getClassName23 = get_class_name_factory_default2("PuckPreview", styles_module_default18);
|
76166
76215
|
var Preview = ({ id = "puck-preview" }) => {
|
76167
|
-
const { config, dispatch, state, setStatus, iframe } = useAppContext2();
|
76216
|
+
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext2();
|
76168
76217
|
const Page = (0, import_react25.useCallback)(
|
76169
76218
|
(pageProps) => {
|
76170
76219
|
var _a3, _b2;
|
@@ -76178,6 +76227,7 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
76178
76227
|
},
|
76179
76228
|
[config.root]
|
76180
76229
|
);
|
76230
|
+
const Frame2 = (0, import_react25.useMemo)(() => overrides.iframe || "div", [overrides]);
|
76181
76231
|
const rootProps = state.data.root.props || state.data.root;
|
76182
76232
|
const ref2 = (0, import_react25.useRef)(null);
|
76183
76233
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
@@ -76198,7 +76248,9 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
76198
76248
|
onStylesLoaded: () => {
|
76199
76249
|
setStatus("READY");
|
76200
76250
|
},
|
76201
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
76251
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react_frame_component2.FrameContextConsumer, { children: ({ document: document2 }) => {
|
76252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame2, { document: document2, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Page, __spreadProps2(__spreadValues2({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId2 }) })) });
|
76253
|
+
} })
|
76202
76254
|
}
|
76203
76255
|
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Page, __spreadProps2(__spreadValues2({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId2 }) })) })
|
76204
76256
|
}
|
@@ -77508,7 +77560,8 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
77508
77560
|
selectedItem: item || currentItem,
|
77509
77561
|
type,
|
77510
77562
|
globalPermissions: globalPermissions || {},
|
77511
|
-
config
|
77563
|
+
config,
|
77564
|
+
appState
|
77512
77565
|
});
|
77513
77566
|
},
|
77514
77567
|
history: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck-plugin-heading-analyzer",
|
3
|
-
"version": "0.16.0-canary.
|
3
|
+
"version": "0.16.0-canary.d08a794",
|
4
4
|
"author": "Measured Corporation Ltd <hello@measured.co>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"dist"
|
19
19
|
],
|
20
20
|
"devDependencies": {
|
21
|
-
"@measured/puck": "^0.16.0-canary.
|
21
|
+
"@measured/puck": "^0.16.0-canary.d08a794",
|
22
22
|
"@types/react": "^18.2.0",
|
23
23
|
"@types/react-dom": "^18.2.0",
|
24
24
|
"eslint": "^7.32.0",
|