@measured/puck-plugin-heading-analyzer 0.21.0-canary.7dca3a5a → 0.21.0-canary.7ed9655b
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/index.d.mts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +47 -73
- package/dist/index.mjs +44 -70
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties,
|
|
1
|
+
import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
|
|
2
2
|
|
|
3
3
|
type ItemSelector = {
|
|
4
4
|
index: number;
|
|
@@ -53,7 +53,7 @@ interface ArrayField<Props extends {
|
|
|
53
53
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
54
|
};
|
|
55
55
|
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
56
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
57
|
max?: number;
|
|
58
58
|
min?: number;
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
80
|
placeholder?: string;
|
|
81
81
|
adaptor: Adaptor<any, any, Props>;
|
|
82
82
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
83
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
84
|
};
|
|
85
85
|
type CacheOpts = {
|
|
86
86
|
enabled?: boolean;
|
|
@@ -97,7 +97,7 @@ interface ExternalField<Props extends any = {
|
|
|
97
97
|
}) => Promise<any[] | null>;
|
|
98
98
|
mapProp?: (value: any) => Props;
|
|
99
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
101
|
showSearch?: boolean;
|
|
102
102
|
renderFooter?: (props: {
|
|
103
103
|
items: any[];
|
|
@@ -118,6 +118,7 @@ interface CustomField<Value extends any> extends BaseField {
|
|
|
118
118
|
type: "custom";
|
|
119
119
|
render: CustomFieldRender<Value>;
|
|
120
120
|
contentEditable?: boolean;
|
|
121
|
+
key?: string;
|
|
121
122
|
}
|
|
122
123
|
interface SlotField extends BaseField {
|
|
123
124
|
type: "slot";
|
|
@@ -145,9 +146,10 @@ type DropZoneProps = {
|
|
|
145
146
|
allow?: string[];
|
|
146
147
|
disallow?: string[];
|
|
147
148
|
style?: CSSProperties;
|
|
148
|
-
minEmptyHeight?: number;
|
|
149
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
149
150
|
className?: string;
|
|
150
151
|
collisionAxis?: DragAxis;
|
|
152
|
+
as?: ElementType;
|
|
151
153
|
};
|
|
152
154
|
|
|
153
155
|
type PuckContext = {
|
|
@@ -236,6 +238,7 @@ UserField extends BaseField = {}> = {
|
|
|
236
238
|
permissions: Partial<Permissions>;
|
|
237
239
|
appState: AppState;
|
|
238
240
|
lastData: DataShape | null;
|
|
241
|
+
parent: ComponentData | null;
|
|
239
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
240
243
|
metadata?: ComponentMetadata;
|
|
241
244
|
} & ComponentConfigExtensions;
|
|
@@ -320,6 +323,7 @@ interface FieldMetadata extends Metadata {
|
|
|
320
323
|
type ItemWithId = {
|
|
321
324
|
_arrayId: string;
|
|
322
325
|
_originalIndex: number;
|
|
326
|
+
_currentIndex: number;
|
|
323
327
|
};
|
|
324
328
|
type ArrayState = {
|
|
325
329
|
items: ItemWithId[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties,
|
|
1
|
+
import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
|
|
2
2
|
|
|
3
3
|
type ItemSelector = {
|
|
4
4
|
index: number;
|
|
@@ -53,7 +53,7 @@ interface ArrayField<Props extends {
|
|
|
53
53
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
54
|
};
|
|
55
55
|
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
56
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
57
|
max?: number;
|
|
58
58
|
min?: number;
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
80
|
placeholder?: string;
|
|
81
81
|
adaptor: Adaptor<any, any, Props>;
|
|
82
82
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
83
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
84
|
};
|
|
85
85
|
type CacheOpts = {
|
|
86
86
|
enabled?: boolean;
|
|
@@ -97,7 +97,7 @@ interface ExternalField<Props extends any = {
|
|
|
97
97
|
}) => Promise<any[] | null>;
|
|
98
98
|
mapProp?: (value: any) => Props;
|
|
99
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
101
|
showSearch?: boolean;
|
|
102
102
|
renderFooter?: (props: {
|
|
103
103
|
items: any[];
|
|
@@ -118,6 +118,7 @@ interface CustomField<Value extends any> extends BaseField {
|
|
|
118
118
|
type: "custom";
|
|
119
119
|
render: CustomFieldRender<Value>;
|
|
120
120
|
contentEditable?: boolean;
|
|
121
|
+
key?: string;
|
|
121
122
|
}
|
|
122
123
|
interface SlotField extends BaseField {
|
|
123
124
|
type: "slot";
|
|
@@ -145,9 +146,10 @@ type DropZoneProps = {
|
|
|
145
146
|
allow?: string[];
|
|
146
147
|
disallow?: string[];
|
|
147
148
|
style?: CSSProperties;
|
|
148
|
-
minEmptyHeight?: number;
|
|
149
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
149
150
|
className?: string;
|
|
150
151
|
collisionAxis?: DragAxis;
|
|
152
|
+
as?: ElementType;
|
|
151
153
|
};
|
|
152
154
|
|
|
153
155
|
type PuckContext = {
|
|
@@ -236,6 +238,7 @@ UserField extends BaseField = {}> = {
|
|
|
236
238
|
permissions: Partial<Permissions>;
|
|
237
239
|
appState: AppState;
|
|
238
240
|
lastData: DataShape | null;
|
|
241
|
+
parent: ComponentData | null;
|
|
239
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
240
243
|
metadata?: ComponentMetadata;
|
|
241
244
|
} & ComponentConfigExtensions;
|
|
@@ -320,6 +323,7 @@ interface FieldMetadata extends Metadata {
|
|
|
320
323
|
type ItemWithId = {
|
|
321
324
|
_arrayId: string;
|
|
322
325
|
_originalIndex: number;
|
|
326
|
+
_currentIndex: number;
|
|
323
327
|
};
|
|
324
328
|
type ArrayState = {
|
|
325
329
|
items: ItemWithId[];
|
package/dist/index.js
CHANGED
|
@@ -268,11 +268,11 @@ var require_flat = __commonJS({
|
|
|
268
268
|
});
|
|
269
269
|
|
|
270
270
|
// index.ts
|
|
271
|
-
var
|
|
272
|
-
__export(
|
|
271
|
+
var index_exports = {};
|
|
272
|
+
__export(index_exports, {
|
|
273
273
|
default: () => HeadingAnalyzer_default
|
|
274
274
|
});
|
|
275
|
-
module.exports = __toCommonJS(
|
|
275
|
+
module.exports = __toCommonJS(index_exports);
|
|
276
276
|
init_react_import();
|
|
277
277
|
|
|
278
278
|
// src/HeadingAnalyzer.tsx
|
|
@@ -853,10 +853,10 @@ var insert = (list, index, item) => {
|
|
|
853
853
|
// ../core/lib/generate-id.ts
|
|
854
854
|
init_react_import();
|
|
855
855
|
|
|
856
|
-
//
|
|
856
|
+
// ../core/node_modules/uuid/dist/esm-node/index.js
|
|
857
857
|
init_react_import();
|
|
858
858
|
|
|
859
|
-
//
|
|
859
|
+
// ../core/node_modules/uuid/dist/esm-node/rng.js
|
|
860
860
|
init_react_import();
|
|
861
861
|
var import_crypto = __toESM(require("crypto"));
|
|
862
862
|
var rnds8Pool = new Uint8Array(256);
|
|
@@ -869,7 +869,7 @@ function rng() {
|
|
|
869
869
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
870
870
|
}
|
|
871
871
|
|
|
872
|
-
//
|
|
872
|
+
// ../core/node_modules/uuid/dist/esm-node/stringify.js
|
|
873
873
|
init_react_import();
|
|
874
874
|
var byteToHex = [];
|
|
875
875
|
for (let i = 0; i < 256; ++i) {
|
|
@@ -879,17 +879,17 @@ function unsafeStringify(arr, offset = 0) {
|
|
|
879
879
|
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
880
880
|
}
|
|
881
881
|
|
|
882
|
-
//
|
|
882
|
+
// ../core/node_modules/uuid/dist/esm-node/v4.js
|
|
883
883
|
init_react_import();
|
|
884
884
|
|
|
885
|
-
//
|
|
885
|
+
// ../core/node_modules/uuid/dist/esm-node/native.js
|
|
886
886
|
init_react_import();
|
|
887
887
|
var import_crypto2 = __toESM(require("crypto"));
|
|
888
888
|
var native_default = {
|
|
889
889
|
randomUUID: import_crypto2.default.randomUUID
|
|
890
890
|
};
|
|
891
891
|
|
|
892
|
-
//
|
|
892
|
+
// ../core/node_modules/uuid/dist/esm-node/v4.js
|
|
893
893
|
function v4(options, buf, offset) {
|
|
894
894
|
if (native_default.randomUUID && !buf && !options) {
|
|
895
895
|
return native_default.randomUUID();
|
|
@@ -1470,7 +1470,7 @@ var createStoreImpl = (createState) => {
|
|
|
1470
1470
|
const initialState = state = createState(setState, getState, api);
|
|
1471
1471
|
return api;
|
|
1472
1472
|
};
|
|
1473
|
-
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
1473
|
+
var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
1474
1474
|
|
|
1475
1475
|
// ../../node_modules/zustand/esm/react.mjs
|
|
1476
1476
|
init_react_import();
|
|
@@ -1479,8 +1479,8 @@ var identity = (arg) => arg;
|
|
|
1479
1479
|
function useStore(api, selector = identity) {
|
|
1480
1480
|
const slice = import_react4.default.useSyncExternalStore(
|
|
1481
1481
|
api.subscribe,
|
|
1482
|
-
() => selector(api.getState()),
|
|
1483
|
-
() => selector(api.getInitialState())
|
|
1482
|
+
import_react4.default.useCallback(() => selector(api.getState()), [api, selector]),
|
|
1483
|
+
import_react4.default.useCallback(() => selector(api.getInitialState()), [api, selector])
|
|
1484
1484
|
);
|
|
1485
1485
|
import_react4.default.useDebugValue(slice);
|
|
1486
1486
|
return slice;
|
|
@@ -1491,13 +1491,13 @@ var createImpl = (createState) => {
|
|
|
1491
1491
|
Object.assign(useBoundStore, api);
|
|
1492
1492
|
return useBoundStore;
|
|
1493
1493
|
};
|
|
1494
|
-
var create = (createState) => createState ? createImpl(createState) : createImpl;
|
|
1494
|
+
var create = ((createState) => createState ? createImpl(createState) : createImpl);
|
|
1495
1495
|
|
|
1496
1496
|
// ../../node_modules/zustand/esm/middleware.mjs
|
|
1497
1497
|
init_react_import();
|
|
1498
1498
|
var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
1499
1499
|
const origSubscribe = api.subscribe;
|
|
1500
|
-
api.subscribe = (selector, optListener, options) => {
|
|
1500
|
+
api.subscribe = ((selector, optListener, options) => {
|
|
1501
1501
|
let listener = selector;
|
|
1502
1502
|
if (optListener) {
|
|
1503
1503
|
const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
|
|
@@ -1514,7 +1514,7 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
|
1514
1514
|
}
|
|
1515
1515
|
}
|
|
1516
1516
|
return origSubscribe(listener);
|
|
1517
|
-
};
|
|
1517
|
+
});
|
|
1518
1518
|
const initialState = fn(set, get, api);
|
|
1519
1519
|
return initialState;
|
|
1520
1520
|
};
|
|
@@ -1731,9 +1731,9 @@ function createIsCircular(areItemsEqual) {
|
|
|
1731
1731
|
function getStrictProperties(object) {
|
|
1732
1732
|
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
|
|
1733
1733
|
}
|
|
1734
|
-
var hasOwn = Object.hasOwn || function(object, property) {
|
|
1734
|
+
var hasOwn = Object.hasOwn || (function(object, property) {
|
|
1735
1735
|
return hasOwnProperty.call(object, property);
|
|
1736
|
-
};
|
|
1736
|
+
});
|
|
1737
1737
|
function sameValueZeroEqual(a, b) {
|
|
1738
1738
|
return a === b || !a && !b && a !== a && b !== b;
|
|
1739
1739
|
}
|
|
@@ -2123,29 +2123,37 @@ var getChanged = (newItem, oldItem) => {
|
|
|
2123
2123
|
|
|
2124
2124
|
// ../core/store/slices/permissions.ts
|
|
2125
2125
|
var createPermissionsSlice = (set, get) => {
|
|
2126
|
-
const resolvePermissions = (..._0) => __async(
|
|
2126
|
+
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
2127
2127
|
const { state, permissions, config } = get();
|
|
2128
2128
|
const { cache: cache2, globalPermissions } = permissions;
|
|
2129
|
-
const
|
|
2130
|
-
var _a, _b
|
|
2129
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
2130
|
+
var _a, _b;
|
|
2131
2131
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
2132
|
+
const itemCache = cache2[item2.props.id];
|
|
2133
|
+
const nodes = appState.indexes.nodes;
|
|
2134
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
2135
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
2136
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
2132
2137
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
2133
2138
|
if (!componentConfig) {
|
|
2134
2139
|
return;
|
|
2135
2140
|
}
|
|
2136
2141
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
2137
2142
|
if (componentConfig.resolvePermissions) {
|
|
2138
|
-
const changed = getChanged(item2,
|
|
2139
|
-
|
|
2143
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
2144
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
2145
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
2146
|
+
if (propsChanged || parentChanged || force2) {
|
|
2140
2147
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
2141
2148
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
2142
2149
|
item2,
|
|
2143
2150
|
{
|
|
2144
2151
|
changed,
|
|
2145
|
-
lastPermissions: (
|
|
2152
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
2146
2153
|
permissions: initialPermissions,
|
|
2147
2154
|
appState: makeStatePublic(appState),
|
|
2148
|
-
lastData: (
|
|
2155
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
2156
|
+
parent: parentData
|
|
2149
2157
|
}
|
|
2150
2158
|
);
|
|
2151
2159
|
const latest = get().permissions;
|
|
@@ -2153,6 +2161,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2153
2161
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
2154
2162
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
2155
2163
|
[item2.props.id]: {
|
|
2164
|
+
lastParentId: parentId,
|
|
2156
2165
|
lastData: item2,
|
|
2157
2166
|
lastPermissions: resolvedPermissions
|
|
2158
2167
|
}
|
|
@@ -2166,9 +2175,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2166
2175
|
}
|
|
2167
2176
|
}
|
|
2168
2177
|
});
|
|
2169
|
-
const
|
|
2178
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
2170
2179
|
const { state: appState } = get();
|
|
2171
|
-
|
|
2180
|
+
resolvePermissionsForItem(
|
|
2172
2181
|
// Shim the root data in by conforming to component data shape
|
|
2173
2182
|
{
|
|
2174
2183
|
type: "root",
|
|
@@ -2179,16 +2188,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2179
2188
|
};
|
|
2180
2189
|
const { item, type, root } = params;
|
|
2181
2190
|
if (item) {
|
|
2182
|
-
yield
|
|
2191
|
+
yield resolvePermissionsForItem(item, force);
|
|
2183
2192
|
} else if (type) {
|
|
2184
|
-
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(
|
|
2185
|
-
yield
|
|
2193
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
2194
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2186
2195
|
}));
|
|
2187
2196
|
} else if (root) {
|
|
2188
|
-
|
|
2197
|
+
resolvePermissionsForRoot(force);
|
|
2189
2198
|
} else {
|
|
2190
|
-
flattenData(state, config).map((item2) => __async(
|
|
2191
|
-
yield
|
|
2199
|
+
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
2200
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2192
2201
|
}));
|
|
2193
2202
|
}
|
|
2194
2203
|
});
|
|
@@ -2242,7 +2251,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
|
2242
2251
|
// ../core/lib/resolve-component-data.ts
|
|
2243
2252
|
init_react_import();
|
|
2244
2253
|
var cache = { lastChange: {} };
|
|
2245
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(
|
|
2254
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
2246
2255
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
2247
2256
|
const resolvedItem = __spreadValues({}, item);
|
|
2248
2257
|
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
@@ -2270,11 +2279,11 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
2270
2279
|
let itemWithResolvedChildren = yield mapFields(
|
|
2271
2280
|
resolvedItem,
|
|
2272
2281
|
{
|
|
2273
|
-
slot: (_02) => __async(
|
|
2282
|
+
slot: (_02) => __async(null, [_02], function* ({ value }) {
|
|
2274
2283
|
const content = value;
|
|
2275
2284
|
return yield Promise.all(
|
|
2276
2285
|
content.map(
|
|
2277
|
-
(childItem) => __async(
|
|
2286
|
+
(childItem) => __async(null, null, function* () {
|
|
2278
2287
|
return (yield resolveComponentData(
|
|
2279
2288
|
childItem,
|
|
2280
2289
|
config,
|
|
@@ -2466,7 +2475,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
|
2466
2475
|
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
|
2467
2476
|
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
|
2468
2477
|
}),
|
|
2469
|
-
resolveComponentData: (componentData, trigger) => __async(
|
|
2478
|
+
resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
|
|
2470
2479
|
const { config, metadata, setComponentLoading, permissions } = get();
|
|
2471
2480
|
const timeouts = {};
|
|
2472
2481
|
return yield resolveComponentData(
|
|
@@ -2477,7 +2486,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
|
2477
2486
|
const id = "id" in item.props ? item.props.id : "root";
|
|
2478
2487
|
timeouts[id] = setComponentLoading(id, true, 50);
|
|
2479
2488
|
},
|
|
2480
|
-
(item) => __async(
|
|
2489
|
+
(item) => __async(null, null, function* () {
|
|
2481
2490
|
const id = "id" in item.props ? item.props.id : "root";
|
|
2482
2491
|
if ("type" in item) {
|
|
2483
2492
|
yield permissions.refreshPermissions({ item });
|
|
@@ -2489,7 +2498,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
|
2489
2498
|
trigger
|
|
2490
2499
|
);
|
|
2491
2500
|
}),
|
|
2492
|
-
resolveAndCommitData: () => __async(
|
|
2501
|
+
resolveAndCommitData: () => __async(null, null, function* () {
|
|
2493
2502
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
|
2494
2503
|
walkAppState(
|
|
2495
2504
|
state,
|
|
@@ -2722,45 +2731,10 @@ classnames/index.js:
|
|
|
2722
2731
|
*)
|
|
2723
2732
|
|
|
2724
2733
|
lucide-react/dist/esm/shared/src/utils.js:
|
|
2725
|
-
(**
|
|
2726
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2727
|
-
*
|
|
2728
|
-
* This source code is licensed under the ISC license.
|
|
2729
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2730
|
-
*)
|
|
2731
|
-
|
|
2732
2734
|
lucide-react/dist/esm/defaultAttributes.js:
|
|
2733
|
-
(**
|
|
2734
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2735
|
-
*
|
|
2736
|
-
* This source code is licensed under the ISC license.
|
|
2737
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2738
|
-
*)
|
|
2739
|
-
|
|
2740
2735
|
lucide-react/dist/esm/Icon.js:
|
|
2741
|
-
(**
|
|
2742
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2743
|
-
*
|
|
2744
|
-
* This source code is licensed under the ISC license.
|
|
2745
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2746
|
-
*)
|
|
2747
|
-
|
|
2748
2736
|
lucide-react/dist/esm/createLucideIcon.js:
|
|
2749
|
-
(**
|
|
2750
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2751
|
-
*
|
|
2752
|
-
* This source code is licensed under the ISC license.
|
|
2753
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2754
|
-
*)
|
|
2755
|
-
|
|
2756
2737
|
lucide-react/dist/esm/icons/heading-1.js:
|
|
2757
|
-
(**
|
|
2758
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2759
|
-
*
|
|
2760
|
-
* This source code is licensed under the ISC license.
|
|
2761
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2762
|
-
*)
|
|
2763
|
-
|
|
2764
2738
|
lucide-react/dist/esm/lucide-react.js:
|
|
2765
2739
|
(**
|
|
2766
2740
|
* @license lucide-react v0.468.0 - ISC
|
package/dist/index.mjs
CHANGED
|
@@ -841,10 +841,10 @@ var insert = (list, index, item) => {
|
|
|
841
841
|
// ../core/lib/generate-id.ts
|
|
842
842
|
init_react_import();
|
|
843
843
|
|
|
844
|
-
//
|
|
844
|
+
// ../core/node_modules/uuid/dist/esm-node/index.js
|
|
845
845
|
init_react_import();
|
|
846
846
|
|
|
847
|
-
//
|
|
847
|
+
// ../core/node_modules/uuid/dist/esm-node/rng.js
|
|
848
848
|
init_react_import();
|
|
849
849
|
import crypto from "crypto";
|
|
850
850
|
var rnds8Pool = new Uint8Array(256);
|
|
@@ -857,7 +857,7 @@ function rng() {
|
|
|
857
857
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
858
858
|
}
|
|
859
859
|
|
|
860
|
-
//
|
|
860
|
+
// ../core/node_modules/uuid/dist/esm-node/stringify.js
|
|
861
861
|
init_react_import();
|
|
862
862
|
var byteToHex = [];
|
|
863
863
|
for (let i = 0; i < 256; ++i) {
|
|
@@ -867,17 +867,17 @@ function unsafeStringify(arr, offset = 0) {
|
|
|
867
867
|
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
868
868
|
}
|
|
869
869
|
|
|
870
|
-
//
|
|
870
|
+
// ../core/node_modules/uuid/dist/esm-node/v4.js
|
|
871
871
|
init_react_import();
|
|
872
872
|
|
|
873
|
-
//
|
|
873
|
+
// ../core/node_modules/uuid/dist/esm-node/native.js
|
|
874
874
|
init_react_import();
|
|
875
875
|
import crypto2 from "crypto";
|
|
876
876
|
var native_default = {
|
|
877
877
|
randomUUID: crypto2.randomUUID
|
|
878
878
|
};
|
|
879
879
|
|
|
880
|
-
//
|
|
880
|
+
// ../core/node_modules/uuid/dist/esm-node/v4.js
|
|
881
881
|
function v4(options, buf, offset) {
|
|
882
882
|
if (native_default.randomUUID && !buf && !options) {
|
|
883
883
|
return native_default.randomUUID();
|
|
@@ -1458,7 +1458,7 @@ var createStoreImpl = (createState) => {
|
|
|
1458
1458
|
const initialState = state = createState(setState, getState, api);
|
|
1459
1459
|
return api;
|
|
1460
1460
|
};
|
|
1461
|
-
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
1461
|
+
var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
1462
1462
|
|
|
1463
1463
|
// ../../node_modules/zustand/esm/react.mjs
|
|
1464
1464
|
init_react_import();
|
|
@@ -1467,8 +1467,8 @@ var identity = (arg) => arg;
|
|
|
1467
1467
|
function useStore(api, selector = identity) {
|
|
1468
1468
|
const slice = React2.useSyncExternalStore(
|
|
1469
1469
|
api.subscribe,
|
|
1470
|
-
() => selector(api.getState()),
|
|
1471
|
-
() => selector(api.getInitialState())
|
|
1470
|
+
React2.useCallback(() => selector(api.getState()), [api, selector]),
|
|
1471
|
+
React2.useCallback(() => selector(api.getInitialState()), [api, selector])
|
|
1472
1472
|
);
|
|
1473
1473
|
React2.useDebugValue(slice);
|
|
1474
1474
|
return slice;
|
|
@@ -1479,13 +1479,13 @@ var createImpl = (createState) => {
|
|
|
1479
1479
|
Object.assign(useBoundStore, api);
|
|
1480
1480
|
return useBoundStore;
|
|
1481
1481
|
};
|
|
1482
|
-
var create = (createState) => createState ? createImpl(createState) : createImpl;
|
|
1482
|
+
var create = ((createState) => createState ? createImpl(createState) : createImpl);
|
|
1483
1483
|
|
|
1484
1484
|
// ../../node_modules/zustand/esm/middleware.mjs
|
|
1485
1485
|
init_react_import();
|
|
1486
1486
|
var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
1487
1487
|
const origSubscribe = api.subscribe;
|
|
1488
|
-
api.subscribe = (selector, optListener, options) => {
|
|
1488
|
+
api.subscribe = ((selector, optListener, options) => {
|
|
1489
1489
|
let listener = selector;
|
|
1490
1490
|
if (optListener) {
|
|
1491
1491
|
const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
|
|
@@ -1502,7 +1502,7 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
|
1502
1502
|
}
|
|
1503
1503
|
}
|
|
1504
1504
|
return origSubscribe(listener);
|
|
1505
|
-
};
|
|
1505
|
+
});
|
|
1506
1506
|
const initialState = fn(set, get, api);
|
|
1507
1507
|
return initialState;
|
|
1508
1508
|
};
|
|
@@ -1719,9 +1719,9 @@ function createIsCircular(areItemsEqual) {
|
|
|
1719
1719
|
function getStrictProperties(object) {
|
|
1720
1720
|
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
|
|
1721
1721
|
}
|
|
1722
|
-
var hasOwn = Object.hasOwn || function(object, property) {
|
|
1722
|
+
var hasOwn = Object.hasOwn || (function(object, property) {
|
|
1723
1723
|
return hasOwnProperty.call(object, property);
|
|
1724
|
-
};
|
|
1724
|
+
});
|
|
1725
1725
|
function sameValueZeroEqual(a, b) {
|
|
1726
1726
|
return a === b || !a && !b && a !== a && b !== b;
|
|
1727
1727
|
}
|
|
@@ -2111,29 +2111,37 @@ var getChanged = (newItem, oldItem) => {
|
|
|
2111
2111
|
|
|
2112
2112
|
// ../core/store/slices/permissions.ts
|
|
2113
2113
|
var createPermissionsSlice = (set, get) => {
|
|
2114
|
-
const resolvePermissions = (..._0) => __async(
|
|
2114
|
+
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
2115
2115
|
const { state, permissions, config } = get();
|
|
2116
2116
|
const { cache: cache2, globalPermissions } = permissions;
|
|
2117
|
-
const
|
|
2118
|
-
var _a, _b
|
|
2117
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
2118
|
+
var _a, _b;
|
|
2119
2119
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
2120
|
+
const itemCache = cache2[item2.props.id];
|
|
2121
|
+
const nodes = appState.indexes.nodes;
|
|
2122
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
2123
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
2124
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
2120
2125
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
2121
2126
|
if (!componentConfig) {
|
|
2122
2127
|
return;
|
|
2123
2128
|
}
|
|
2124
2129
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
2125
2130
|
if (componentConfig.resolvePermissions) {
|
|
2126
|
-
const changed = getChanged(item2,
|
|
2127
|
-
|
|
2131
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
2132
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
2133
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
2134
|
+
if (propsChanged || parentChanged || force2) {
|
|
2128
2135
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
2129
2136
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
2130
2137
|
item2,
|
|
2131
2138
|
{
|
|
2132
2139
|
changed,
|
|
2133
|
-
lastPermissions: (
|
|
2140
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
2134
2141
|
permissions: initialPermissions,
|
|
2135
2142
|
appState: makeStatePublic(appState),
|
|
2136
|
-
lastData: (
|
|
2143
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
2144
|
+
parent: parentData
|
|
2137
2145
|
}
|
|
2138
2146
|
);
|
|
2139
2147
|
const latest = get().permissions;
|
|
@@ -2141,6 +2149,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2141
2149
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
2142
2150
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
2143
2151
|
[item2.props.id]: {
|
|
2152
|
+
lastParentId: parentId,
|
|
2144
2153
|
lastData: item2,
|
|
2145
2154
|
lastPermissions: resolvedPermissions
|
|
2146
2155
|
}
|
|
@@ -2154,9 +2163,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2154
2163
|
}
|
|
2155
2164
|
}
|
|
2156
2165
|
});
|
|
2157
|
-
const
|
|
2166
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
2158
2167
|
const { state: appState } = get();
|
|
2159
|
-
|
|
2168
|
+
resolvePermissionsForItem(
|
|
2160
2169
|
// Shim the root data in by conforming to component data shape
|
|
2161
2170
|
{
|
|
2162
2171
|
type: "root",
|
|
@@ -2167,16 +2176,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2167
2176
|
};
|
|
2168
2177
|
const { item, type, root } = params;
|
|
2169
2178
|
if (item) {
|
|
2170
|
-
yield
|
|
2179
|
+
yield resolvePermissionsForItem(item, force);
|
|
2171
2180
|
} else if (type) {
|
|
2172
|
-
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(
|
|
2173
|
-
yield
|
|
2181
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
2182
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2174
2183
|
}));
|
|
2175
2184
|
} else if (root) {
|
|
2176
|
-
|
|
2185
|
+
resolvePermissionsForRoot(force);
|
|
2177
2186
|
} else {
|
|
2178
|
-
flattenData(state, config).map((item2) => __async(
|
|
2179
|
-
yield
|
|
2187
|
+
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
2188
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2180
2189
|
}));
|
|
2181
2190
|
}
|
|
2182
2191
|
});
|
|
@@ -2230,7 +2239,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
|
2230
2239
|
// ../core/lib/resolve-component-data.ts
|
|
2231
2240
|
init_react_import();
|
|
2232
2241
|
var cache = { lastChange: {} };
|
|
2233
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(
|
|
2242
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
2234
2243
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
2235
2244
|
const resolvedItem = __spreadValues({}, item);
|
|
2236
2245
|
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
@@ -2258,11 +2267,11 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
2258
2267
|
let itemWithResolvedChildren = yield mapFields(
|
|
2259
2268
|
resolvedItem,
|
|
2260
2269
|
{
|
|
2261
|
-
slot: (_02) => __async(
|
|
2270
|
+
slot: (_02) => __async(null, [_02], function* ({ value }) {
|
|
2262
2271
|
const content = value;
|
|
2263
2272
|
return yield Promise.all(
|
|
2264
2273
|
content.map(
|
|
2265
|
-
(childItem) => __async(
|
|
2274
|
+
(childItem) => __async(null, null, function* () {
|
|
2266
2275
|
return (yield resolveComponentData(
|
|
2267
2276
|
childItem,
|
|
2268
2277
|
config,
|
|
@@ -2454,7 +2463,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
|
2454
2463
|
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
|
2455
2464
|
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
|
2456
2465
|
}),
|
|
2457
|
-
resolveComponentData: (componentData, trigger) => __async(
|
|
2466
|
+
resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
|
|
2458
2467
|
const { config, metadata, setComponentLoading, permissions } = get();
|
|
2459
2468
|
const timeouts = {};
|
|
2460
2469
|
return yield resolveComponentData(
|
|
@@ -2465,7 +2474,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
|
2465
2474
|
const id = "id" in item.props ? item.props.id : "root";
|
|
2466
2475
|
timeouts[id] = setComponentLoading(id, true, 50);
|
|
2467
2476
|
},
|
|
2468
|
-
(item) => __async(
|
|
2477
|
+
(item) => __async(null, null, function* () {
|
|
2469
2478
|
const id = "id" in item.props ? item.props.id : "root";
|
|
2470
2479
|
if ("type" in item) {
|
|
2471
2480
|
yield permissions.refreshPermissions({ item });
|
|
@@ -2477,7 +2486,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
|
2477
2486
|
trigger
|
|
2478
2487
|
);
|
|
2479
2488
|
}),
|
|
2480
|
-
resolveAndCommitData: () => __async(
|
|
2489
|
+
resolveAndCommitData: () => __async(null, null, function* () {
|
|
2481
2490
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
|
2482
2491
|
walkAppState(
|
|
2483
2492
|
state,
|
|
@@ -2713,45 +2722,10 @@ classnames/index.js:
|
|
|
2713
2722
|
*)
|
|
2714
2723
|
|
|
2715
2724
|
lucide-react/dist/esm/shared/src/utils.js:
|
|
2716
|
-
(**
|
|
2717
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2718
|
-
*
|
|
2719
|
-
* This source code is licensed under the ISC license.
|
|
2720
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2721
|
-
*)
|
|
2722
|
-
|
|
2723
2725
|
lucide-react/dist/esm/defaultAttributes.js:
|
|
2724
|
-
(**
|
|
2725
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2726
|
-
*
|
|
2727
|
-
* This source code is licensed under the ISC license.
|
|
2728
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2729
|
-
*)
|
|
2730
|
-
|
|
2731
2726
|
lucide-react/dist/esm/Icon.js:
|
|
2732
|
-
(**
|
|
2733
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2734
|
-
*
|
|
2735
|
-
* This source code is licensed under the ISC license.
|
|
2736
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2737
|
-
*)
|
|
2738
|
-
|
|
2739
2727
|
lucide-react/dist/esm/createLucideIcon.js:
|
|
2740
|
-
(**
|
|
2741
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2742
|
-
*
|
|
2743
|
-
* This source code is licensed under the ISC license.
|
|
2744
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2745
|
-
*)
|
|
2746
|
-
|
|
2747
2728
|
lucide-react/dist/esm/icons/heading-1.js:
|
|
2748
|
-
(**
|
|
2749
|
-
* @license lucide-react v0.468.0 - ISC
|
|
2750
|
-
*
|
|
2751
|
-
* This source code is licensed under the ISC license.
|
|
2752
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
2753
|
-
*)
|
|
2754
|
-
|
|
2755
2729
|
lucide-react/dist/esm/lucide-react.js:
|
|
2756
2730
|
(**
|
|
2757
2731
|
* @license lucide-react v0.468.0 - ISC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck-plugin-heading-analyzer",
|
|
3
|
-
"version": "0.21.0-canary.
|
|
3
|
+
"version": "0.21.0-canary.7ed9655b",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "measuredco/puck",
|
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@measured/puck": "^0.21.0-canary.
|
|
28
|
+
"@measured/puck": "^0.21.0-canary.7ed9655b",
|
|
29
|
+
"@types/minimatch": "3.0.5",
|
|
29
30
|
"@types/react": "^19.0.1",
|
|
30
31
|
"@types/react-dom": "^19.0.2",
|
|
31
32
|
"eslint": "^7.32.0",
|