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