@rkmodules/rules 0.0.171 → 0.0.172
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 +58 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +58 -8
- package/dist/index.esm.mjs.map +1 -1
- package/dist/lib/Engine/cache.d.ts +6 -1
- package/package.json +1 -1
- package/readme.md +11 -6
package/dist/index.cjs.js
CHANGED
|
@@ -753,6 +753,50 @@ function sameRecord(a, b) {
|
|
|
753
753
|
var otherKeys = Object.keys(b);
|
|
754
754
|
return keys.length === otherKeys.length && keys.every(function (key, i) { return key === otherKeys[i] && Object.is(a[key], b[key]); });
|
|
755
755
|
}
|
|
756
|
+
/** Compare immutable graph configuration, never runtime dependency trees.
|
|
757
|
+
* Preserve key order (interpolation observes it); opaque objects retain identity
|
|
758
|
+
* semantics. Cyclic configurations conservatively miss instead of recursing forever.
|
|
759
|
+
*/
|
|
760
|
+
function sameConfiguration(a, b, ancestors) {
|
|
761
|
+
if (Object.is(a, b))
|
|
762
|
+
return true;
|
|
763
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object")
|
|
764
|
+
return false;
|
|
765
|
+
var prototype = Object.getPrototypeOf(a);
|
|
766
|
+
if (prototype !== Object.getPrototypeOf(b))
|
|
767
|
+
return false;
|
|
768
|
+
if (Array.isArray(a)) {
|
|
769
|
+
if (!Array.isArray(b) || a.length !== b.length)
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
else if (prototype !== Object.prototype && prototype !== null)
|
|
773
|
+
return false;
|
|
774
|
+
if ((ancestors === null || ancestors === void 0 ? void 0 : ancestors.has(a)) || (ancestors === null || ancestors === void 0 ? void 0 : ancestors.has(b)))
|
|
775
|
+
return false;
|
|
776
|
+
var keys = Reflect.ownKeys(a);
|
|
777
|
+
var otherKeys = Reflect.ownKeys(b);
|
|
778
|
+
if (keys.length !== otherKeys.length)
|
|
779
|
+
return false;
|
|
780
|
+
ancestors = ancestors || new Set();
|
|
781
|
+
ancestors.add(a);
|
|
782
|
+
ancestors.add(b);
|
|
783
|
+
try {
|
|
784
|
+
return keys.every(function (key, i) {
|
|
785
|
+
if (key !== otherKeys[i])
|
|
786
|
+
return false;
|
|
787
|
+
var left = Object.getOwnPropertyDescriptor(a, key);
|
|
788
|
+
var right = Object.getOwnPropertyDescriptor(b, key);
|
|
789
|
+
// Accessors may read external state; do not invoke them for comparison.
|
|
790
|
+
return "value" in left && "value" in right &&
|
|
791
|
+
left.enumerable === right.enumerable &&
|
|
792
|
+
sameConfiguration(left.value, right.value, ancestors);
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
finally {
|
|
796
|
+
ancestors.delete(a);
|
|
797
|
+
ancestors.delete(b);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
756
800
|
function put(map, key, value) {
|
|
757
801
|
map.delete(key);
|
|
758
802
|
map.set(key, value);
|
|
@@ -850,7 +894,8 @@ var ExecutionCache = /** @class */ (function () {
|
|
|
850
894
|
finally { if (e_2) throw e_2.error; }
|
|
851
895
|
}
|
|
852
896
|
};
|
|
853
|
-
ExecutionCache.prototype.interpolate = function (run, path, raw, scope) {
|
|
897
|
+
ExecutionCache.prototype.interpolate = function (run, path, raw, scope, configuration) {
|
|
898
|
+
if (configuration === void 0) { configuration = false; }
|
|
854
899
|
var key = cachePath(path);
|
|
855
900
|
run.visited.add(key);
|
|
856
901
|
if (!this.current(run))
|
|
@@ -862,13 +907,16 @@ var ExecutionCache = /** @class */ (function () {
|
|
|
862
907
|
// Deep references depend on the base tree's identity. Unrelated scope
|
|
863
908
|
// entries never invalidate this port; a fresh execution context is fine.
|
|
864
909
|
var old = previous === null || previous === void 0 ? void 0 : previous.ports.get(name);
|
|
865
|
-
var
|
|
910
|
+
var sameRaw = old && (configuration
|
|
911
|
+
? sameConfiguration(old.raw, value) : Object.is(old.raw, value));
|
|
912
|
+
var paths = sameRaw ? old.paths :
|
|
866
913
|
getReferencePaths(value).map(function (path) { return path.split(".").slice(0, 2).join("."); });
|
|
867
914
|
var dependencies = paths.map(function (path) { return getValue$1(scope, path); });
|
|
868
|
-
var same =
|
|
915
|
+
var same = sameRaw &&
|
|
869
916
|
old.dependencies.length === dependencies.length &&
|
|
870
917
|
dependencies.every(function (value, i) { return Object.is(value, old.dependencies[i]); });
|
|
871
|
-
|
|
918
|
+
// Remember the latest raw reference so subsequent runs take the fast path.
|
|
919
|
+
var port = same ? __assign(__assign({}, old), { raw: value }) : {
|
|
872
920
|
raw: value,
|
|
873
921
|
paths: paths,
|
|
874
922
|
dependencies: dependencies,
|
|
@@ -893,8 +941,10 @@ var ExecutionCache = /** @class */ (function () {
|
|
|
893
941
|
return;
|
|
894
942
|
var entry = run.scope[kind].get(key);
|
|
895
943
|
if (entry && entry.definition === fn && entry.impl === fn.impl &&
|
|
896
|
-
|
|
897
|
-
|
|
944
|
+
sameConfiguration(entry.metadata, this.key(call)) && sameRecord(entry.inputs, inputs) &&
|
|
945
|
+
sameConfiguration(entry.params, params)) {
|
|
946
|
+
entry.metadata = this.key(call);
|
|
947
|
+
entry.params = __assign({}, params);
|
|
898
948
|
put(run.scope[kind], key, entry);
|
|
899
949
|
return entry;
|
|
900
950
|
}
|
|
@@ -3644,7 +3694,7 @@ var Engine = /** @class */ (function () {
|
|
|
3644
3694
|
if (!fn)
|
|
3645
3695
|
throw new Error("function ".concat(fnCall.name, " not found in index"));
|
|
3646
3696
|
callPath = __spreadArray(__spreadArray([], __read(path), false), [name_1], false);
|
|
3647
|
-
inputs_1 = this.cache.interpolate(run, __spreadArray(__spreadArray([], __read(callPath), false), ["$inputs"], false), fnCall.inputs || {}, context.scope);
|
|
3697
|
+
inputs_1 = this.cache.interpolate(run, __spreadArray(__spreadArray([], __read(callPath), false), ["$inputs"], false), fnCall.inputs || {}, context.scope, true);
|
|
3648
3698
|
params_1 = fnCall.params || {};
|
|
3649
3699
|
context.calls[name_1] = fnCall;
|
|
3650
3700
|
context.inputs[name_1] = inputs_1;
|
|
@@ -3668,7 +3718,7 @@ var Engine = /** @class */ (function () {
|
|
|
3668
3718
|
finally { if (e_1) throw e_1.error; }
|
|
3669
3719
|
return [7 /*endfinally*/];
|
|
3670
3720
|
case 8:
|
|
3671
|
-
result = this.cache.interpolate(run, __spreadArray(__spreadArray([], __read(path), false), ["$outputs"], false), node.outputs || {}, context.scope);
|
|
3721
|
+
result = this.cache.interpolate(run, __spreadArray(__spreadArray([], __read(path), false), ["$outputs"], false), node.outputs || {}, context.scope, true);
|
|
3672
3722
|
endTime = performance.now();
|
|
3673
3723
|
response = {
|
|
3674
3724
|
name: node.name,
|