@n8n/composables 1.15.0 → 1.17.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.
@@ -0,0 +1,36 @@
1
+ let vue = require("vue");
2
+
3
+ //#region src/structuralComputed.ts
4
+ /**
5
+ * Wraps a derivation in a `computed` that returns the same reference when the
6
+ * new value is considered equal to the previous one by the provided `isEqual`
7
+ * function (defaults to `Object.is`).
8
+ *
9
+ * Vue's `computed` uses `Object.is` on return values to decide whether to
10
+ * notify subscribers. By returning a stable reference on equal content,
11
+ * consumers only re-render when the value actually changes — without each
12
+ * consumer writing its own equality gate.
13
+ *
14
+ * Typical use: pass a deep-equality function (e.g. `lodash/isEqual`) for
15
+ * derivations that produce fresh objects/arrays on every evaluation but are
16
+ * structurally identical most of the time.
17
+ *
18
+ * @example
19
+ * import isEqual from 'lodash/isEqual';
20
+ * const ports = structuralComputed(() => computePorts(...), isEqual);
21
+ */
22
+ function structuralComputed(derive, isEqual = Object.is) {
23
+ let cached;
24
+ let primed = false;
25
+ return (0, vue.computed)(() => {
26
+ const next = derive();
27
+ if (primed && isEqual(cached, next)) return cached;
28
+ cached = next;
29
+ primed = true;
30
+ return cached;
31
+ });
32
+ }
33
+
34
+ //#endregion
35
+ exports.structuralComputed = structuralComputed;
36
+ //# sourceMappingURL=structuralComputed.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structuralComputed.cjs","names":["cached: T"],"sources":["../src/structuralComputed.ts"],"sourcesContent":["import { computed, type ComputedRef } from 'vue';\n\n/**\n * Wraps a derivation in a `computed` that returns the same reference when the\n * new value is considered equal to the previous one by the provided `isEqual`\n * function (defaults to `Object.is`).\n *\n * Vue's `computed` uses `Object.is` on return values to decide whether to\n * notify subscribers. By returning a stable reference on equal content,\n * consumers only re-render when the value actually changes — without each\n * consumer writing its own equality gate.\n *\n * Typical use: pass a deep-equality function (e.g. `lodash/isEqual`) for\n * derivations that produce fresh objects/arrays on every evaluation but are\n * structurally identical most of the time.\n *\n * @example\n * import isEqual from 'lodash/isEqual';\n * const ports = structuralComputed(() => computePorts(...), isEqual);\n */\nexport function structuralComputed<T>(\n\tderive: () => T,\n\tisEqual: (a: T, b: T) => boolean = Object.is,\n): ComputedRef<T> {\n\tlet cached: T;\n\tlet primed = false;\n\treturn computed<T>(() => {\n\t\tconst next = derive();\n\t\tif (primed && isEqual(cached, next)) return cached;\n\t\tcached = next;\n\t\tprimed = true;\n\t\treturn cached;\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mBACf,QACA,UAAmC,OAAO,IACzB;CACjB,IAAIA;CACJ,IAAI,SAAS;AACb,gCAAyB;EACxB,MAAM,OAAO,QAAQ;AACrB,MAAI,UAAU,QAAQ,QAAQ,KAAK,CAAE,QAAO;AAC5C,WAAS;AACT,WAAS;AACT,SAAO;GACN"}
@@ -0,0 +1,7 @@
1
+ import { ComputedRef } from "vue";
2
+
3
+ //#region src/structuralComputed.d.ts
4
+ declare function structuralComputed<T>(derive: () => T, isEqual?: (a: T, b: T) => boolean): ComputedRef<T>;
5
+ //#endregion
6
+ export { structuralComputed };
7
+ //# sourceMappingURL=structuralComputed.d.cts.map
@@ -0,0 +1,7 @@
1
+ import { ComputedRef } from "vue";
2
+
3
+ //#region src/structuralComputed.d.ts
4
+ declare function structuralComputed<T>(derive: () => T, isEqual?: (a: T, b: T) => boolean): ComputedRef<T>;
5
+ //#endregion
6
+ export { structuralComputed };
7
+ //# sourceMappingURL=structuralComputed.d.mts.map
@@ -0,0 +1,36 @@
1
+ import { computed } from "vue";
2
+
3
+ //#region src/structuralComputed.ts
4
+ /**
5
+ * Wraps a derivation in a `computed` that returns the same reference when the
6
+ * new value is considered equal to the previous one by the provided `isEqual`
7
+ * function (defaults to `Object.is`).
8
+ *
9
+ * Vue's `computed` uses `Object.is` on return values to decide whether to
10
+ * notify subscribers. By returning a stable reference on equal content,
11
+ * consumers only re-render when the value actually changes — without each
12
+ * consumer writing its own equality gate.
13
+ *
14
+ * Typical use: pass a deep-equality function (e.g. `lodash/isEqual`) for
15
+ * derivations that produce fresh objects/arrays on every evaluation but are
16
+ * structurally identical most of the time.
17
+ *
18
+ * @example
19
+ * import isEqual from 'lodash/isEqual';
20
+ * const ports = structuralComputed(() => computePorts(...), isEqual);
21
+ */
22
+ function structuralComputed(derive, isEqual = Object.is) {
23
+ let cached;
24
+ let primed = false;
25
+ return computed(() => {
26
+ const next = derive();
27
+ if (primed && isEqual(cached, next)) return cached;
28
+ cached = next;
29
+ primed = true;
30
+ return cached;
31
+ });
32
+ }
33
+
34
+ //#endregion
35
+ export { structuralComputed };
36
+ //# sourceMappingURL=structuralComputed.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structuralComputed.mjs","names":["cached: T"],"sources":["../src/structuralComputed.ts"],"sourcesContent":["import { computed, type ComputedRef } from 'vue';\n\n/**\n * Wraps a derivation in a `computed` that returns the same reference when the\n * new value is considered equal to the previous one by the provided `isEqual`\n * function (defaults to `Object.is`).\n *\n * Vue's `computed` uses `Object.is` on return values to decide whether to\n * notify subscribers. By returning a stable reference on equal content,\n * consumers only re-render when the value actually changes — without each\n * consumer writing its own equality gate.\n *\n * Typical use: pass a deep-equality function (e.g. `lodash/isEqual`) for\n * derivations that produce fresh objects/arrays on every evaluation but are\n * structurally identical most of the time.\n *\n * @example\n * import isEqual from 'lodash/isEqual';\n * const ports = structuralComputed(() => computePorts(...), isEqual);\n */\nexport function structuralComputed<T>(\n\tderive: () => T,\n\tisEqual: (a: T, b: T) => boolean = Object.is,\n): ComputedRef<T> {\n\tlet cached: T;\n\tlet primed = false;\n\treturn computed<T>(() => {\n\t\tconst next = derive();\n\t\tif (primed && isEqual(cached, next)) return cached;\n\t\tcached = next;\n\t\tprimed = true;\n\t\treturn cached;\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mBACf,QACA,UAAmC,OAAO,IACzB;CACjB,IAAIA;CACJ,IAAI,SAAS;AACb,QAAO,eAAkB;EACxB,MAAM,OAAO,QAAQ;AACrB,MAAI,UAAU,QAAQ,QAAQ,KAAK,CAAE,QAAO;AAC5C,WAAS;AACT,WAAS;AACT,SAAO;GACN"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@n8n/composables",
3
3
  "type": "module",
4
- "version": "1.15.0",
4
+ "version": "1.17.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "LICENSE.md",
@@ -15,9 +15,9 @@
15
15
  }
16
16
  },
17
17
  "devDependencies": {
18
+ "@testing-library/vue": "^8.1.0",
18
19
  "@testing-library/jest-dom": "^6.6.3",
19
20
  "@testing-library/user-event": "^14.6.1",
20
- "@testing-library/vue": "^8.1.0",
21
21
  "@vitejs/plugin-vue": "^5.2.4",
22
22
  "@vue/tsconfig": "^0.7.0",
23
23
  "@vueuse/core": "^10.11.0",
@@ -27,9 +27,9 @@
27
27
  "vite": "^8.0.2",
28
28
  "vitest": "^4.1.1",
29
29
  "vue-tsc": "^2.2.8",
30
- "@n8n/eslint-config": "0.0.1",
31
30
  "@n8n/typescript-config": "1.4.0",
32
- "@n8n/vitest-config": "1.9.0"
31
+ "@n8n/vitest-config": "1.11.0",
32
+ "@n8n/eslint-config": "0.0.1"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@vueuse/core": "^10.11.0",