@keload/node-red-dxp 1.5.0 → 1.7.0

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.
@@ -1,72 +1,6 @@
1
+ import { merge } from '../chunk-DATO2UPN.js';
1
2
  import { createSignal, onCleanup, createEffect } from 'solid-js';
2
3
 
3
- // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js
4
- function getType(payload) {
5
- return Object.prototype.toString.call(payload).slice(8, -1);
6
- }
7
-
8
- // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js
9
- function isPlainObject(payload) {
10
- if (getType(payload) !== "Object")
11
- return false;
12
- const prototype = Object.getPrototypeOf(payload);
13
- return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
14
- }
15
-
16
- // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isSymbol.js
17
- function isSymbol(payload) {
18
- return getType(payload) === "Symbol";
19
- }
20
-
21
- // node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/merge.js
22
- function assignProp(carry, key, newVal, originalObject) {
23
- const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
24
- if (propType === "enumerable")
25
- carry[key] = newVal;
26
- if (propType === "nonenumerable") {
27
- Object.defineProperty(carry, key, {
28
- value: newVal,
29
- enumerable: false,
30
- writable: true,
31
- configurable: true
32
- });
33
- }
34
- }
35
- function mergeRecursively(origin, newComer, compareFn) {
36
- if (!isPlainObject(newComer))
37
- return newComer;
38
- let newObject = {};
39
- if (isPlainObject(origin)) {
40
- const props2 = Object.getOwnPropertyNames(origin);
41
- const symbols2 = Object.getOwnPropertySymbols(origin);
42
- newObject = [...props2, ...symbols2].reduce((carry, key) => {
43
- const targetVal = origin[key];
44
- if (!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) {
45
- assignProp(carry, key, targetVal, origin);
46
- }
47
- return carry;
48
- }, {});
49
- }
50
- const props = Object.getOwnPropertyNames(newComer);
51
- const symbols = Object.getOwnPropertySymbols(newComer);
52
- const result = [...props, ...symbols].reduce((carry, key) => {
53
- let newVal = newComer[key];
54
- const targetVal = isPlainObject(origin) ? origin[key] : void 0;
55
- if (targetVal !== void 0 && isPlainObject(newVal)) {
56
- newVal = mergeRecursively(targetVal, newVal);
57
- }
58
- const propToAssign = newVal;
59
- assignProp(carry, key, propToAssign, newComer);
60
- return carry;
61
- }, newObject);
62
- return result;
63
- }
64
- function merge(object, ...otherObjects) {
65
- return otherObjects.reduce((result, newComer) => {
66
- return mergeRecursively(result, newComer);
67
- }, object);
68
- }
69
-
70
4
  // src/editor/utils.ts
