@php-wasm/util 0.6.7 → 0.6.9

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.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +33 -27
  3. 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:t}){this._running=0,this.concurrency=t,this.queue=[]}get running(){return this._running}async acquire(){for(;;)if(this._running>=this.concurrency)await new Promise(t=>this.queue.push(t));else{this._running++;let t=!1;return()=>{t||(t=!0,this._running--,this.queue.length>0&&this.queue.shift()())}}}async run(t){const i=await this.acquire();try{return await t()}finally{i()}}}function g(...e){let t=e.join("/");const i=t[0]==="/",s=t.substring(t.length-1)==="/";return t=h(t),!t&&!i&&(t="."),t&&s&&(t+="/"),t}function E(e){if(e==="/")return"/";e=h(e);const t=e.lastIndexOf("/");return t===-1?"":t===0?"/":e.substr(0,t)}function m(e){if(e==="/")return"/";e=h(e);const t=e.lastIndexOf("/");return t===-1?e:e.substr(t+1)}function h(e){const t=e[0]==="/";return e=p(e.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+e.replace(/\/$/,"")}function p(e,t){let i=0;for(let s=e.length-1;s>=0;s--){const r=e[s];r==="."?e.splice(s,1):r===".."?(e.splice(s,1),i++):i&&(e.splice(s,1),i--)}if(t)for(;i;i--)e.unshift("..");return e}function w(e){let s=0,r="";const l=[];let n="";for(let u=0;u<e.length;u++){const o=e[u];o==="\\"?((e[u+1]==='"'||e[u+1]==="'")&&u++,n+=e[u]):s===0?o==='"'||o==="'"?(s=1,r=o):o.match(/\s/)?(n.trim().length&&l.push(n.trim()),n=o):l.length&&!n?n=l.pop()+o:n+=o:s===1&&(o===r?(s=0,r=""):n+=o)}return n&&l.push(n.trim()),l}function y(e){return function(t,i=[],s={}){const r=new P,l=new D(r);return setTimeout(async()=>{let n=[];if(i.length)n=[t,...i];else if(typeof t=="string")n=w(t);else if(Array.isArray(t))n=t;else throw new Error("Invalid command ",t);await e(n,l,s),r.emit("spawn",!0)}),r}}class c{constructor(){this.listeners={}}emit(t,i){this.listeners[t]&&this.listeners[t].forEach(function(s){s(i)})}on(t,i){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(i)}}class D extends c{constructor(t){super(),this.childProcess=t,this.exited=!1,this.stdinData=[],t.on("stdin",i=>{this.stdinData?this.stdinData.push(i.slice()):this.emit("stdin",i)})}stdout(t){typeof t=="string"&&(t=new TextEncoder().encode(t)),this.childProcess.stdout.emit("data",t)}stdoutEnd(){this.childProcess.stdout.emit("end",{})}stderr(t){typeof t=="string"&&(t=new TextEncoder().encode(t)),this.childProcess.stderr.emit("data",t)}stderrEnd(){this.childProcess.stderr.emit("end",{})}exit(t){this.exited||(this.exited=!0,this.childProcess.emit("exit",t))}flushStdin(){if(this.stdinData)for(let t=0;t<this.stdinData.length;t++)this.emit("stdin",this.stdinData[t]);this.stdinData=null}}let O=9743;class P extends c{constructor(t=O++){super(),this.pid=t,this.stdout=new c,this.stderr=new c;const i=this;this.stdin={write:s=>{i.emit("stdin",s)}}}}function f(e=36,t="!@#$%^&*()_+=-[]/.,<>?"){const i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"+t;let s="";for(let r=e;r>0;--r)s+=i[Math.floor(Math.random()*i.length)];return s}function _(){return f(36,"-_")}function a(e){return`json_decode(base64_decode('${T(JSON.stringify(e))}'), true)`}function S(e){const t={};for(const i in e)t[i]=a(e[i]);return t}function T(e){return b(new TextEncoder().encode(e))}function b(e){const t=String.fromCodePoint(...e);return btoa(t)}exports.Semaphore=d;exports.basename=m;exports.createSpawnHandler=y;exports.dirname=E;exports.joinPaths=g;exports.normalizePath=h;exports.phpVar=a;exports.phpVars=S;exports.randomFilename=_;exports.randomString=f;
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 y {
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
- function p(...e) {
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 = f(t), !t && !s && (t = "."), t && i && (t += "/"), t;
37
+ return t = h(t), !t && !s && (t = "."), t && i && (t += "/"), t;
33
38
  }
34
- function P(e) {
39
+ function x(e) {
35
40
  if (e === "/")
36
41
  return "/";
37
- e = f(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 = f(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 f(e) {
53
+ function h(e) {
49
54
  const t = e[0] === "/";
50
- return e = h(
55
+ return e = f(
51
56
  e.split("/").filter((s) => !!s),
52
57
  !t
53
58
  ).join("/"), (t ? "/" : "") + e.replace(/\/$/, "");
54
59
  }
55
- function h(e, t) {
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 x(e) {
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 w(e = 36, t = "!@#$%^&*()_+=-[]/.,<>?") {
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 T() {
154
- return w(36, "-_");
158
+ function M() {
159
+ return y(36, "-_");
155
160
  }
156
- function D(e) {
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] = D(e[s]);
169
+ t[s] = w(e[s]);
165
170
  return t;
166
171
  }
167
- function _(e) {
168
- return O(new TextEncoder().encode(e));
172
+ function D(e) {
173
+ return _(new TextEncoder().encode(e));
169
174
  }
170
- function O(e) {
175
+ function _(e) {
171
176
  const t = String.fromCodePoint(...e);
172
177
  return btoa(t);
173
178
  }
174
179
  export {
175
- y as Semaphore,
180
+ O as PhpWasmError,
181
+ p as Semaphore,
176
182
  m as basename,
177
- x as createSpawnHandler,
178
- P as dirname,
179
- p as joinPaths,
180
- f as normalizePath,
181
- D as phpVar,
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
- T as randomFilename,
184
- w as randomString
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.7",
3
+ "version": "0.6.9",
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": "c4c52563eee8997b94cd4a0875e10fb5d8ccda42",
15
+ "gitHead": "f6b98ad6d05617ee8cb1234c21318fdde17a6e56",
16
16
  "engines": {
17
17
  "node": ">=18.18.2",
18
18
  "npm": ">=8.11.0"