@x-python/core
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,3 +0,2 @@ | ||
import m from "immer"; | ||
function w(I, g, C) { | ||
function Y(I, g, C) { | ||
return g in I ? Object.defineProperty(I, g, { | ||
@@ -13,6 +12,6 @@ value: C, | ||
if (Object.getOwnPropertySymbols) { | ||
var A = Object.getOwnPropertySymbols(I); | ||
g && (A = A.filter(function(i) { | ||
return Object.getOwnPropertyDescriptor(I, i).enumerable; | ||
})), C.push.apply(C, A); | ||
var l = Object.getOwnPropertySymbols(I); | ||
g && (l = l.filter(function(A) { | ||
return Object.getOwnPropertyDescriptor(I, A).enumerable; | ||
})), C.push.apply(C, l); | ||
} | ||
@@ -24,6 +23,6 @@ return C; | ||
var C = arguments[g] != null ? arguments[g] : {}; | ||
g % 2 ? X(Object(C), !0).forEach(function(A) { | ||
w(I, A, C[A]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(I, Object.getOwnPropertyDescriptors(C)) : X(Object(C)).forEach(function(A) { | ||
Object.defineProperty(I, A, Object.getOwnPropertyDescriptor(C, A)); | ||
g % 2 ? X(Object(C), !0).forEach(function(l) { | ||
Y(I, l, C[l]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(I, Object.getOwnPropertyDescriptors(C)) : X(Object(C)).forEach(function(l) { | ||
Object.defineProperty(I, l, Object.getOwnPropertyDescriptor(C, l)); | ||
}); | ||
@@ -33,54 +32,54 @@ } | ||
} | ||
function Y() { | ||
function H() { | ||
for (var I = arguments.length, g = new Array(I), C = 0; C < I; C++) | ||
g[C] = arguments[C]; | ||
return function(A) { | ||
return g.reduceRight(function(i, l) { | ||
return l(i); | ||
}, A); | ||
return function(l) { | ||
return g.reduceRight(function(A, i) { | ||
return i(A); | ||
}, l); | ||
}; | ||
} | ||
function s(I) { | ||
function m(I) { | ||
return function g() { | ||
for (var C = this, A = arguments.length, i = new Array(A), l = 0; l < A; l++) | ||
i[l] = arguments[l]; | ||
return i.length >= I.length ? I.apply(this, i) : function() { | ||
for (var c = arguments.length, B = new Array(c), G = 0; G < c; G++) | ||
B[G] = arguments[G]; | ||
return g.apply(C, [].concat(i, B)); | ||
for (var C = this, l = arguments.length, A = new Array(l), i = 0; i < l; i++) | ||
A[i] = arguments[i]; | ||
return A.length >= I.length ? I.apply(this, A) : function() { | ||
for (var G = arguments.length, d = new Array(G), b = 0; b < G; b++) | ||
d[b] = arguments[b]; | ||
return g.apply(C, [].concat(A, d)); | ||
}; | ||
}; | ||
} | ||
function e(I) { | ||
function K(I) { | ||
return {}.toString.call(I).includes("Object"); | ||
} | ||
function H(I) { | ||
function V(I) { | ||
return !Object.keys(I).length; | ||
} | ||
function K(I) { | ||
function s(I) { | ||
return typeof I == "function"; | ||
} | ||
function V(I, g) { | ||
function k(I, g) { | ||
return Object.prototype.hasOwnProperty.call(I, g); | ||
} | ||
function k(I, g) { | ||
return e(g) || n("changeType"), Object.keys(g).some(function(C) { | ||
return !V(I, C); | ||
function r(I, g) { | ||
return K(g) || n("changeType"), Object.keys(g).some(function(C) { | ||
return !k(I, C); | ||
}) && n("changeField"), g; | ||
} | ||
function r(I) { | ||
K(I) || n("selectorType"); | ||
} | ||
function L(I) { | ||
K(I) || e(I) || n("handlerType"), e(I) && Object.values(I).some(function(g) { | ||
return !K(g); | ||
}) && n("handlersType"); | ||
s(I) || n("selectorType"); | ||
} | ||
function R(I) { | ||
I || n("initialIsRequired"), e(I) || n("initialType"), H(I) && n("initialContent"); | ||
s(I) || K(I) || n("handlerType"), K(I) && Object.values(I).some(function(g) { | ||
return !s(g); | ||
}) && n("handlersType"); | ||
} | ||
function J(I, g) { | ||
function J(I) { | ||
I || n("initialIsRequired"), K(I) || n("initialType"), V(I) && n("initialContent"); | ||
} | ||
function v(I, g) { | ||
throw new Error(I[g] || I.default); | ||
} | ||
var v = { | ||
var F = { | ||
initialIsRequired: "initial state is required", | ||
@@ -95,41 +94,41 @@ initialType: "initial state should be an object", | ||
default: "an unknown error accured in `state-local` package" | ||
}, n = s(J)(v), a = { | ||
changes: k, | ||
selector: r, | ||
handler: L, | ||
initial: R | ||
}, n = m(v)(F), u = { | ||
changes: r, | ||
selector: L, | ||
handler: R, | ||
initial: J | ||
}; | ||
function F(I) { | ||
function U(I) { | ||
var g = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; | ||
a.initial(I), a.handler(g); | ||
u.initial(I), u.handler(g); | ||
var C = { | ||
current: I | ||
}, A = s(z)(C, g), i = s(N)(C), l = s(a.changes)(I), c = s(U)(C); | ||
function B() { | ||
var b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(y) { | ||
return y; | ||
}, l = m(Q)(C, g), A = m(z)(C), i = m(u.changes)(I), G = m(N)(C); | ||
function d() { | ||
var c = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(w) { | ||
return w; | ||
}; | ||
return a.selector(b), b(C.current); | ||
return u.selector(c), c(C.current); | ||
} | ||
function G(b) { | ||
Y(A, i, l, c)(b); | ||
function b(c) { | ||
H(l, A, i, G)(c); | ||
} | ||
return [B, G]; | ||
return [d, b]; | ||
} | ||
function U(I, g) { | ||
return K(g) ? g(I.current) : g; | ||
function N(I, g) { | ||
return s(g) ? g(I.current) : g; | ||
} | ||
function N(I, g) { | ||
function z(I, g) { | ||
return I.current = W(W({}, I.current), g), g; | ||
} | ||
function z(I, g, C) { | ||
return K(g) ? g(I.current) : Object.keys(C).forEach(function(A) { | ||
var i; | ||
return (i = g[A]) === null || i === void 0 ? void 0 : i.call(g, I.current[A]); | ||
function Q(I, g, C) { | ||
return s(g) ? g(I.current) : Object.keys(C).forEach(function(l) { | ||
var A; | ||
return (A = g[l]) === null || A === void 0 ? void 0 : A.call(g, I.current[l]); | ||
}), C; | ||
} | ||
var Q = { | ||
create: F | ||
var T = { | ||
create: U | ||
}; | ||
const T = { | ||
const O = { | ||
loadPyodideOptions: { | ||
@@ -139,13 +138,20 @@ indexURL: "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/" | ||
}; | ||
var t = /* @__PURE__ */ ((I) => (I[I.READY = 0] = "READY", I))(t || {}), d = /* @__PURE__ */ ((I) => (I[I.EXEC = 0] = "EXEC", I[I.COMPLETE = 1] = "COMPLETE", I[I.INSTALL = 2] = "INSTALL", I[I.FORMAT = 3] = "FORMAT", I))(d || {}); | ||
function O(I) { | ||
var t = /* @__PURE__ */ ((I) => (I[I.READY = 0] = "READY", I))(t || {}), o = /* @__PURE__ */ ((I) => (I[I.EXEC = 0] = "EXEC", I[I.COMPLETE = 1] = "COMPLETE", I[I.INSTALL = 2] = "INSTALL", I[I.FORMAT = 3] = "FORMAT", I))(o || {}); | ||
function f(I) { | ||
let g; | ||
return () => (g || (g = I()), g); | ||
} | ||
function p(I, g) { | ||
function e(I, g) { | ||
if (!g) | ||
throw new Error(`a wrong id is provided from worker - callback with ${I} id doesn't exist`); | ||
} | ||
function p(I, g) { | ||
const { [g]: C, ...l } = I; | ||
return l; | ||
} | ||
function y(I, g, C) { | ||
return { ...I, [g]: C }; | ||
} | ||
const h = "dmFyIHksIFAsIHgsIFQsIEMgPSB7IGV4cG9ydHM6IHt9IH07CkMuZXhwb3J0cyA9IGZ1bmN0aW9uKCkgewogIGZ1bmN0aW9uIGUocykgewogICAgcmV0dXJuICFpc05hTihwYXJzZUZsb2F0KHMpKSAmJiBpc0Zpbml0ZShzKTsKICB9CiAgZnVuY3Rpb24gdChzKSB7CiAgICByZXR1cm4gcy5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIHMuc3Vic3RyaW5nKDEpOwogIH0KICBmdW5jdGlvbiBuKHMpIHsKICAgIHJldHVybiBmdW5jdGlvbigpIHsKICAgICAgcmV0dXJuIHRoaXNbc107CiAgICB9OwogIH0KICB2YXIgciA9IFsiaXNDb25zdHJ1Y3RvciIsICJpc0V2YWwiLCAiaXNOYXRpdmUiLCAiaXNUb3BsZXZlbCJdLCBpID0gWyJjb2x1bW5OdW1iZXIiLCAibGluZU51bWJlciJdLCBvID0gWyJmaWxlTmFt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AgIHJldHVybiBmdW5jdGlvbihwKSB7CiAgICAgICAgdGhpc1tzXSA9IEJvb2xlYW4ocCk7CiAgICAgIH07CiAgICB9KHJbZl0pOwogIGZvciAodmFyIGMgPSAwOyBjIDwgaS5sZW5ndGg7IGMrKykKICAgIGwucHJvdG90eXBlWyJnZXQiICsgdChpW2NdKV0gPSBuKGlbY10pLCBsLnByb3RvdHlwZVsic2V0IiArIHQoaVtjXSldID0gZnVuY3Rpb24ocykgewogICAgICByZXR1cm4gZnVuY3Rpb24ocCkgewogICAgICAgIGlmICghZShwKSkKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IocyArICIgbXVzdCBiZSBhIE51bWJlciIpOwogICAgICAgIHRoaXNbc10gPSBOdW1iZXIocCk7CiAgICAgIH07CiAgICB9KGlbY10pOwogIGZvciAodmFyIHUgPSAwOyB1IDwgby5sZW5ndGg7IHUrKykKICAgIGwucHJvdG90eXBlWyJnZXQiICsgdChvW3VdKV0gPSBuKG9bdV0pLCBsLnByb3RvdHlwZVsic2V0IiArIHQob1t1XSldID0gZnVuY3Rpb24ocykgewogICAgICByZXR1cm4gZnVuY3Rpb24ocCkgewogICAgICAgIHRoaXNbc10gPSBTdHJpbmcocCk7CiAgICAgIH07CiAgICB9KG9bdV0pOwogIHJldHVybiBsOwp9KCk7CnZhciBxID0gKHkgPSBDLmV4cG9ydHMsIFAgPSAvKF58QClcUys6XGQrLywgeCA9IC9eXHMqYXQgLiooXFMrOlxkK3xcKG5hdGl2ZVwpKS9tLCBUID0gL14oZXZhbEApPyhcW25hdGl2ZSBjb2RlXSk/JC8sIHsgcGFyc2U6IGZ1bmN0aW9uKGUpIHsKICBpZiAoZS5zdGFja3RyYWNlICE9PSB2b2lkIDAgfHwgZVsib3BlcmEjc291cmNlbG9jIl0gIT09IHZvaWQgMCkKICAgIHJldHVybiB0aGlzLnBhcnNlT3BlcmEoZSk7CiAgaWYgKGUuc3RhY2sgJiYgZS5zdGFjay5tYXRjaCh4KSkKICA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IHJldHVybiBzdHJpbmcsIG51bGwsIG9yIHVuZGVmaW5lZCwgZ290IHR5cGUgJHt0eXBlb2YgbH0uYCk7CiAgICAgICAgICAgIGwuZW5kc1dpdGgoYApgKSB8fCAobCArPSBgCmApLCBhID0gby5lbmNvZGUobCksIGQgPSAwOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGQgPCBhLmxlbmd0aCkgewogICAgICAgICAgICBsZXQgbCA9IGFbZF07CiAgICAgICAgICAgIHJldHVybiBkKyssIGw7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gZCA9IC0xLCBudWxsOwogICAgICAgIH0gY2F0Y2ggKGwpIHsKICAgICAgICAgIHRocm93IGNvbnNvbGUuZXJyb3IoIkVycm9yIHRocm93biBpbiBzdGRpbjoiKSwgY29uc29sZS5lcnJvcihsKSwgbDsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIG07CiAgICB9KHQpLCBudWxsLCBudWxsKTsKICB9KTsKfQpmdW5jdGlvbiBHKGUsIHQpIHsKICBlLnJ1blB5dGhvbkludGVybmFsX2RpY3QgPSBlLl9weW9kaWRlLl9iYXNlLmV2YWxfY29kZSgie30iKSwgZS5pbXBvcnRsaWIgPSBlLnJ1blB5dGhvbkludGVybmFsKCJpbXBvcnQgaW1wb3J0bGliOyBpbXBvcnRsaWIiKTsKICBsZXQgbiA9IGUuaW1wb3J0bGliLmltcG9ydF9tb2R1bGU7CiAgZS5zeXMgPSBuKCJzeXMiKSwgZS5zeXMucGF0aC5pbnNlcnQoMCwgdC5ob21lZGlyKTsKICBsZXQgciA9IGUucnVuUHl0aG9uSW50ZXJuYWwoImltcG9ydCBfX21haW5fXzsgX19tYWluX18uX19kaWN0X18iKSwgaSA9IGUucnVuUHl0aG9uSW50ZXJuYWwoImltcG9ydCBidWlsdGluczsgYnVpbHRpbnMuX19kaWN0X18iKTsKICB2YXIgbzsKICBlLmdsb2JhbHMgPSAobyA9IGksIG5ldyBQcm94eShyLCB7IGdldDogKG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aXQgSihZLmxvYWRQeW9kaWRlT3B0aW9ucyk7CiAgYXdhaXQgZS5sb2FkUGFja2FnZSgibWljcm9waXAiKSwgYXdhaXQgZS5ydW5QeXRob25Bc3luYyhLKSwgcG9zdE1lc3NhZ2UoQS5SRUFEWSk7CiAgY29uc3QgdCA9IHsKICAgIFtnLkVYRUNdOiBhc3luYyAoeyBjb2RlOiBuLCBjb250ZXh0OiByID0ge30gfSkgPT4gewogICAgICBPYmplY3QuZW50cmllcyhyKS5mb3JFYWNoKChbaSwgb10pID0+IHsKICAgICAgICBlLmdsb2JhbHMuc2V0KGksIGUudG9QeShvKSk7CiAgICAgIH0pOwogICAgICB0cnkgewogICAgICAgIGF3YWl0IGUubG9hZFBhY2thZ2VzRnJvbUltcG9ydHMobiksIGUucnVuUHl0aG9uKCJpbXBvcnQgc3lzLCBpbzsgc3lzLnN0ZG91dCA9IGlvLlN0cmluZ0lPKCk7IHN5cy5zdGRlcnIgPSBpby5TdHJpbmdJTygpIik7CiAgICAgICAgY29uc3QgaSA9IGF3YWl0IGUucnVuUHl0aG9uQXN5bmMobiksIG8gPSBlLnJ1blB5dGhvbigiaW1wb3J0IHN5czsgc3lzLnN0ZG91dC5nZXR2YWx1ZSgpIikudHJpbSgpLCBhID0gZS5ydW5QeXRob24oImltcG9ydCBzeXM7IHN5cy5zdGRlcnIuZ2V0dmFsdWUoKSIpLnRyaW0oKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcmVzdWx0OiBfKGksIGUpLAogICAgICAgICAgc3Rkb3V0OiBfKG8sIGUpLAogICAgICAgICAgc3RkZXJyOiBhLAogICAgICAgICAgZXJyb3I6IG51bGwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChpKSB7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHJlc3VsdDogbnVsbCwKICAgICAgICAgIHN0ZG91dDogbnVsbCwKICAgICAgICAgIHN0ZGVycjogbnVsbCwKICAgICAgICAgIGVycm9yOiBRKGkubWVzc2FnZSkKICAgICAgICB9OwogICAgICB9IGZpbmFsbHkgewogICAgICAgIE9iamVjdC5lbnRyaWVzKHIpLmZvckVhY2goKFtpXSkgPT4gewogICAgICAgICAgdmFyIG87CiAgICAgICAgICBlLmdsb2JhbHMuc2V0KGksIChvID0gZS50b1B5KG51bGwpKSA9PSBudWxsID8gdm9pZCAwIDogby50b1N0cmluZygpKTsKICAgICAgICB9KTsKICAgICAgfQogICAgfSwKICAgIFtnLkNPTVBMRVRFXTogYXN5bmMgKHsKICAgICAgY29kZTogbiwKICAgICAgbGluZTogciwKICAgICAgY29sdW1uOiBpCiAgICB9KSA9PiB7CiAgICAgIGF3YWl0IGUubG9hZFBhY2thZ2VzRnJvbUltcG9ydHMobik7CiAgICAgIGNvbnN0IG8gPSBlLmdsb2JhbHMuZ2V0KCJnZXRfYXV0b2NvbXBsZXRpb24iKShuLCByLCBpKTsKICAgICAgcmV0dXJuIHsgcmVzdWx0OiBfKG8sIGUpLCBlcnJvcjogbnVsbCB9OwogICAgfSwKICAgIFtnLklOU1RBTExdOiBhc3luYyAoeyBwYWNrYWdlczogbiB9KSA9PiB7CiAgICAgIGNvbnN0IHIgPSBhd2FpdCBlLmdsb2JhbHMuZ2V0KCJpbnN0YWxsX3BhY2FrZ2UiKShuWzBdKTsKICAgICAgcmV0dXJuIGNvbnNvbGUubG9nKF8ociwgZSkpLCBfKHIsIGUpOwogICAgfSwKICAgIFtnLkZPUk1BVF06IGFzeW5jICh7IGNvZGU6IG4gfSkgPT4gewogICAgICBjb25zdCByID0gZS5nbG9iYWxzLmdldCgiZm9ybWF0X2NvZGUiKShuKTsKICAgICAgcmV0dXJuIHsgcmVzdWx0OiBfKHIsIGUpLCBlcnJvcjogbnVsbCB9OwogICAgfQogIH07CiAgb25tZXNzYWdlID0gYXN5bmMgZnVuY3Rpb24ocikgewogICAgY29uc3QgeyBpZDogaSwgYWN0aW9uOiBvID0gZy5FWEVDIH0gPSByLmRhdGE7CiAgICBzd2l0Y2ggKG8pIHsKICAgICAgY2FzZSBnLkVYRUM6CiAgICAgICAgY29uc3QgYSA9IGF3YWl0IHRbZy5FWEVDXShyLmRhdGEucGF5bG9hZCk7CiAgICAgICAgcG9zdE1lc3NhZ2UoewogICAgICAgICAgLi4uYSwKICAgICAgICAgIGlkOiBpLAogICAgICAgICAgYWN0aW9uOiBvCiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgZy5DT01QTEVURToKICAgICAgICBjb25zdCBkID0gYXdhaXQgdFtnLkNPTVBMRVRFXSgKICAgICAgICAgIHIuZGF0YS5wYXlsb2FkCiAgICAgICAgKTsKICAgICAgICBwb3N0TWVzc2FnZSh7CiAgICAgICAgICAuLi5kLAogICAgICAgICAgaWQ6IGksCiAgICAgICAgICBhY3Rpb246IG8KICAgICAgICB9KTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBnLklOU1RBTEw6CiAgICAgICAgY29uc3QgbSA9IGF3YWl0IHRbZy5JTlNUQUxMXShyLmRhdGEucGF5bG9hZCk7CiAgICAgICAgcG9zdE1lc3NhZ2UoewogICAgICAgICAgLi4ubSwKICAgICAgICAgIGlkOiBpLAogICAgICAgICAgYWN0aW9uOiBvCiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgZy5GT1JNQVQ6CiAgICAgICAgY29uc3QgbCA9IGF3YWl0IHRbZy5GT1JNQVRdKHIuZGF0YS5wYXlsb2FkKTsKICAgICAgICBwb3N0TWVzc2FnZSh7CiAgICAgICAgICAuLi5sLAogICAgICAgICAgaWQ6IGksCiAgICAgICAgICBhY3Rpb246IG8KICAgICAgICB9KTsKICAgICAgICBicmVhazsKICAgIH0KICB9Owp9ClooKTsK", S = typeof window < "u" && window.Blob && new Blob([atob(h)], { type: "text/javascript;charset=utf-8" }); | ||
function f() { | ||
function M() { | ||
const I = S && (window.URL || window.webkitURL).createObjectURL(S); | ||
@@ -158,4 +164,4 @@ try { | ||
} | ||
const M = Boolean(globalThis.Worker), [Z, o] = Q.create({ | ||
config: T, | ||
const j = Boolean(globalThis.Worker), [B, Z] = T.create({ | ||
config: O, | ||
pyodideWorker: null, | ||
@@ -167,86 +173,78 @@ execCallbacks: {}, | ||
commandUniqueId: 0 | ||
}), u = { | ||
}), a = { | ||
async ensureWorkerIsSetup() { | ||
const { pyodideWorker: I } = Z(); | ||
I || await E(); | ||
const { pyodideWorker: I } = B(); | ||
I || await q(); | ||
}, | ||
async command(I, g) { | ||
await u.ensureWorkerIsSetup(); | ||
const { commandUniqueId: C, pyodideWorker: A } = Z(); | ||
o({ commandUniqueId: C + 1 }), A == null || A.postMessage({ payload: I, id: C, action: g }); | ||
await a.ensureWorkerIsSetup(); | ||
const { commandUniqueId: C, pyodideWorker: l } = B(); | ||
Z({ commandUniqueId: C + 1 }), l == null || l.postMessage({ payload: I, id: C, action: g }); | ||
} | ||
}; | ||
function j({ result: I, error: g, id: C, stderr: A, stdout: i }) { | ||
const { execCallbacks: l } = Z(); | ||
p(C, Boolean(l[C])); | ||
const { resolve: c } = l[C]; | ||
o({ | ||
execCallbacks: m(l, (B) => { | ||
delete B[C]; | ||
}) | ||
}), c({ result: I, error: g, stderr: A, stdout: i }); | ||
function P({ result: I, error: g, id: C, stderr: l, stdout: A }) { | ||
const { execCallbacks: i } = B(); | ||
e(C, Boolean(i[C])); | ||
const { resolve: G } = i[C]; | ||
Z({ | ||
execCallbacks: p(i, C) | ||
}), G({ result: I, error: g, stderr: l, stdout: A }); | ||
} | ||
function P({ result: I, error: g, id: C }) { | ||
const { completeCallbacks: A } = Z(); | ||
p(C, Boolean(A[C])); | ||
const { resolve: i, reject: l } = A[C]; | ||
if (o({ | ||
completeCallbacks: m(A, (c) => { | ||
delete c[C]; | ||
}) | ||
function x({ result: I, error: g, id: C }) { | ||
const { completeCallbacks: l } = B(); | ||
e(C, Boolean(l[C])); | ||
const { resolve: A, reject: i } = l[C]; | ||
if (Z({ | ||
completeCallbacks: p(l, C) | ||
}), g) { | ||
l == null || l(g); | ||
i == null || i(g); | ||
return; | ||
} | ||
i(I); | ||
A(I); | ||
} | ||
function x({ success: I, error: g, id: C }) { | ||
const { installCallbacks: A } = Z(); | ||
p(C, Boolean(A[C])); | ||
const { resolve: i, reject: l } = A[C]; | ||
if (o({ | ||
installCallbacks: m(A, (c) => { | ||
delete c[C]; | ||
}) | ||
function D({ success: I, error: g, id: C }) { | ||
const { installCallbacks: l } = B(); | ||
e(C, Boolean(l[C])); | ||
const { resolve: A, reject: i } = l[C]; | ||
if (Z({ | ||
installCallbacks: p(l, C) | ||
}), g) { | ||
l == null || l(g); | ||
i == null || i(g); | ||
return; | ||
} | ||
i({ success: I, error: g }); | ||
A({ success: I, error: g }); | ||
} | ||
function D({ result: I, error: g, id: C }) { | ||
const { formatCallbacks: A } = Z(); | ||
p(C, Boolean(A[C])); | ||
const { resolve: i } = A[C]; | ||
o({ | ||
formatCallbacks: m(A, (l) => { | ||
delete l[C]; | ||
}) | ||
}), i({ result: I, error: g }); | ||
function E({ result: I, error: g, id: C }) { | ||
const { formatCallbacks: l } = B(); | ||
e(C, Boolean(l[C])); | ||
const { resolve: A } = l[C]; | ||
Z({ | ||
formatCallbacks: p(l, C) | ||
}), A({ result: I, error: g }); | ||
} | ||
const E = O(function() { | ||
const q = f(function() { | ||
return new Promise((g, C) => { | ||
M || C(new Error(`your browser does | ||
j || C(new Error(`your browser does | ||
t support web workers!`)); | ||
const A = new f(); | ||
A.onmessage = function(l) { | ||
l.data === t.READY ? (o({ pyodideWorker: A }), A.onmessage = function(B) { | ||
const { action: G, ...b } = B.data; | ||
switch (G) { | ||
case d.EXEC: | ||
j(b); | ||
const l = new M(); | ||
l.onmessage = function(i) { | ||
i.data === t.READY ? (Z({ pyodideWorker: l }), l.onmessage = function(d) { | ||
const { action: b, ...c } = d.data; | ||
switch (b) { | ||
case o.EXEC: | ||
P(c); | ||
break; | ||
case d.COMPLETE: | ||
P(b); | ||
case o.COMPLETE: | ||
x(c); | ||
break; | ||
case d.INSTALL: | ||
x(b); | ||
case o.INSTALL: | ||
D(c); | ||
break; | ||
case d.FORMAT: | ||
D(b); | ||
case o.FORMAT: | ||
E(c); | ||
break; | ||
} | ||
}, g(A)) : C(new Error("unexpected error in setup process")); | ||
}, A.onerror = function(l) { | ||
C(l.message); | ||
}, g(l)) : C(new Error("unexpected error in setup process")); | ||
}, l.onerror = function(i) { | ||
C(i.message); | ||
}; | ||
@@ -257,7 +255,5 @@ }); | ||
return new Promise((g) => { | ||
const { execCallbacks: C, commandUniqueId: A } = Z(); | ||
u.command(I, d.EXEC), o({ | ||
execCallbacks: m(C, (i) => { | ||
i[A] = { resolve: g }; | ||
}) | ||
const { execCallbacks: C, commandUniqueId: l } = B(); | ||
a.command(I, o.EXEC), Z({ | ||
execCallbacks: y(C, l, { resolve: g }) | ||
}); | ||
@@ -269,9 +265,10 @@ }); | ||
return new Promise((g, C) => { | ||
const { commandUniqueId: A, completeCallbacks: i } = Z(), { code: l, line: c, column: B } = I; | ||
let G = c, b = B; | ||
c || (G = l.split(` | ||
`).length), b || (b = l.split(` | ||
`)[G - 1].length), u.command({ code: l, line: G, column: b }, d.COMPLETE), o({ | ||
completeCallbacks: m(i, (y) => { | ||
y[A] = { resolve: g, reject: C }; | ||
const { commandUniqueId: l, completeCallbacks: A } = B(), { code: i, line: G, column: d } = I; | ||
let b = G, c = d; | ||
G || (b = i.split(` | ||
`).length), c || (c = i.split(` | ||
`)[b - 1].length), a.command({ code: i, line: b, column: c }, o.COMPLETE), Z({ | ||
completeCallbacks: y(A, l, { | ||
resolve: g, | ||
reject: C | ||
}) | ||
@@ -284,6 +281,7 @@ }); | ||
return new Promise((g, C) => { | ||
const { installCallbacks: A, commandUniqueId: i } = Z(); | ||
u.command({ packages: I }, d.INSTALL), o({ | ||
installCallbacks: m(A, (l) => { | ||
l[i] = { resolve: g, reject: C }; | ||
const { installCallbacks: l, commandUniqueId: A } = B(); | ||
a.command({ packages: I }, o.INSTALL), Z({ | ||
installCallbacks: y(l, A, { | ||
resolve: g, | ||
reject: C | ||
}) | ||
@@ -295,6 +293,7 @@ }); | ||
return new Promise((g, C) => { | ||
const { formatCallbacks: A, commandUniqueId: i } = Z(); | ||
u.command(I, d.FORMAT), o({ | ||
formatCallbacks: m(A, (l) => { | ||
l[i] = { resolve: g, reject: C }; | ||
const { formatCallbacks: l, commandUniqueId: A } = B(); | ||
a.command(I, o.FORMAT), Z({ | ||
formatCallbacks: y(l, A, { | ||
resolve: g, | ||
reject: C | ||
}) | ||
@@ -308,4 +307,4 @@ }); | ||
gI as format, | ||
E as init, | ||
q as init, | ||
II as install | ||
}; |
{ | ||
"name": "@x-python/core", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"type": "module", | ||
@@ -54,3 +54,2 @@ "license": "MIT", | ||
"dependencies": { | ||
"immer": "^9.0.16", | ||
"pyodide": "^0.21.3", | ||
@@ -57,0 +56,0 @@ "state-local": "^1.0.7" |
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
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
2
1
0
0
77517
561
- Removedimmer@^9.0.16
- Removedimmer@9.0.21(transitive)