71
5
  function resolveSelector(inSelector) {
72
6
  if (inSelector.startsWith("$$")) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js","../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js","../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isSymbol.js","../../node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/merge.js","../../src/editor/utils.ts","../../src/editor/dom.ts","../../src/editor/index.ts"],"names":["props","symbols"],"mappings":";;;AACO,SAAS,QAAQ,OAAS,EAAA;AAC7B,EAAO,OAAA,MAAA,CAAO,UAAU,QAAS,CAAA,IAAA,CAAK,OAAO,CAAE,CAAA,KAAA,CAAM,GAAG,CAAE,CAAA,CAAA;AAC9D;;;ACEO,SAAS,cAAc,OAAS,EAAA;AACnC,EAAI,IAAA,OAAA,CAAQ,OAAO,CAAM,KAAA,QAAA;AACrB,IAAO,OAAA,KAAA;AACX,EAAM,MAAA,SAAA,GAAY,MAAO,CAAA,cAAA,CAAe,OAAO,CAAA;AAC/C,EAAA,OAAO,CAAC,CAAC,SAAA,IAAa,UAAU,WAAgB,KAAA,MAAA,IAAU,cAAc,MAA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AAA;AAEP,MAAA,QAAA,CAAS,MAAM,CAAA;AAAA,KAChB,CAAA;AAAA;AAGH,EAAO,OAAA;AAAA,IACL,aAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/** Returns the object type of the given payload */\nexport function getType(payload) {\n return Object.prototype.toString.call(payload).slice(8, -1);\n}\n","import { getType } from './getType.js';\n/**\n * Returns whether the payload is a plain JavaScript object (excluding special classes or objects\n * with other prototypes)\n */\nexport function isPlainObject(payload) {\n if (getType(payload) !== 'Object')\n return false;\n const prototype = Object.getPrototypeOf(payload);\n return !!prototype && prototype.constructor === Object && prototype === Object.prototype;\n}\n","import { getType } from './getType.js';\n/** Returns whether the payload is a Symbol */\nexport function isSymbol(payload) {\n return getType(payload) === 'Symbol';\n}\n","import { isPlainObject, isSymbol } from 'is-what';\nimport { concatArrays } from './extensions.js';\nfunction assignProp(carry, key, newVal, originalObject) {\n const propType = {}.propertyIsEnumerable.call(originalObject, key)\n ? 'enumerable'\n : 'nonenumerable';\n if (propType === 'enumerable')\n carry[key] = newVal;\n if (propType === 'nonenumerable') {\n Object.defineProperty(carry, key, {\n value: newVal,\n enumerable: false,\n writable: true,\n configurable: true,\n });\n }\n}\nfunction mergeRecursively(origin, newComer, compareFn) {\n // always return newComer if its not an object\n if (!isPlainObject(newComer))\n return newComer;\n // define newObject to merge all values upon\n let newObject = {};\n if (isPlainObject(origin)) {\n const props = Object.getOwnPropertyNames(origin);\n const symbols = Object.getOwnPropertySymbols(origin);\n newObject = [...props, ...symbols].reduce((carry, key) => {\n const targetVal = origin[key];\n if ((!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key)) ||\n (isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key))) {\n assignProp(carry, key, targetVal, origin);\n }\n return carry;\n }, {});\n }\n // newObject has all properties that newComer hasn't\n const props = Object.getOwnPropertyNames(newComer);\n const symbols = Object.getOwnPropertySymbols(newComer);\n const result = [...props, ...symbols].reduce((carry, key) => {\n // re-define the origin and newComer as targetVal and newVal\n let newVal = newComer[key];\n const targetVal = isPlainObject(origin) ? origin[key] : undefined;\n // When newVal is an object do the merge recursively\n if (targetVal !== undefined && isPlainObject(newVal)) {\n newVal = mergeRecursively(targetVal, newVal, compareFn);\n }\n const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal;\n assignProp(carry, key, propToAssign, newComer);\n return carry;\n }, newObject);\n return result;\n}\n/**\n * Merge anything recursively.\n * Objects get merged, special objects (classes etc.) are re-assigned \"as is\".\n * Basic types overwrite objects or other basic types.\n */\nexport function merge(object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer);\n }, object);\n}\nexport function mergeAndCompare(compareFn, object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer, compareFn);\n }, object);\n}\nexport function mergeAndConcat(object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer, concatArrays);\n }, object);\n}\n// import { Timestamp } from '../test/Timestamp'\n// type T1 = { date: Timestamp }\n// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }]\n// type TestT = Merge<T1, T2>\n// type A1 = { arr: string[] }\n// type A2 = { arr: number[] }\n// type A3 = { arr: boolean[] }\n// type TestA = Merge<A1, [A2, A3]>\n// interface I1 {\n// date: Timestamp\n// }\n// interface I2 {\n// date: Timestamp\n// }\n// const _a: I2 = { date: '' } as unknown as I2\n// type TestI = Merge<I1, [I2]>\n// // ReturnType<(typeof merge)<I1, I2>>\n// const a = merge(_a, [_a])\n// interface Arguments extends Record<string | number | symbol, unknown> {\n// key: string;\n// }\n// const aa1: Arguments = { key: \"value1\" }\n// const aa2: Arguments = { key: \"value2\" }\n// const aa = merge(a1, a2);\n// interface Barguments {\n// key: string\n// }\n// const ba1: Barguments = { key: 'value1' }\n// const ba2: Barguments = { key: 'value2' }\n// const ba = merge(ba1, ba2)\n// interface Carguments {\n// key: string\n// }\n// const ca = merge<Carguments, Carguments[]>({ key: 'value1' }, { key: 'value2' })\n// type P = Pop<Carguments[]>\n","export function resolveSelector(inSelector: string) {\n if (inSelector.startsWith('$$')) {\n return `#node-config-input-${inSelector.replace('$$', '')}`;\n }\n\n if (inSelector.startsWith('$')) {\n return `#node-input-${inSelector.replace('$', '')}`;\n }\n\n return inSelector;\n}\n\nfunction isNodeInput(selector: string) {\n const isShortcut = selector.startsWith('$$') || selector.startsWith('$');\n const isFullSelector = selector.startsWith('#node-config-input') || selector.startsWith('#node-input');\n\n return isShortcut || isFullSelector;\n}\n","import { createEffect, createSignal, onCleanup } from 'solid-js';\nimport { resolveSelector } from './utils';\n\nexport function createReactiveField<T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>(\n selector: string,\n defaultValue?: string,\n): [() => string, (value: string) => void] {\n const realSelector = resolveSelector(selector);\n\n const formElement = document.querySelector(realSelector) as T;\n\n if (!formElement) {\n throw new Error(`Element with id '${selector}' not found`);\n }\n\n const [fieldValue, setFieldValue] = createSignal(defaultValue || '');\n\n const updateSignal = () => {\n setFieldValue(formElement.value);\n };\n\n const updateDOM = (newValue: string) => {\n if (formElement.value !== newValue) {\n formElement.value = newValue;\n }\n };\n\n formElement.addEventListener('input', updateSignal);\n\n onCleanup(() => {\n console.log('JE CLEAN');\n formElement.removeEventListener('input', updateSignal);\n });\n\n createEffect(() => {\n updateDOM(fieldValue());\n });\n\n setFieldValue(formElement.value || defaultValue);\n\n return [fieldValue, setFieldValue];\n}\n","// @ts-ignore\nimport { merge } from 'merge-anything';\nimport type { EditorNodeDef, EditorNodeInstance, EditorNodeProperties } from 'node-red';\nimport type { EditorDomHelper } from './types';\nimport { resolveSelector } from './utils';\nexport type * from './types';\nexport * from './utils';\nexport * from './dom';\n\nconst defaultNodeDef: Partial<EditorNodeDef> = {};\n\nexport function createEditorNode<\n TProps extends EditorNodeProperties,\n TCreds = undefined,\n TInstProps extends TProps = TProps,\n>(props: Partial<EditorNodeDef<TProps, TCreds, TInstProps>>): EditorNodeDef<TProps, TCreds, TInstProps> {\n return merge(defaultNodeDef, props) as EditorNodeDef<TProps, TCreds, TInstProps>;\n}\n\nfunction resolveInputKey(selector: string) {\n const realSelector = resolveSelector(selector);\n return realSelector.split('-input-')[1];\n}\n\nexport function domHelper<TProps>(vm: EditorNodeInstance) {\n function getVmInputKey(key: string) {\n return vm[key];\n }\n\n const initSelect = (\n selector: string,\n options: Record<string, string>[],\n params?: EditorDomHelper.InitSelectParams,\n ) => {\n const selectedValue = params?.selected || getVmInputKey(resolveInputKey(selector));\n const realSelector = resolveSelector(selector);\n let realOptions = options;\n if (params?.emptyValue) {\n realOptions = [{ value: '', text: params.emptyValue }, ...options];\n }\n $(realSelector)\n .empty()\n .append(\n realOptions.map((opt) => {\n return $('<option>', { value: opt.value, text: opt.text, selected: opt.value === selectedValue });\n }),\n );\n };\n\n const getInputValue = (key: Exclude<keyof TProps, 'inputs'>) => {\n const keyStr = key as string;\n return $(`#node-input-${keyStr}`).val();\n };\n\n function setText(selector: string, text: string) {\n const realSelector = resolveSelector(selector);\n $(realSelector).text(text);\n }\n\n function jqSelector(selector: string) {\n const realSelector = resolveSelector(selector);\n return $(realSelector);\n }\n\n function setInputValue(selector: string, val: string) {\n const realSelector = resolveSelector(selector);\n $(realSelector).val(val);\n }\n\n function watchInput<T = any>(selectors: string | string[], callback: (values: T[]) => void) {\n const selectorsArray = Array.isArray(selectors) ? selectors : [selectors];\n const realSelectors = selectorsArray.map(resolveSelector).join(', ');\n\n $(realSelectors).on('input', () => {\n const values = $(realSelectors)\n .map(function () {\n return $(this).val() as T;\n })\n .get();\n\n callback(values);\n });\n }\n\n return {\n getInputValue,\n watchInput,\n setText,\n setInputValue,\n jqSelector,\n initSelect,\n };\n}\n"]}
1
+ {"version":3,"sources":["../../src/editor/utils.ts","../../src/editor/dom.ts","../../src/editor/index.ts"],"names":[],"mappings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A;AAAA,OACpB,EACA,GAAI,EAAA;AAEP,MAAA,QAAA,CAAS,MAAM,CAAA;AAAA,KAChB,CAAA;AAAA;AAGH,EAAO,OAAA;AAAA,IACL,aAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["export function resolveSelector(inSelector: string) {\n if (inSelector.startsWith('$$')) {\n return `#node-config-input-${inSelector.replace('$$', '')}`;\n }\n\n if (inSelector.startsWith('$')) {\n return `#node-input-${inSelector.replace('$', '')}`;\n }\n\n return inSelector;\n}\n\nfunction isNodeInput(selector: string) {\n const isShortcut = selector.startsWith('$$') || selector.startsWith('$');\n const isFullSelector = selector.startsWith('#node-config-input') || selector.startsWith('#node-input');\n\n return isShortcut || isFullSelector;\n}\n","import { createEffect, createSignal, onCleanup } from 'solid-js';\nimport { resolveSelector } from './utils';\n\nexport function createReactiveField<T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>(\n selector: string,\n defaultValue?: string,\n): [() => string, (value: string) => void] {\n const realSelector = resolveSelector(selector);\n\n const formElement = document.querySelector(realSelector) as T;\n\n if (!formElement) {\n throw new Error(`Element with id '${selector}' not found`);\n }\n\n const [fieldValue, setFieldValue] = createSignal(defaultValue || '');\n\n const updateSignal = () => {\n setFieldValue(formElement.value);\n };\n\n const updateDOM = (newValue: string) => {\n if (formElement.value !== newValue) {\n formElement.value = newValue;\n }\n };\n\n formElement.addEventListener('input', updateSignal);\n\n onCleanup(() => {\n console.log('JE CLEAN');\n formElement.removeEventListener('input', updateSignal);\n });\n\n createEffect(() => {\n updateDOM(fieldValue());\n });\n\n setFieldValue(formElement.value || defaultValue);\n\n return [fieldValue, setFieldValue];\n}\n","// @ts-ignore\nimport { merge } from 'merge-anything';\nimport type { EditorNodeDef, EditorNodeInstance, EditorNodeProperties } from 'node-red';\nimport type { EditorDomHelper } from './types';\nimport { resolveSelector } from './utils';\nexport type * from './types';\nexport * from './utils';\nexport * from './dom';\n\nconst defaultNodeDef: Partial<EditorNodeDef> = {};\n\nexport function createEditorNode<\n TProps extends EditorNodeProperties,\n TCreds = undefined,\n TInstProps extends TProps = TProps,\n>(props: Partial<EditorNodeDef<TProps, TCreds, TInstProps>>): EditorNodeDef<TProps, TCreds, TInstProps> {\n return merge(defaultNodeDef, props) as EditorNodeDef<TProps, TCreds, TInstProps>;\n}\n\nfunction resolveInputKey(selector: string) {\n const realSelector = resolveSelector(selector);\n return realSelector.split('-input-')[1];\n}\n\nexport function domHelper<TProps>(vm: EditorNodeInstance) {\n function getVmInputKey(key: string) {\n return vm[key];\n }\n\n const initSelect = (\n selector: string,\n options: Record<string, string>[],\n params?: EditorDomHelper.InitSelectParams,\n ) => {\n const selectedValue = params?.selected || getVmInputKey(resolveInputKey(selector));\n const realSelector = resolveSelector(selector);\n let realOptions = options;\n if (params?.emptyValue) {\n realOptions = [{ value: '', text: params.emptyValue }, ...options];\n }\n $(realSelector)\n .empty()\n .append(\n realOptions.map((opt) => {\n return $('<option>', { value: opt.value, text: opt.text, selected: opt.value === selectedValue });\n }),\n );\n };\n\n const getInputValue = (key: Exclude<keyof TProps, 'inputs'>) => {\n const keyStr = key as string;\n return $(`#node-input-${keyStr}`).val();\n };\n\n function setText(selector: string, text: string) {\n const realSelector = resolveSelector(selector);\n $(realSelector).text(text);\n }\n\n function jqSelector(selector: string) {\n const realSelector = resolveSelector(selector);\n return $(realSelector);\n }\n\n function setInputValue(selector: string, val: string) {\n const realSelector = resolveSelector(selector);\n $(realSelector).val(val);\n }\n\n function watchInput<T = any>(selectors: string | string[], callback: (values: T[]) => void) {\n const selectorsArray = Array.isArray(selectors) ? selectors : [selectors];\n const realSelectors = selectorsArray.map(resolveSelector).join(', ');\n\n $(realSelectors).on('input', () => {\n const values = $(realSelectors)\n .map(function () {\n return $(this).val() as T;\n })\n .get();\n\n callback(values);\n });\n }\n\n return {\n getInputValue,\n watchInput,\n setText,\n setInputValue,\n jqSelector,\n initSelect,\n };\n}\n"]}
package/dist/utils.cjs ADDED
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
3
+ var isIp = require('is-ip');
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var validators = {
11
+ isIP: isIp.isIP,
12
+ isIPv4: isIp.isIPv4,
13
+ isIPv6: isIp.isIPv6,
14
+ ipVersion: isIp.ipVersion
15
+ };
16
+
17
+ // node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/index.js
18
+ var dist_exports = {};
19
+ __export(dist_exports, {
20
+ concatArrays: () => concatArrays,
21
+ merge: () => merge,
22
+ mergeAndCompare: () => mergeAndCompare,
23
+ mergeAndConcat: () => mergeAndConcat
24
+ });
25
+
26
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js
27
+ function getType(payload) {
28
+ return Object.prototype.toString.call(payload).slice(8, -1);
29
+ }
30
+
31
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isArray.js
32
+ function isArray(payload) {
33
+ return getType(payload) === "Array";
34
+ }
35
+
36
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js
37
+ function isPlainObject(payload) {
38
+ if (getType(payload) !== "Object")
39
+ return false;
40
+ const prototype = Object.getPrototypeOf(payload);
41
+ return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
42
+ }
43
+
44
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isSymbol.js
45
+ function isSymbol(payload) {
46
+ return getType(payload) === "Symbol";
47
+ }
48
+
49
+ // node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/extensions.js
50
+ function concatArrays(originVal, newVal) {
51
+ if (isArray(originVal) && isArray(newVal)) {
52
+ return originVal.concat(newVal);
53
+ }
54
+ return newVal;
55
+ }
56
+
57
+ // node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/merge.js
58
+ function assignProp(carry, key, newVal, originalObject) {
59
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
60
+ if (propType === "enumerable")
61
+ carry[key] = newVal;
62
+ if (propType === "nonenumerable") {
63
+ Object.defineProperty(carry, key, {
64
+ value: newVal,
65
+ enumerable: false,
66
+ writable: true,
67
+ configurable: true
68
+ });
69
+ }
70
+ }
71
+ function mergeRecursively(origin, newComer, compareFn) {
72
+ if (!isPlainObject(newComer))
73
+ return newComer;
74
+ let newObject = {};
75
+ if (isPlainObject(origin)) {
76
+ const props2 = Object.getOwnPropertyNames(origin);
77
+ const symbols2 = Object.getOwnPropertySymbols(origin);
78
+ newObject = [...props2, ...symbols2].reduce((carry, key) => {
79
+ const targetVal = origin[key];
80
+ if (!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) {
81
+ assignProp(carry, key, targetVal, origin);
82
+ }
83
+ return carry;
84
+ }, {});
85
+ }
86
+ const props = Object.getOwnPropertyNames(newComer);
87
+ const symbols = Object.getOwnPropertySymbols(newComer);
88
+ const result = [...props, ...symbols].reduce((carry, key) => {
89
+ let newVal = newComer[key];
90
+ const targetVal = isPlainObject(origin) ? origin[key] : void 0;
91
+ if (targetVal !== void 0 && isPlainObject(newVal)) {
92
+ newVal = mergeRecursively(targetVal, newVal, compareFn);
93
+ }
94
+ const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal;
95
+ assignProp(carry, key, propToAssign, newComer);
96
+ return carry;
97
+ }, newObject);
98
+ return result;
99
+ }
100
+ function merge(object, ...otherObjects) {
101
+ return otherObjects.reduce((result, newComer) => {
102
+ return mergeRecursively(result, newComer);
103
+ }, object);
104
+ }
105
+ function mergeAndCompare(compareFn, object, ...otherObjects) {
106
+ return otherObjects.reduce((result, newComer) => {
107
+ return mergeRecursively(result, newComer, compareFn);
108
+ }, object);
109
+ }
110
+ function mergeAndConcat(object, ...otherObjects) {
111
+ return otherObjects.reduce((result, newComer) => {
112
+ return mergeRecursively(result, newComer, concatArrays);
113
+ }, object);
114
+ }
115
+
116
+ exports.mergeAnything = dist_exports;
117
+ exports.validators = validators;
118
+ //# sourceMappingURL=utils.cjs.map
119
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/validators.ts","../node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/index.js","../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js","../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isArray.js","../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js","../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isSymbol.js","../node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/extensions.js","../node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/merge.js"],"names":["isIP","isIPv4","isIPv6","ipVersion","props","symbols"],"mappings":";;;;;;;;;AAEO,IAAM,UAAa,GAAA;AAAA,QACxBA,SAAA;AAAA,UACAC,WAAA;AAAA,UACAC,WAAA;AAAA,aACAC;AACF;;;ACPA,IAAA,YAAA,GAAA;AAAA,QAAA,CAAA,YAAA,EAAA;AAAA,EAAA,YAAA,EAAA,MAAA,YAAA;AAAA,EAAA,KAAA,EAAA,MAAA,KAAA;AAAA,EAAA,eAAA,EAAA,MAAA,eAAA;AAAA,EAAA,cAAA,EAAA,MAAA;AAAA,CAAA,CAAA;;;ACCO,SAAS,QAAQ,OAAS,EAAA;AAC7B,EAAO,OAAA,MAAA,CAAO,UAAU,QAAS,CAAA,IAAA,CAAK,OAAO,CAAE,CAAA,KAAA,CAAM,GAAG,CAAE,CAAA,CAAA;AAC9D;;;ACDO,SAAS,QAAQ,OAAS,EAAA;AAC7B,EAAO,OAAA,OAAA,CAAQ,OAAO,CAAM,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M,CAAG,EAAA;AAClD,MAAS,MAAA,GAAA,gBAAA,CAAiB,SAAW,EAAA,MAAA,EAAQ,SAAS,CAAA;AAAA;AAE1D,IAAA,MAAM,eAAe,SAAY,GAAA,SAAA,CAAU,SAAW,EAAA,MAAA,EAAQ,GAAG,CAAI,GAAA,MAAA;AACrE,IAAW,UAAA,CAAA,KAAA,EAAO,GAAK,EAAA,YAAA,EAAc,QAAQ,CAAA;AAC7C,IAAO,OAAA,KAAA;AAAA,KACR,SAAS,CAAA;AACZ,EAAO,OAAA,MAAA;AACX;AAMO,SAAS,KAAA,CAAM,WAAW,YAAc,EAAA;AAC3C,EAAA,OAAO,YAAa,CAAA,MAAA,CAAO,CAAC,MAAA,EAAQ,QAAa,KAAA;AAC7C,IAAO,OAAA,gBAAA,CAAiB,QAAQ,QAAQ,CAAA;AAAA,KACzC,MAAM,CAAA;AACb;AACO,SAAS,eAAA,CAAgB,SAAW,EAAA,MAAA,EAAA,GAAW,YAAc,EAAA;AAChE,EAAA,OAAO,YAAa,CAAA,MAAA,CAAO,CAAC,MAAA,EAAQ,QAAa,KAAA;AAC7C,IAAO,OAAA,gBAAA,CAAiB,MAAQ,EAAA,QAAA,EAAU,SAAS,CAAA;AAAA,KACpD,MAAM,CAAA;AACb;AACO,SAAS,cAAA,CAAe,WAAW,YAAc,EAAA;AACpD,EAAA,OAAO,YAAa,CAAA,MAAA,CAAO,CAAC,MAAA,EAAQ,QAAa,KAAA;AAC7C,IAAO,OAAA,gBAAA,CAAiB,MAAQ,EAAA,QAAA,EAAU,YAAY,CAAA;AAAA,KACvD,MAAM,CAAA;AACb","file":"utils.cjs","sourcesContent":["import { ipVersion, isIP, isIPv4, isIPv6 } from 'is-ip';\n\nexport const validators = {\n isIP,\n isIPv4,\n isIPv6,\n ipVersion,\n};\n","export * from './extensions.js';\nexport * from './merge.js';\n","/** Returns the object type of the given payload */\nexport function getType(payload) {\n return Object.prototype.toString.call(payload).slice(8, -1);\n}\n","import { getType } from './getType.js';\n/** Returns whether the payload is an array */\nexport function isArray(payload) {\n return getType(payload) === 'Array';\n}\n","import { getType } from './getType.js';\n/**\n * Returns whether the payload is a plain JavaScript object (excluding special classes or objects\n * with other prototypes)\n */\nexport function isPlainObject(payload) {\n if (getType(payload) !== 'Object')\n return false;\n const prototype = Object.getPrototypeOf(payload);\n return !!prototype && prototype.constructor === Object && prototype === Object.prototype;\n}\n","import { getType } from './getType.js';\n/** Returns whether the payload is a Symbol */\nexport function isSymbol(payload) {\n return getType(payload) === 'Symbol';\n}\n","import { isArray } from 'is-what';\nexport function concatArrays(originVal, newVal) {\n if (isArray(originVal) && isArray(newVal)) {\n // concat logic\n return originVal.concat(newVal);\n }\n return newVal; // always return newVal as fallback!!\n}\n","import { isPlainObject, isSymbol } from 'is-what';\nimport { concatArrays } from './extensions.js';\nfunction assignProp(carry, key, newVal, originalObject) {\n const propType = {}.propertyIsEnumerable.call(originalObject, key)\n ? 'enumerable'\n : 'nonenumerable';\n if (propType === 'enumerable')\n carry[key] = newVal;\n if (propType === 'nonenumerable') {\n Object.defineProperty(carry, key, {\n value: newVal,\n enumerable: false,\n writable: true,\n configurable: true,\n });\n }\n}\nfunction mergeRecursively(origin, newComer, compareFn) {\n // always return newComer if its not an object\n if (!isPlainObject(newComer))\n return newComer;\n // define newObject to merge all values upon\n let newObject = {};\n if (isPlainObject(origin)) {\n const props = Object.getOwnPropertyNames(origin);\n const symbols = Object.getOwnPropertySymbols(origin);\n newObject = [...props, ...symbols].reduce((carry, key) => {\n const targetVal = origin[key];\n if ((!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key)) ||\n (isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key))) {\n assignProp(carry, key, targetVal, origin);\n }\n return carry;\n }, {});\n }\n // newObject has all properties that newComer hasn't\n const props = Object.getOwnPropertyNames(newComer);\n const symbols = Object.getOwnPropertySymbols(newComer);\n const result = [...props, ...symbols].reduce((carry, key) => {\n // re-define the origin and newComer as targetVal and newVal\n let newVal = newComer[key];\n const targetVal = isPlainObject(origin) ? origin[key] : undefined;\n // When newVal is an object do the merge recursively\n if (targetVal !== undefined && isPlainObject(newVal)) {\n newVal = mergeRecursively(targetVal, newVal, compareFn);\n }\n const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal;\n assignProp(carry, key, propToAssign, newComer);\n return carry;\n }, newObject);\n return result;\n}\n/**\n * Merge anything recursively.\n * Objects get merged, special objects (classes etc.) are re-assigned \"as is\".\n * Basic types overwrite objects or other basic types.\n */\nexport function merge(object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer);\n }, object);\n}\nexport function mergeAndCompare(compareFn, object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer, compareFn);\n }, object);\n}\nexport function mergeAndConcat(object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer, concatArrays);\n }, object);\n}\n// import { Timestamp } from '../test/Timestamp'\n// type T1 = { date: Timestamp }\n// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }]\n// type TestT = Merge<T1, T2>\n// type A1 = { arr: string[] }\n// type A2 = { arr: number[] }\n// type A3 = { arr: boolean[] }\n// type TestA = Merge<A1, [A2, A3]>\n// interface I1 {\n// date: Timestamp\n// }\n// interface I2 {\n// date: Timestamp\n// }\n// const _a: I2 = { date: '' } as unknown as I2\n// type TestI = Merge<I1, [I2]>\n// // ReturnType<(typeof merge)<I1, I2>>\n// const a = merge(_a, [_a])\n// interface Arguments extends Record<string | number | symbol, unknown> {\n// key: string;\n// }\n// const aa1: Arguments = { key: \"value1\" }\n// const aa2: Arguments = { key: \"value2\" }\n// const aa = merge(a1, a2);\n// interface Barguments {\n// key: string\n// }\n// const ba1: Barguments = { key: 'value1' }\n// const ba2: Barguments = { key: 'value2' }\n// const ba = merge(ba1, ba2)\n// interface Carguments {\n// key: string\n// }\n// const ca = merge<Carguments, Carguments[]>({ key: 'value1' }, { key: 'value2' })\n// type P = Pop<Carguments[]>\n"]}
@@ -0,0 +1,12 @@
1
+ import { isIP, isIPv4, isIPv6, ipVersion } from 'is-ip';
2
+ import * as mergeAnything from 'merge-anything';
3
+ export { mergeAnything };
4
+
5
+ declare const validators: {
6
+ isIP: typeof isIP;
7
+ isIPv4: typeof isIPv4;
8
+ isIPv6: typeof isIPv6;
9
+ ipVersion: typeof ipVersion;
10
+ };
11
+
12
+ export { validators };
@@ -0,0 +1,12 @@
1
+ import { isIP, isIPv4, isIPv6, ipVersion } from 'is-ip';
2
+ import * as mergeAnything from 'merge-anything';
3
+ export { mergeAnything };
4
+
5
+ declare const validators: {
6
+ isIP: typeof isIP;
7
+ isIPv4: typeof isIPv4;
8
+ isIPv6: typeof isIPv6;
9
+ ipVersion: typeof ipVersion;
10
+ };
11
+
12
+ export { validators };
package/dist/utils.js ADDED
@@ -0,0 +1,13 @@
1
+ export { dist_exports as mergeAnything } from './chunk-DATO2UPN.js';
2
+ import { isIP, isIPv4, isIPv6, ipVersion } from 'is-ip';
3
+
4
+ var validators = {
5
+ isIP,
6
+ isIPv4,
7
+ isIPv6,
8
+ ipVersion
9
+ };
10
+
11
+ export { validators };
12
+ //# sourceMappingURL=utils.js.map
13
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/validators.ts"],"names":[],"mappings":";;;AAEO,IAAM,UAAa,GAAA;AAAA,EACxB,IAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF","file":"utils.js","sourcesContent":["import { ipVersion, isIP, isIPv4, isIPv6 } from 'is-ip';\n\nexport const validators = {\n isIP,\n isIPv4,\n isIPv6,\n ipVersion,\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keload/node-red-dxp",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -31,6 +31,14 @@
31
31
  "import": "./dist/editor/index.js",
32
32
  "require": "./dist/editor/index.cjs"
33
33
  },
34
+ "./builder": {
35
+ "import": "./dist/builder/index.js",
36
+ "require": "./dist/builder/index.cjs"
37
+ },
38
+ "./utils": {
39
+ "import": "./dist/utils.js",
40
+ "require": "./dist/utils.cjs"
41
+ },
34
42
  "./package.json": "./package.json"
35
43
  },
36
44
  "keywords": [],
@@ -47,7 +55,6 @@
47
55
  "devDependencies": {
48
56
  "@biomejs/biome": "1.9.4",
49
57
  "@release-it/conventional-changelog": "9.0.3",
50
- "@types/handlebars": "4.1.0",
51
58
  "release-it": "17.10.0",
52
59
  "tsup": "8.3.5",
53
60
  "tsx": "4.19.2",
@@ -70,9 +77,10 @@
70
77
  "cosmiconfig": "9.0.0",
71
78
  "cssnano": "^7.0.6",
72
79
  "esbuild": "0.24.0",
73
- "glob": "11.0.0",
80
+ "fast-glob": "^3.3.2",
74
81
  "handlebars": "4.7.8",
75
82
  "html-minifier-terser": "7.2.0",
83
+ "is-ip": "^5.0.1",
76
84
  "merge-anything": "6.0.2",
77
85
  "nodemon": "3.1.7",
78
86
  "ora": "8.1.1",