-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c8db2f
commit 8880b0a
Showing
18 changed files
with
1,650 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
Object.getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function(obj) { | ||
if (obj === null || obj === void 0) throw new TypeError("Cannot convert undefined or null to object"); | ||
const protoPropDescriptor = Object.getOwnPropertyDescriptor(obj, "__proto__"); | ||
const descriptors = protoPropDescriptor ? { ["__proto__"]: protoPropDescriptor } : {}; | ||
for (const name of Object.getOwnPropertyNames(obj)) { | ||
descriptors[name] = Object.getOwnPropertyDescriptor(obj, name); | ||
} | ||
return descriptors; | ||
}; | ||
|
||
Object.entries = Object.entries || function (obj) { | ||
return Object.keys(obj).map((key) => [key, obj[key]]); | ||
}; | ||
|
||
Object.fromEntries = Object.fromEntries || function (entries) { | ||
return [...entries].reduce((obj, [key, val]) => { | ||
obj[key] = val; | ||
return obj; | ||
}, {}); | ||
}; | ||
|
||
|
||
var __create = Object.create; | ||
|
||
var __defProp = Object.defineProperty; | ||
|
||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
|
||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
|
||
var __getProtoOf = Object.getPrototypeOf; | ||
|
||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
|
||
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
|
||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
|
||
var __defProps = Object.defineProperties; | ||
|
||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
|
||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
|
||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
|
||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
|
||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
|
||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
|
||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
|
||
var __async = (__this, __arguments, generator) => { | ||
return new Promise((resolve, reject) => { | ||
var fulfilled = (value) => { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}; | ||
var rejected = (value) => { | ||
try { | ||
step(generator.throw(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}; | ||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); | ||
step((generator = generator.apply(__this, __arguments)).next()); | ||
}); | ||
}; | ||
|
||
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
|
||
module.exports = { | ||
__create, | ||
__defProp, | ||
__getOwnPropDesc, | ||
__getOwnPropNames, | ||
__getProtoOf, | ||
__hasOwnProp, | ||
__export, | ||
__copyProps, | ||
__toESM, | ||
__toCommonJS, | ||
__defProps, | ||
__getOwnPropDescs, | ||
__getOwnPropSymbols, | ||
__propIsEnum, | ||
__defNormalProp, | ||
__spreadValues, | ||
__spreadProps, | ||
__reExport, | ||
__async, | ||
__publicField | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
"use strict"; | ||
const { | ||
__export, | ||
__toESM, | ||
__toCommonJS | ||
} = require('./cjslib.cjs'); | ||
|
||
|
||
// src/main/ts/index.ts | ||
var ts_exports = {}; | ||
__export(ts_exports, { | ||
$: () => $, | ||
buildCmd: () => import_util5.buildCmd, | ||
defaults: () => import_spawn2.defaults, | ||
exec: () => import_spawn2.exec, | ||
invoke: () => import_spawn2.invoke, | ||
zurk: () => import_zurk5.zurk | ||
}); | ||
module.exports = __toCommonJS(ts_exports); | ||
var import_spawn2 = require("./spawn.cjs"); | ||
|
||
// src/main/ts/x.ts | ||
var import_zurk4 = require("./zurk.cjs"); | ||
var import_util4 = require("./util.cjs"); | ||
|
||
// src/main/ts/mixin/pipe.ts | ||
var import_node_stream = require("stream"); | ||
var import_util = require("./util.cjs"); | ||
var import_spawn = require("./spawn.cjs"); | ||
var import_zurk = require("./zurk.cjs"); | ||
var pipeMixin = ($2, result, ctx) => (0, import_zurk.isZurkAny)(result) ? (0, import_util.assign)(result, { | ||
pipe(...args) { | ||
const [target, ...rest] = args; | ||
const { fulfilled, store, ee } = ctx; | ||
const from = new import_spawn.VoidStream(); | ||
const sync = !("then" in result); | ||
const input = fulfilled ? fulfilled.stdout : from; | ||
const fill = () => { | ||
for (const chunk of store.stdout) { | ||
from.write(chunk); | ||
} | ||
}; | ||
let _result; | ||
if ((0, import_zurk.isZurkAny)(target)) { | ||
target.ctx.input = input; | ||
_result = target; | ||
} else if (target instanceof import_node_stream.Writable) { | ||
_result = from.pipe(target); | ||
} else if ((0, import_util.isStringLiteral)(target, ...rest)) { | ||
_result = $2.apply({ input, sync }, args); | ||
} else { | ||
throw new Error("Unsupported pipe argument"); | ||
} | ||
if (fulfilled) { | ||
fill(); | ||
from.end(); | ||
} else { | ||
const onStdout = (chunk) => from.write(chunk); | ||
ee.once("stdout", () => { | ||
fill(); | ||
ee.on("stdout", onStdout); | ||
}).once("end", () => { | ||
ee.removeListener("stdout", onStdout); | ||
from.end(); | ||
}); | ||
} | ||
return _result; | ||
} | ||
}) : result; | ||
|
||
// src/main/ts/mixin/kill.ts | ||
var import_node_process = __toESM(require("process"), 1); | ||
var import_util2 = require("./util.cjs"); | ||
var import_zurk2 = require("./zurk.cjs"); | ||
var kill = (child, signal = "SIGTERM") => new Promise((resolve, reject) => { | ||
if (child) { | ||
child.on("exit", (code, signal2) => { | ||
resolve(signal2); | ||
}); | ||
import_node_process.default.kill(-child.pid, signal); | ||
} else { | ||
reject(new Error("No child process to kill")); | ||
} | ||
}); | ||
var killMixin = ($2, result, ctx) => (0, import_zurk2.isZurkAny)(result) ? (0, import_util2.assign)(result, { | ||
kill(signal) { | ||
return kill(ctx.child, signal); | ||
}, | ||
abort(reason) { | ||
ctx.ac.abort(reason); | ||
} | ||
}) : result; | ||
|
||
// src/main/ts/mixin/timeout.ts | ||
var import_node_process2 = __toESM(require("process"), 1); | ||
var import_util3 = require("./util.cjs"); | ||
var import_zurk3 = require("./zurk.cjs"); | ||
var attachTimeout = (ctx, result) => { | ||
clearTimeout(ctx.timer); | ||
if (ctx.timeout === void 0) return; | ||
const kill2 = () => { | ||
const { child, timeoutSignal = "SIGTERM" } = ctx; | ||
if (result.kill) return result.kill(timeoutSignal); | ||
if (child == null ? void 0 : child.pid) import_node_process2.default.kill(child.pid, timeoutSignal); | ||
}; | ||
ctx.timer = setTimeout(kill2, ctx.timeout); | ||
}; | ||
var timeoutMixin = ($2, result, ctx) => { | ||
if ((0, import_zurk3.isZurkPromise)(result)) { | ||
(0, import_util3.assign)(result, { | ||
set timeoutSignal(timeoutSignal) { | ||
(0, import_util3.assign)(ctx, { timeoutSignal }); | ||
}, | ||
set timeout(timeout) { | ||
(0, import_util3.assign)(ctx, { timeout }); | ||
attachTimeout(ctx, result); | ||
} | ||
}); | ||
attachTimeout(ctx, result); | ||
(0, import_util3.pFinally)(result, () => clearTimeout(ctx.timer)); | ||
} | ||
return result; | ||
}; | ||
|
||
// src/main/ts/x.ts | ||
var $ = function(pieces, ...args) { | ||
const self = this !== import_util4.g && this; | ||
const preset = self || {}; | ||
if (pieces === void 0) return applyMixins($, preset); | ||
if ((0, import_util4.isStringLiteral)(pieces, ...args)) return ignite(preset, pieces, ...args); | ||
return (...args2) => $.apply(self ? (0, import_util4.assign)(self, pieces) : pieces, args2); | ||
}; | ||
var ignite = (preset, pieces, ...args) => { | ||
const cmd = (0, import_util4.buildCmd)(preset.quote || import_util4.quote, pieces, args); | ||
const input = (0, import_util4.parseInput)(preset.input); | ||
const run = cmd instanceof Promise ? (cb, ctx) => cmd.then((cmd2) => { | ||
ctx.cmd = cmd2; | ||
cb(); | ||
}) : import_util4.immediate; | ||
const opts = (0, import_util4.assign)(preset, { cmd, run, input }); | ||
return applyMixins($, opts); | ||
}; | ||
var zurkMixin = ($2, target) => { | ||
if ((0, import_zurk4.isZurkAny)(target)) return target; | ||
const result = (0, import_zurk4.zurk)(target); | ||
return (0, import_util4.isPromiseLike)(result) ? (0, import_zurk4.zurkifyPromise)( | ||
result.then((r) => applyMixins($2, r, result)), | ||
result.ctx | ||
) : result; | ||
}; | ||
$.mixins = [zurkMixin, killMixin, pipeMixin, timeoutMixin]; | ||
var applyMixins = ($2, result, parent) => { | ||
let ctx = parent == null ? void 0 : parent.ctx; | ||
return $2.mixins.reduce((r, m) => { | ||
ctx = ctx || r.ctx; | ||
return m($2, r, ctx); | ||
}, result); | ||
}; | ||
|
||
// src/main/ts/index.ts | ||
var import_zurk5 = require("./zurk.cjs"); | ||
var import_util5 = require("./util.cjs"); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
$, | ||
buildCmd, | ||
defaults, | ||
exec, | ||
invoke, | ||
zurk | ||
}); |
Oops, something went wrong.