@x-python/core
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,20 +0,149 @@ | ||
import d from "immer"; | ||
import S from "state-local"; | ||
const a = { | ||
pyodideSource: "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/" | ||
import m from "immer"; | ||
function w(I, g, C) { | ||
return g in I ? Object.defineProperty(I, g, { | ||
value: C, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : I[g] = C, I; | ||
} | ||
function X(I, g) { | ||
var C = Object.keys(I); | ||
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); | ||
} | ||
return C; | ||
} | ||
function W(I) { | ||
for (var g = 1; g < arguments.length; g++) { | ||
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)); | ||
}); | ||
} | ||
return I; | ||
} | ||
function Y() { | ||
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); | ||
}; | ||
} | ||
function s(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)); | ||
}; | ||
}; | ||
} | ||
function e(I) { | ||
return {}.toString.call(I).includes("Object"); | ||
} | ||
function H(I) { | ||
return !Object.keys(I).length; | ||
} | ||
function K(I) { | ||
return typeof I == "function"; | ||
} | ||
function V(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); | ||
}) && 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"); | ||
} | ||
function R(I) { | ||
I || n("initialIsRequired"), e(I) || n("initialType"), H(I) && n("initialContent"); | ||
} | ||
function J(I, g) { | ||
throw new Error(I[g] || I.default); | ||
} | ||
var v = { | ||
initialIsRequired: "initial state is required", | ||
initialType: "initial state should be an object", | ||
initialContent: "initial state shouldn't be an empty object", | ||
handlerType: "handler should be an object or a function", | ||
handlersType: "all handlers should be a functions", | ||
selectorType: "selector should be a function", | ||
changeType: "provided value of changes should be an object", | ||
changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state', | ||
default: "an unknown error accured in `state-local` package" | ||
}, n = s(J)(v), a = { | ||
changes: k, | ||
selector: r, | ||
handler: L, | ||
initial: R | ||
}; | ||
var p = /* @__PURE__ */ ((I) => (I[I.READY = 0] = "READY", I))(p || {}), c = /* @__PURE__ */ ((I) => (I[I.EXEC = 0] = "EXEC", I[I.COMPLETE = 1] = "COMPLETE", I[I.INSTALL = 2] = "INSTALL", I[I.FORMAT = 3] = "FORMAT", I))(c || {}); | ||
function u(I) { | ||
let A; | ||
return () => (A || (A = I()), A); | ||
function F(I) { | ||
var g = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; | ||
a.initial(I), a.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; | ||
}; | ||
return a.selector(b), b(C.current); | ||
} | ||
function G(b) { | ||
Y(A, i, l, c)(b); | ||
} | ||
return [B, G]; | ||
} | ||
function s(I, A) { | ||
if (!A) | ||
function U(I, g) { | ||
return K(g) ? g(I.current) : g; | ||
} | ||
function N(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]); | ||
}), C; | ||
} | ||
var Q = { | ||
create: F | ||
}; | ||
const T = { | ||
loadPyodideOptions: { | ||
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) { | ||
let g; | ||
return () => (g || (g = I()), g); | ||
} | ||
function p(I, g) { | ||
if (!g) | ||
throw new Error(`a wrong id is provided from worker - callback with ${I} id doesn't exist`); | ||
} | ||
const W = "dmFyIHksIFAsIHgsIFQsIEMgPSB7IGV4cG9ydHM6IHt9IH07CkMuZXhwb3J0cyA9IGZ1bmN0aW9uKCkgewogIGZ1bmN0aW9uIGUocykgewogICAgcmV0dXJuICFpc05hTihwYXJzZUZsb2F0KHMpKSAmJiBpc0Zpbml0ZShzKTsKICB9CiAgZnVuY3Rpb24gdChzKSB7CiAgICByZXR1cm4gcy5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIHMuc3Vic3RyaW5nKDEpOwogIH0KICBmdW5jdGlvbiByKHMpIHsKICAgIHJldHVybiBmdW5jdGlvbigpIHsKICAgICAgcmV0dXJuIHRoaXNbc107CiAgICB9OwogIH0KICB2YXIgbiA9IFsiaXNDb25zdHJ1Y3RvciIsICJpc0V2YWwiLCAiaXNOY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ldCIgKyB0KG5bZl0pXSA9IHIobltmXSksIGwucHJvdG90eXBlWyJzZXQiICsgdChuW2ZdKV0gPSBmdW5jdGlvbihzKSB7CiAgICAgIHJldHVybiBmdW5jdGlvbihwKSB7CiAgICAgICAgdGhpc1tzXSA9IEJvb2xlYW4ocCk7CiAgICAgIH07CiAgICB9KG5bZl0pOwogIGZvciAodmFyIGMgPSAwOyBjIDwgaS5sZW5ndGg7IGMrKykKICAgIGwucHJvdG90eXBlWyJnZXQiICsgdChpW2NdKV0gPSByKGlbY10pLCBsLnByb3RvdHlwZVsic2V0IiArIHQoaVtjXSldID0gZnVuY3Rpb24ocykgewogICAgICByZXR1cm4gZnVuY3Rpb24ocCkgewogICAgICAgIGlmICghZShwKSkKICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IocyArICIgbXVzdCBiZSBhIE51bWJlciIpOwogICAgICAgIHRoaXNbc10gPSBOdW1iZXIocCk7CiAgICAgIH07CiAgICB9KGlbY10pOwogIGZvciAodmFyIHUgPSAwOyB1IDwgby5sZW5ndGg7IHUrKykKICAgIGwucHJvdG90eXBlWyJnZXQiICsgdChvW3VdKV0gPSByKG9bdV0pLCBsLnByb3RvdHlwZVsic2V0IiArIHQob1t1XSldID0gZnVuY3Rpb24ocykgewogICAgICByZXR1cm4gZnVuY3Rpb24ocCkgewogICAgICAgIHRoaXNbc10gPSBTdHJpbmcocCk7CiAgICAgIH07CiAgICB9KG9bdV0pOwogIHJldHVybiBsOwp9KCk7CnZhciBxID0gKHkgPSBDLmV4cG9ydHMsIFAgPSAvKF58QClcUys6XGQrLywgeCA9IC9eXHMqYXQgLiooXFMrOlxkK3xcKG5hdGl2ZVwpKS9tLCBUID0gL14oZXZhbEApPyhcW25hdGl2ZSBjb2RlXSk/JC8sIHsgcGFyc2U6IGZ1bmN0aW9uKGUpIHsKICBpZiAoZS5zdGFja3RyYWNlICE9PSB2b2lkIDAgfHwgZVsib3BlcmEjc291cmNlbG9jIl0gIT09IHZvaWQgMC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vZiBsICE9ICJzdHJpbmciKQogICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoYEV4cGVjdGVkIHN0ZGluIHRvIHJldHVybiBzdHJpbmcsIG51bGwsIG9yIHVuZGVmaW5lZCwgZ290IHR5cGUgJHt0eXBlb2YgbH0uYCk7CiAgICAgICAgICAgIGwuZW5kc1dpdGgoYApgKSB8fCAobCArPSBgCmApLCBhID0gby5lbmNvZGUobCksIGQgPSAwOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGQgPCBhLmxlbmd0aCkgewogICAgICAgICAgICBsZXQgbCA9IGFbZF07CiAgICAgICAgICAgIHJldHVybiBkKyssIGw7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gZCA9IC0xLCBudWxsOwogICAgICAgIH0gY2F0Y2ggKGwpIHsKICAgICAgICAgIHRocm93IGNvbnNvbGUuZXJyb3IoIkVycm9yIHRocm93biBpbiBzdGRpbjoiKSwgY29uc29sZS5lcnJvcihsKSwgbDsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIG07CiAgICB9KHQpLCBudWxsLCBudWxsKTsKICB9KTsKfQpmdW5jdGlvbiBHKGUsIHQpIHsKICBlLnJ1blB5dGhvbkludGVybmFsX2RpY3QgPSBlLl9weW9kaWRlLl9iYXNlLmV2YWxfY29kZSgie30iKSwgZS5pbXBvcnRsaWIgPSBlLnJ1blB5dGhvbkludGVybmFsKCJpbXBvcnQgaW1wb3J0bGliOyBpbXBvcnRsaWIiKTsKICBsZXQgciA9IGUuaW1wb3J0bGliLmltcG9ydF9tb2R1bGU7CiAgZS5zeXMgPSByKCJzeXMiKSwgZS5zeXMucGF0aC5pbnNlcnQoMCwgdC5ob21lZGlyKTsKICBsZXQgbiA9IGUucnVuUHl0aG9uSW50ZXJuYWwoImltcG9ydCBfX21haW5fXzsgX19tYWluX18uX19kaWN0X18iKSwgaSA9IGUucnVuUHl0aG9uSW50ZXJuYWwoImltcG9ydCBidWlsdGluczsgYnVpb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Agc3Rkb3V0OiBudWxsLAogICAgICAgICAgc3RkZXJyOiBudWxsLAogICAgICAgICAgZXJyb3I6IFEoaS5tZXNzYWdlKQogICAgICAgIH07CiAgICAgIH0gZmluYWxseSB7CiAgICAgICAgT2JqZWN0LmVudHJpZXMobikuZm9yRWFjaCgoW2ldKSA9PiB7CiAgICAgICAgICB2YXIgbzsKICAgICAgICAgIGUuZ2xvYmFscy5zZXQoaSwgKG8gPSBlLnRvUHkobnVsbCkpID09IG51bGwgPyB2b2lkIDAgOiBvLnRvU3RyaW5nKCkpOwogICAgICAgIH0pOwogICAgICB9CiAgICB9LAogICAgW2cuQ09NUExFVEVdOiBhc3luYyAoewogICAgICBjb2RlOiByLAogICAgICBsaW5lOiBuLAogICAgICBjb2x1bW46IGkKICAgIH0pID0+IHsKICAgICAgYXdhaXQgZS5sb2FkUGFja2FnZXNGcm9tSW1wb3J0cyhyKTsKICAgICAgY29uc3QgbyA9IGUuZ2xvYmFscy5nZXQoImdldF9hdXRvY29tcGxldGlvbiIpKHIsIG4sIGkpOwogICAgICByZXR1cm4geyByZXN1bHQ6IF8obywgZSksIGVycm9yOiBudWxsIH07CiAgICB9LAogICAgW2cuSU5TVEFMTF06IGFzeW5jICh7IHBhY2thZ2VzOiByIH0pID0+IHsKICAgICAgY29uc3QgbiA9IGF3YWl0IGUuZ2xvYmFscy5nZXQoImluc3RhbGxfcGFjYWtnZSIpKHJbMF0pOwogICAgICByZXR1cm4gY29uc29sZS5sb2coXyhuLCBlKSksIF8obiwgZSk7CiAgICB9LAogICAgW2cuRk9STUFUXTogYXN5bmMgKHsgY29kZTogciB9KSA9PiB7CiAgICAgIGNvbnN0IG4gPSBlLmdsb2JhbHMuZ2V0KCJmb3JtYXRfY29kZSIpKHIpOwogICAgICByZXR1cm4geyByZXN1bHQ6IF8obiwgZSksIGVycm9yOiBudWxsIH07CiAgICB9CiAgfTsKICBvbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihuKSB7CiAgICBjb25zdCB7IGlkOiBpLCBhY3Rpb246IG8gPSBnLkVYRUMgfSA9IG4uZGF0YTsKICAgIHN3aXRjaCAobykgewogICAgICBjYXNlIGcuRVhFQzoKICAgICAgICBjb25zdCBhID0gYXdhaXQgdFtnLkVYRUNdKG4uZGF0YS5wYXlsb2FkKTsKICAgICAgICBwb3N0TWVzc2FnZSh7CiAgICAgICAgICAuLi5hLAogICAgICAgICAgaWQ6IGksCiAgICAgICAgICBhY3Rpb246IG8KICAgICAgICB9KTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBnLkNPTVBMRVRFOgogICAgICAgIGNvbnN0IGQgPSBhd2FpdCB0W2cuQ09NUExFVEVdKAogICAgICAgICAgbi5kYXRhLnBheWxvYWQKICAgICAgICApOwogICAgICAgIHBvc3RNZXNzYWdlKHsKICAgICAgICAgIC4uLmQsCiAgICAgICAgICBpZDogaSwKICAgICAgICAgIGFjdGlvbjogbwogICAgICAgIH0pOwogICAgICAgIGJyZWFrOwogICAgICBjYXNlIGcuSU5TVEFMTDoKICAgICAgICBjb25zdCBtID0gYXdhaXQgdFtnLklOU1RBTExdKG4uZGF0YS5wYXlsb2FkKTsKICAgICAgICBwb3N0TWVzc2FnZSh7CiAgICAgICAgICAuLi5tLAogICAgICAgICAgaWQ6IGksCiAgICAgICAgICBhY3Rpb246IG8KICAgICAgICB9KTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBnLkZPUk1BVDoKICAgICAgICBjb25zdCBsID0gYXdhaXQgdFtnLkZPUk1BVF0obi5kYXRhLnBheWxvYWQpOwogICAgICAgIHBvc3RNZXNzYWdlKHsKICAgICAgICAgIC4uLmwsCiAgICAgICAgICBpZDogaSwKICAgICAgICAgIGFjdGlvbjogbwogICAgICAgIH0pOwogICAgICAgIGJyZWFrOwogICAgfQogIH07Cn0KWigpOwo=", X = typeof window < "u" && window.Blob && new Blob([atob(W)], { type: "text/javascript;charset=utf-8" }); | ||
function n() { | ||
const I = X && (window.URL || window.webkitURL).createObjectURL(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sIG4sIHIpIHsKICBuICYmIChlLnByaW50ID0gbiksIHIgJiYgKGUucHJpbnRFcnIgPSByKSwgdCAmJiBlLnByZVJ1bi5wdXNoKGZ1bmN0aW9uKCkgewogICAgZS5GUy5pbml0KGZ1bmN0aW9uKGkpIHsKICAgICAgY29uc3QgbyA9IG5ldyBUZXh0RW5jb2RlcigpOwogICAgICBsZXQgYSA9IG5ldyBVaW50OEFycmF5KDApLCBkID0gLTE7CiAgICAgIGZ1bmN0aW9uIG0oKSB7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIGlmIChkID09PSAtMSkgewogICAgICAgICAgICBsZXQgbCA9IGkoKTsKICAgICAgICAgICAgaWYgKGwgPT0gbnVsbCkKICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgaWYgKHR5cGVvZiBsICE9ICJzdHJpbmciKQogICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoYEV4cGVjdGVkIHN0ZGluIHRvIHJldHVybiBzdHJpbmcsIG51bGwsIG9yIHVuZGVmaW5lZCwgZ290IHR5cGUgJHt0eXBlb2YgbH0uYCk7CiAgICAgICAgICAgIGwuZW5kc1dpdGgoYApgKSB8fCAobCArPSBgCmApLCBhID0gby5lbmNvZGUobCksIGQgPSAwOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGQgPCBhLmxlbmd0aCkgewogICAgICAgICAgICBsZXQgbCA9IGFbZF07CiAgICAgICAgICAgIHJldHVybiBkKyssIGw7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gZCA9IC0xLCBudWxsOwogICAgICAgIH0gY2F0Y2ggKGwpIHsKICAgICAgICAgIHRocm93IGNvbnNvbGUuZXJyb3IoIkVycm9yIHRocm93biBpbiBzdGRpbjoiKSwgY29uc29sZS5lcnJvcihsKSwgbDsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIG07CiAgICB9KHQpLCBudWxsLCBudWxsKTsKICB9KTsKfQpmdW5jdGlvbiBHK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CBsaW5lLCBjb2x1bW4pOgogICAgcmVzdWx0ID0gamVkaS5JbnRlcnByZXRlcihjb2RlLCBbZ2xvYmFscygpLCBsb2NhbHMoKV0pCgogICAgY29tcGxldGlvbnMgPSByZXN1bHQuY29tcGxldGUobGluZSwgY29sdW1uKQoKICAgIG1hdGNoZXMgPSBbXQogICAgZm9yIGNvbXAgaW4gY29tcGxldGlvbnM6CiAgICAgICAgbWF0Y2hlcy5hcHBlbmQoZGljdCgKICAgICAgICAgICAgbmFtZT1jb21wLm5hbWUsCiAgICAgICAgICAgIHR5cGU9Y29tcC50eXBlLAogICAgICAgICAgICBkZXNjcmlwdGlvbj1jb21wLmRlc2NyaXB0aW9uLAogICAgICAgICAgICBmdWxsX25hbWU9Y29tcC5mdWxsX25hbWUKICAgICAgICApKQoKICAgIHJldHVybiB7CiAgICAgICAgIm1hdGNoZXMiOiBtYXRjaGVzCiAgICB9CgoKYXN5bmMgZGVmIGluc3RhbGxfcGFjYWtnZShwYWNrYWdlKToKICAgIHRyeToKICAgICAgICBhd2FpdCBtaWNyb3BpcC5pbnN0YWxsKHBhY2thZ2UsIGtlZXBfZ29pbmc9VHJ1ZSkKICAgICAgICByZXR1cm4gewogICAgICAgICAgICAic3VjY2VzcyI6IFRydWUKICAgICAgICB9CiAgICBleGNlcHQgRXhjZXB0aW9uIGFzIGU6CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgInN1Y2Nlc3MiOiBGYWxzZSwKICAgICAgICAgICAgImVycm9yIjogc3RyKGUpCiAgICAgICAgfQoKCmRlZiBmb3JtYXRfY29kZShjb2RlKToKICAgIHJldHVybiBmb3JtYXRfc3RyKGNvZGUsIG1vZGU9RmlsZU1vZGUoKSkKYCwgQSA9IC8qIEBfX1BVUkVfXyAqLyAoKGUpID0+IChlW2UuUkVBRFkgPSAwXSA9ICJSRUFEWSIsIGUpKShBIHx8IHt9KSwgZyA9IC8qIEBfX1BVUkVfXyAqLyAoKGUpID0+IChlW2UuRVhFQyA9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gY29uc3QgaSA9IGF3YWl0IGUucnVuUHl0aG9uQXN5bmMobiksIG8gPSBlLnJ1blB5dGhvbigiaW1wb3J0IHN5czsgc3lzLnN0ZG91dC5nZXR2YWx1ZSgpIikudHJpbSgpLCBhID0gZS5ydW5QeXRob24oImltcG9ydCBzeXM7IHN5cy5zdGRlcnIuZ2V0dmFsdWUoKSIpLnRyaW0oKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcmVzdWx0OiBfKGksIGUpLAogICAgICAgICAgc3Rkb3V0OiBfKG8sIGUpLAogICAgICAgICAgc3RkZXJyOiBhLAogICAgICAgICAgZXJyb3I6IG51bGwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChpKSB7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHJlc3VsdDogbnVsbCwKICAgICAgICAgIHN0ZG91dDogbnVsbCwKICAgICAgICAgIHN0ZGVycjogbnVsbCwKICAgICAgICAgIGVycm9yOiBRKGkubWVzc2FnZSkKICAgICAgICB9OwogICAgICB9IGZpbmFsbHkgewogICAgICAgIE9iamVjdC5lbnRyaWVzKHIpLmZvckVhY2goKFtpXSkgPT4gewogICAgICAgICAgdmFyIG87CiAgICAgICAgICBlLmdsb2JhbHMuc2V0KGksIChvID0gZS50b1B5KG51bGwpKSA9PSBudWxsID8gdm9pZCAwIDogby50b1N0cmluZygpKTsKICAgICAgICB9KTsKICAgICAgfQogICAgfSwKICAgIFtnLkNPTVBMRVRFXTogYXN5bmMgKHsKICAgICAgY29kZTogbiwKICAgICAgbGluZTogciwKICAgICAgY29sdW1uOiBpCiAgICB9KSA9PiB7CiAgICAgIGF3YWl0IGUubG9hZFBhY2thZ2VzRnJvbUltcG9ydHMobik7CiAgICAgIGNvbnN0IG8gPSBlLmdsb2JhbHMuZ2V0KCJnZXRfYXV0b2NvbXBsZXRpb24iKShuLCByLCBpKTsKICAgICAgcmV0dXJuIHsgcmVzdWx0OiBfKG8sIGUpLCBlcnJvcjogbnVsbCB9OwogICAgfSwKICAgIFtnLklOU1RBTExdOiBhc3luYyAoeyBwYWNrYWdlczogbiB9KSA9PiB7CiAgICAgIGNvbnN0IHIgPSBhd2FpdCBlLmdsb2JhbHMuZ2V0KCJpbnN0YWxsX3BhY2FrZ2UiKShuWzBdKTsKICAgICAgcmV0dXJuIGNvbnNvbGUubG9nKF8ociwgZSkpLCBfKHIsIGUpOwogICAgfSwKICAgIFtnLkZPUk1BVF06IGFzeW5jICh7IGNvZGU6IG4gfSkgPT4gewogICAgICBjb25zdCByID0gZS5nbG9iYWxzLmdldCgiZm9ybWF0X2NvZGUiKShuKTsKICAgICAgcmV0dXJuIHsgcmVzdWx0OiBfKHIsIGUpLCBlcnJvcjogbnVsbCB9OwogICAgfQogIH07CiAgb25tZXNzYWdlID0gYXN5bmMgZnVuY3Rpb24ocikgewogICAgY29uc3QgeyBpZDogaSwgYWN0aW9uOiBvID0gZy5FWEVDIH0gPSByLmRhdGE7CiAgICBzd2l0Y2ggKG8pIHsKICAgICAgY2FzZSBnLkVYRUM6CiAgICAgICAgY29uc3QgYSA9IGF3YWl0IHRbZy5FWEVDXShyLmRhdGEucGF5bG9hZCk7CiAgICAgICAgcG9zdE1lc3NhZ2UoewogICAgICAgICAgLi4uYSwKICAgICAgICAgIGlkOiBpLAogICAgICAgICAgYWN0aW9uOiBvCiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgZy5DT01QTEVURToKICAgICAgICBjb25zdCBkID0gYXdhaXQgdFtnLkNPTVBMRVRFXSgKICAgICAgICAgIHIuZGF0YS5wYXlsb2FkCiAgICAgICAgKTsKICAgICAgICBwb3N0TWVzc2FnZSh7CiAgICAgICAgICAuLi5kLAogICAgICAgICAgaWQ6IGksCiAgICAgICAgICBhY3Rpb246IG8KICAgICAgICB9KTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBnLklOU1RBTEw6CiAgICAgICAgY29uc3QgbSA9IGF3YWl0IHRbZy5JTlNUQUxMXShyLmRhdGEucGF5bG9hZCk7CiAgICAgICAgcG9zdE1lc3NhZ2UoewogICAgICAgICAgLi4ubSwKICAgICAgICAgIGlkOiBpLAogICAgICAgICAgYWN0aW9uOiBvCiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgZy5GT1JNQVQ6CiAgICAgICAgY29uc3QgbCA9IGF3YWl0IHRbZy5GT1JNQVRdKHIuZGF0YS5wYXlsb2FkKTsKICAgICAgICBwb3N0TWVzc2FnZSh7CiAgICAgICAgICAuLi5sLAogICAgICAgICAgaWQ6IGksCiAgICAgICAgICBhY3Rpb246IG8KICAgICAgICB9KTsKICAgICAgICBicmVhazsKICAgIH0KICB9Owp9ClooKTsK", S = typeof window < "u" && window.Blob && new Blob([atob(h)], { type: "text/javascript;charset=utf-8" }); | ||
function f() { | ||
const I = S && (window.URL || window.webkitURL).createObjectURL(S); | ||
try { | ||
return I ? new Worker(I) : new Worker("data:application/javascript;base64," + W, { type: "module" }); | ||
return I ? new Worker(I) : new Worker("data:application/javascript;base64," + h, { type: "module" }); | ||
} finally { | ||
@@ -24,4 +153,4 @@ I && (window.URL || window.webkitURL).revokeObjectURL(I); | ||
} | ||
const H = Boolean(globalThis.Worker), [G, B] = S.create({ | ||
config: a, | ||
const M = Boolean(globalThis.Worker), [Z, o] = Q.create({ | ||
config: T, | ||
pyodideWorker: null, | ||
@@ -33,95 +162,95 @@ execCallbacks: {}, | ||
commandUniqueId: 0 | ||
}), m = { | ||
}), u = { | ||
async ensureWorkerIsSetup() { | ||
const { pyodideWorker: I } = G(); | ||
I || await h(); | ||
const { pyodideWorker: I } = Z(); | ||
I || await E(); | ||
}, | ||
async command(I, A) { | ||
await m.ensureWorkerIsSetup(); | ||
const { commandUniqueId: g, pyodideWorker: C } = G(); | ||
B({ commandUniqueId: g + 1 }), C == null || C.postMessage({ payload: I, id: g, action: A }); | ||
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 }); | ||
} | ||
}; | ||
function w({ result: I, error: A, id: g, stderr: C, stdout: b }) { | ||
const { execCallbacks: l } = G(); | ||
s(g, Boolean(l[g])); | ||
const { resolve: Z } = l[g]; | ||
B({ | ||
execCallbacks: d(l, (o) => { | ||
delete o[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]; | ||
}) | ||
}), Z({ result: I, error: A, stderr: C, stdout: b }); | ||
}), c({ result: I, error: g, stderr: A, stdout: i }); | ||
} | ||
function Y({ result: I, error: A, id: g }) { | ||
const { completeCallbacks: C } = G(); | ||
s(g, Boolean(C[g])); | ||
const { resolve: b, reject: l } = C[g]; | ||
if (B({ | ||
completeCallbacks: d(C, (Z) => { | ||
delete Z[g]; | ||
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]; | ||
}) | ||
}), A) { | ||
l == null || l(A); | ||
}), g) { | ||
l == null || l(g); | ||
return; | ||
} | ||
b(I); | ||
i(I); | ||
} | ||
function V({ success: I, error: A, id: g }) { | ||
const { installCallbacks: C } = G(); | ||
s(g, Boolean(C[g])); | ||
const { resolve: b, reject: l } = C[g]; | ||
if (B({ | ||
installCallbacks: d(C, (Z) => { | ||
delete Z[g]; | ||
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]; | ||
}) | ||
}), A) { | ||
l == null || l(A); | ||
}), g) { | ||
l == null || l(g); | ||
return; | ||
} | ||
b({ success: I, error: A }); | ||
i({ success: I, error: g }); | ||
} | ||
function k({ result: I, error: A, id: g }) { | ||
const { formatCallbacks: C } = G(); | ||
s(g, Boolean(C[g])); | ||
const { resolve: b } = C[g]; | ||
B({ | ||
formatCallbacks: d(C, (l) => { | ||
delete l[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]; | ||
}) | ||
}), b({ result: I, error: A }); | ||
}), i({ result: I, error: g }); | ||
} | ||
const h = u(function() { | ||
return new Promise((A, g) => { | ||
H || g(new Error(`your browser does | ||
const E = O(function() { | ||
return new Promise((g, C) => { | ||
M || C(new Error(`your browser does | ||
t support web workers!`)); | ||
const C = new n(); | ||
C.onmessage = function(l) { | ||
l.data === p.READY ? (B({ pyodideWorker: C }), C.onmessage = function(o) { | ||
const { action: K, ...i } = o.data; | ||
switch (K) { | ||
case c.EXEC: | ||
w(i); | ||
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); | ||
break; | ||
case c.COMPLETE: | ||
Y(i); | ||
case d.COMPLETE: | ||
P(b); | ||
break; | ||
case c.INSTALL: | ||
V(i); | ||
case d.INSTALL: | ||
x(b); | ||
break; | ||
case c.FORMAT: | ||
k(i); | ||
case d.FORMAT: | ||
D(b); | ||
break; | ||
} | ||
}, A(C)) : g(new Error("unexpected error in setup process")); | ||
}, C.onerror = function(l) { | ||
g(l.message); | ||
}, g(A)) : C(new Error("unexpected error in setup process")); | ||
}, A.onerror = function(l) { | ||
C(l.message); | ||
}; | ||
}); | ||
}); | ||
async function e(I) { | ||
return new Promise((A) => { | ||
const { execCallbacks: g, commandUniqueId: C } = G(); | ||
m.command(I, c.EXEC), B({ | ||
execCallbacks: d(g, (b) => { | ||
b[C] = { resolve: A }; | ||
async function $(I) { | ||
return new Promise((g) => { | ||
const { execCallbacks: C, commandUniqueId: A } = Z(); | ||
u.command(I, d.EXEC), o({ | ||
execCallbacks: m(C, (i) => { | ||
i[A] = { resolve: g }; | ||
}) | ||
@@ -131,12 +260,12 @@ }); | ||
} | ||
const J = { | ||
const _ = { | ||
async repl(I) { | ||
return new Promise((A, g) => { | ||
const { commandUniqueId: C, completeCallbacks: b } = G(), { code: l, line: Z, column: o } = I; | ||
let K = Z, i = o; | ||
Z || (K = l.split(` | ||
`).length), i || (i = l.split(` | ||
`)[K - 1].length), m.command({ code: l, line: K, column: i }, c.COMPLETE), B({ | ||
completeCallbacks: d(b, (y) => { | ||
y[C] = { resolve: A, reject: g }; | ||
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 }; | ||
}) | ||
@@ -147,8 +276,8 @@ }); | ||
}; | ||
async function F(I) { | ||
return new Promise((A, g) => { | ||
const { installCallbacks: C, commandUniqueId: b } = G(); | ||
m.command({ packages: I }, c.INSTALL), B({ | ||
installCallbacks: d(C, (l) => { | ||
l[b] = { resolve: A, reject: g }; | ||
async function II(I) { | ||
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 }; | ||
}) | ||
@@ -158,8 +287,8 @@ }); | ||
} | ||
async function v(I) { | ||
return new Promise((A, g) => { | ||
const { formatCallbacks: C, commandUniqueId: b } = G(); | ||
m.command(I, c.FORMAT), B({ | ||
formatCallbacks: d(C, (l) => { | ||
l[b] = { resolve: A, reject: g }; | ||
async function gI(I) { | ||
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 }; | ||
}) | ||
@@ -170,7 +299,7 @@ }); | ||
export { | ||
J as complete, | ||
e as exec, | ||
v as format, | ||
h as init, | ||
F as install | ||
_ as complete, | ||
$ as exec, | ||
gI as format, | ||
E as init, | ||
II as install | ||
}; |
{ | ||
"name": "@x-python/core", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"type": "module", | ||
@@ -20,3 +20,3 @@ "license": "MIT", | ||
], | ||
"main": "./dist/x-python.cjs", | ||
"main": "./dist/x-python.umd.cjs", | ||
"module": "./dist/x-python.js", | ||
@@ -51,3 +51,3 @@ "unpkg": "./dist/x-python.umd.cjs", | ||
"import": "./dist/x-python.js", | ||
"require": "./dist/x-python.cjs" | ||
"require": "./dist/x-python.umd.cjs" | ||
} | ||
@@ -54,0 +54,0 @@ }, |
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed 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
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
562
2
2
77675
7
1