@ws-ui/datasources
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -1,642 +0,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
Store: () => Store, | ||
getKey: () => getKey, | ||
normalizePath: () => normalizePath, | ||
selectByKey: () => selectByKey | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/store.ts | ||
var import_lodash4 = require("lodash"); | ||
var import_rxjs = require("rxjs"); | ||
var import_operators = require("rxjs/operators"); | ||
// src/devtools.ts | ||
function inspect(name = "Qodly", subject, opts = {}) { | ||
const hasReduxDevtools = window && typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== "undefined"; | ||
if (!hasReduxDevtools) { | ||
console.error( | ||
"You must have Redux DevTools Extension installed in order to use react-inspect-props. Install it at http://extension.remotedev.io/" | ||
); | ||
return; | ||
} | ||
const connection = window.__REDUX_DEVTOOLS_EXTENSION__?.connect({ | ||
...opts, | ||
name, | ||
trace: true, | ||
features: { | ||
...opts.features, | ||
pause: true, | ||
lock: true, | ||
export: true, | ||
import: "custom", | ||
jump: true, | ||
skip: true, | ||
reorder: true, | ||
persist: true, | ||
dispatch: true, | ||
test: false | ||
} | ||
}); | ||
connection?.init({}); | ||
subject.subscribe((state) => { | ||
connection?.send({ type: "@@UPDATE" }, state); | ||
}); | ||
connection?.subscribe((data) => { | ||
if (typeof data?.state === "string") { | ||
subject.next(JSON.parse(data.state)); | ||
} | ||
}); | ||
return connection; | ||
} | ||
// node_modules/immer/dist/immer.esm.mjs | ||
function n(n2) { | ||
for (var r2 = arguments.length, t2 = Array(r2 > 1 ? r2 - 1 : 0), e = 1; e < r2; e++) | ||
t2[e - 1] = arguments[e]; | ||
if ("production" !== process.env.NODE_ENV) { | ||
var i2 = Y[n2], o2 = i2 ? "function" == typeof i2 ? i2.apply(null, t2) : i2 : "unknown error nr: " + n2; | ||
throw Error("[Immer] " + o2); | ||
} | ||
throw Error("[Immer] minified error nr: " + n2 + (t2.length ? " " + t2.map(function(n3) { | ||
return "'" + n3 + "'"; | ||
}).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf"); | ||
} | ||
function r(n2) { | ||
return !!n2 && !!n2[Q]; | ||
} | ||
function t(n2) { | ||
var r2; | ||
return !!n2 && (function(n3) { | ||
if (!n3 || "object" != typeof n3) | ||
return false; | ||
var r3 = Object.getPrototypeOf(n3); | ||
if (null === r3) | ||
return true; | ||
var t2 = Object.hasOwnProperty.call(r3, "constructor") && r3.constructor; | ||
return t2 === Object || "function" == typeof t2 && Function.toString.call(t2) === Z; | ||
}(n2) || Array.isArray(n2) || !!n2[L] || !!(null === (r2 = n2.constructor) || void 0 === r2 ? void 0 : r2[L]) || s(n2) || v(n2)); | ||
} | ||
function i(n2, r2, t2) { | ||
void 0 === t2 && (t2 = false), 0 === o(n2) ? (t2 ? Object.keys : nn)(n2).forEach(function(e) { | ||
t2 && "symbol" == typeof e || r2(e, n2[e], n2); | ||
}) : n2.forEach(function(t3, e) { | ||
return r2(e, t3, n2); | ||
}); | ||
} | ||
function o(n2) { | ||
var r2 = n2[Q]; | ||
return r2 ? r2.i > 3 ? r2.i - 4 : r2.i : Array.isArray(n2) ? 1 : s(n2) ? 2 : v(n2) ? 3 : 0; | ||
} | ||
function u(n2, r2) { | ||
return 2 === o(n2) ? n2.has(r2) : Object.prototype.hasOwnProperty.call(n2, r2); | ||
} | ||
function a(n2, r2) { | ||
return 2 === o(n2) ? n2.get(r2) : n2[r2]; | ||
} | ||
function f(n2, r2, t2) { | ||
var e = o(n2); | ||
2 === e ? n2.set(r2, t2) : 3 === e ? (n2.delete(r2), n2.add(t2)) : n2[r2] = t2; | ||
} | ||
function c(n2, r2) { | ||
return n2 === r2 ? 0 !== n2 || 1 / n2 == 1 / r2 : n2 != n2 && r2 != r2; | ||
} | ||
function s(n2) { | ||
return X && n2 instanceof Map; | ||
} | ||
function v(n2) { | ||
return q && n2 instanceof Set; | ||
} | ||
function p(n2) { | ||
return n2.o || n2.t; | ||
} | ||
function l(n2) { | ||
if (Array.isArray(n2)) | ||
return Array.prototype.slice.call(n2); | ||
var r2 = rn(n2); | ||
delete r2[Q]; | ||
for (var t2 = nn(r2), e = 0; e < t2.length; e++) { | ||
var i2 = t2[e], o2 = r2[i2]; | ||
false === o2.writable && (o2.writable = true, o2.configurable = true), (o2.get || o2.set) && (r2[i2] = { configurable: true, writable: true, enumerable: o2.enumerable, value: n2[i2] }); | ||
} | ||
return Object.create(Object.getPrototypeOf(n2), r2); | ||
} | ||
function d(n2, e) { | ||
return void 0 === e && (e = false), y(n2) || r(n2) || !t(n2) ? n2 : (o(n2) > 1 && (n2.set = n2.add = n2.clear = n2.delete = h), Object.freeze(n2), e && i(n2, function(n3, r2) { | ||
return d(r2, true); | ||
}, true), n2); | ||
} | ||
function h() { | ||
n(2); | ||
} | ||
function y(n2) { | ||
return null == n2 || "object" != typeof n2 || Object.isFrozen(n2); | ||
} | ||
function b(r2) { | ||
var t2 = tn[r2]; | ||
return t2 || n(18, r2), t2; | ||
} | ||
function _() { | ||
return "production" === process.env.NODE_ENV || U || n(0), U; | ||
} | ||
function j(n2, r2) { | ||
r2 && (b("Patches"), n2.u = [], n2.s = [], n2.v = r2); | ||
} | ||
function O(n2) { | ||
g(n2), n2.p.forEach(S), n2.p = null; | ||
} | ||
function g(n2) { | ||
n2 === U && (U = n2.l); | ||
} | ||
function w(n2) { | ||
return U = { p: [], l: U, h: n2, m: true, _: 0 }; | ||
} | ||
function S(n2) { | ||
var r2 = n2[Q]; | ||
0 === r2.i || 1 === r2.i ? r2.j() : r2.O = true; | ||
} | ||
function P(r2, e) { | ||
e._ = e.p.length; | ||
var i2 = e.p[0], o2 = void 0 !== r2 && r2 !== i2; | ||
return e.h.g || b("ES5").S(e, r2, o2), o2 ? (i2[Q].P && (O(e), n(4)), t(r2) && (r2 = M(e, r2), e.l || x(e, r2)), e.u && b("Patches").M(i2[Q].t, r2, e.u, e.s)) : r2 = M(e, i2, []), O(e), e.u && e.v(e.u, e.s), r2 !== H ? r2 : void 0; | ||
} | ||
function M(n2, r2, t2) { | ||
if (y(r2)) | ||
return r2; | ||
var e = r2[Q]; | ||
if (!e) | ||
return i(r2, function(i2, o3) { | ||
return A(n2, e, r2, i2, o3, t2); | ||
}, true), r2; | ||
if (e.A !== n2) | ||
return r2; | ||
if (!e.P) | ||
return x(n2, e.t, true), e.t; | ||
if (!e.I) { | ||
e.I = true, e.A._--; | ||
var o2 = 4 === e.i || 5 === e.i ? e.o = l(e.k) : e.o; | ||
i(3 === e.i ? new Set(o2) : o2, function(r3, i2) { | ||
return A(n2, e, o2, r3, i2, t2); | ||
}), x(n2, o2, false), t2 && n2.u && b("Patches").R(e, t2, n2.u, n2.s); | ||
} | ||
return e.o; | ||
} | ||
function A(e, i2, o2, a2, c2, s2) { | ||
if ("production" !== process.env.NODE_ENV && c2 === o2 && n(5), r(c2)) { | ||
var v2 = M(e, c2, s2 && i2 && 3 !== i2.i && !u(i2.D, a2) ? s2.concat(a2) : void 0); | ||
if (f(o2, a2, v2), !r(v2)) | ||
return; | ||
e.m = false; | ||
} | ||
if (t(c2) && !y(c2)) { | ||
if (!e.h.F && e._ < 1) | ||
return; | ||
M(e, c2), i2 && i2.A.l || x(e, c2); | ||
} | ||
} | ||
function x(n2, r2, t2) { | ||
void 0 === t2 && (t2 = false), n2.h.F && n2.m && d(r2, t2); | ||
} | ||
function z(n2, r2) { | ||
var t2 = n2[Q]; | ||
return (t2 ? p(t2) : n2)[r2]; | ||
} | ||
function I(n2, r2) { | ||
if (r2 in n2) | ||
for (var t2 = Object.getPrototypeOf(n2); t2; ) { | ||
var e = Object.getOwnPropertyDescriptor(t2, r2); | ||
if (e) | ||
return e; | ||
t2 = Object.getPrototypeOf(t2); | ||
} | ||
} | ||
function k(n2) { | ||
n2.P || (n2.P = true, n2.l && k(n2.l)); | ||
} | ||
function E(n2) { | ||
n2.o || (n2.o = l(n2.t)); | ||
} | ||
function R(n2, r2, t2) { | ||
var e = s(r2) ? b("MapSet").N(r2, t2) : v(r2) ? b("MapSet").T(r2, t2) : n2.g ? function(n3, r3) { | ||
var t3 = Array.isArray(n3), e2 = { i: t3 ? 1 : 0, A: r3 ? r3.A : _(), P: false, I: false, D: {}, l: r3, t: n3, k: null, o: null, j: null, C: false }, i2 = e2, o2 = en; | ||
t3 && (i2 = [e2], o2 = on); | ||
var u2 = Proxy.revocable(i2, o2), a2 = u2.revoke, f2 = u2.proxy; | ||
return e2.k = f2, e2.j = a2, f2; | ||
}(r2, t2) : b("ES5").J(r2, t2); | ||
return (t2 ? t2.A : _()).p.push(e), e; | ||
} | ||
function D(e) { | ||
return r(e) || n(22, e), function n2(r2) { | ||
if (!t(r2)) | ||
return r2; | ||
var e2, u2 = r2[Q], c2 = o(r2); | ||
if (u2) { | ||
if (!u2.P && (u2.i < 4 || !b("ES5").K(u2))) | ||
return u2.t; | ||
u2.I = true, e2 = F(r2, c2), u2.I = false; | ||
} else | ||
e2 = F(r2, c2); | ||
return i(e2, function(r3, t2) { | ||
u2 && a(u2.t, r3) === t2 || f(e2, r3, n2(t2)); | ||
}), 3 === c2 ? new Set(e2) : e2; | ||
}(e); | ||
} | ||
function F(n2, r2) { | ||
switch (r2) { | ||
case 2: | ||
return new Map(n2); | ||
case 3: | ||
return Array.from(n2); | ||
} | ||
return l(n2); | ||
} | ||
var G; | ||
var U; | ||
var W = "undefined" != typeof Symbol && "symbol" == typeof Symbol("x"); | ||
var X = "undefined" != typeof Map; | ||
var q = "undefined" != typeof Set; | ||
var B = "undefined" != typeof Proxy && void 0 !== Proxy.revocable && "undefined" != typeof Reflect; | ||
var H = W ? Symbol.for("immer-nothing") : ((G = {})["immer-nothing"] = true, G); | ||
var L = W ? Symbol.for("immer-draftable") : "__$immer_draftable"; | ||
var Q = W ? Symbol.for("immer-state") : "__$immer_state"; | ||
var Y = { 0: "Illegal state", 1: "Immer drafts cannot have computed properties", 2: "This object has been frozen and should not be mutated", 3: function(n2) { | ||
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + n2; | ||
}, 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.", 5: "Immer forbids circular references", 6: "The first or second argument to `produce` must be a function", 7: "The third argument to `produce` must be a function or undefined", 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object", 9: "First argument to `finishDraft` must be a draft returned by `createDraft`", 10: "The given draft is already finalized", 11: "Object.defineProperty() cannot be used on an Immer draft", 12: "Object.setPrototypeOf() cannot be used on an Immer draft", 13: "Immer only supports deleting array indices", 14: "Immer only supports setting array indices and the 'length' property", 15: function(n2) { | ||
return "Cannot apply patch, path doesn't resolve: " + n2; | ||
}, 16: 'Sets cannot have "replace" patches.', 17: function(n2) { | ||
return "Unsupported patch operation: " + n2; | ||
}, 18: function(n2) { | ||
return "The plugin for '" + n2 + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + n2 + "()` when initializing your application."; | ||
}, 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available", 21: function(n2) { | ||
return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '" + n2 + "'"; | ||
}, 22: function(n2) { | ||
return "'current' expects a draft, got: " + n2; | ||
}, 23: function(n2) { | ||
return "'original' expects a draft, got: " + n2; | ||
}, 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed" }; | ||
var Z = "" + Object.prototype.constructor; | ||
var nn = "undefined" != typeof Reflect && Reflect.ownKeys ? Reflect.ownKeys : void 0 !== Object.getOwnPropertySymbols ? function(n2) { | ||
return Object.getOwnPropertyNames(n2).concat(Object.getOwnPropertySymbols(n2)); | ||
} : Object.getOwnPropertyNames; | ||
var rn = Object.getOwnPropertyDescriptors || function(n2) { | ||
var r2 = {}; | ||
return nn(n2).forEach(function(t2) { | ||
r2[t2] = Object.getOwnPropertyDescriptor(n2, t2); | ||
}), r2; | ||
}; | ||
var tn = {}; | ||
var en = { get: function(n2, r2) { | ||
if (r2 === Q) | ||
return n2; | ||
var e = p(n2); | ||
if (!u(e, r2)) | ||
return function(n3, r3, t2) { | ||
var e2, i3 = I(r3, t2); | ||
return i3 ? "value" in i3 ? i3.value : null === (e2 = i3.get) || void 0 === e2 ? void 0 : e2.call(n3.k) : void 0; | ||
}(n2, e, r2); | ||
var i2 = e[r2]; | ||
return n2.I || !t(i2) ? i2 : i2 === z(n2.t, r2) ? (E(n2), n2.o[r2] = R(n2.A.h, i2, n2)) : i2; | ||
}, has: function(n2, r2) { | ||
return r2 in p(n2); | ||
}, ownKeys: function(n2) { | ||
return Reflect.ownKeys(p(n2)); | ||
}, set: function(n2, r2, t2) { | ||
var e = I(p(n2), r2); | ||
if (null == e ? void 0 : e.set) | ||
return e.set.call(n2.k, t2), true; | ||
if (!n2.P) { | ||
var i2 = z(p(n2), r2), o2 = null == i2 ? void 0 : i2[Q]; | ||
if (o2 && o2.t === t2) | ||
return n2.o[r2] = t2, n2.D[r2] = false, true; | ||
if (c(t2, i2) && (void 0 !== t2 || u(n2.t, r2))) | ||
return true; | ||
E(n2), k(n2); | ||
} | ||
return n2.o[r2] === t2 && "number" != typeof t2 && (void 0 !== t2 || r2 in n2.o) || (n2.o[r2] = t2, n2.D[r2] = true, true); | ||
}, deleteProperty: function(n2, r2) { | ||
return void 0 !== z(n2.t, r2) || r2 in n2.t ? (n2.D[r2] = false, E(n2), k(n2)) : delete n2.D[r2], n2.o && delete n2.o[r2], true; | ||
}, getOwnPropertyDescriptor: function(n2, r2) { | ||
var t2 = p(n2), e = Reflect.getOwnPropertyDescriptor(t2, r2); | ||
return e ? { writable: true, configurable: 1 !== n2.i || "length" !== r2, enumerable: e.enumerable, value: t2[r2] } : e; | ||
}, defineProperty: function() { | ||
n(11); | ||
}, getPrototypeOf: function(n2) { | ||
return Object.getPrototypeOf(n2.t); | ||
}, setPrototypeOf: function() { | ||
n(12); | ||
} }; | ||
var on = {}; | ||
i(en, function(n2, r2) { | ||
on[n2] = function() { | ||
return arguments[0] = arguments[0][0], r2.apply(this, arguments); | ||
}; | ||
}), on.deleteProperty = function(r2, t2) { | ||
return "production" !== process.env.NODE_ENV && isNaN(parseInt(t2)) && n(13), on.set.call(this, r2, t2, void 0); | ||
}, on.set = function(r2, t2, e) { | ||
return "production" !== process.env.NODE_ENV && "length" !== t2 && isNaN(parseInt(t2)) && n(14), en.set.call(this, r2[0], t2, e, r2[0]); | ||
}; | ||
var un = function() { | ||
function e(r2) { | ||
var e2 = this; | ||
this.g = B, this.F = true, this.produce = function(r3, i3, o2) { | ||
if ("function" == typeof r3 && "function" != typeof i3) { | ||
var u2 = i3; | ||
i3 = r3; | ||
var a2 = e2; | ||
return function(n2) { | ||
var r4 = this; | ||
void 0 === n2 && (n2 = u2); | ||
for (var t2 = arguments.length, e3 = Array(t2 > 1 ? t2 - 1 : 0), o3 = 1; o3 < t2; o3++) | ||
e3[o3 - 1] = arguments[o3]; | ||
return a2.produce(n2, function(n3) { | ||
var t3; | ||
return (t3 = i3).call.apply(t3, [r4, n3].concat(e3)); | ||
}); | ||
}; | ||
} | ||
var f2; | ||
if ("function" != typeof i3 && n(6), void 0 !== o2 && "function" != typeof o2 && n(7), t(r3)) { | ||
var c2 = w(e2), s2 = R(e2, r3, void 0), v2 = true; | ||
try { | ||
f2 = i3(s2), v2 = false; | ||
} finally { | ||
v2 ? O(c2) : g(c2); | ||
} | ||
return "undefined" != typeof Promise && f2 instanceof Promise ? f2.then(function(n2) { | ||
return j(c2, o2), P(n2, c2); | ||
}, function(n2) { | ||
throw O(c2), n2; | ||
}) : (j(c2, o2), P(f2, c2)); | ||
} | ||
if (!r3 || "object" != typeof r3) { | ||
if (void 0 === (f2 = i3(r3)) && (f2 = r3), f2 === H && (f2 = void 0), e2.F && d(f2, true), o2) { | ||
var p2 = [], l2 = []; | ||
b("Patches").M(r3, f2, p2, l2), o2(p2, l2); | ||
} | ||
return f2; | ||
} | ||
n(21, r3); | ||
}, this.produceWithPatches = function(n2, r3) { | ||
if ("function" == typeof n2) | ||
return function(r4) { | ||
for (var t3 = arguments.length, i4 = Array(t3 > 1 ? t3 - 1 : 0), o3 = 1; o3 < t3; o3++) | ||
i4[o3 - 1] = arguments[o3]; | ||
return e2.produceWithPatches(r4, function(r5) { | ||
return n2.apply(void 0, [r5].concat(i4)); | ||
}); | ||
}; | ||
var t2, i3, o2 = e2.produce(n2, r3, function(n3, r4) { | ||
t2 = n3, i3 = r4; | ||
}); | ||
return "undefined" != typeof Promise && o2 instanceof Promise ? o2.then(function(n3) { | ||
return [n3, t2, i3]; | ||
}) : [o2, t2, i3]; | ||
}, "boolean" == typeof (null == r2 ? void 0 : r2.useProxies) && this.setUseProxies(r2.useProxies), "boolean" == typeof (null == r2 ? void 0 : r2.autoFreeze) && this.setAutoFreeze(r2.autoFreeze); | ||
} | ||
var i2 = e.prototype; | ||
return i2.createDraft = function(e2) { | ||
t(e2) || n(8), r(e2) && (e2 = D(e2)); | ||
var i3 = w(this), o2 = R(this, e2, void 0); | ||
return o2[Q].C = true, g(i3), o2; | ||
}, i2.finishDraft = function(r2, t2) { | ||
var e2 = r2 && r2[Q]; | ||
"production" !== process.env.NODE_ENV && (e2 && e2.C || n(9), e2.I && n(10)); | ||
var i3 = e2.A; | ||
return j(i3, t2), P(void 0, i3); | ||
}, i2.setAutoFreeze = function(n2) { | ||
this.F = n2; | ||
}, i2.setUseProxies = function(r2) { | ||
r2 && !B && n(20), this.g = r2; | ||
}, i2.applyPatches = function(n2, t2) { | ||
var e2; | ||
for (e2 = t2.length - 1; e2 >= 0; e2--) { | ||
var i3 = t2[e2]; | ||
if (0 === i3.path.length && "replace" === i3.op) { | ||
n2 = i3.value; | ||
break; | ||
} | ||
} | ||
e2 > -1 && (t2 = t2.slice(e2 + 1)); | ||
var o2 = b("Patches").$; | ||
return r(n2) ? o2(n2, t2) : this.produce(n2, function(n3) { | ||
return o2(n3, t2); | ||
}); | ||
}, e; | ||
}(); | ||
var an = new un(); | ||
var fn = an.produce; | ||
var cn = an.produceWithPatches.bind(an); | ||
var sn = an.setAutoFreeze.bind(an); | ||
var vn = an.setUseProxies.bind(an); | ||
var pn = an.applyPatches.bind(an); | ||
var ln = an.createDraft.bind(an); | ||
var dn = an.finishDraft.bind(an); | ||
var immer_esm_default = fn; | ||
// src/middlewares/string.ts | ||
var import_lodash = require("lodash"); | ||
var StringMiddleware = { | ||
check(datasource) { | ||
return datasource.type === "scalar" && datasource.dataType === "string"; | ||
}, | ||
create(datasource) { | ||
if (!StringMiddleware.check(datasource)) | ||
return; | ||
}, | ||
set(root, _2, value, ctx) { | ||
const { value: state } = ctx; | ||
const datasource = state.sources[root]; | ||
if (!datasource || !StringMiddleware.check(datasource)) | ||
return; | ||
const newValue = immer_esm_default(state, (draft) => { | ||
(0, import_lodash.set)(draft.sources, `${root}.value`, value); | ||
}); | ||
ctx.next(newValue); | ||
} | ||
}; | ||
// src/middlewares/boolean.ts | ||
var import_lodash2 = require("lodash"); | ||
var BoolMiddleware = { | ||
check(datasource) { | ||
return datasource.type === "scalar" && datasource.dataType === "boolean"; | ||
}, | ||
create(datasource) { | ||
if (!BoolMiddleware.check(datasource)) | ||
return; | ||
}, | ||
set(root, _2, value, ctx) { | ||
const { value: state } = ctx; | ||
const datasource = state.sources[root]; | ||
if (!datasource || !BoolMiddleware.check(datasource)) | ||
return; | ||
const newValue = immer_esm_default(state, (draft) => { | ||
(0, import_lodash2.set)(draft.sources, `${root}.value`, value); | ||
}); | ||
ctx.next(newValue); | ||
} | ||
}; | ||
// src/middlewares/object.ts | ||
var import_lodash3 = require("lodash"); | ||
var ObjectMiddleware = { | ||
check(datasource) { | ||
return datasource.type === "scalar" && datasource.dataType === "object"; | ||
}, | ||
create(datasource) { | ||
if (!ObjectMiddleware.check(datasource)) | ||
return; | ||
}, | ||
set(root, path, value, ctx) { | ||
const { value: state } = ctx; | ||
const datasource = state.sources[root]; | ||
if (!datasource || !ObjectMiddleware.check(datasource)) | ||
return; | ||
const newValue = immer_esm_default(state, (draft) => { | ||
(0, import_lodash3.set)( | ||
draft.sources, | ||
`${root}.value${path.length > 0 ? "." : ""}${path.join(".")}`, | ||
value | ||
); | ||
}); | ||
ctx.next(newValue); | ||
} | ||
}; | ||
// src/store.ts | ||
var DEFAULT_NS = "__default"; | ||
function selectByKey(path) { | ||
const key = normalizePath(path); | ||
const [root, ...chunks] = key.split("."); | ||
return function(source) { | ||
return source.pipe( | ||
(0, import_operators.map)((value) => { | ||
return (0, import_lodash4.get)( | ||
value.sources, | ||
`${root}.value${chunks.length > 0 ? "." : ""}${chunks.join(".")}` | ||
); | ||
}), | ||
(0, import_operators.distinctUntilChanged)(), | ||
(0, import_operators.filter)((v2) => typeof v2 !== "undefined") | ||
); | ||
}; | ||
} | ||
function normalizePath(path) { | ||
let [namespace, id] = path.split(":"); | ||
if (!id) { | ||
[id, namespace] = [namespace, DEFAULT_NS]; | ||
} | ||
return getKey(id, namespace); | ||
} | ||
function getKey(id, namespace = DEFAULT_NS) { | ||
return `${namespace}:${id}`; | ||
} | ||
var _Store = class { | ||
middlewares = []; | ||
$_state = new import_rxjs.BehaviorSubject({ | ||
catalogs: {}, | ||
sources: {} | ||
}); | ||
$state = this.$_state.asObservable(); | ||
connection; | ||
constructor() { | ||
this.use(StringMiddleware); | ||
this.use(BoolMiddleware); | ||
this.use(ObjectMiddleware); | ||
} | ||
inspect(opts) { | ||
if (!this.connection) { | ||
this.connection = inspect( | ||
opts.name ?? "Qodly Mobile", | ||
this.$_state, | ||
opts | ||
); | ||
} | ||
return this.connection; | ||
} | ||
static getInstance() { | ||
if (!_Store.instance) { | ||
_Store.instance = new _Store(); | ||
} | ||
return _Store.instance; | ||
} | ||
create(datasource) { | ||
const { id, namespace = DEFAULT_NS } = datasource; | ||
const key = getKey(id, namespace); | ||
const { value } = this.$_state; | ||
const found = this.getSourceByKey(key); | ||
if (typeof found !== "undefined") { | ||
throw new Error("datasource already exists"); | ||
} | ||
this.middlewares.forEach(({ create }) => { | ||
create(datasource, value); | ||
}); | ||
this.$_state.next({ | ||
...value, | ||
sources: { | ||
...value.sources, | ||
[key]: datasource | ||
} | ||
}); | ||
this.$_state.pipe((0, import_operators.distinctUntilChanged)()); | ||
} | ||
getSourceByKey(key) { | ||
return this.$_state.value.sources[key]; | ||
} | ||
get(path) { | ||
const key = normalizePath(path); | ||
return this.$_state.pipe((0, import_operators.map)((value) => value.sources[key])); | ||
} | ||
set(path, value) { | ||
const key = normalizePath(path); | ||
const [root, ...chunks] = key.split("."); | ||
const found = this.getSourceByKey(root); | ||
if (!found) | ||
return; | ||
this.middlewares.forEach(({ set }) => { | ||
set(root, chunks, value, this.$_state); | ||
}); | ||
} | ||
close() { | ||
this.$_state.complete(); | ||
} | ||
use(middleware) { | ||
this.middlewares.push(middleware); | ||
} | ||
}; | ||
var Store = _Store; | ||
__publicField(Store, "instance"); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
Store, | ||
getKey, | ||
normalizePath, | ||
selectByKey | ||
}); | ||
"use strict";var k=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var _e=(e,t)=>{for(var r in t)k(e,r,{get:t[r],enumerable:!0})},he=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of de(t))!pe.call(e,o)&&o!==r&&k(e,o,{get:()=>t[o],enumerable:!(n=le(t,o))||n.enumerable});return e};var ye=e=>he(k({},"__esModule",{value:!0}),e);var Me={};_e(Me,{Store:()=>V,getKey:()=>X,normalizePath:()=>A,selectByKey:()=>xe});module.exports=ye(Me);var ce=require("lodash"),ae=require("rxjs"),d=require("rxjs/operators");function G(e="Qodly",t,r={}){if(!(window&&typeof window.__REDUX_DEVTOOLS_EXTENSION__<"u")){console.error("You must have Redux DevTools Extension installed in order to use qodly inspector.");return}let o=window.__REDUX_DEVTOOLS_EXTENSION__?.connect({...r,name:e,trace:!0,features:{...r.features,pause:!0,lock:!0,export:!0,import:"custom",jump:!0,skip:!0,reorder:!0,persist:!0,dispatch:!0,test:!1}});return o?.init({}),t.subscribe(s=>{o?.send({type:"@@UPDATE"},s)}),o?.subscribe(s=>{typeof s?.state=="string"&&t.next(JSON.parse(s.state))}),o}var Y=Symbol.for("immer-nothing"),J=Symbol.for("immer-draftable"),u=Symbol.for("immer-state"),me=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function a(e,...t){if(process.env.NODE_ENV!=="production"){let r=me[e],n=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var y=Object.getPrototypeOf;function m(e){return!!e&&!!e[u]}function _(e){return e?Z(e)||Array.isArray(e)||!!e[J]||!!e.constructor?.[J]||P(e)||D(e):!1}var ge=Object.prototype.constructor.toString();function Z(e){if(!e||typeof e!="object")return!1;let t=y(e);if(t===null)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===ge}function w(e,t){E(e)===0?Object.entries(e).forEach(([r,n])=>{t(r,n,e)}):e.forEach((r,n)=>t(n,r,e))}function E(e){let t=e[u];return t?t.type_:Array.isArray(e)?1:P(e)?2:D(e)?3:0}function C(e,t){return E(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ee(e,t,r){let n=E(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function we(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function P(e){return e instanceof Map}function D(e){return e instanceof Set}function p(e){return e.copy_||e.base_}function F(e,t){if(P(e))return new Map(e);if(D(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Z(e))return y(e)?{...e}:Object.assign(Object.create(null),e);let r=Object.getOwnPropertyDescriptors(e);delete r[u];let n=Reflect.ownKeys(r);for(let o=0;o<n.length;o++){let s=n[o],i=r[s];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(r[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(y(e),r)}function j(e,t=!1){return z(e)||m(e)||!_(e)||(E(e)>1&&(e.set=e.add=e.clear=e.delete=ve),Object.freeze(e),t&&w(e,(r,n)=>j(n,!0),!0)),e}function ve(){a(2)}function z(e){return Object.isFrozen(e)}var Se={};function h(e){let t=Se[e];return t||a(0,e),t}var v;function te(){return v}function be(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function L(e,t){t&&(h("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function $(e){R(e),e.drafts_.forEach(Oe),e.drafts_=null}function R(e){e===v&&(v=e.parent_)}function Q(e){return v=be(v,e)}function Oe(e){let t=e[u];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function q(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[u].modified_&&($(t),a(4)),_(e)&&(e=b(t,e),t.parent_||O(t,e)),t.patches_&&h("Patches").generateReplacementPatches_(r[u].base_,e,t.patches_,t.inversePatches_)):e=b(t,r,[]),$(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Y?e:void 0}function b(e,t,r){if(z(t))return t;let n=t[u];if(!n)return w(t,(o,s)=>H(e,n,t,o,s,r),!0),t;if(n.scope_!==e)return t;if(!n.modified_)return O(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let o=n.copy_,s=o,i=!1;n.type_===3&&(s=new Set(o),o.clear(),i=!0),w(s,(c,l)=>H(e,n,o,c,l,r,i)),O(e,o,!1),r&&e.patches_&&h("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function H(e,t,r,n,o,s,i){if(process.env.NODE_ENV!=="production"&&o===r&&a(5),m(o)){let c=s&&t&&t.type_!==3&&!C(t.assigned_,n)?s.concat(n):void 0,l=b(e,o,c);if(ee(r,n,l),m(l))e.canAutoFreeze_=!1;else return}else i&&r.add(o);if(_(o)&&!z(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;b(e,o),(!t||!t.scope_.parent_)&&O(e,o)}}function O(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&j(t,r)}function Ee(e,t){let r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:te(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,s=K;r&&(o=[n],s=S);let{revoke:i,proxy:c}=Proxy.revocable(o,s);return n.draft_=c,n.revoke_=i,c}var K={get(e,t){if(t===u)return e;let r=p(e);if(!C(r,t))return Pe(e,r,t);let n=r[t];return e.finalized_||!_(n)?n:n===N(e.base_,t)?(T(e),e.copy_[t]=U(n,e)):n},has(e,t){return t in p(e)},ownKeys(e){return Reflect.ownKeys(p(e))},set(e,t,r){let n=re(p(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=N(p(e),t),s=o?.[u];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(we(r,o)&&(r!==void 0||C(e.base_,t)))return!0;T(e),B(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return N(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,T(e),B(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=p(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){a(11)},getPrototypeOf(e){return y(e.base_)},setPrototypeOf(){a(12)}},S={};w(K,(e,t)=>{S[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});S.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&a(13),S.set.call(this,e,t,void 0)};S.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&a(14),K.set.call(this,e[0],t,r,e[0])};function N(e,t){let r=e[u];return(r?p(r):e)[t]}function Pe(e,t,r){let n=re(t,r);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}function re(e,t){if(!(t in e))return;let r=y(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=y(r)}}function B(e){e.modified_||(e.modified_=!0,e.parent_&&B(e.parent_))}function T(e){e.copy_||(e.copy_=F(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var De=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let i=this;return function(l=s,...ue){return i.produce(l,fe=>r.call(this,fe,...ue))}}typeof r!="function"&&a(6),n!==void 0&&typeof n!="function"&&a(7);let o;if(_(t)){let s=Q(this),i=U(t,void 0),c=!0;try{o=r(i),c=!1}finally{c?$(s):R(s)}return L(s,n),q(o,s)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===Y&&(o=void 0),this.autoFreeze_&&j(o,!0),n){let s=[],i=[];h("Patches").generateReplacementPatches_(t,o,s,i),n(s,i)}return o}else a(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(i,...c)=>this.produceWithPatches(i,l=>t(l,...c));let n,o;return[this.produce(t,r,(i,c)=>{n=i,o=c}),n,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){_(e)||a(8),m(e)&&(e=ze(e));let t=Q(this),r=U(e,void 0);return r[u].isManual_=!0,R(t),r}finishDraft(e,t){let r=e&&e[u];(!r||!r.isManual_)&&a(9);let{scope_:n}=r;return L(n,t),q(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=h("Patches").applyPatches_;return m(e)?n(e,t):this.produce(e,o=>n(o,t))}};function U(e,t){let r=P(e)?h("MapSet").proxyMap_(e,t):D(e)?h("MapSet").proxySet_(e,t):Ee(e,t);return(t?t.scope_:te()).drafts_.push(r),r}function ze(e){return m(e)||a(10,e),ne(e)}function ne(e){if(!_(e)||z(e))return e;let t=e[u],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=F(e,t.scope_.immer_.useStrictShallowCopy_)}else r=F(e,!0);return w(r,(n,o)=>{ee(r,n,ne(o))}),t&&(t.finalized_=!1),r}var f=new De,g=f.produce,ke=f.produceWithPatches.bind(f),Ne=f.setAutoFreeze.bind(f),Te=f.setUseStrictShallowCopy.bind(f),Ce=f.applyPatches.bind(f),Fe=f.createDraft.bind(f),$e=f.finishDraft.bind(f);var oe=require("lodash"),x={check(e){return e.type==="scalar"&&e.dataType==="string"},create(e){x.check(e)},set(e,t,r,n){let{value:o}=n,s=o.sources[e];if(!s||!x.check(s))return;let i=g(o,c=>{(0,oe.set)(c.sources,`${e}.value`,r)});n.next(i)}};var se=require("lodash"),M={check(e){return e.type==="scalar"&&e.dataType==="boolean"},create(e){M.check(e)},set(e,t,r,n){let{value:o}=n,s=o.sources[e];if(!s||!M.check(s))return;let i=g(o,c=>{(0,se.set)(c.sources,`${e}.value`,r)});n.next(i)}};var ie=require("lodash"),I={check(e){return e.type==="scalar"&&e.dataType==="object"},create(e){I.check(e)},set(e,t,r,n){let{value:o}=n,s=o.sources[e];if(!s||!I.check(s))return;let i=g(o,c=>{(0,ie.set)(c.sources,`${e}.value${t.length>0?".":""}${t.join(".")}`,r)});n.next(i)}};var W="__default";function xe(e){let t=A(e),[r,...n]=t.split(".");return function(o){return o.pipe((0,d.map)(s=>(0,ce.get)(s.sources,`${r}.value${n.length>0?".":""}${n.join(".")}`)),(0,d.distinctUntilChanged)(),(0,d.filter)(s=>typeof s<"u"))}}function A(e){let[t,r]=e.split(":");return r||([r,t]=[t,W]),X(r,t)}function X(e,t=W){return`${t}:${e}`}var V=class e{constructor(){this.middlewares=[];this.$_state=new ae.BehaviorSubject({catalogs:{},sources:{}});this.$state=this.$_state.asObservable();this.use(x),this.use(M),this.use(I)}inspect(t){return this.connection||(this.connection=G(t.name??"Qodly Mobile",this.$_state,t)),this.connection}static getInstance(){return e.instance||(e.instance=new e),e.instance}static destroy(){e.instance=void 0}create(t){let{id:r,namespace:n=W}=t,o=X(r,n),{value:s}=this.$_state;if(typeof this.getSourceByKey(o)<"u")throw new Error("datasource already exists");this.middlewares.forEach(({create:c})=>{c(t,s)}),this.$_state.next({...s,sources:{...s.sources,[o]:t}}),this.$_state.pipe((0,d.distinctUntilChanged)())}getSourceByKey(t){return this.$_state.value.sources[t]}get(t){let r=A(t);return this.$_state.pipe((0,d.map)(n=>n.sources[r]))}set(t,r){let n=A(t),[o,...s]=n.split(".");this.getSourceByKey(o)&&this.middlewares.forEach(({set:c})=>{c(o,s,r,this.$_state)})}unsubscribe(){this.$_state.complete()}use(t){this.middlewares.push(t)}};0&&(module.exports={Store,getKey,normalizePath,selectByKey}); | ||
//# sourceMappingURL=index.js.map |
@@ -1,614 +0,2 @@ | ||
var __defProp = Object.defineProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
// src/store.ts | ||
import { get as _get } from "lodash"; | ||
import { BehaviorSubject } from "rxjs"; | ||
import { filter, map, distinctUntilChanged } from "rxjs/operators"; | ||
// src/devtools.ts | ||
function inspect(name = "Qodly", subject, opts = {}) { | ||
const hasReduxDevtools = window && typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== "undefined"; | ||
if (!hasReduxDevtools) { | ||
console.error( | ||
"You must have Redux DevTools Extension installed in order to use react-inspect-props. Install it at http://extension.remotedev.io/" | ||
); | ||
return; | ||
} | ||
const connection = window.__REDUX_DEVTOOLS_EXTENSION__?.connect({ | ||
...opts, | ||
name, | ||
trace: true, | ||
features: { | ||
...opts.features, | ||
pause: true, | ||
lock: true, | ||
export: true, | ||
import: "custom", | ||
jump: true, | ||
skip: true, | ||
reorder: true, | ||
persist: true, | ||
dispatch: true, | ||
test: false | ||
} | ||
}); | ||
connection?.init({}); | ||
subject.subscribe((state) => { | ||
connection?.send({ type: "@@UPDATE" }, state); | ||
}); | ||
connection?.subscribe((data) => { | ||
if (typeof data?.state === "string") { | ||
subject.next(JSON.parse(data.state)); | ||
} | ||
}); | ||
return connection; | ||
} | ||
// node_modules/immer/dist/immer.esm.mjs | ||
function n(n2) { | ||
for (var r2 = arguments.length, t2 = Array(r2 > 1 ? r2 - 1 : 0), e = 1; e < r2; e++) | ||
t2[e - 1] = arguments[e]; | ||
if ("production" !== process.env.NODE_ENV) { | ||
var i2 = Y[n2], o2 = i2 ? "function" == typeof i2 ? i2.apply(null, t2) : i2 : "unknown error nr: " + n2; | ||
throw Error("[Immer] " + o2); | ||
} | ||
throw Error("[Immer] minified error nr: " + n2 + (t2.length ? " " + t2.map(function(n3) { | ||
return "'" + n3 + "'"; | ||
}).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf"); | ||
} | ||
function r(n2) { | ||
return !!n2 && !!n2[Q]; | ||
} | ||
function t(n2) { | ||
var r2; | ||
return !!n2 && (function(n3) { | ||
if (!n3 || "object" != typeof n3) | ||
return false; | ||
var r3 = Object.getPrototypeOf(n3); | ||
if (null === r3) | ||
return true; | ||
var t2 = Object.hasOwnProperty.call(r3, "constructor") && r3.constructor; | ||
return t2 === Object || "function" == typeof t2 && Function.toString.call(t2) === Z; | ||
}(n2) || Array.isArray(n2) || !!n2[L] || !!(null === (r2 = n2.constructor) || void 0 === r2 ? void 0 : r2[L]) || s(n2) || v(n2)); | ||
} | ||
function i(n2, r2, t2) { | ||
void 0 === t2 && (t2 = false), 0 === o(n2) ? (t2 ? Object.keys : nn)(n2).forEach(function(e) { | ||
t2 && "symbol" == typeof e || r2(e, n2[e], n2); | ||
}) : n2.forEach(function(t3, e) { | ||
return r2(e, t3, n2); | ||
}); | ||
} | ||
function o(n2) { | ||
var r2 = n2[Q]; | ||
return r2 ? r2.i > 3 ? r2.i - 4 : r2.i : Array.isArray(n2) ? 1 : s(n2) ? 2 : v(n2) ? 3 : 0; | ||
} | ||
function u(n2, r2) { | ||
return 2 === o(n2) ? n2.has(r2) : Object.prototype.hasOwnProperty.call(n2, r2); | ||
} | ||
function a(n2, r2) { | ||
return 2 === o(n2) ? n2.get(r2) : n2[r2]; | ||
} | ||
function f(n2, r2, t2) { | ||
var e = o(n2); | ||
2 === e ? n2.set(r2, t2) : 3 === e ? (n2.delete(r2), n2.add(t2)) : n2[r2] = t2; | ||
} | ||
function c(n2, r2) { | ||
return n2 === r2 ? 0 !== n2 || 1 / n2 == 1 / r2 : n2 != n2 && r2 != r2; | ||
} | ||
function s(n2) { | ||
return X && n2 instanceof Map; | ||
} | ||
function v(n2) { | ||
return q && n2 instanceof Set; | ||
} | ||
function p(n2) { | ||
return n2.o || n2.t; | ||
} | ||
function l(n2) { | ||
if (Array.isArray(n2)) | ||
return Array.prototype.slice.call(n2); | ||
var r2 = rn(n2); | ||
delete r2[Q]; | ||
for (var t2 = nn(r2), e = 0; e < t2.length; e++) { | ||
var i2 = t2[e], o2 = r2[i2]; | ||
false === o2.writable && (o2.writable = true, o2.configurable = true), (o2.get || o2.set) && (r2[i2] = { configurable: true, writable: true, enumerable: o2.enumerable, value: n2[i2] }); | ||
} | ||
return Object.create(Object.getPrototypeOf(n2), r2); | ||
} | ||
function d(n2, e) { | ||
return void 0 === e && (e = false), y(n2) || r(n2) || !t(n2) ? n2 : (o(n2) > 1 && (n2.set = n2.add = n2.clear = n2.delete = h), Object.freeze(n2), e && i(n2, function(n3, r2) { | ||
return d(r2, true); | ||
}, true), n2); | ||
} | ||
function h() { | ||
n(2); | ||
} | ||
function y(n2) { | ||
return null == n2 || "object" != typeof n2 || Object.isFrozen(n2); | ||
} | ||
function b(r2) { | ||
var t2 = tn[r2]; | ||
return t2 || n(18, r2), t2; | ||
} | ||
function _() { | ||
return "production" === process.env.NODE_ENV || U || n(0), U; | ||
} | ||
function j(n2, r2) { | ||
r2 && (b("Patches"), n2.u = [], n2.s = [], n2.v = r2); | ||
} | ||
function O(n2) { | ||
g(n2), n2.p.forEach(S), n2.p = null; | ||
} | ||
function g(n2) { | ||
n2 === U && (U = n2.l); | ||
} | ||
function w(n2) { | ||
return U = { p: [], l: U, h: n2, m: true, _: 0 }; | ||
} | ||
function S(n2) { | ||
var r2 = n2[Q]; | ||
0 === r2.i || 1 === r2.i ? r2.j() : r2.O = true; | ||
} | ||
function P(r2, e) { | ||
e._ = e.p.length; | ||
var i2 = e.p[0], o2 = void 0 !== r2 && r2 !== i2; | ||
return e.h.g || b("ES5").S(e, r2, o2), o2 ? (i2[Q].P && (O(e), n(4)), t(r2) && (r2 = M(e, r2), e.l || x(e, r2)), e.u && b("Patches").M(i2[Q].t, r2, e.u, e.s)) : r2 = M(e, i2, []), O(e), e.u && e.v(e.u, e.s), r2 !== H ? r2 : void 0; | ||
} | ||
function M(n2, r2, t2) { | ||
if (y(r2)) | ||
return r2; | ||
var e = r2[Q]; | ||
if (!e) | ||
return i(r2, function(i2, o3) { | ||
return A(n2, e, r2, i2, o3, t2); | ||
}, true), r2; | ||
if (e.A !== n2) | ||
return r2; | ||
if (!e.P) | ||
return x(n2, e.t, true), e.t; | ||
if (!e.I) { | ||
e.I = true, e.A._--; | ||
var o2 = 4 === e.i || 5 === e.i ? e.o = l(e.k) : e.o; | ||
i(3 === e.i ? new Set(o2) : o2, function(r3, i2) { | ||
return A(n2, e, o2, r3, i2, t2); | ||
}), x(n2, o2, false), t2 && n2.u && b("Patches").R(e, t2, n2.u, n2.s); | ||
} | ||
return e.o; | ||
} | ||
function A(e, i2, o2, a2, c2, s2) { | ||
if ("production" !== process.env.NODE_ENV && c2 === o2 && n(5), r(c2)) { | ||
var v2 = M(e, c2, s2 && i2 && 3 !== i2.i && !u(i2.D, a2) ? s2.concat(a2) : void 0); | ||
if (f(o2, a2, v2), !r(v2)) | ||
return; | ||
e.m = false; | ||
} | ||
if (t(c2) && !y(c2)) { | ||
if (!e.h.F && e._ < 1) | ||
return; | ||
M(e, c2), i2 && i2.A.l || x(e, c2); | ||
} | ||
} | ||
function x(n2, r2, t2) { | ||
void 0 === t2 && (t2 = false), n2.h.F && n2.m && d(r2, t2); | ||
} | ||
function z(n2, r2) { | ||
var t2 = n2[Q]; | ||
return (t2 ? p(t2) : n2)[r2]; | ||
} | ||
function I(n2, r2) { | ||
if (r2 in n2) | ||
for (var t2 = Object.getPrototypeOf(n2); t2; ) { | ||
var e = Object.getOwnPropertyDescriptor(t2, r2); | ||
if (e) | ||
return e; | ||
t2 = Object.getPrototypeOf(t2); | ||
} | ||
} | ||
function k(n2) { | ||
n2.P || (n2.P = true, n2.l && k(n2.l)); | ||
} | ||
function E(n2) { | ||
n2.o || (n2.o = l(n2.t)); | ||
} | ||
function R(n2, r2, t2) { | ||
var e = s(r2) ? b("MapSet").N(r2, t2) : v(r2) ? b("MapSet").T(r2, t2) : n2.g ? function(n3, r3) { | ||
var t3 = Array.isArray(n3), e2 = { i: t3 ? 1 : 0, A: r3 ? r3.A : _(), P: false, I: false, D: {}, l: r3, t: n3, k: null, o: null, j: null, C: false }, i2 = e2, o2 = en; | ||
t3 && (i2 = [e2], o2 = on); | ||
var u2 = Proxy.revocable(i2, o2), a2 = u2.revoke, f2 = u2.proxy; | ||
return e2.k = f2, e2.j = a2, f2; | ||
}(r2, t2) : b("ES5").J(r2, t2); | ||
return (t2 ? t2.A : _()).p.push(e), e; | ||
} | ||
function D(e) { | ||
return r(e) || n(22, e), function n2(r2) { | ||
if (!t(r2)) | ||
return r2; | ||
var e2, u2 = r2[Q], c2 = o(r2); | ||
if (u2) { | ||
if (!u2.P && (u2.i < 4 || !b("ES5").K(u2))) | ||
return u2.t; | ||
u2.I = true, e2 = F(r2, c2), u2.I = false; | ||
} else | ||
e2 = F(r2, c2); | ||
return i(e2, function(r3, t2) { | ||
u2 && a(u2.t, r3) === t2 || f(e2, r3, n2(t2)); | ||
}), 3 === c2 ? new Set(e2) : e2; | ||
}(e); | ||
} | ||
function F(n2, r2) { | ||
switch (r2) { | ||
case 2: | ||
return new Map(n2); | ||
case 3: | ||
return Array.from(n2); | ||
} | ||
return l(n2); | ||
} | ||
var G; | ||
var U; | ||
var W = "undefined" != typeof Symbol && "symbol" == typeof Symbol("x"); | ||
var X = "undefined" != typeof Map; | ||
var q = "undefined" != typeof Set; | ||
var B = "undefined" != typeof Proxy && void 0 !== Proxy.revocable && "undefined" != typeof Reflect; | ||
var H = W ? Symbol.for("immer-nothing") : ((G = {})["immer-nothing"] = true, G); | ||
var L = W ? Symbol.for("immer-draftable") : "__$immer_draftable"; | ||
var Q = W ? Symbol.for("immer-state") : "__$immer_state"; | ||
var Y = { 0: "Illegal state", 1: "Immer drafts cannot have computed properties", 2: "This object has been frozen and should not be mutated", 3: function(n2) { | ||
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + n2; | ||
}, 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.", 5: "Immer forbids circular references", 6: "The first or second argument to `produce` must be a function", 7: "The third argument to `produce` must be a function or undefined", 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object", 9: "First argument to `finishDraft` must be a draft returned by `createDraft`", 10: "The given draft is already finalized", 11: "Object.defineProperty() cannot be used on an Immer draft", 12: "Object.setPrototypeOf() cannot be used on an Immer draft", 13: "Immer only supports deleting array indices", 14: "Immer only supports setting array indices and the 'length' property", 15: function(n2) { | ||
return "Cannot apply patch, path doesn't resolve: " + n2; | ||
}, 16: 'Sets cannot have "replace" patches.', 17: function(n2) { | ||
return "Unsupported patch operation: " + n2; | ||
}, 18: function(n2) { | ||
return "The plugin for '" + n2 + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + n2 + "()` when initializing your application."; | ||
}, 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available", 21: function(n2) { | ||
return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '" + n2 + "'"; | ||
}, 22: function(n2) { | ||
return "'current' expects a draft, got: " + n2; | ||
}, 23: function(n2) { | ||
return "'original' expects a draft, got: " + n2; | ||
}, 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed" }; | ||
var Z = "" + Object.prototype.constructor; | ||
var nn = "undefined" != typeof Reflect && Reflect.ownKeys ? Reflect.ownKeys : void 0 !== Object.getOwnPropertySymbols ? function(n2) { | ||
return Object.getOwnPropertyNames(n2).concat(Object.getOwnPropertySymbols(n2)); | ||
} : Object.getOwnPropertyNames; | ||
var rn = Object.getOwnPropertyDescriptors || function(n2) { | ||
var r2 = {}; | ||
return nn(n2).forEach(function(t2) { | ||
r2[t2] = Object.getOwnPropertyDescriptor(n2, t2); | ||
}), r2; | ||
}; | ||
var tn = {}; | ||
var en = { get: function(n2, r2) { | ||
if (r2 === Q) | ||
return n2; | ||
var e = p(n2); | ||
if (!u(e, r2)) | ||
return function(n3, r3, t2) { | ||
var e2, i3 = I(r3, t2); | ||
return i3 ? "value" in i3 ? i3.value : null === (e2 = i3.get) || void 0 === e2 ? void 0 : e2.call(n3.k) : void 0; | ||
}(n2, e, r2); | ||
var i2 = e[r2]; | ||
return n2.I || !t(i2) ? i2 : i2 === z(n2.t, r2) ? (E(n2), n2.o[r2] = R(n2.A.h, i2, n2)) : i2; | ||
}, has: function(n2, r2) { | ||
return r2 in p(n2); | ||
}, ownKeys: function(n2) { | ||
return Reflect.ownKeys(p(n2)); | ||
}, set: function(n2, r2, t2) { | ||
var e = I(p(n2), r2); | ||
if (null == e ? void 0 : e.set) | ||
return e.set.call(n2.k, t2), true; | ||
if (!n2.P) { | ||
var i2 = z(p(n2), r2), o2 = null == i2 ? void 0 : i2[Q]; | ||
if (o2 && o2.t === t2) | ||
return n2.o[r2] = t2, n2.D[r2] = false, true; | ||
if (c(t2, i2) && (void 0 !== t2 || u(n2.t, r2))) | ||
return true; | ||
E(n2), k(n2); | ||
} | ||
return n2.o[r2] === t2 && "number" != typeof t2 && (void 0 !== t2 || r2 in n2.o) || (n2.o[r2] = t2, n2.D[r2] = true, true); | ||
}, deleteProperty: function(n2, r2) { | ||
return void 0 !== z(n2.t, r2) || r2 in n2.t ? (n2.D[r2] = false, E(n2), k(n2)) : delete n2.D[r2], n2.o && delete n2.o[r2], true; | ||
}, getOwnPropertyDescriptor: function(n2, r2) { | ||
var t2 = p(n2), e = Reflect.getOwnPropertyDescriptor(t2, r2); | ||
return e ? { writable: true, configurable: 1 !== n2.i || "length" !== r2, enumerable: e.enumerable, value: t2[r2] } : e; | ||
}, defineProperty: function() { | ||
n(11); | ||
}, getPrototypeOf: function(n2) { | ||
return Object.getPrototypeOf(n2.t); | ||
}, setPrototypeOf: function() { | ||
n(12); | ||
} }; | ||
var on = {}; | ||
i(en, function(n2, r2) { | ||
on[n2] = function() { | ||
return arguments[0] = arguments[0][0], r2.apply(this, arguments); | ||
}; | ||
}), on.deleteProperty = function(r2, t2) { | ||
return "production" !== process.env.NODE_ENV && isNaN(parseInt(t2)) && n(13), on.set.call(this, r2, t2, void 0); | ||
}, on.set = function(r2, t2, e) { | ||
return "production" !== process.env.NODE_ENV && "length" !== t2 && isNaN(parseInt(t2)) && n(14), en.set.call(this, r2[0], t2, e, r2[0]); | ||
}; | ||
var un = function() { | ||
function e(r2) { | ||
var e2 = this; | ||
this.g = B, this.F = true, this.produce = function(r3, i3, o2) { | ||
if ("function" == typeof r3 && "function" != typeof i3) { | ||
var u2 = i3; | ||
i3 = r3; | ||
var a2 = e2; | ||
return function(n2) { | ||
var r4 = this; | ||
void 0 === n2 && (n2 = u2); | ||
for (var t2 = arguments.length, e3 = Array(t2 > 1 ? t2 - 1 : 0), o3 = 1; o3 < t2; o3++) | ||
e3[o3 - 1] = arguments[o3]; | ||
return a2.produce(n2, function(n3) { | ||
var t3; | ||
return (t3 = i3).call.apply(t3, [r4, n3].concat(e3)); | ||
}); | ||
}; | ||
} | ||
var f2; | ||
if ("function" != typeof i3 && n(6), void 0 !== o2 && "function" != typeof o2 && n(7), t(r3)) { | ||
var c2 = w(e2), s2 = R(e2, r3, void 0), v2 = true; | ||
try { | ||
f2 = i3(s2), v2 = false; | ||
} finally { | ||
v2 ? O(c2) : g(c2); | ||
} | ||
return "undefined" != typeof Promise && f2 instanceof Promise ? f2.then(function(n2) { | ||
return j(c2, o2), P(n2, c2); | ||
}, function(n2) { | ||
throw O(c2), n2; | ||
}) : (j(c2, o2), P(f2, c2)); | ||
} | ||
if (!r3 || "object" != typeof r3) { | ||
if (void 0 === (f2 = i3(r3)) && (f2 = r3), f2 === H && (f2 = void 0), e2.F && d(f2, true), o2) { | ||
var p2 = [], l2 = []; | ||
b("Patches").M(r3, f2, p2, l2), o2(p2, l2); | ||
} | ||
return f2; | ||
} | ||
n(21, r3); | ||
}, this.produceWithPatches = function(n2, r3) { | ||
if ("function" == typeof n2) | ||
return function(r4) { | ||
for (var t3 = arguments.length, i4 = Array(t3 > 1 ? t3 - 1 : 0), o3 = 1; o3 < t3; o3++) | ||
i4[o3 - 1] = arguments[o3]; | ||
return e2.produceWithPatches(r4, function(r5) { | ||
return n2.apply(void 0, [r5].concat(i4)); | ||
}); | ||
}; | ||
var t2, i3, o2 = e2.produce(n2, r3, function(n3, r4) { | ||
t2 = n3, i3 = r4; | ||
}); | ||
return "undefined" != typeof Promise && o2 instanceof Promise ? o2.then(function(n3) { | ||
return [n3, t2, i3]; | ||
}) : [o2, t2, i3]; | ||
}, "boolean" == typeof (null == r2 ? void 0 : r2.useProxies) && this.setUseProxies(r2.useProxies), "boolean" == typeof (null == r2 ? void 0 : r2.autoFreeze) && this.setAutoFreeze(r2.autoFreeze); | ||
} | ||
var i2 = e.prototype; | ||
return i2.createDraft = function(e2) { | ||
t(e2) || n(8), r(e2) && (e2 = D(e2)); | ||
var i3 = w(this), o2 = R(this, e2, void 0); | ||
return o2[Q].C = true, g(i3), o2; | ||
}, i2.finishDraft = function(r2, t2) { | ||
var e2 = r2 && r2[Q]; | ||
"production" !== process.env.NODE_ENV && (e2 && e2.C || n(9), e2.I && n(10)); | ||
var i3 = e2.A; | ||
return j(i3, t2), P(void 0, i3); | ||
}, i2.setAutoFreeze = function(n2) { | ||
this.F = n2; | ||
}, i2.setUseProxies = function(r2) { | ||
r2 && !B && n(20), this.g = r2; | ||
}, i2.applyPatches = function(n2, t2) { | ||
var e2; | ||
for (e2 = t2.length - 1; e2 >= 0; e2--) { | ||
var i3 = t2[e2]; | ||
if (0 === i3.path.length && "replace" === i3.op) { | ||
n2 = i3.value; | ||
break; | ||
} | ||
} | ||
e2 > -1 && (t2 = t2.slice(e2 + 1)); | ||
var o2 = b("Patches").$; | ||
return r(n2) ? o2(n2, t2) : this.produce(n2, function(n3) { | ||
return o2(n3, t2); | ||
}); | ||
}, e; | ||
}(); | ||
var an = new un(); | ||
var fn = an.produce; | ||
var cn = an.produceWithPatches.bind(an); | ||
var sn = an.setAutoFreeze.bind(an); | ||
var vn = an.setUseProxies.bind(an); | ||
var pn = an.applyPatches.bind(an); | ||
var ln = an.createDraft.bind(an); | ||
var dn = an.finishDraft.bind(an); | ||
var immer_esm_default = fn; | ||
// src/middlewares/string.ts | ||
import { set as _set } from "lodash"; | ||
var StringMiddleware = { | ||
check(datasource) { | ||
return datasource.type === "scalar" && datasource.dataType === "string"; | ||
}, | ||
create(datasource) { | ||
if (!StringMiddleware.check(datasource)) | ||
return; | ||
}, | ||
set(root, _2, value, ctx) { | ||
const { value: state } = ctx; | ||
const datasource = state.sources[root]; | ||
if (!datasource || !StringMiddleware.check(datasource)) | ||
return; | ||
const newValue = immer_esm_default(state, (draft) => { | ||
_set(draft.sources, `${root}.value`, value); | ||
}); | ||
ctx.next(newValue); | ||
} | ||
}; | ||
// src/middlewares/boolean.ts | ||
import { set as _set2 } from "lodash"; | ||
var BoolMiddleware = { | ||
check(datasource) { | ||
return datasource.type === "scalar" && datasource.dataType === "boolean"; | ||
}, | ||
create(datasource) { | ||
if (!BoolMiddleware.check(datasource)) | ||
return; | ||
}, | ||
set(root, _2, value, ctx) { | ||
const { value: state } = ctx; | ||
const datasource = state.sources[root]; | ||
if (!datasource || !BoolMiddleware.check(datasource)) | ||
return; | ||
const newValue = immer_esm_default(state, (draft) => { | ||
_set2(draft.sources, `${root}.value`, value); | ||
}); | ||
ctx.next(newValue); | ||
} | ||
}; | ||
// src/middlewares/object.ts | ||
import { set as _set3 } from "lodash"; | ||
var ObjectMiddleware = { | ||
check(datasource) { | ||
return datasource.type === "scalar" && datasource.dataType === "object"; | ||
}, | ||
create(datasource) { | ||
if (!ObjectMiddleware.check(datasource)) | ||
return; | ||
}, | ||
set(root, path, value, ctx) { | ||
const { value: state } = ctx; | ||
const datasource = state.sources[root]; | ||
if (!datasource || !ObjectMiddleware.check(datasource)) | ||
return; | ||
const newValue = immer_esm_default(state, (draft) => { | ||
_set3( | ||
draft.sources, | ||
`${root}.value${path.length > 0 ? "." : ""}${path.join(".")}`, | ||
value | ||
); | ||
}); | ||
ctx.next(newValue); | ||
} | ||
}; | ||
// src/store.ts | ||
var DEFAULT_NS = "__default"; | ||
function selectByKey(path) { | ||
const key = normalizePath(path); | ||
const [root, ...chunks] = key.split("."); | ||
return function(source) { | ||
return source.pipe( | ||
map((value) => { | ||
return _get( | ||
value.sources, | ||
`${root}.value${chunks.length > 0 ? "." : ""}${chunks.join(".")}` | ||
); | ||
}), | ||
distinctUntilChanged(), | ||
filter((v2) => typeof v2 !== "undefined") | ||
); | ||
}; | ||
} | ||
function normalizePath(path) { | ||
let [namespace, id] = path.split(":"); | ||
if (!id) { | ||
[id, namespace] = [namespace, DEFAULT_NS]; | ||
} | ||
return getKey(id, namespace); | ||
} | ||
function getKey(id, namespace = DEFAULT_NS) { | ||
return `${namespace}:${id}`; | ||
} | ||
var _Store = class { | ||
middlewares = []; | ||
$_state = new BehaviorSubject({ | ||
catalogs: {}, | ||
sources: {} | ||
}); | ||
$state = this.$_state.asObservable(); | ||
connection; | ||
constructor() { | ||
this.use(StringMiddleware); | ||
this.use(BoolMiddleware); | ||
this.use(ObjectMiddleware); | ||
} | ||
inspect(opts) { | ||
if (!this.connection) { | ||
this.connection = inspect( | ||
opts.name ?? "Qodly Mobile", | ||
this.$_state, | ||
opts | ||
); | ||
} | ||
return this.connection; | ||
} | ||
static getInstance() { | ||
if (!_Store.instance) { | ||
_Store.instance = new _Store(); | ||
} | ||
return _Store.instance; | ||
} | ||
create(datasource) { | ||
const { id, namespace = DEFAULT_NS } = datasource; | ||
const key = getKey(id, namespace); | ||
const { value } = this.$_state; | ||
const found = this.getSourceByKey(key); | ||
if (typeof found !== "undefined") { | ||
throw new Error("datasource already exists"); | ||
} | ||
this.middlewares.forEach(({ create }) => { | ||
create(datasource, value); | ||
}); | ||
this.$_state.next({ | ||
...value, | ||
sources: { | ||
...value.sources, | ||
[key]: datasource | ||
} | ||
}); | ||
this.$_state.pipe(distinctUntilChanged()); | ||
} | ||
getSourceByKey(key) { | ||
return this.$_state.value.sources[key]; | ||
} | ||
get(path) { | ||
const key = normalizePath(path); | ||
return this.$_state.pipe(map((value) => value.sources[key])); | ||
} | ||
set(path, value) { | ||
const key = normalizePath(path); | ||
const [root, ...chunks] = key.split("."); | ||
const found = this.getSourceByKey(root); | ||
if (!found) | ||
return; | ||
this.middlewares.forEach(({ set }) => { | ||
set(root, chunks, value, this.$_state); | ||
}); | ||
} | ||
close() { | ||
this.$_state.complete(); | ||
} | ||
use(middleware) { | ||
this.middlewares.push(middleware); | ||
} | ||
}; | ||
var Store = _Store; | ||
__publicField(Store, "instance"); | ||
export { | ||
Store, | ||
getKey, | ||
normalizePath, | ||
selectByKey | ||
}; | ||
import{get as ve}from"lodash";import{BehaviorSubject as Se}from"rxjs";import{filter as be,map as te,distinctUntilChanged as re}from"rxjs/operators";function K(e="Qodly",t,r={}){if(!(window&&typeof window.__REDUX_DEVTOOLS_EXTENSION__<"u")){console.error("You must have Redux DevTools Extension installed in order to use qodly inspector.");return}let o=window.__REDUX_DEVTOOLS_EXTENSION__?.connect({...r,name:e,trace:!0,features:{...r.features,pause:!0,lock:!0,export:!0,import:"custom",jump:!0,skip:!0,reorder:!0,persist:!0,dispatch:!0,test:!1}});return o?.init({}),t.subscribe(s=>{o?.send({type:"@@UPDATE"},s)}),o?.subscribe(s=>{typeof s?.state=="string"&&t.next(JSON.parse(s.state))}),o}var L=Symbol.for("immer-nothing"),V=Symbol.for("immer-draftable"),u=Symbol.for("immer-state"),ie=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function a(e,...t){if(process.env.NODE_ENV!=="production"){let r=ie[e],n=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var h=Object.getPrototypeOf;function y(e){return!!e&&!!e[u]}function p(e){return e?Q(e)||Array.isArray(e)||!!e[V]||!!e.constructor?.[V]||E(e)||P(e):!1}var ce=Object.prototype.constructor.toString();function Q(e){if(!e||typeof e!="object")return!1;let t=h(e);if(t===null)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===ce}function g(e,t){O(e)===0?Object.entries(e).forEach(([r,n])=>{t(r,n,e)}):e.forEach((r,n)=>t(n,r,e))}function O(e){let t=e[u];return t?t.type_:Array.isArray(e)?1:E(e)?2:P(e)?3:0}function k(e,t){return O(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function q(e,t,r){let n=O(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function ae(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function E(e){return e instanceof Map}function P(e){return e instanceof Set}function d(e){return e.copy_||e.base_}function N(e,t){if(E(e))return new Map(e);if(P(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Q(e))return h(e)?{...e}:Object.assign(Object.create(null),e);let r=Object.getOwnPropertyDescriptors(e);delete r[u];let n=Reflect.ownKeys(r);for(let o=0;o<n.length;o++){let s=n[o],i=r[s];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(r[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(h(e),r)}function R(e,t=!1){return D(e)||y(e)||!p(e)||(O(e)>1&&(e.set=e.add=e.clear=e.delete=ue),Object.freeze(e),t&&g(e,(r,n)=>R(n,!0),!0)),e}function ue(){a(2)}function D(e){return Object.isFrozen(e)}var fe={};function _(e){let t=fe[e];return t||a(0,e),t}var w;function H(){return w}function le(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function W(e,t){t&&(_("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function T(e){C(e),e.drafts_.forEach(de),e.drafts_=null}function C(e){e===w&&(w=e.parent_)}function X(e){return w=le(w,e)}function de(e){let t=e[u];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function G(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[u].modified_&&(T(t),a(4)),p(e)&&(e=S(t,e),t.parent_||b(t,e)),t.patches_&&_("Patches").generateReplacementPatches_(r[u].base_,e,t.patches_,t.inversePatches_)):e=S(t,r,[]),T(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==L?e:void 0}function S(e,t,r){if(D(t))return t;let n=t[u];if(!n)return g(t,(o,s)=>J(e,n,t,o,s,r),!0),t;if(n.scope_!==e)return t;if(!n.modified_)return b(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let o=n.copy_,s=o,i=!1;n.type_===3&&(s=new Set(o),o.clear(),i=!0),g(s,(c,l)=>J(e,n,o,c,l,r,i)),b(e,o,!1),r&&e.patches_&&_("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function J(e,t,r,n,o,s,i){if(process.env.NODE_ENV!=="production"&&o===r&&a(5),y(o)){let c=s&&t&&t.type_!==3&&!k(t.assigned_,n)?s.concat(n):void 0,l=S(e,o,c);if(q(r,n,l),y(l))e.canAutoFreeze_=!1;else return}else i&&r.add(o);if(p(o)&&!D(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;S(e,o),(!t||!t.scope_.parent_)&&b(e,o)}}function b(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&R(t,r)}function pe(e,t){let r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:H(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,s=B;r&&(o=[n],s=v);let{revoke:i,proxy:c}=Proxy.revocable(o,s);return n.draft_=c,n.revoke_=i,c}var B={get(e,t){if(t===u)return e;let r=d(e);if(!k(r,t))return _e(e,r,t);let n=r[t];return e.finalized_||!p(n)?n:n===I(e.base_,t)?(A(e),e.copy_[t]=$(n,e)):n},has(e,t){return t in d(e)},ownKeys(e){return Reflect.ownKeys(d(e))},set(e,t,r){let n=Y(d(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=I(d(e),t),s=o?.[u];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(ae(r,o)&&(r!==void 0||k(e.base_,t)))return!0;A(e),F(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return I(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,A(e),F(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=d(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){a(11)},getPrototypeOf(e){return h(e.base_)},setPrototypeOf(){a(12)}},v={};g(B,(e,t)=>{v[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});v.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&a(13),v.set.call(this,e,t,void 0)};v.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&a(14),B.set.call(this,e[0],t,r,e[0])};function I(e,t){let r=e[u];return(r?d(r):e)[t]}function _e(e,t,r){let n=Y(t,r);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}function Y(e,t){if(!(t in e))return;let r=h(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=h(r)}}function F(e){e.modified_||(e.modified_=!0,e.parent_&&F(e.parent_))}function A(e){e.copy_||(e.copy_=N(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var he=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let i=this;return function(l=s,...oe){return i.produce(l,se=>r.call(this,se,...oe))}}typeof r!="function"&&a(6),n!==void 0&&typeof n!="function"&&a(7);let o;if(p(t)){let s=X(this),i=$(t,void 0),c=!0;try{o=r(i),c=!1}finally{c?T(s):C(s)}return W(s,n),G(o,s)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===L&&(o=void 0),this.autoFreeze_&&R(o,!0),n){let s=[],i=[];_("Patches").generateReplacementPatches_(t,o,s,i),n(s,i)}return o}else a(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(i,...c)=>this.produceWithPatches(i,l=>t(l,...c));let n,o;return[this.produce(t,r,(i,c)=>{n=i,o=c}),n,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){p(e)||a(8),y(e)&&(e=ye(e));let t=X(this),r=$(e,void 0);return r[u].isManual_=!0,C(t),r}finishDraft(e,t){let r=e&&e[u];(!r||!r.isManual_)&&a(9);let{scope_:n}=r;return W(n,t),G(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=_("Patches").applyPatches_;return y(e)?n(e,t):this.produce(e,o=>n(o,t))}};function $(e,t){let r=E(e)?_("MapSet").proxyMap_(e,t):P(e)?_("MapSet").proxySet_(e,t):pe(e,t);return(t?t.scope_:H()).drafts_.push(r),r}function ye(e){return y(e)||a(10,e),Z(e)}function Z(e){if(!p(e)||D(e))return e;let t=e[u],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=N(e,t.scope_.immer_.useStrictShallowCopy_)}else r=N(e,!0);return g(r,(n,o)=>{q(r,n,Z(o))}),t&&(t.finalized_=!1),r}var f=new he,m=f.produce,Ee=f.produceWithPatches.bind(f),Pe=f.setAutoFreeze.bind(f),De=f.setUseStrictShallowCopy.bind(f),ze=f.applyPatches.bind(f),xe=f.createDraft.bind(f),Me=f.finishDraft.bind(f);import{set as me}from"lodash";var z={check(e){return e.type==="scalar"&&e.dataType==="string"},create(e){z.check(e)},set(e,t,r,n){let{value:o}=n,s=o.sources[e];if(!s||!z.check(s))return;let i=m(o,c=>{me(c.sources,`${e}.value`,r)});n.next(i)}};import{set as ge}from"lodash";var x={check(e){return e.type==="scalar"&&e.dataType==="boolean"},create(e){x.check(e)},set(e,t,r,n){let{value:o}=n,s=o.sources[e];if(!s||!x.check(s))return;let i=m(o,c=>{ge(c.sources,`${e}.value`,r)});n.next(i)}};import{set as we}from"lodash";var M={check(e){return e.type==="scalar"&&e.dataType==="object"},create(e){M.check(e)},set(e,t,r,n){let{value:o}=n,s=o.sources[e];if(!s||!M.check(s))return;let i=m(o,c=>{we(c.sources,`${e}.value${t.length>0?".":""}${t.join(".")}`,r)});n.next(i)}};var j="__default";function He(e){let t=U(e),[r,...n]=t.split(".");return function(o){return o.pipe(te(s=>ve(s.sources,`${r}.value${n.length>0?".":""}${n.join(".")}`)),re(),be(s=>typeof s<"u"))}}function U(e){let[t,r]=e.split(":");return r||([r,t]=[t,j]),ne(r,t)}function ne(e,t=j){return`${t}:${e}`}var ee=class e{constructor(){this.middlewares=[];this.$_state=new Se({catalogs:{},sources:{}});this.$state=this.$_state.asObservable();this.use(z),this.use(x),this.use(M)}inspect(t){return this.connection||(this.connection=K(t.name??"Qodly Mobile",this.$_state,t)),this.connection}static getInstance(){return e.instance||(e.instance=new e),e.instance}static destroy(){e.instance=void 0}create(t){let{id:r,namespace:n=j}=t,o=ne(r,n),{value:s}=this.$_state;if(typeof this.getSourceByKey(o)<"u")throw new Error("datasource already exists");this.middlewares.forEach(({create:c})=>{c(t,s)}),this.$_state.next({...s,sources:{...s.sources,[o]:t}}),this.$_state.pipe(re())}getSourceByKey(t){return this.$_state.value.sources[t]}get(t){let r=U(t);return this.$_state.pipe(te(n=>n.sources[r]))}set(t,r){let n=U(t),[o,...s]=n.split(".");this.getSourceByKey(o)&&this.middlewares.forEach(({set:c})=>{c(o,s,r,this.$_state)})}unsubscribe(){this.$_state.complete()}use(t){this.middlewares.push(t)}};export{ee as Store,ne as getKey,U as normalizePath,He as selectByKey}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@ws-ui/datasources", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"type": "module", | ||
"description": "Datasources library for the Qodly Studio project", | ||
@@ -22,8 +23,7 @@ "keywords": [ | ||
"engines": { | ||
"node": "^18.7.0 || >= 16", | ||
"npm": "^8.16.0 || >= 8" | ||
"node": ">=20", | ||
"npm": ">=10" | ||
}, | ||
"volta": { | ||
"node": "18.7.0", | ||
"npm": "8.16.0" | ||
"node": "20.10.0" | ||
}, | ||
@@ -34,5 +34,6 @@ "publishConfig": { | ||
"scripts": { | ||
"build": "npm run clean && npm run type:dts && npm run build:main", | ||
"build:main": "node -r ./esbuild-hook ./scripts/build", | ||
"clean": "node -r ./esbuild-hook ./scripts/clean", | ||
"build": "npm run clean && npm run swc && npm run type:dts && npm run build:main", | ||
"swc": "swc ./src -d build -s true --copy-files", | ||
"build:main": "tsx ./scripts/build", | ||
"clean": "tsx ./scripts/clean", | ||
"type:dts": "tsc --emitDeclarationOnly", | ||
@@ -47,37 +48,22 @@ "type:check": "tsc --noEmit", | ||
"test:watch": "vitest watch", | ||
"test:coverage": "vitest run --coverage", | ||
"test:setup": "node -r ./esbuild-hook ./scripts/testSetup", | ||
"spell:check": "cspell \"{README.md,CODE_OF_CONDUCT.md,CONTRIBUTING.md,.github/*.md,src/**/*.ts}\"", | ||
"cz": "cz", | ||
"semantic-release": "semantic-release" | ||
"test:coverage": "vitest run --coverage" | ||
}, | ||
"devDependencies": { | ||
"@ryansonshine/commitizen": "^4.2.8", | ||
"@ryansonshine/cz-conventional-changelog": "^3.3.4", | ||
"@semantic-release/changelog": "^6.0.2", | ||
"@semantic-release/commit-analyzer": "^9.0.2", | ||
"@semantic-release/github": "^8.0.7", | ||
"@semantic-release/npm": "^9.0.1", | ||
"@semantic-release/release-notes-generator": "^10.0.3", | ||
"@types/lodash": "^4.14.191", | ||
"@types/node": "^18.11.15", | ||
"@types/prompts": "^2.4.2", | ||
"@typescript-eslint/eslint-plugin": "^5.46.1", | ||
"@typescript-eslint/parser": "^5.46.1", | ||
"@swc/cli": "^0.1.63", | ||
"@swc/core": "^1.3.102", | ||
"@types/lodash": "^4.14.202", | ||
"@types/node": "^20.10.6", | ||
"@typescript-eslint/eslint-plugin": "^6.17.0", | ||
"@vitest/coverage-c8": "^0.25.8", | ||
"c8": "^7.12.0", | ||
"cspell": "^6.17.0", | ||
"esbuild": "^0.16.7", | ||
"eslint": "^8.29.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-import-resolver-typescript": "^3.5.2", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.8.1", | ||
"rxjs": "^7.8.0", | ||
"semantic-release": "^19.0.5", | ||
"@vitest/coverage-v8": "^1.1.2", | ||
"esbuild": "^0.19.11", | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-plugin-import": "^2.29.1", | ||
"prettier": "^3.1.1", | ||
"source-map-support": "^0.5.21", | ||
"typescript": "^4.9.4", | ||
"vitest": "^0.25.8", | ||
"tsx": "^4.7.0", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.1.2", | ||
"yalc": "^1.0.0-pre.53" | ||
@@ -89,13 +75,13 @@ }, | ||
"peerDependencies": { | ||
"lodash": "^4.17.21", | ||
"rxjs": "^7.x" | ||
"lodash": "^4", | ||
"rxjs": "^7" | ||
}, | ||
"files": [ | ||
"build", | ||
"src", | ||
"!src/__tests__" | ||
"!__tests__" | ||
], | ||
"dependencies": { | ||
"immer": "^9.0.16" | ||
"immer": "^10.0.3", | ||
"rxjs": "^7" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18
39
11
Yes
251661
4
764
2
1
+ Addedrxjs@^7
+ Addedimmer@10.1.1(transitive)
- Removedimmer@9.0.21(transitive)
Updatedimmer@^10.0.3