@php-wasm/util 0.6.7 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.mjs +33 -27
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class d{constructor({concurrency:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class d{constructor({concurrency:e}){this._running=0,this.concurrency=e,this.queue=[]}get running(){return this._running}async acquire(){for(;;)if(this._running>=this.concurrency)await new Promise(e=>this.queue.push(e));else{this._running++;let e=!1;return()=>{e||(e=!0,this._running--,this.queue.length>0&&this.queue.shift()())}}}async run(e){const s=await this.acquire();try{return await e()}finally{s()}}}class g extends Error{constructor(e,s){super(e),this.userFriendlyMessage=s,this.userFriendlyMessage||(this.userFriendlyMessage=e)}}function E(...t){let e=t.join("/");const s=e[0]==="/",i=e.substring(e.length-1)==="/";return e=h(e),!e&&!s&&(e="."),e&&i&&(e+="/"),e}function p(t){if(t==="/")return"/";t=h(t);const e=t.lastIndexOf("/");return e===-1?"":e===0?"/":t.substr(0,e)}function m(t){if(t==="/")return"/";t=h(t);const e=t.lastIndexOf("/");return e===-1?t:t.substr(e+1)}function h(t){const e=t[0]==="/";return t=y(t.split("/").filter(s=>!!s),!e).join("/"),(e?"/":"")+t.replace(/\/$/,"")}function y(t,e){let s=0;for(let i=t.length-1;i>=0;i--){const r=t[i];r==="."?t.splice(i,1):r===".."?(t.splice(i,1),s++):s&&(t.splice(i,1),s--)}if(e)for(;s;s--)t.unshift("..");return t}function P(t){let i=0,r="";const l=[];let n="";for(let u=0;u<t.length;u++){const o=t[u];o==="\\"?((t[u+1]==='"'||t[u+1]==="'")&&u++,n+=t[u]):i===0?o==='"'||o==="'"?(i=1,r=o):o.match(/\s/)?(n.trim().length&&l.push(n.trim()),n=o):l.length&&!n?n=l.pop()+o:n+=o:i===1&&(o===r?(i=0,r=""):n+=o)}return n&&l.push(n.trim()),l}function w(t){return function(e,s=[],i={}){const r=new _,l=new D(r);return setTimeout(async()=>{let n=[];if(s.length)n=[e,...s];else if(typeof e=="string")n=P(e);else if(Array.isArray(e))n=e;else throw new Error("Invalid command ",e);await t(n,l,i),r.emit("spawn",!0)}),r}}class c{constructor(){this.listeners={}}emit(e,s){this.listeners[e]&&this.listeners[e].forEach(function(i){i(s)})}on(e,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(s)}}class D extends c{constructor(e){super(),this.childProcess=e,this.exited=!1,this.stdinData=[],e.on("stdin",s=>{this.stdinData?this.stdinData.push(s.slice()):this.emit("stdin",s)})}stdout(e){typeof e=="string"&&(e=new TextEncoder().encode(e)),this.childProcess.stdout.emit("data",e)}stdoutEnd(){this.childProcess.stdout.emit("end",{})}stderr(e){typeof e=="string"&&(e=new TextEncoder().encode(e)),this.childProcess.stderr.emit("data",e)}stderrEnd(){this.childProcess.stderr.emit("end",{})}exit(e){this.exited||(this.exited=!0,this.childProcess.emit("exit",e))}flushStdin(){if(this.stdinData)for(let e=0;e<this.stdinData.length;e++)this.emit("stdin",this.stdinData[e]);this.stdinData=null}}let O=9743;class _ extends c{constructor(e=O++){super(),this.pid=e,this.stdout=new c,this.stderr=new c;const s=this;this.stdin={write:i=>{s.emit("stdin",i)}}}}function f(t=36,e="!@#$%^&*()_+=-[]/.,<>?"){const s="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"+e;let i="";for(let r=t;r>0;--r)i+=s[Math.floor(Math.random()*s.length)];return i}function S(){return f(36,"-_")}function a(t){return`json_decode(base64_decode('${b(JSON.stringify(t))}'), true)`}function T(t){const e={};for(const s in t)e[s]=a(t[s]);return e}function b(t){return x(new TextEncoder().encode(t))}function x(t){const e=String.fromCodePoint(...t);return btoa(e)}exports.PhpWasmError=g;exports.Semaphore=d;exports.basename=m;exports.createSpawnHandler=w;exports.dirname=p;exports.joinPaths=E;exports.normalizePath=h;exports.phpVar=a;exports.phpVars=T;exports.randomFilename=S;exports.randomString=f;
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class p {
|
|
2
2
|
constructor({ concurrency: t }) {
|
|
3
3
|
this._running = 0, this.concurrency = t, this.queue = [];
|
|
4
4
|
}
|
|
@@ -26,33 +26,38 @@ class y {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
class O extends Error {
|
|
30
|
+
constructor(t, s) {
|
|
31
|
+
super(t), this.userFriendlyMessage = s, this.userFriendlyMessage || (this.userFriendlyMessage = t);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function P(...e) {
|
|
30
35
|
let t = e.join("/");
|
|
31
36
|
const s = t[0] === "/", i = t.substring(t.length - 1) === "/";
|
|
32
|
-
return t =
|
|
37
|
+
return t = h(t), !t && !s && (t = "."), t && i && (t += "/"), t;
|
|
33
38
|
}
|
|
34
|
-
function
|
|
39
|
+
function x(e) {
|
|
35
40
|
if (e === "/")
|
|
36
41
|
return "/";
|
|
37
|
-
e =
|
|
42
|
+
e = h(e);
|
|
38
43
|
const t = e.lastIndexOf("/");
|
|
39
44
|
return t === -1 ? "" : t === 0 ? "/" : e.substr(0, t);
|
|
40
45
|
}
|
|
41
46
|
function m(e) {
|
|
42
47
|
if (e === "/")
|
|
43
48
|
return "/";
|
|
44
|
-
e =
|
|
49
|
+
e = h(e);
|
|
45
50
|
const t = e.lastIndexOf("/");
|
|
46
51
|
return t === -1 ? e : e.substr(t + 1);
|
|
47
52
|
}
|
|
48
|
-
function
|
|
53
|
+
function h(e) {
|
|
49
54
|
const t = e[0] === "/";
|
|
50
|
-
return e =
|
|
55
|
+
return e = f(
|
|
51
56
|
e.split("/").filter((s) => !!s),
|
|
52
57
|
!t
|
|
53
58
|
).join("/"), (t ? "/" : "") + e.replace(/\/$/, "");
|
|
54
59
|
}
|
|
55
|
-
function
|
|
60
|
+
function f(e, t) {
|
|
56
61
|
let s = 0;
|
|
57
62
|
for (let i = e.length - 1; i >= 0; i--) {
|
|
58
63
|
const r = e[i];
|
|
@@ -73,7 +78,7 @@ function d(e) {
|
|
|
73
78
|
}
|
|
74
79
|
return n && l.push(n.trim()), l;
|
|
75
80
|
}
|
|
76
|
-
function
|
|
81
|
+
function T(e) {
|
|
77
82
|
return function(t, s = [], i = {}) {
|
|
78
83
|
const r = new E(), l = new a(r);
|
|
79
84
|
return setTimeout(async () => {
|
|
@@ -143,43 +148,44 @@ class E extends c {
|
|
|
143
148
|
};
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
|
-
function
|
|
151
|
+
function y(e = 36, t = "!@#$%^&*()_+=-[]/.,<>?") {
|
|
147
152
|
const s = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + t;
|
|
148
153
|
let i = "";
|
|
149
154
|
for (let r = e; r > 0; --r)
|
|
150
155
|
i += s[Math.floor(Math.random() * s.length)];
|
|
151
156
|
return i;
|
|
152
157
|
}
|
|
153
|
-
function
|
|
154
|
-
return
|
|
158
|
+
function M() {
|
|
159
|
+
return y(36, "-_");
|
|
155
160
|
}
|
|
156
|
-
function
|
|
157
|
-
return `json_decode(base64_decode('${
|
|
161
|
+
function w(e) {
|
|
162
|
+
return `json_decode(base64_decode('${D(
|
|
158
163
|
JSON.stringify(e)
|
|
159
164
|
)}'), true)`;
|
|
160
165
|
}
|
|
161
166
|
function S(e) {
|
|
162
167
|
const t = {};
|
|
163
168
|
for (const s in e)
|
|
164
|
-
t[s] =
|
|
169
|
+
t[s] = w(e[s]);
|
|
165
170
|
return t;
|
|
166
171
|
}
|
|
167
|
-
function
|
|
168
|
-
return
|
|
172
|
+
function D(e) {
|
|
173
|
+
return _(new TextEncoder().encode(e));
|
|
169
174
|
}
|
|
170
|
-
function
|
|
175
|
+
function _(e) {
|
|
171
176
|
const t = String.fromCodePoint(...e);
|
|
172
177
|
return btoa(t);
|
|
173
178
|
}
|
|
174
179
|
export {
|
|
175
|
-
|
|
180
|
+
O as PhpWasmError,
|
|
181
|
+
p as Semaphore,
|
|
176
182
|
m as basename,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
183
|
+
T as createSpawnHandler,
|
|
184
|
+
x as dirname,
|
|
185
|
+
P as joinPaths,
|
|
186
|
+
h as normalizePath,
|
|
187
|
+
w as phpVar,
|
|
182
188
|
S as phpVars,
|
|
183
|
-
|
|
184
|
-
|
|
189
|
+
M as randomFilename,
|
|
190
|
+
y as randomString
|
|
185
191
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/util",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"typedoc": {
|
|
6
6
|
"entryPoint": "./src/index.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"access": "public",
|
|
13
13
|
"directory": "../../../dist/packages/php-wasm/util"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "cb7b1af260489022238495a2fc0d96f767a1294a",
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=18.18.2",
|
|
18
18
|
"npm": ">=8.11.0"
|