@linkdlab/funcnodes_react_flow 2.1.2 → 2.2.1-a0
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.cjs.js +143 -143
- package/dist/index.d.ts +200 -4
- package/dist/index.es.js +4286 -4259
- package/dist/index.umd.js +139 -139
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -291,6 +291,147 @@ export declare const DataViewRendererToOverlayRenderer: (DV: DataViewRendererTyp
|
|
|
291
291
|
|
|
292
292
|
export declare type DataViewRendererType = BasicDataViewRendererType | React.MemoExoticComponent<BasicDataViewRendererType>;
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Deeply merges two objects, with the source object's properties taking precedence over the target's.
|
|
296
|
+
*
|
|
297
|
+
* This function creates a new object by recursively merging properties from the source object
|
|
298
|
+
* into the target object. Unlike shallow merging, this function traverses nested objects and
|
|
299
|
+
* merges them at each level. The function returns both the merged result and a boolean flag
|
|
300
|
+
* indicating whether any changes were made during the merge process.
|
|
301
|
+
*
|
|
302
|
+
* @template T - The type of the target object and the resulting merged object
|
|
303
|
+
*
|
|
304
|
+
* @param target - The base object that will be merged with the source. Must be a plain object.
|
|
305
|
+
* @param source - The object whose properties will override or extend the target object.
|
|
306
|
+
* Can be a partial representation of T with any level of nesting optional.
|
|
307
|
+
*
|
|
308
|
+
* @returns An object containing:
|
|
309
|
+
* - `new_obj`: A new object of type T with merged properties
|
|
310
|
+
* - `change`: Boolean indicating if any modifications were made during merging
|
|
311
|
+
*
|
|
312
|
+
* @throws {Error} Throws an error if either target or source is not a plain object
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* const target = {
|
|
317
|
+
* user: { name: 'John', age: 30 },
|
|
318
|
+
* settings: { theme: 'light', lang: 'en' }
|
|
319
|
+
* };
|
|
320
|
+
*
|
|
321
|
+
* const source = {
|
|
322
|
+
* user: { age: 31 }, // Will override age, keep name
|
|
323
|
+
* settings: { theme: 'dark' } // Will override theme, keep lang
|
|
324
|
+
* };
|
|
325
|
+
*
|
|
326
|
+
* const result = deep_merge(target, source);
|
|
327
|
+
* // result.new_obj = {
|
|
328
|
+
* // user: { name: 'John', age: 31 },
|
|
329
|
+
* // settings: { theme: 'dark', lang: 'en' }
|
|
330
|
+
* // }
|
|
331
|
+
* // result.change = true
|
|
332
|
+
* ```
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```typescript
|
|
336
|
+
* // No changes scenario
|
|
337
|
+
* const target = { a: 1, b: { c: 2 } };
|
|
338
|
+
* const source = { a: 1, b: { c: 2 } };
|
|
339
|
+
* const result = deep_merge(target, source);
|
|
340
|
+
* // result.new_obj = { a: 1, b: { c: 2 } }
|
|
341
|
+
* // result.change = false
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* @note This function creates a new object rather than modifying the target in place.
|
|
345
|
+
* @note The function uses deep_compare_objects to determine if changes actually occurred.
|
|
346
|
+
* @note Nested objects are recursively merged, but arrays and other object types are replaced entirely.
|
|
347
|
+
*
|
|
348
|
+
* @see DeepPartial - Type used for the source parameter
|
|
349
|
+
* @see deep_compare_objects - Used to detect changes during merging
|
|
350
|
+
* @see isPlainObject - Used to validate object types
|
|
351
|
+
* @see deep_update - Alternative function for adding missing properties only
|
|
352
|
+
*/
|
|
353
|
+
export declare const deep_merge: <T extends {}>(target: T, source: DeepPartial<T>) => {
|
|
354
|
+
new_obj: T;
|
|
355
|
+
change: boolean;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Deeply updates the target object by adding missing properties from the source object.
|
|
360
|
+
*
|
|
361
|
+
* Unlike deep_merge which overwrites existing properties, deep_update only adds properties
|
|
362
|
+
* that are missing (undefined) in the target object. This is useful for filling in default
|
|
363
|
+
* values or ensuring an object has all required properties without overwriting existing data.
|
|
364
|
+
* The function recursively processes nested objects to add missing properties at any depth.
|
|
365
|
+
*
|
|
366
|
+
* @template T - The type of the complete object structure (source object type)
|
|
367
|
+
*
|
|
368
|
+
* @param target - A partial object that may be missing some properties. Can have any subset
|
|
369
|
+
* of properties from T, with nested objects also being partial.
|
|
370
|
+
* @param source - A complete object of type T that provides the default/missing values.
|
|
371
|
+
* This object should contain all the properties that might be missing from target.
|
|
372
|
+
*
|
|
373
|
+
* @returns An object containing:
|
|
374
|
+
* - `new_obj`: A complete object of type T with all properties filled in
|
|
375
|
+
* - `change`: Boolean indicating if any properties were added during the update
|
|
376
|
+
*
|
|
377
|
+
* @throws {Error} Throws an error if either target or source is not a plain object
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* ```typescript
|
|
381
|
+
* interface Config {
|
|
382
|
+
* user: { name: string; age: number; email: string };
|
|
383
|
+
* settings: { theme: string; lang: string; notifications: boolean };
|
|
384
|
+
* }
|
|
385
|
+
*
|
|
386
|
+
* const partialConfig = {
|
|
387
|
+
* user: { name: 'John' }, // Missing age and email
|
|
388
|
+
* settings: { theme: 'dark' } // Missing lang and notifications
|
|
389
|
+
* };
|
|
390
|
+
*
|
|
391
|
+
* const defaultConfig: Config = {
|
|
392
|
+
* user: { name: 'Anonymous', age: 0, email: 'none@example.com' },
|
|
393
|
+
* settings: { theme: 'light', lang: 'en', notifications: true }
|
|
394
|
+
* };
|
|
395
|
+
*
|
|
396
|
+
* const result = deep_update(partialConfig, defaultConfig);
|
|
397
|
+
* // result.new_obj = {
|
|
398
|
+
* // user: { name: 'John', age: 0, email: 'none@example.com' },
|
|
399
|
+
* // settings: { theme: 'dark', lang: 'en', notifications: true }
|
|
400
|
+
* // }
|
|
401
|
+
* // result.change = true
|
|
402
|
+
* ```
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```typescript
|
|
406
|
+
* // No changes needed scenario
|
|
407
|
+
* const completeConfig = {
|
|
408
|
+
* user: { name: 'John', age: 30, email: 'john@example.com' },
|
|
409
|
+
* settings: { theme: 'dark', lang: 'fr', notifications: false }
|
|
410
|
+
* };
|
|
411
|
+
*
|
|
412
|
+
* const result = deep_update(completeConfig, defaultConfig);
|
|
413
|
+
* // result.new_obj = completeConfig (unchanged)
|
|
414
|
+
* // result.change = false
|
|
415
|
+
* ```
|
|
416
|
+
*
|
|
417
|
+
* @note This function only adds missing properties (undefined values). Existing properties,
|
|
418
|
+
* even if null or empty, are preserved and not overwritten.
|
|
419
|
+
*
|
|
420
|
+
* @note The function recursively processes nested objects but does not update properties
|
|
421
|
+
* where the target has a non-object value but the source has an object value.
|
|
422
|
+
*
|
|
423
|
+
* @note This is particularly useful for object factories and default value scenarios.
|
|
424
|
+
*
|
|
425
|
+
* @see LimitedDeepPartial - Type used for the target parameter
|
|
426
|
+
* @see deep_merge - Alternative function that overwrites existing properties
|
|
427
|
+
* @see object_factory_maker - Uses this function for applying partial updates
|
|
428
|
+
* @see isPlainObject - Used to validate object types
|
|
429
|
+
*/
|
|
430
|
+
export declare const deep_update: <T extends {}>(target: LimitedDeepPartial<T>, source: T) => {
|
|
431
|
+
new_obj: T;
|
|
432
|
+
change: boolean;
|
|
433
|
+
};
|
|
434
|
+
|
|
294
435
|
/**
|
|
295
436
|
* A utility type that makes all properties of an object type T optional recursively.
|
|
296
437
|
*
|
|
@@ -358,7 +499,7 @@ export declare type DataViewRendererType = BasicDataViewRendererType | React.Mem
|
|
|
358
499
|
* @see deep_merge - Function that works well with DeepPartial types for object merging
|
|
359
500
|
* @see deep_update - Function that accepts DeepPartial-like objects for updating
|
|
360
501
|
*/
|
|
361
|
-
declare type DeepPartial<T> = T extends object ? {
|
|
502
|
+
export declare type DeepPartial<T> = T extends object ? {
|
|
362
503
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
363
504
|
} : T;
|
|
364
505
|
|
|
@@ -826,7 +967,7 @@ declare interface LibZustandInterface {
|
|
|
826
967
|
* @see Prev - The helper type array that defines available depth values
|
|
827
968
|
* @see deep_update - Function that works with LimitedDeepPartial types
|
|
828
969
|
*/
|
|
829
|
-
declare type LimitedDeepPartial<T, D extends number = 10> = D extends 0 ? T : T extends object ? {
|
|
970
|
+
export declare type LimitedDeepPartial<T, D extends number = 10> = D extends 0 ? T : T extends object ? {
|
|
830
971
|
[K in keyof T]?: LimitedDeepPartial<T[K], Prev[D]>;
|
|
831
972
|
} : T;
|
|
832
973
|
|
|
@@ -1048,6 +1189,58 @@ declare interface NodeType extends Omit<BasicNodeType, "in_trigger" | "io"> {
|
|
|
1048
1189
|
[key: string]: any;
|
|
1049
1190
|
}
|
|
1050
1191
|
|
|
1192
|
+
/**
|
|
1193
|
+
* Creates a factory function that generates objects based on a default template with optional customizations.
|
|
1194
|
+
*
|
|
1195
|
+
* This function returns a factory that can create new instances of objects by:
|
|
1196
|
+
* 1. Deep cloning the default object (using JSON serialization)
|
|
1197
|
+
* 2. Applying optional factory updates to modify the default object
|
|
1198
|
+
* 3. Merging any provided partial object with the result using deep_update
|
|
1199
|
+
*
|
|
1200
|
+
* @template T - The type of the default object and the objects created by the factory
|
|
1201
|
+
*
|
|
1202
|
+
* @param default_obj - The template object that serves as the base for all created objects.
|
|
1203
|
+
* This object will be deep cloned using JSON serialization, so it must be JSON-serializable.
|
|
1204
|
+
*
|
|
1205
|
+
* @param factory_updates - Optional function that receives the cloned default object and returns
|
|
1206
|
+
* a modified version. This is useful for applying dynamic updates or
|
|
1207
|
+
* transformations to the default object before merging with user input.
|
|
1208
|
+
* If undefined, no modifications are applied to the default object.
|
|
1209
|
+
*
|
|
1210
|
+
* @returns A factory function that accepts a partial object and returns a complete object of type T.
|
|
1211
|
+
* The returned factory function:
|
|
1212
|
+
* - Takes an optional LimitedDeepPartial<T> parameter for customizations
|
|
1213
|
+
* - Returns a complete object of type T
|
|
1214
|
+
* - If no parameter is provided, returns the (possibly updated) default object
|
|
1215
|
+
* - If a parameter is provided, deep merges it with the default using deep_update
|
|
1216
|
+
*
|
|
1217
|
+
* @example
|
|
1218
|
+
* ```typescript
|
|
1219
|
+
* // Basic usage
|
|
1220
|
+
* const defaultConfig = { theme: 'light', lang: 'en', features: { darkMode: false } };
|
|
1221
|
+
* const configFactory = object_factory_maker(defaultConfig);
|
|
1222
|
+
*
|
|
1223
|
+
* const config1 = configFactory(); // Returns exact copy of defaultConfig
|
|
1224
|
+
* const config2 = configFactory({ theme: 'dark' }); // { theme: 'dark', lang: 'en', features: { darkMode: false } }
|
|
1225
|
+
* const config3 = configFactory({ features: { darkMode: true } }); // Nested merge
|
|
1226
|
+
*
|
|
1227
|
+
* // With factory updates
|
|
1228
|
+
* const configFactoryWithUpdates = object_factory_maker(
|
|
1229
|
+
* defaultConfig,
|
|
1230
|
+
* (obj) => ({ ...obj, timestamp: Date.now() })
|
|
1231
|
+
* );
|
|
1232
|
+
* const config4 = configFactoryWithUpdates({ theme: 'dark' }); // Includes timestamp
|
|
1233
|
+
* ```
|
|
1234
|
+
*
|
|
1235
|
+
* @note The default object must be JSON-serializable since deep cloning is performed using
|
|
1236
|
+
* JSON.stringify/JSON.parse. Objects with functions, undefined values, symbols, or
|
|
1237
|
+
* circular references will not work correctly.
|
|
1238
|
+
*
|
|
1239
|
+
* @see deep_update - Used internally to merge partial objects with the default
|
|
1240
|
+
* @see LimitedDeepPartial - Type used for the partial object parameter
|
|
1241
|
+
*/
|
|
1242
|
+
export declare const object_factory_maker: <T extends {}>(default_obj: T, factory_updates?: ((obj: T) => T) | undefined) => ((obj?: LimitedDeepPartial<T>) => T);
|
|
1243
|
+
|
|
1051
1244
|
export declare type OutputRendererProps = {};
|
|
1052
1245
|
|
|
1053
1246
|
export declare type OutputRendererType = BasicOutputRendererType | React.MemoExoticComponent<BasicOutputRendererType>;
|
|
@@ -1060,7 +1253,7 @@ declare interface PackedPlugin {
|
|
|
1060
1253
|
|
|
1061
1254
|
declare type PartialSerializedIOType = LimitedDeepPartial<SerializedIOType>;
|
|
1062
1255
|
|
|
1063
|
-
declare type PartialSerializedNodeType = LimitedDeepPartial<SerializedNodeType>;
|
|
1256
|
+
export declare type PartialSerializedNodeType = LimitedDeepPartial<SerializedNodeType>;
|
|
1064
1257
|
|
|
1065
1258
|
declare class PluginManagerHandler extends AbstractFuncNodesReactFlowHandleHandler implements PluginManagerManagerAPI {
|
|
1066
1259
|
plugins: UseBoundStore<StoreApi<{
|
|
@@ -1328,7 +1521,7 @@ declare type SerializedNodeIOMappingType = {
|
|
|
1328
1521
|
[key: string]: SerializedIOType | undefined;
|
|
1329
1522
|
};
|
|
1330
1523
|
|
|
1331
|
-
declare interface SerializedNodeType extends BasicNodeType {
|
|
1524
|
+
export declare interface SerializedNodeType extends BasicNodeType {
|
|
1332
1525
|
in_trigger: boolean;
|
|
1333
1526
|
io: SerializedNodeIOMappingType | SerializedIOType[];
|
|
1334
1527
|
io_order?: string[];
|
|
@@ -1831,10 +2024,13 @@ declare class WorkerSyncManager extends AbstractWorkerHandler {
|
|
|
1831
2024
|
_local_nodeupdates: Map<string, PartialSerializedNodeType>;
|
|
1832
2025
|
_local_groupupdates: Map<string, Partial<NodeGroup>>;
|
|
1833
2026
|
_groupupdatetimer: ReturnType<typeof setTimeout> | undefined;
|
|
2027
|
+
_after_next_sync: ((worker: FuncNodesWorker) => Promise<void>)[];
|
|
1834
2028
|
constructor(context: WorkerSyncManagerContext);
|
|
1835
2029
|
start(): void;
|
|
1836
2030
|
stop(): void;
|
|
1837
2031
|
stepwise_fullsync(): Promise<void>;
|
|
2032
|
+
add_after_next_sync(callback: (worker: FuncNodesWorker) => Promise<void>): void;
|
|
2033
|
+
remove_after_next_sync(callback: (worker: FuncNodesWorker) => Promise<void>): void;
|
|
1838
2034
|
sync_lib(): Promise<void>;
|
|
1839
2035
|
sync_external_worker(): Promise<void>;
|
|
1840
2036
|
sync_funcnodes_plugins(): Promise<void>;
|