@netlisian/softconfig 0.1.7 → 0.1.8
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/puck/index.d.mts +6 -2
- package/dist/puck/index.d.ts +6 -2
- package/dist/puck/index.js +67 -82
- package/dist/puck/index.mjs +65 -81
- package/package.json +1 -1
package/dist/puck/index.d.mts
CHANGED
|
@@ -530,7 +530,7 @@ declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: Soft
|
|
|
530
530
|
* @param props.useVersioning - Flag to enable or disable versioning (defaults to false).
|
|
531
531
|
*/
|
|
532
532
|
declare const SoftConfigProvider: ({ children, hardConfig, softComponents, customFields, overrides, value, onActions, useVersioning, }: {
|
|
533
|
-
children: (softConfig: Config
|
|
533
|
+
children: (softConfig: Config) => ReactNode;
|
|
534
534
|
hardConfig: Config;
|
|
535
535
|
softComponents?: SoftComponents;
|
|
536
536
|
customFields?: CustomFields;
|
|
@@ -542,6 +542,10 @@ declare const SoftConfigProvider: ({ children, hardConfig, softComponents, custo
|
|
|
542
542
|
|
|
543
543
|
declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
544
544
|
declare const useSoftConfig: <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
545
|
+
/**
|
|
546
|
+
* Access the soft config store instance without subscribing to state changes.
|
|
547
|
+
*/
|
|
548
|
+
declare const useSoftConfigStore: () => StoreApi<AppStore>;
|
|
545
549
|
|
|
546
550
|
declare const useBuild: (name?: string) => {
|
|
547
551
|
handleBuild: () => void;
|
|
@@ -742,4 +746,4 @@ declare const isArrayMappingPath: (path: string) => boolean;
|
|
|
742
746
|
declare const getArrayBasePath: (arrayPath: string) => string | null;
|
|
743
747
|
declare const getArrayItemSubPath: (arrayPath: string) => string | null;
|
|
744
748
|
|
|
745
|
-
export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type ApplyMappingOptions, type ApplyMappingResult, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, type CustomFieldDefinition, type CustomFieldReturnType, type CustomFields, Drawer, DrawerItem, type FieldSettings, Header, HeaderActions, type MapEntry, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type SoftFieldDefinition, type SoftFieldSettings, type VersionedSoftComponent, applyMapping, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, filterToOptionsForFrom, getArrayBasePath, getArrayItemSubPath, isArrayMappingPath, notify, resolveSoftConfig, resolveValueByPath, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
|
|
749
|
+
export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type ApplyMappingOptions, type ApplyMappingResult, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, type CustomFieldDefinition, type CustomFieldReturnType, type CustomFields, Drawer, DrawerItem, type FieldSettings, Header, HeaderActions, type MapEntry, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type SoftFieldDefinition, type SoftFieldSettings, type VersionedSoftComponent, applyMapping, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, filterToOptionsForFrom, getArrayBasePath, getArrayItemSubPath, isArrayMappingPath, notify, resolveSoftConfig, resolveValueByPath, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig, useSoftConfigStore };
|
package/dist/puck/index.d.ts
CHANGED
|
@@ -530,7 +530,7 @@ declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: Soft
|
|
|
530
530
|
* @param props.useVersioning - Flag to enable or disable versioning (defaults to false).
|
|
531
531
|
*/
|
|
532
532
|
declare const SoftConfigProvider: ({ children, hardConfig, softComponents, customFields, overrides, value, onActions, useVersioning, }: {
|
|
533
|
-
children: (softConfig: Config
|
|
533
|
+
children: (softConfig: Config) => ReactNode;
|
|
534
534
|
hardConfig: Config;
|
|
535
535
|
softComponents?: SoftComponents;
|
|
536
536
|
customFields?: CustomFields;
|
|
@@ -542,6 +542,10 @@ declare const SoftConfigProvider: ({ children, hardConfig, softComponents, custo
|
|
|
542
542
|
|
|
543
543
|
declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
544
544
|
declare const useSoftConfig: <T>(selector: (state: AppStore) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
545
|
+
/**
|
|
546
|
+
* Access the soft config store instance without subscribing to state changes.
|
|
547
|
+
*/
|
|
548
|
+
declare const useSoftConfigStore: () => StoreApi<AppStore>;
|
|
545
549
|
|
|
546
550
|
declare const useBuild: (name?: string) => {
|
|
547
551
|
handleBuild: () => void;
|
|
@@ -742,4 +746,4 @@ declare const isArrayMappingPath: (path: string) => boolean;
|
|
|
742
746
|
declare const getArrayBasePath: (arrayPath: string) => string | null;
|
|
743
747
|
declare const getArrayItemSubPath: (arrayPath: string) => string | null;
|
|
744
748
|
|
|
745
|
-
export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type ApplyMappingOptions, type ApplyMappingResult, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, type CustomFieldDefinition, type CustomFieldReturnType, type CustomFields, Drawer, DrawerItem, type FieldSettings, Header, HeaderActions, type MapEntry, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type SoftFieldDefinition, type SoftFieldSettings, type VersionedSoftComponent, applyMapping, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, filterToOptionsForFrom, getArrayBasePath, getArrayItemSubPath, isArrayMappingPath, notify, resolveSoftConfig, resolveValueByPath, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
|
|
749
|
+
export { ActionBarOverride as ActionBar, type ActionEventPayload, type AppStore, type AppStoreApi, type ApplyMappingOptions, type ApplyMappingResult, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Drawer as ComponentList, type CustomFieldDefinition, type CustomFieldReturnType, type CustomFields, Drawer, DrawerItem, type FieldSettings, Header, HeaderActions, type MapEntry, Modal, type OnActionsCallback, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, type SoftFieldDefinition, type SoftFieldSettings, type VersionedSoftComponent, applyMapping, confirm, createActionCallback, createSoftConfigStore, createUseSoftConfig, filterToOptionsForFrom, getArrayBasePath, getArrayItemSubPath, isArrayMappingPath, notify, resolveSoftConfig, resolveValueByPath, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig, useSoftConfigStore };
|
package/dist/puck/index.js
CHANGED
|
@@ -99,7 +99,8 @@ __export(puck_exports, {
|
|
|
99
99
|
useInspect: () => useInspect,
|
|
100
100
|
useRemodel: () => useRemodel,
|
|
101
101
|
useSetDefaultVersion: () => useSetDefaultVersion,
|
|
102
|
-
useSoftConfig: () => useSoftConfig
|
|
102
|
+
useSoftConfig: () => useSoftConfig,
|
|
103
|
+
useSoftConfigStore: () => useSoftConfigStore
|
|
103
104
|
});
|
|
104
105
|
module.exports = __toCommonJS(puck_exports);
|
|
105
106
|
|
|
@@ -670,6 +671,15 @@ var createUseSoftConfig = () => {
|
|
|
670
671
|
};
|
|
671
672
|
};
|
|
672
673
|
var useSoftConfig = createUseSoftConfig();
|
|
674
|
+
var useSoftConfigStore = () => {
|
|
675
|
+
const context = (0, import_react.useContext)(appStoreContext);
|
|
676
|
+
if (!context) {
|
|
677
|
+
throw new Error(
|
|
678
|
+
"useSoftConfigStore must be used inside a SoftConfigProvider."
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
return context;
|
|
682
|
+
};
|
|
673
683
|
|
|
674
684
|
// src/puck/lib/apply-mapping.ts
|
|
675
685
|
var import_react_fast_compare = __toESM(require("react-fast-compare"));
|
|
@@ -3287,47 +3297,6 @@ var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {
|
|
|
3287
3297
|
|
|
3288
3298
|
// src/puck/context/storeProvider.tsx
|
|
3289
3299
|
var import_react5 = require("react");
|
|
3290
|
-
|
|
3291
|
-
// src/puck/lib/notify.ts
|
|
3292
|
-
var customHandler = null;
|
|
3293
|
-
var defaultHandler = (message, type) => {
|
|
3294
|
-
if (type === "error") {
|
|
3295
|
-
console.error(`[Error] ${message}`);
|
|
3296
|
-
} else {
|
|
3297
|
-
console.log(`[Success] ${message}`);
|
|
3298
|
-
}
|
|
3299
|
-
};
|
|
3300
|
-
var setNotificationHandler = (handler) => {
|
|
3301
|
-
customHandler = handler;
|
|
3302
|
-
};
|
|
3303
|
-
var notify = {
|
|
3304
|
-
error: (message) => {
|
|
3305
|
-
const handler = customHandler || defaultHandler;
|
|
3306
|
-
handler(message, "error");
|
|
3307
|
-
},
|
|
3308
|
-
success: (message) => {
|
|
3309
|
-
const handler = customHandler || defaultHandler;
|
|
3310
|
-
handler(message, "success");
|
|
3311
|
-
}
|
|
3312
|
-
};
|
|
3313
|
-
|
|
3314
|
-
// src/puck/lib/action-callback.ts
|
|
3315
|
-
var createActionCallback = (validateAction, undo) => {
|
|
3316
|
-
return (action) => {
|
|
3317
|
-
if (!undo) {
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
|
-
const isValid = validateAction(action);
|
|
3321
|
-
if (!isValid) {
|
|
3322
|
-
notify.error(
|
|
3323
|
-
"Editing outside the soft component is not allowed when you are editing component definition."
|
|
3324
|
-
);
|
|
3325
|
-
requestAnimationFrame(() => undo());
|
|
3326
|
-
}
|
|
3327
|
-
};
|
|
3328
|
-
};
|
|
3329
|
-
|
|
3330
|
-
// src/puck/context/storeProvider.tsx
|
|
3331
3300
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3332
3301
|
var SoftConfigProvider = ({
|
|
3333
3302
|
children,
|
|
@@ -3339,8 +3308,8 @@ var SoftConfigProvider = ({
|
|
|
3339
3308
|
onActions,
|
|
3340
3309
|
useVersioning = false
|
|
3341
3310
|
}) => {
|
|
3342
|
-
const store =
|
|
3343
|
-
() => createSoftConfigStore(
|
|
3311
|
+
const store = (0, import_react5.useMemo)(
|
|
3312
|
+
() => value != null ? value : createSoftConfigStore(
|
|
3344
3313
|
hardConfig,
|
|
3345
3314
|
softComponents,
|
|
3346
3315
|
overrides,
|
|
@@ -3348,55 +3317,54 @@ var SoftConfigProvider = ({
|
|
|
3348
3317
|
useVersioning,
|
|
3349
3318
|
customFields
|
|
3350
3319
|
),
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
useVersioning,
|
|
3357
|
-
customFields
|
|
3358
|
-
]
|
|
3320
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3321
|
+
[value]
|
|
3322
|
+
// Intentionally omitting the rest: createSoftConfigStore params are
|
|
3323
|
+
// treated as initialisation-time values. If callers need to react to
|
|
3324
|
+
// prop changes they should pass a new `value` store instead.
|
|
3359
3325
|
);
|
|
3360
3326
|
const [softConfig, setSoftConfig] = (0, import_react5.useState)(
|
|
3361
3327
|
() => store.getState().softConfig
|
|
3362
3328
|
);
|
|
3363
|
-
const [internalSoftComponents, setSoftComponents] = (0, import_react5.useState)(
|
|
3364
|
-
() => store.getState().softComponents
|
|
3365
|
-
);
|
|
3366
|
-
const [actionGuard, setActionGuard] = (0, import_react5.useState)(
|
|
3367
|
-
(action) => null
|
|
3368
|
-
);
|
|
3369
3329
|
(0, import_react5.useEffect)(() => {
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
unsubscribe();
|
|
3376
|
-
};
|
|
3377
|
-
}, [store]);
|
|
3378
|
-
(0, import_react5.useEffect)(() => {
|
|
3379
|
-
const unsubscribe = store.subscribe((state, prevState) => {
|
|
3380
|
-
if (prevState && prevState.undoFn === state.undoFn) {
|
|
3381
|
-
return;
|
|
3330
|
+
let prev = store.getState().softConfig;
|
|
3331
|
+
const unsubscribe = store.subscribe((state) => {
|
|
3332
|
+
if (state.softConfig !== prev) {
|
|
3333
|
+
prev = state.softConfig;
|
|
3334
|
+
setSoftConfig(state.softConfig);
|
|
3382
3335
|
}
|
|
3383
|
-
setActionGuard(
|
|
3384
|
-
() => createActionCallback(
|
|
3385
|
-
state.validateAction,
|
|
3386
|
-
state.undoFn
|
|
3387
|
-
)
|
|
3388
|
-
);
|
|
3389
3336
|
});
|
|
3390
|
-
return
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
}, [store.getState().undoFn]);
|
|
3394
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(appStoreContext.Provider, { value: store, children: children(softConfig, internalSoftComponents, actionGuard) });
|
|
3337
|
+
return unsubscribe;
|
|
3338
|
+
}, [store]);
|
|
3339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(appStoreContext.Provider, { value: store, children: children(softConfig) });
|
|
3395
3340
|
};
|
|
3396
3341
|
|
|
3397
3342
|
// src/puck/actions/useBuild.tsx
|
|
3398
3343
|
var import_puck5 = require("@measured/puck");
|
|
3399
3344
|
|
|
3345
|
+
// src/puck/lib/notify.ts
|
|
3346
|
+
var customHandler = null;
|
|
3347
|
+
var defaultHandler = (message, type) => {
|
|
3348
|
+
if (type === "error") {
|
|
3349
|
+
console.error(`[Error] ${message}`);
|
|
3350
|
+
} else {
|
|
3351
|
+
console.log(`[Success] ${message}`);
|
|
3352
|
+
}
|
|
3353
|
+
};
|
|
3354
|
+
var setNotificationHandler = (handler) => {
|
|
3355
|
+
customHandler = handler;
|
|
3356
|
+
};
|
|
3357
|
+
var notify = {
|
|
3358
|
+
error: (message) => {
|
|
3359
|
+
const handler = customHandler || defaultHandler;
|
|
3360
|
+
handler(message, "error");
|
|
3361
|
+
},
|
|
3362
|
+
success: (message) => {
|
|
3363
|
+
const handler = customHandler || defaultHandler;
|
|
3364
|
+
handler(message, "success");
|
|
3365
|
+
}
|
|
3366
|
+
};
|
|
3367
|
+
|
|
3400
3368
|
// src/puck/hooks/useActionEvent.ts
|
|
3401
3369
|
var import_react6 = require("react");
|
|
3402
3370
|
var useActionEvent = () => {
|
|
@@ -4403,6 +4371,22 @@ var HeaderActions = ({ children }) => {
|
|
|
4403
4371
|
] }) : children });
|
|
4404
4372
|
};
|
|
4405
4373
|
|
|
4374
|
+
// src/puck/lib/action-callback.ts
|
|
4375
|
+
var createActionCallback = (validateAction, undo) => {
|
|
4376
|
+
return (action) => {
|
|
4377
|
+
if (!undo) {
|
|
4378
|
+
return;
|
|
4379
|
+
}
|
|
4380
|
+
const isValid = validateAction(action);
|
|
4381
|
+
if (!isValid) {
|
|
4382
|
+
notify.error(
|
|
4383
|
+
"Editing outside the soft component is not allowed when you are editing component definition."
|
|
4384
|
+
);
|
|
4385
|
+
requestAnimationFrame(() => undo());
|
|
4386
|
+
}
|
|
4387
|
+
};
|
|
4388
|
+
};
|
|
4389
|
+
|
|
4406
4390
|
// src/puck/lib/dissolve-all-soft-components.ts
|
|
4407
4391
|
function extractDependencies2(softComponents, componentName, version) {
|
|
4408
4392
|
var _a, _b;
|
|
@@ -4637,5 +4621,6 @@ var resolveSoftConfig = (data, softComponents, config) => {
|
|
|
4637
4621
|
useInspect,
|
|
4638
4622
|
useRemodel,
|
|
4639
4623
|
useSetDefaultVersion,
|
|
4640
|
-
useSoftConfig
|
|
4624
|
+
useSoftConfig,
|
|
4625
|
+
useSoftConfigStore
|
|
4641
4626
|
});
|
package/dist/puck/index.mjs
CHANGED
|
@@ -611,6 +611,15 @@ var createUseSoftConfig = () => {
|
|
|
611
611
|
};
|
|
612
612
|
};
|
|
613
613
|
var useSoftConfig = createUseSoftConfig();
|
|
614
|
+
var useSoftConfigStore = () => {
|
|
615
|
+
const context = useContext(appStoreContext);
|
|
616
|
+
if (!context) {
|
|
617
|
+
throw new Error(
|
|
618
|
+
"useSoftConfigStore must be used inside a SoftConfigProvider."
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
return context;
|
|
622
|
+
};
|
|
614
623
|
|
|
615
624
|
// src/puck/lib/apply-mapping.ts
|
|
616
625
|
import equal from "react-fast-compare";
|
|
@@ -3228,47 +3237,6 @@ var createSoftConfigStore = (hardConfig = { components: {} }, softComponents = {
|
|
|
3228
3237
|
|
|
3229
3238
|
// src/puck/context/storeProvider.tsx
|
|
3230
3239
|
import { useEffect as useEffect2, useMemo as useMemo2, useState } from "react";
|
|
3231
|
-
|
|
3232
|
-
// src/puck/lib/notify.ts
|
|
3233
|
-
var customHandler = null;
|
|
3234
|
-
var defaultHandler = (message, type) => {
|
|
3235
|
-
if (type === "error") {
|
|
3236
|
-
console.error(`[Error] ${message}`);
|
|
3237
|
-
} else {
|
|
3238
|
-
console.log(`[Success] ${message}`);
|
|
3239
|
-
}
|
|
3240
|
-
};
|
|
3241
|
-
var setNotificationHandler = (handler) => {
|
|
3242
|
-
customHandler = handler;
|
|
3243
|
-
};
|
|
3244
|
-
var notify = {
|
|
3245
|
-
error: (message) => {
|
|
3246
|
-
const handler = customHandler || defaultHandler;
|
|
3247
|
-
handler(message, "error");
|
|
3248
|
-
},
|
|
3249
|
-
success: (message) => {
|
|
3250
|
-
const handler = customHandler || defaultHandler;
|
|
3251
|
-
handler(message, "success");
|
|
3252
|
-
}
|
|
3253
|
-
};
|
|
3254
|
-
|
|
3255
|
-
// src/puck/lib/action-callback.ts
|
|
3256
|
-
var createActionCallback = (validateAction, undo) => {
|
|
3257
|
-
return (action) => {
|
|
3258
|
-
if (!undo) {
|
|
3259
|
-
return;
|
|
3260
|
-
}
|
|
3261
|
-
const isValid = validateAction(action);
|
|
3262
|
-
if (!isValid) {
|
|
3263
|
-
notify.error(
|
|
3264
|
-
"Editing outside the soft component is not allowed when you are editing component definition."
|
|
3265
|
-
);
|
|
3266
|
-
requestAnimationFrame(() => undo());
|
|
3267
|
-
}
|
|
3268
|
-
};
|
|
3269
|
-
};
|
|
3270
|
-
|
|
3271
|
-
// src/puck/context/storeProvider.tsx
|
|
3272
3240
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
3273
3241
|
var SoftConfigProvider = ({
|
|
3274
3242
|
children,
|
|
@@ -3280,8 +3248,8 @@ var SoftConfigProvider = ({
|
|
|
3280
3248
|
onActions,
|
|
3281
3249
|
useVersioning = false
|
|
3282
3250
|
}) => {
|
|
3283
|
-
const store =
|
|
3284
|
-
() => createSoftConfigStore(
|
|
3251
|
+
const store = useMemo2(
|
|
3252
|
+
() => value != null ? value : createSoftConfigStore(
|
|
3285
3253
|
hardConfig,
|
|
3286
3254
|
softComponents,
|
|
3287
3255
|
overrides,
|
|
@@ -3289,55 +3257,54 @@ var SoftConfigProvider = ({
|
|
|
3289
3257
|
useVersioning,
|
|
3290
3258
|
customFields
|
|
3291
3259
|
),
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
useVersioning,
|
|
3298
|
-
customFields
|
|
3299
|
-
]
|
|
3260
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3261
|
+
[value]
|
|
3262
|
+
// Intentionally omitting the rest: createSoftConfigStore params are
|
|
3263
|
+
// treated as initialisation-time values. If callers need to react to
|
|
3264
|
+
// prop changes they should pass a new `value` store instead.
|
|
3300
3265
|
);
|
|
3301
3266
|
const [softConfig, setSoftConfig] = useState(
|
|
3302
3267
|
() => store.getState().softConfig
|
|
3303
3268
|
);
|
|
3304
|
-
const [internalSoftComponents, setSoftComponents] = useState(
|
|
3305
|
-
() => store.getState().softComponents
|
|
3306
|
-
);
|
|
3307
|
-
const [actionGuard, setActionGuard] = useState(
|
|
3308
|
-
(action) => null
|
|
3309
|
-
);
|
|
3310
3269
|
useEffect2(() => {
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
unsubscribe();
|
|
3317
|
-
};
|
|
3318
|
-
}, [store]);
|
|
3319
|
-
useEffect2(() => {
|
|
3320
|
-
const unsubscribe = store.subscribe((state, prevState) => {
|
|
3321
|
-
if (prevState && prevState.undoFn === state.undoFn) {
|
|
3322
|
-
return;
|
|
3270
|
+
let prev = store.getState().softConfig;
|
|
3271
|
+
const unsubscribe = store.subscribe((state) => {
|
|
3272
|
+
if (state.softConfig !== prev) {
|
|
3273
|
+
prev = state.softConfig;
|
|
3274
|
+
setSoftConfig(state.softConfig);
|
|
3323
3275
|
}
|
|
3324
|
-
setActionGuard(
|
|
3325
|
-
() => createActionCallback(
|
|
3326
|
-
state.validateAction,
|
|
3327
|
-
state.undoFn
|
|
3328
|
-
)
|
|
3329
|
-
);
|
|
3330
3276
|
});
|
|
3331
|
-
return
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
}, [store.getState().undoFn]);
|
|
3335
|
-
return /* @__PURE__ */ jsx7(appStoreContext.Provider, { value: store, children: children(softConfig, internalSoftComponents, actionGuard) });
|
|
3277
|
+
return unsubscribe;
|
|
3278
|
+
}, [store]);
|
|
3279
|
+
return /* @__PURE__ */ jsx7(appStoreContext.Provider, { value: store, children: children(softConfig) });
|
|
3336
3280
|
};
|
|
3337
3281
|
|
|
3338
3282
|
// src/puck/actions/useBuild.tsx
|
|
3339
3283
|
import { createUsePuck as createUsePuck2 } from "@measured/puck";
|
|
3340
3284
|
|
|
3285
|
+
// src/puck/lib/notify.ts
|
|
3286
|
+
var customHandler = null;
|
|
3287
|
+
var defaultHandler = (message, type) => {
|
|
3288
|
+
if (type === "error") {
|
|
3289
|
+
console.error(`[Error] ${message}`);
|
|
3290
|
+
} else {
|
|
3291
|
+
console.log(`[Success] ${message}`);
|
|
3292
|
+
}
|
|
3293
|
+
};
|
|
3294
|
+
var setNotificationHandler = (handler) => {
|
|
3295
|
+
customHandler = handler;
|
|
3296
|
+
};
|
|
3297
|
+
var notify = {
|
|
3298
|
+
error: (message) => {
|
|
3299
|
+
const handler = customHandler || defaultHandler;
|
|
3300
|
+
handler(message, "error");
|
|
3301
|
+
},
|
|
3302
|
+
success: (message) => {
|
|
3303
|
+
const handler = customHandler || defaultHandler;
|
|
3304
|
+
handler(message, "success");
|
|
3305
|
+
}
|
|
3306
|
+
};
|
|
3307
|
+
|
|
3341
3308
|
// src/puck/hooks/useActionEvent.ts
|
|
3342
3309
|
import { useCallback } from "react";
|
|
3343
3310
|
var useActionEvent = () => {
|
|
@@ -4344,6 +4311,22 @@ var HeaderActions = ({ children }) => {
|
|
|
4344
4311
|
] }) : children });
|
|
4345
4312
|
};
|
|
4346
4313
|
|
|
4314
|
+
// src/puck/lib/action-callback.ts
|
|
4315
|
+
var createActionCallback = (validateAction, undo) => {
|
|
4316
|
+
return (action) => {
|
|
4317
|
+
if (!undo) {
|
|
4318
|
+
return;
|
|
4319
|
+
}
|
|
4320
|
+
const isValid = validateAction(action);
|
|
4321
|
+
if (!isValid) {
|
|
4322
|
+
notify.error(
|
|
4323
|
+
"Editing outside the soft component is not allowed when you are editing component definition."
|
|
4324
|
+
);
|
|
4325
|
+
requestAnimationFrame(() => undo());
|
|
4326
|
+
}
|
|
4327
|
+
};
|
|
4328
|
+
};
|
|
4329
|
+
|
|
4347
4330
|
// src/puck/lib/dissolve-all-soft-components.ts
|
|
4348
4331
|
function extractDependencies2(softComponents, componentName, version) {
|
|
4349
4332
|
var _a, _b;
|
|
@@ -4577,5 +4560,6 @@ export {
|
|
|
4577
4560
|
useInspect,
|
|
4578
4561
|
useRemodel,
|
|
4579
4562
|
useSetDefaultVersion,
|
|
4580
|
-
useSoftConfig
|
|
4563
|
+
useSoftConfig,
|
|
4564
|
+
useSoftConfigStore
|
|
4581
4565
|
};
|