@psdk/frame-father
Advanced tools
Comparing version 0.5.4 to 0.5.5
2151
dist/index.js
@@ -1,2151 +0,2 @@ | ||
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ var __webpack_modules__ = ({ | ||
/***/ 391: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.FakeConnectedDevice = void 0; | ||
/** | ||
* Connected device | ||
*/ | ||
const types_1 = __nccwpck_require__(145); | ||
const father_1 = __nccwpck_require__(842); | ||
/** | ||
* Fake connected device | ||
*/ | ||
class FakeConnectedDevice { | ||
origin() { | ||
return "FAKE-DEVICE"; | ||
} | ||
connectionState() { | ||
return types_1.ConnectionState.CONNECTED; | ||
} | ||
deviceName() { | ||
return "FAKE-DEVICE"; | ||
} | ||
async disconnect() { | ||
} | ||
canRead() { | ||
return true; | ||
} | ||
async read(options) { | ||
return father_1.PsdkConst.EMPTY_BYTES; | ||
} | ||
async write(data) { | ||
console.log('WRITE: ', data); | ||
} | ||
flush() { | ||
} | ||
} | ||
exports.FakeConnectedDevice = FakeConnectedDevice; | ||
/***/ }), | ||
/***/ 909: | ||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
__exportStar(__nccwpck_require__(391), exports); | ||
__exportStar(__nccwpck_require__(145), exports); | ||
/***/ }), | ||
/***/ 145: | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.ReadOptions = exports.WroteReporter = exports.ConnectionState = void 0; | ||
/** | ||
* Connection state | ||
*/ | ||
var ConnectionState; | ||
(function (ConnectionState) { | ||
/** | ||
* connected | ||
*/ | ||
ConnectionState["CONNECTED"] = "CONNECTED"; | ||
/** | ||
* disconnect | ||
*/ | ||
ConnectionState["DISCONNECTED"] = "DISCONNECTED"; | ||
})(ConnectionState || (exports.ConnectionState = ConnectionState = {})); | ||
/** | ||
* Wrote reporter | ||
*/ | ||
class WroteReporter { | ||
ok; | ||
binary; | ||
controlExit; | ||
exception; | ||
constructor( | ||
/** | ||
* Wrote is ok | ||
*/ | ||
ok, | ||
/** | ||
* Wrote data | ||
*/ | ||
binary, | ||
/** | ||
* control exit | ||
*/ | ||
controlExit, | ||
/** | ||
* exception | ||
*/ | ||
exception) { | ||
this.ok = ok; | ||
this.binary = binary; | ||
this.controlExit = controlExit; | ||
this.exception = exception; | ||
} | ||
} | ||
exports.WroteReporter = WroteReporter; | ||
/** | ||
* Read options | ||
*/ | ||
class ReadOptions { | ||
timeout; | ||
constructor(options) { | ||
this.timeout = options?.timeout; | ||
} | ||
} | ||
exports.ReadOptions = ReadOptions; | ||
/***/ }), | ||
/***/ 501: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.PSDK = void 0; | ||
const types_1 = __nccwpck_require__(526); | ||
const write_operation_1 = __nccwpck_require__(475); | ||
class PSDK { | ||
/** | ||
* sdk version | ||
*/ | ||
sversion() { | ||
return '0.2.67'; | ||
} | ||
/** | ||
* authors | ||
*/ | ||
authors() { | ||
return types_1.PsdkConst.DEF_AUTHORS; | ||
} | ||
/** | ||
* Push raw command | ||
* @param raw raw | ||
*/ | ||
raw(raw) { | ||
this.commander().pushArg(raw); | ||
return this; | ||
} | ||
/** | ||
* Put variable | ||
* @param name name | ||
* @param value value | ||
*/ | ||
variable(name, value) { | ||
this.commander().variable(name, value); | ||
return this; | ||
} | ||
/** | ||
* get command | ||
*/ | ||
command() { | ||
return this.commander().command(); | ||
} | ||
/** | ||
* Clear command | ||
*/ | ||
clear() { | ||
this.commander().clear(); | ||
return this; | ||
} | ||
/** | ||
* Write data to device | ||
*/ | ||
async write(options) { | ||
const connectedDevice = this.connectedDevice(); | ||
if (!connectedDevice) | ||
throw Error('It\'s seems you missing to set connectedDevice'); | ||
options = options ?? types_1.WriteOptions.def(); | ||
const command = this.command(); | ||
const binary = command.binary(); | ||
const operation = new write_operation_1.DataWriteOperation(options, binary, connectedDevice); | ||
const reporter = await operation.write(); | ||
this.clear(); | ||
return reporter; | ||
} | ||
/** | ||
* Newline command | ||
*/ | ||
newline() { | ||
this.commander().newline(); | ||
return this; | ||
} | ||
/** | ||
* Push command | ||
* @param command | ||
*/ | ||
push(command) { | ||
this.commander().pushArg(command); | ||
return this; | ||
} | ||
} | ||
exports.PSDK = PSDK; | ||
/***/ }), | ||
/***/ 267: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.BasicArg = void 0; | ||
const types_1 = __nccwpck_require__(526); | ||
class BasicArg { | ||
newline() { | ||
return types_1.PsdkConst.DEF_ENABLED_NEWLINE; | ||
} | ||
} | ||
exports.BasicArg = BasicArg; | ||
/***/ }), | ||
/***/ 408: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.OnlyTextHeaderArg = exports.OnlyBinaryHeaderArg = exports.EasyArg = void 0; | ||
const arg_1 = __nccwpck_require__(267); | ||
const command_1 = __nccwpck_require__(687); | ||
/** | ||
* Easy argument abstract class | ||
*/ | ||
class EasyArg extends arg_1.BasicArg { | ||
prependClauses; | ||
appendClauses; | ||
constructor() { | ||
super(); | ||
this.prependClauses = []; | ||
this.appendClauses = []; | ||
} | ||
/** | ||
* Append another argument for this clause | ||
* @param arg | ||
*/ | ||
append(arg) { | ||
this.appendClauses.push(...arg.clauses()); | ||
return this; | ||
} | ||
/** | ||
* Prepend another argument for this clause | ||
* @param arg | ||
*/ | ||
prepend(arg) { | ||
this.prependClauses.push(...arg.clauses()); | ||
return this; | ||
} | ||
/** | ||
* Get current command clauses | ||
*/ | ||
clauses() { | ||
const clause = this.clause(); | ||
const currentClauses = []; | ||
if (clause.type !== command_1.ClauseType.NONE) { | ||
currentClauses.push(clause); | ||
if (this.newline()) { | ||
currentClauses.push(command_1.CommandClause.newline()); | ||
} | ||
} | ||
return [ | ||
...this.prependClauses, | ||
...currentClauses, | ||
...this.appendClauses, | ||
]; | ||
} | ||
clear() { | ||
this.prependClauses.splice(0, this.prependClauses.length); | ||
this.appendClauses.splice(0, this.appendClauses.length); | ||
} | ||
} | ||
exports.EasyArg = EasyArg; | ||
class OnlyBinaryHeaderArg extends EasyArg { | ||
append(arg) { | ||
super.append(arg); | ||
return this; | ||
} | ||
prepend(arg) { | ||
super.prepend(arg); | ||
return this; | ||
} | ||
clause() { | ||
return command_1.CommandClause.binary(this.header()); | ||
} | ||
newline() { | ||
return false; | ||
} | ||
} | ||
exports.OnlyBinaryHeaderArg = OnlyBinaryHeaderArg; | ||
class OnlyTextHeaderArg extends EasyArg { | ||
append(arg) { | ||
super.append(arg); | ||
return this; | ||
} | ||
prepend(arg) { | ||
super.prepend(arg); | ||
return this; | ||
} | ||
clause() { | ||
return command_1.CommandClause.text(this.header()); | ||
} | ||
} | ||
exports.OnlyTextHeaderArg = OnlyTextHeaderArg; | ||
/***/ }), | ||
/***/ 75: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.RawMode = exports.Raw = void 0; | ||
const easy_1 = __nccwpck_require__(408); | ||
const command_1 = __nccwpck_require__(687); | ||
const types_1 = __nccwpck_require__(526); | ||
class Raw extends easy_1.EasyArg { | ||
_mode; | ||
_text; | ||
_charset; | ||
_binary; | ||
_newline = types_1.PsdkConst.DEF_ENABLED_NEWLINE; | ||
constructor() { | ||
super(); | ||
} | ||
static text(text, options) { | ||
const raw = new Raw(); | ||
raw._mode = RawMode.TEXT; | ||
raw._text = text; | ||
raw._charset = options?.charset ?? types_1.PsdkConst.DEF_CHARSET; | ||
raw._newline = options?.newline ?? types_1.PsdkConst.DEF_ENABLED_NEWLINE; | ||
return raw; | ||
} | ||
static binary(binary, options) { | ||
const raw = new Raw(); | ||
raw._mode = RawMode.BINARY; | ||
raw._binary = binary; | ||
raw._charset = options?.charset ?? types_1.PsdkConst.DEF_CHARSET; | ||
raw._newline = options?.newline ?? types_1.PsdkConst.DEF_ENABLED_NEWLINE; | ||
return raw; | ||
} | ||
append(arg) { | ||
super.append(arg); | ||
return this; | ||
} | ||
prepend(arg) { | ||
super.prepend(arg); | ||
return this; | ||
} | ||
clause() { | ||
let clause; | ||
switch (this._mode) { | ||
case RawMode.TEXT: | ||
clause = command_1.CommandClause.text(this._text, this._charset); | ||
break; | ||
case RawMode.BINARY: | ||
clause = command_1.CommandClause.binary(this._binary); | ||
break; | ||
default: | ||
clause = command_1.CommandClause.none(); | ||
break; | ||
} | ||
return clause; | ||
} | ||
header() { | ||
return types_1.PsdkConst.EMPTY_BYTES; | ||
} | ||
newline() { | ||
return this._newline; | ||
} | ||
} | ||
exports.Raw = Raw; | ||
var RawMode; | ||
(function (RawMode) { | ||
RawMode["BINARY"] = "BINARY"; | ||
RawMode["TEXT"] = "TEXT"; | ||
})(RawMode || (exports.RawMode = RawMode = {})); | ||
/***/ }), | ||
/***/ 697: | ||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
__exportStar(__nccwpck_require__(267), exports); | ||
__exportStar(__nccwpck_require__(408), exports); | ||
__exportStar(__nccwpck_require__(75), exports); | ||
/***/ }), | ||
/***/ 687: | ||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
__exportStar(__nccwpck_require__(434), exports); | ||
__exportStar(__nccwpck_require__(472), exports); | ||
__exportStar(__nccwpck_require__(298), exports); | ||
__exportStar(__nccwpck_require__(838), exports); | ||
__exportStar(__nccwpck_require__(25), exports); | ||
__exportStar(__nccwpck_require__(92), exports); | ||
/***/ }), | ||
/***/ 434: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.DefaultCommand = exports.BasicCommand = void 0; | ||
/** | ||
* All printer sdk command interface | ||
*/ | ||
const types_1 = __nccwpck_require__(526); | ||
const base64_1 = __nccwpck_require__(401); | ||
const command_clause_1 = __nccwpck_require__(298); | ||
const toolkit_1 = __nccwpck_require__(195); | ||
class BasicCommand { | ||
base64() { | ||
return base64_1.Base64.fromUint8Array(this.binary()); | ||
} | ||
} | ||
exports.BasicCommand = BasicCommand; | ||
class DefaultCommand extends BasicCommand { | ||
bytes; | ||
constructor(clauses, variable) { | ||
super(); | ||
let bytes = []; | ||
for (const clause of clauses) { | ||
switch (clause.type) { | ||
case command_clause_1.ClauseType.TEXT: | ||
const t = toolkit_1.PVariableKit.replace(clause.text, variable); | ||
//# use gbk encoding | ||
// const t_buffer = iconv.encode(t, clause.charset ?? PsdkConst.DEF_CHARSET); | ||
const t_buffer = toolkit_1.FastGBK.encode(t); | ||
const t_binary = Array.prototype.slice.call(t_buffer, 0); | ||
bytes = bytes.concat(t_binary); | ||
//# use utf8 encoding | ||
// const t_binary = ByteKit.textToU8A(t) | ||
// const array = Array.from(t_binary) | ||
// bytes.push(...array); | ||
break; | ||
case command_clause_1.ClauseType.NEWLINE: | ||
case command_clause_1.ClauseType.BINARY: | ||
const b = Array.from(clause.binary ?? types_1.PsdkConst.EMPTY_BYTES); | ||
bytes = bytes.concat(b); | ||
break; | ||
} | ||
} | ||
this.bytes = new Uint8Array(bytes); | ||
} | ||
binary() { | ||
return this.bytes; | ||
} | ||
hex(output) { | ||
return (output ?? types_1.HexOutput.def()).format(this.binary()); | ||
} | ||
string(charset) { | ||
// const buffer = Array.from(this.binary()); | ||
// @ts-ignore | ||
// return iconv.decode(buffer, charset ?? PsdkConst.DEF_CHARSET); | ||
// return gbkDecoder.decode(this.binary()); | ||
return toolkit_1.FastGBK.decode(this.binary()); | ||
} | ||
} | ||
exports.DefaultCommand = DefaultCommand; | ||
/***/ }), | ||
/***/ 298: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.CommandClause = exports.ClauseType = void 0; | ||
const types_1 = __nccwpck_require__(526); | ||
var ClauseType; | ||
(function (ClauseType) { | ||
ClauseType["TEXT"] = "TEXT"; | ||
ClauseType["BINARY"] = "BINARY"; | ||
ClauseType["NEWLINE"] = "NEWLINE"; | ||
ClauseType["NONE"] = "NONE"; | ||
})(ClauseType || (exports.ClauseType = ClauseType = {})); | ||
class CommandClause { | ||
/** | ||
* Clause type | ||
* @private | ||
*/ | ||
_type; | ||
/** | ||
* Text command | ||
* @private | ||
*/ | ||
_text; | ||
/** | ||
* Charset | ||
* @private | ||
*/ | ||
_charset; | ||
/** | ||
* Binary command | ||
* @private | ||
*/ | ||
_binary; | ||
constructor(type, text, charset, binary) { | ||
this._type = type; | ||
this._text = text; | ||
this._charset = charset; | ||
this._binary = binary; | ||
} | ||
static text(command, charset = types_1.PsdkConst.DEF_CHARSET) { | ||
return new CommandClause(ClauseType.TEXT, command, charset, undefined); | ||
} | ||
static binary(binary) { | ||
return new CommandClause(ClauseType.BINARY, undefined, undefined, binary); | ||
} | ||
static newline() { | ||
return new CommandClause(ClauseType.NEWLINE, undefined, undefined, types_1.PsdkConst.DEF_NEWLINE_BINARY); | ||
} | ||
static none() { | ||
return new CommandClause(ClauseType.NONE, undefined, undefined, undefined); | ||
} | ||
get type() { | ||
return this._type; | ||
} | ||
get text() { | ||
return this._text; | ||
} | ||
get charset() { | ||
return this._charset; | ||
} | ||
get binary() { | ||
return this._binary; | ||
} | ||
} | ||
exports.CommandClause = CommandClause; | ||
/***/ }), | ||
/***/ 472: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.Commander = void 0; | ||
const command_clause_1 = __nccwpck_require__(298); | ||
const types_1 = __nccwpck_require__(526); | ||
const command_1 = __nccwpck_require__(434); | ||
/** | ||
* Command builder | ||
*/ | ||
class Commander { | ||
/** | ||
* Command clauses | ||
* @private | ||
*/ | ||
clauses; | ||
_variable; | ||
constructor() { | ||
this.clauses = []; | ||
this._variable = new Map(); | ||
} | ||
/** | ||
* Make a commander | ||
*/ | ||
static make() { | ||
return new Commander(); | ||
} | ||
/** | ||
* Push a text command | ||
* @param command command | ||
* @param options Options: { newline: newline, charset: charset } | ||
*/ | ||
pushText(command, options) { | ||
if (command.startsWith(types_1.PsdkConst.CRLF)) { | ||
command = command.substring(2); | ||
} | ||
const clause = command_clause_1.CommandClause.text(command, options?.charset ?? types_1.PsdkConst.DEF_CHARSET); | ||
return this.pushClause(clause, options?.newline ?? types_1.PsdkConst.DEF_ENABLED_NEWLINE); | ||
} | ||
/** | ||
* Push binary command | ||
* @param command Command | ||
* @param newline Add new line for this command | ||
*/ | ||
pushBinary(command, newline) { | ||
const clause = command_clause_1.CommandClause.binary(command); | ||
return this.pushClause(clause, newline ?? types_1.PsdkConst.DEF_ENABLED_NEWLINE); | ||
} | ||
/** | ||
* Push clause | ||
* @param clause Command clause object | ||
* @param newline Add new line for this command | ||
*/ | ||
pushClause(clause, newline) { | ||
this.clauses.push(clause); | ||
if (newline ?? types_1.PsdkConst.DEF_ENABLED_NEWLINE) { | ||
this.clauses.push(command_clause_1.CommandClause.newline()); | ||
} | ||
return this; | ||
} | ||
/** | ||
* Push multiple clause | ||
* @param clauses | ||
*/ | ||
pushClauses(clauses) { | ||
clauses.forEach(item => this.pushClause(item, false)); | ||
return this; | ||
} | ||
/** | ||
* Push arg | ||
* @param arg arg | ||
*/ | ||
pushArg(arg) { | ||
this.pushClauses(arg.clauses()); | ||
return this; | ||
} | ||
/** | ||
* Add newline | ||
*/ | ||
newline() { | ||
const clause = command_clause_1.CommandClause.newline(); | ||
return this.pushClause(clause, false); | ||
} | ||
/** | ||
* Add a new variable | ||
* @param name name | ||
* @param value value | ||
*/ | ||
variable(name, value) { | ||
this._variable.set(name, value); | ||
return this; | ||
} | ||
/** | ||
* Clear all commands | ||
*/ | ||
clear() { | ||
this.clauses.splice(0, this.clauses.length); | ||
this._variable.clear(); | ||
return this; | ||
} | ||
/** | ||
* Get command | ||
*/ | ||
command() { | ||
return new command_1.DefaultCommand(this.clauses, this._variable); | ||
} | ||
} | ||
exports.Commander = Commander; | ||
/***/ }), | ||
/***/ 838: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.TextAppendat = exports.Appendat = void 0; | ||
const toolkit_1 = __nccwpck_require__(195); | ||
class Appendat { | ||
_argument; | ||
_condition; | ||
_callback; | ||
constructor(argument, condition, callback) { | ||
this._argument = argument; | ||
this._condition = condition; | ||
this._callback = callback; | ||
} | ||
get condition() { | ||
return this._condition; | ||
} | ||
callback(callback) { | ||
this._callback = callback; | ||
return this; | ||
} | ||
quote() { | ||
return this; | ||
} | ||
argument() { | ||
if (!toolkit_1.Checker.truthy(this._callback)) | ||
return this._argument; | ||
if (!toolkit_1.Checker.truthy(this._argument)) | ||
return undefined; | ||
return this._callback.callback(this._argument); | ||
} | ||
} | ||
exports.Appendat = Appendat; | ||
class TextAppendat extends Appendat { | ||
_quote; | ||
constructor(argument, condition, callback) { | ||
super(argument, condition ?? true, callback); | ||
this._quote = false; | ||
} | ||
/** | ||
* Create new text appendat | ||
* @param argument argument | ||
* @param options options: { condition: condition for this arg, callback: value callback } | ||
*/ | ||
static create(argument, options) { | ||
return new TextAppendat(argument, options?.condition ?? true, new class { | ||
callback(data) { | ||
const cb = options?.callback; | ||
if (cb) { | ||
return cb(data); | ||
} | ||
return data; | ||
} | ||
}); | ||
} | ||
callback(callback) { | ||
super.callback(callback); | ||
return this; | ||
} | ||
quote() { | ||
this._quote = true; | ||
return this; | ||
} | ||
argument() { | ||
const arg = super.argument(); | ||
if (!toolkit_1.Checker.truthy(arg)) | ||
return this._quote ? '""' : ''; | ||
if (this._quote) { | ||
return `"${arg}"`; | ||
} | ||
return arg; | ||
} | ||
} | ||
exports.TextAppendat = TextAppendat; | ||
/***/ }), | ||
/***/ 25: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.BinaryCommand = void 0; | ||
const command_clause_1 = __nccwpck_require__(298); | ||
// import * as iconv from 'iconv-lite'; | ||
const toolkit_1 = __nccwpck_require__(195); | ||
class BinaryCommand { | ||
binary; | ||
constructor(binary) { | ||
this.binary = binary ?? []; | ||
} | ||
static make() { | ||
return new BinaryCommand(); | ||
} | ||
static with(u8a) { | ||
const b = Array.from(u8a); | ||
return new BinaryCommand(b); | ||
} | ||
appendNumber(num) { | ||
this.binary.push(num); | ||
return this; | ||
} | ||
appendText(text, charset) { | ||
// const encoding = (charset ?? PsdkConst.DEF_CHARSET).toLowerCase(); | ||
// const binary = iconv.encode(text, encoding); | ||
const binary = toolkit_1.FastGBK.encode(text); | ||
this.binary.push(...binary); | ||
return this; | ||
} | ||
appendU8A(u8a) { | ||
const b = Array.from(u8a); | ||
this.binary = this.binary.concat(b); | ||
return this; | ||
} | ||
output() { | ||
return new Uint8Array(this.binary); | ||
} | ||
clause() { | ||
const output = this.output(); | ||
return command_clause_1.CommandClause.binary(output); | ||
} | ||
} | ||
exports.BinaryCommand = BinaryCommand; | ||
/***/ }), | ||
/***/ 92: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.TSPLCommand = exports.CPCLCommand = exports.SingleCommand = void 0; | ||
/** | ||
* Single Command | ||
*/ | ||
const appendat_1 = __nccwpck_require__(838); | ||
const command_clause_1 = __nccwpck_require__(298); | ||
const toolkit_1 = __nccwpck_require__(195); | ||
class SingleCommand { | ||
/** | ||
* arguments | ||
* @private | ||
*/ | ||
_arguments; | ||
_symbolAfterHeader; | ||
_symbolBetweenArguments; | ||
_header; | ||
_charset; | ||
constructor(symbolAfterHeader, symbolBetweenArguments, charset) { | ||
this._arguments = []; | ||
this._symbolAfterHeader = symbolAfterHeader; | ||
this._symbolBetweenArguments = symbolBetweenArguments; | ||
this._charset = charset; | ||
} | ||
get getHeader() { | ||
return this._header; | ||
} | ||
get symbolAfterHeader() { | ||
return this._symbolAfterHeader; | ||
} | ||
get symbolBetweenArguments() { | ||
return this._symbolBetweenArguments; | ||
} | ||
header(header) { | ||
this._header = header; | ||
return this; | ||
} | ||
get charset() { | ||
return this._charset; | ||
} | ||
append(appendat) { | ||
if (!appendat.condition) | ||
return this; | ||
const argument = appendat.argument(); | ||
if (!toolkit_1.Checker.truthy(argument)) | ||
return this; | ||
this._arguments.push(argument); | ||
return this; | ||
} | ||
arguments() { | ||
return this._arguments; | ||
} | ||
} | ||
exports.SingleCommand = SingleCommand; | ||
class BasicStringSingleCommand extends SingleCommand { | ||
constructor(symbolAfterHeader, symbolBetweenArguments, charset) { | ||
super(symbolAfterHeader, symbolBetweenArguments, charset); | ||
} | ||
append(appendat) { | ||
const argument = appendat.argument(); | ||
if (!toolkit_1.Checker.truthy(argument)) | ||
return this; | ||
super.append(appendat); | ||
return this; | ||
} | ||
appendText(text) { | ||
return this.append(appendat_1.TextAppendat.create(text ?? '', {})); | ||
} | ||
appendNumber(num) { | ||
if (isNaN(num)) | ||
return this; | ||
return this.append(appendat_1.TextAppendat.create((num ?? '').toString(), {})); | ||
} | ||
output() { | ||
let ret = ''; | ||
if (toolkit_1.Checker.truthy(super.getHeader)) { | ||
ret += super.getHeader; | ||
ret += super.symbolAfterHeader; | ||
} | ||
const args = super.arguments(); | ||
const len = args.length; | ||
let seq = 0; | ||
for (const arg of args) { | ||
seq += 1; | ||
if (!toolkit_1.Checker.truthy(arg)) | ||
continue; | ||
ret += arg; | ||
if (seq < len) { | ||
ret += super.symbolBetweenArguments; | ||
} | ||
} | ||
return ret; | ||
} | ||
clause() { | ||
const output = this.output(); | ||
if (!toolkit_1.Checker.truthy(output)) { | ||
return command_clause_1.CommandClause.none(); | ||
} | ||
return command_clause_1.CommandClause.text(output, super.charset); | ||
} | ||
} | ||
class CPCLCommand extends BasicStringSingleCommand { | ||
constructor(header, charset) { | ||
super(' ', ' ', charset); | ||
super.header(header); | ||
} | ||
static with(header, charset) { | ||
return new CPCLCommand(header, charset); | ||
} | ||
append(appendat) { | ||
super.append(appendat); | ||
return this; | ||
} | ||
appendText(text) { | ||
super.appendText(text); | ||
return this; | ||
} | ||
appendNumber(num) { | ||
super.appendNumber(num); | ||
return this; | ||
} | ||
} | ||
exports.CPCLCommand = CPCLCommand; | ||
class TSPLCommand extends BasicStringSingleCommand { | ||
constructor(header, charset) { | ||
super(' ', ',', charset); | ||
super.header(header); | ||
} | ||
static with(header, charset) { | ||
return new TSPLCommand(header, charset); | ||
} | ||
append(appendat) { | ||
super.append(appendat); | ||
return this; | ||
} | ||
appendText(text) { | ||
super.appendText(text); | ||
return this; | ||
} | ||
appendNumber(num) { | ||
super.appendNumber(num); | ||
return this; | ||
} | ||
} | ||
exports.TSPLCommand = TSPLCommand; | ||
/***/ }), | ||
/***/ 475: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.DataWriteOperation = void 0; | ||
/** | ||
* Data write operation | ||
*/ | ||
const types_1 = __nccwpck_require__(526); | ||
const adapter_1 = __nccwpck_require__(909); | ||
const toolkit_1 = __nccwpck_require__(195); | ||
class DataWriteOperation { | ||
options; | ||
binary; | ||
connectedDevice; | ||
constructor( | ||
/** | ||
* Write options | ||
* @private | ||
*/ | ||
options, | ||
/** | ||
* Write binary | ||
* @private | ||
*/ | ||
binary, | ||
/** | ||
* Connected device | ||
* @private | ||
*/ | ||
connectedDevice) { | ||
this.options = options; | ||
this.binary = binary; | ||
this.connectedDevice = connectedDevice; | ||
} | ||
async write() { | ||
if (!this.options.enableChunkWrite) { | ||
const reporter = await this.writData(this.binary); | ||
this.doCallback(reporter, this.binary, 1, 1); | ||
return reporter; | ||
} | ||
const writeData = Array.from(this.binary); | ||
const parts = toolkit_1.CollectionKit.split(writeData, this.options.chunkSize); | ||
const totalTimes = parts.length; | ||
let currentTimes = 0; | ||
for (const part of parts) { | ||
currentTimes += 1; | ||
const partBinary = new Uint8Array(part); | ||
const reporter = await this.writData(partBinary); | ||
const control = this.doCallback(reporter, partBinary, currentTimes, totalTimes); | ||
if (control == types_1.WriteControl.STOP) { | ||
reporter.controlExit = true; | ||
return reporter; | ||
} | ||
if (!reporter.ok) { | ||
return reporter; | ||
} | ||
} | ||
return new adapter_1.WroteReporter(true, this.binary, false); | ||
} | ||
doCallback(reporter, binary, currentTimes, totalTimes) { | ||
const callback = this.options.callback; | ||
if (!callback) | ||
return types_1.WriteControl.CONTINUE; | ||
const dataWrote = new types_1.DataWrote(binary, currentTimes, totalTimes); | ||
if (reporter.ok) { | ||
return callback.success(dataWrote); | ||
} | ||
if (callback.failed) { | ||
callback.failed(dataWrote, reporter.exception); | ||
} | ||
else { | ||
console.log('no custom failed callback, full exception: ', reporter.exception); | ||
} | ||
return types_1.WriteControl.STOP; | ||
} | ||
async writData(binary) { | ||
try { | ||
await this.connectedDevice.write(binary); | ||
return new adapter_1.WroteReporter(true, binary, false); | ||
} | ||
catch (e) { | ||
return new adapter_1.WroteReporter(false, binary, false, e); | ||
} | ||
} | ||
} | ||
exports.DataWriteOperation = DataWriteOperation; | ||
/***/ }), | ||
/***/ 842: | ||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
__exportStar(__nccwpck_require__(697), exports); | ||
__exportStar(__nccwpck_require__(526), exports); | ||
__exportStar(__nccwpck_require__(687), exports); | ||
__exportStar(__nccwpck_require__(501), exports); | ||
/***/ }), | ||
/***/ 157: | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.HexOutput = void 0; | ||
const DEF_MAX_LENGTH_OF_LINE = 32; | ||
/** | ||
* hex output | ||
*/ | ||
class HexOutput { | ||
enableFormat; | ||
spacing; | ||
maxLengthOfLine; | ||
// private format: boolean; | ||
// | ||
// private spacing: boolean; | ||
// | ||
// private maxLengthOfLine: number = DEF_MAX_LENGTH_OF_LINE; | ||
constructor( | ||
/** | ||
* Is format | ||
*/ | ||
enableFormat, | ||
/** | ||
* Enable spacing between byte | ||
*/ | ||
spacing, | ||
/** | ||
* Max length of line | ||
*/ | ||
maxLengthOfLine = DEF_MAX_LENGTH_OF_LINE) { | ||
this.enableFormat = enableFormat; | ||
this.spacing = spacing; | ||
this.maxLengthOfLine = maxLengthOfLine; | ||
} | ||
static def() { | ||
return new HexOutput(false, false, DEF_MAX_LENGTH_OF_LINE); | ||
} | ||
static simple(format = true) { | ||
return new HexOutput(format, true, DEF_MAX_LENGTH_OF_LINE); | ||
} | ||
static formatWithMaxLength(maxLengthOfLine) { | ||
return new HexOutput(true, true, maxLengthOfLine); | ||
} | ||
/** | ||
* Format binary | ||
*/ | ||
format(binary) { | ||
// const hex = toHex(binary); | ||
const hex = Array.from(binary, function (byte) { | ||
return ('0' + (byte & 0xFF).toString(16)).slice(-2); | ||
}).join(''); | ||
if (!this.enableFormat) { | ||
return hex; | ||
} | ||
let fmted = ''; | ||
const textLength = hex.length; | ||
let lineIndex = 0; | ||
for (let ix = 0; ix < textLength; ix++) { | ||
const seq = ix + 1; | ||
const v = hex[ix]; | ||
fmted += v; | ||
if (seq % 2 == 0 && this.spacing) { | ||
if (seq < textLength) { | ||
if (lineIndex + 1 < this.maxLengthOfLine) { | ||
fmted += ' '; | ||
} | ||
lineIndex += 1; | ||
} | ||
} | ||
if (lineIndex >= this.maxLengthOfLine) { | ||
fmted += '\n'; | ||
lineIndex = 0; | ||
} | ||
} | ||
return fmted; | ||
} | ||
} | ||
exports.HexOutput = HexOutput; | ||
/***/ }), | ||
/***/ 526: | ||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
__exportStar(__nccwpck_require__(844), exports); | ||
__exportStar(__nccwpck_require__(157), exports); | ||
__exportStar(__nccwpck_require__(888), exports); | ||
__exportStar(__nccwpck_require__(87), exports); | ||
/***/ }), | ||
/***/ 87: | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.Lifecycle = void 0; | ||
class Lifecycle { | ||
connectedDevice; | ||
constructor( | ||
/** | ||
* Connected device | ||
*/ | ||
connectedDevice) { | ||
this.connectedDevice = connectedDevice; | ||
} | ||
} | ||
exports.Lifecycle = Lifecycle; | ||
/***/ }), | ||
/***/ 844: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.PsdkConst = void 0; | ||
const toolkit_1 = __nccwpck_require__(195); | ||
const CR = '\r'; | ||
const LF = '\n'; | ||
const CRLF = `${CR}${LF}`; | ||
/** | ||
* constants | ||
*/ | ||
exports.PsdkConst = { | ||
DEF_CHARSET: 'gbk', | ||
CR, | ||
LF, | ||
CRLF, | ||
QUOTE: '"', | ||
DEF_NEWLINE_BINARY: toolkit_1.ByteKit.textToU8A(CRLF), | ||
DEF_AUTHORS: ['fewensa <osuni@protonmail.com>'], | ||
DEF_ENABLED_NEWLINE: true, | ||
DEF_WRITE_CHUNK_SIZE: 512, | ||
EMPTY_BYTES: new Uint8Array([]), | ||
}; | ||
/***/ }), | ||
/***/ 888: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.WriteControl = exports.DataWrote = exports.DataWrite = exports.IDataWriteCallback = exports.WriteOptions = void 0; | ||
const psdk_const_1 = __nccwpck_require__(844); | ||
/** | ||
* Write to device options | ||
*/ | ||
class WriteOptions { | ||
enableChunkWrite; | ||
chunkSize; | ||
callback; | ||
constructor( | ||
/** | ||
* Enable data splitting | ||
*/ | ||
enableChunkWrite = true, | ||
/** | ||
* Part size | ||
*/ | ||
chunkSize = psdk_const_1.PsdkConst.DEF_WRITE_CHUNK_SIZE, | ||
/** | ||
* Data write callback | ||
*/ | ||
callback) { | ||
this.enableChunkWrite = enableChunkWrite; | ||
this.chunkSize = chunkSize; | ||
this.callback = callback; | ||
} | ||
static def() { | ||
return new WriteOptions(true, psdk_const_1.PsdkConst.DEF_WRITE_CHUNK_SIZE, undefined); | ||
} | ||
} | ||
exports.WriteOptions = WriteOptions; | ||
/** | ||
* Data write callback | ||
*/ | ||
class IDataWriteCallback { | ||
failed(data, exception) { | ||
console.error(`Write data failed: ${exception.message}`); | ||
} | ||
} | ||
exports.IDataWriteCallback = IDataWriteCallback; | ||
/** | ||
* Data write | ||
*/ | ||
class DataWrite { | ||
binary; | ||
currentTimes; | ||
totalTimes; | ||
constructor( | ||
/** | ||
* Wrote binary | ||
*/ | ||
binary, | ||
/** | ||
* Write current times | ||
*/ | ||
currentTimes, | ||
/** | ||
* Write total times | ||
*/ | ||
totalTimes) { | ||
this.binary = binary; | ||
this.currentTimes = currentTimes; | ||
this.totalTimes = totalTimes; | ||
} | ||
} | ||
exports.DataWrite = DataWrite; | ||
/** | ||
* Data wrote | ||
*/ | ||
class DataWrote extends DataWrite { | ||
} | ||
exports.DataWrote = DataWrote; | ||
/** | ||
* Write control | ||
*/ | ||
var WriteControl; | ||
(function (WriteControl) { | ||
WriteControl["CONTINUE"] = "CONTINUE"; | ||
WriteControl["STOP"] = "STOP"; | ||
})(WriteControl || (exports.WriteControl = WriteControl = {})); | ||
/***/ }), | ||
/***/ 926: | ||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
__exportStar(__nccwpck_require__(909), exports); | ||
__exportStar(__nccwpck_require__(842), exports); | ||
__exportStar(__nccwpck_require__(195), exports); | ||
/***/ }), | ||
/***/ 401: | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.Base64 = exports.extendBuiltins = exports.extendUint8Array = exports.extendString = exports.toUint8Array = exports.fromUint8Array = exports.isValid = exports.decode = exports.btou = exports.encodeURL = exports.encodeURI = exports.encode = exports.utob = exports.toBase64 = exports.fromBase64 = exports.btoaPolyfill = exports.btoa = exports.atobPolyfill = exports.atob = exports.VERSION = exports.version = void 0; | ||
// https://github.com/dankogai/js-base64/blob/main/base64.ts | ||
/** | ||
* base64.ts | ||
* | ||
* Licensed under the BSD 3-Clause License. | ||
* http://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* References: | ||
* http://en.wikipedia.org/wiki/Base64 | ||
* | ||
* @author Dan Kogai (https://github.com/dankogai) | ||
*/ | ||
const version = '3.7.7'; | ||
exports.version = version; | ||
/** | ||
* @deprecated use lowercase `version`. | ||
*/ | ||
const VERSION = version; | ||
exports.VERSION = VERSION; | ||
const _hasBuffer = typeof Buffer === 'function'; | ||
const _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined; | ||
const _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined; | ||
const b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; | ||
const b64chs = Array.prototype.slice.call(b64ch); | ||
const b64tab = ((a) => { | ||
let tab = {}; | ||
a.forEach((c, i) => tab[c] = i); | ||
return tab; | ||
})(b64chs); | ||
const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/; | ||
const _fromCC = String.fromCharCode.bind(String); | ||
const _U8Afrom = typeof Uint8Array.from === 'function' | ||
? Uint8Array.from.bind(Uint8Array) | ||
: (it) => new Uint8Array(Array.prototype.slice.call(it, 0)); | ||
const _mkUriSafe = (src) => src | ||
.replace(/=/g, '').replace(/[+\/]/g, (m0) => m0 == '+' ? '-' : '_'); | ||
const _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, ''); | ||
/** | ||
* polyfill version of `btoa` | ||
*/ | ||
const btoaPolyfill = (bin) => { | ||
// console.log('polyfilled'); | ||
let u32, c0, c1, c2, asc = ''; | ||
const pad = bin.length % 3; | ||
for (let i = 0; i < bin.length;) { | ||
if ((c0 = bin.charCodeAt(i++)) > 255 || | ||
(c1 = bin.charCodeAt(i++)) > 255 || | ||
(c2 = bin.charCodeAt(i++)) > 255) | ||
throw new TypeError('invalid character found'); | ||
u32 = (c0 << 16) | (c1 << 8) | c2; | ||
asc += b64chs[u32 >> 18 & 63] | ||
+ b64chs[u32 >> 12 & 63] | ||
+ b64chs[u32 >> 6 & 63] | ||
+ b64chs[u32 & 63]; | ||
} | ||
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc; | ||
}; | ||
exports.btoaPolyfill = btoaPolyfill; | ||
/** | ||
* does what `window.btoa` of web browsers do. | ||
* @param {String} bin binary string | ||
* @returns {string} Base64-encoded string | ||
*/ | ||
const _btoa = typeof btoa === 'function' ? (bin) => btoa(bin) | ||
: _hasBuffer ? (bin) => Buffer.from(bin, 'binary').toString('base64') | ||
: btoaPolyfill; | ||
exports.btoa = _btoa; | ||
const _fromUint8Array = _hasBuffer | ||
? (u8a) => Buffer.from(u8a).toString('base64') | ||
: (u8a) => { | ||
// cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326 | ||
const maxargs = 0x1000; | ||
let strs = []; | ||
for (let i = 0, l = u8a.length; i < l; i += maxargs) { | ||
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs))); | ||
} | ||
return _btoa(strs.join('')); | ||
}; | ||
/** | ||
* converts a Uint8Array to a Base64 string. | ||
* @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5 | ||
* @returns {string} Base64 string | ||
*/ | ||
const fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a); | ||
exports.fromUint8Array = fromUint8Array; | ||
// This trick is found broken https://github.com/dankogai/js-base64/issues/130 | ||
// const utob = (src: string) => unescape(encodeURIComponent(src)); | ||
// reverting good old fationed regexp | ||
const cb_utob = (c) => { | ||
if (c.length < 2) { | ||
var cc = c.charCodeAt(0); | ||
return cc < 0x80 ? c | ||
: cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6)) | ||
+ _fromCC(0x80 | (cc & 0x3f))) | ||
: (_fromCC(0xe0 | ((cc >>> 12) & 0x0f)) | ||
+ _fromCC(0x80 | ((cc >>> 6) & 0x3f)) | ||
+ _fromCC(0x80 | (cc & 0x3f))); | ||
} | ||
else { | ||
var cc = 0x10000 | ||
+ (c.charCodeAt(0) - 0xD800) * 0x400 | ||
+ (c.charCodeAt(1) - 0xDC00); | ||
return (_fromCC(0xf0 | ((cc >>> 18) & 0x07)) | ||
+ _fromCC(0x80 | ((cc >>> 12) & 0x3f)) | ||
+ _fromCC(0x80 | ((cc >>> 6) & 0x3f)) | ||
+ _fromCC(0x80 | (cc & 0x3f))); | ||
} | ||
}; | ||
const re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g; | ||
/** | ||
* @deprecated should have been internal use only. | ||
* @param {string} src UTF-8 string | ||
* @returns {string} UTF-16 string | ||
*/ | ||
const utob = (u) => u.replace(re_utob, cb_utob); | ||
exports.utob = utob; | ||
// | ||
const _encode = _hasBuffer | ||
? (s) => Buffer.from(s, 'utf8').toString('base64') | ||
: _TE | ||
? (s) => _fromUint8Array(_TE.encode(s)) | ||
: (s) => _btoa(utob(s)); | ||
/** | ||
* converts a UTF-8-encoded string to a Base64 string. | ||
* @param {boolean} [urlsafe] if `true` make the result URL-safe | ||
* @returns {string} Base64 string | ||
*/ | ||
const encode = (src, urlsafe = false) => urlsafe | ||
? _mkUriSafe(_encode(src)) | ||
: _encode(src); | ||
exports.toBase64 = encode; | ||
exports.encode = encode; | ||
/** | ||
* converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5. | ||
* @returns {string} Base64 string | ||
*/ | ||
const encodeURI = (src) => encode(src, true); | ||
exports.encodeURI = encodeURI; | ||
exports.encodeURL = encodeURI; | ||
// This trick is found broken https://github.com/dankogai/js-base64/issues/130 | ||
// const btou = (src: string) => decodeURIComponent(escape(src)); | ||
// reverting good old fationed regexp | ||
const re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g; | ||
const cb_btou = (cccc) => { | ||
switch (cccc.length) { | ||
case 4: | ||
var cp = ((0x07 & cccc.charCodeAt(0)) << 18) | ||
| ((0x3f & cccc.charCodeAt(1)) << 12) | ||
| ((0x3f & cccc.charCodeAt(2)) << 6) | ||
| (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000; | ||
return (_fromCC((offset >>> 10) + 0xD800) | ||
+ _fromCC((offset & 0x3FF) + 0xDC00)); | ||
case 3: | ||
return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12) | ||
| ((0x3f & cccc.charCodeAt(1)) << 6) | ||
| (0x3f & cccc.charCodeAt(2))); | ||
default: | ||
return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6) | ||
| (0x3f & cccc.charCodeAt(1))); | ||
} | ||
}; | ||
/** | ||
* @deprecated should have been internal use only. | ||
* @param {string} src UTF-16 string | ||
* @returns {string} UTF-8 string | ||
*/ | ||
const btou = (b) => b.replace(re_btou, cb_btou); | ||
exports.btou = btou; | ||
/** | ||
* polyfill version of `atob` | ||
*/ | ||
const atobPolyfill = (asc) => { | ||
// console.log('polyfilled'); | ||
asc = asc.replace(/\s+/g, ''); | ||
if (!b64re.test(asc)) | ||
throw new TypeError('malformed base64.'); | ||
asc += '=='.slice(2 - (asc.length & 3)); | ||
let u24, bin = '', r1, r2; | ||
for (let i = 0; i < asc.length;) { | ||
u24 = b64tab[asc.charAt(i++)] << 18 | ||
| b64tab[asc.charAt(i++)] << 12 | ||
| (r1 = b64tab[asc.charAt(i++)]) << 6 | ||
| (r2 = b64tab[asc.charAt(i++)]); | ||
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255) | ||
: r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255) | ||
: _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255); | ||
} | ||
return bin; | ||
}; | ||
exports.atobPolyfill = atobPolyfill; | ||
/** | ||
* does what `window.atob` of web browsers do. | ||
* @param {String} asc Base64-encoded string | ||
* @returns {string} binary string | ||
*/ | ||
const _atob = typeof atob === 'function' ? (asc) => atob(_tidyB64(asc)) | ||
: _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary') | ||
: atobPolyfill; | ||
exports.atob = _atob; | ||
// | ||
const _toUint8Array = _hasBuffer | ||
? (a) => _U8Afrom(Buffer.from(a, 'base64')) | ||
: (a) => _U8Afrom(_atob(a).split('').map(c => c.charCodeAt(0))); | ||
/** | ||
* converts a Base64 string to a Uint8Array. | ||
*/ | ||
const toUint8Array = (a) => _toUint8Array(_unURI(a)); | ||
exports.toUint8Array = toUint8Array; | ||
// | ||
const _decode = _hasBuffer | ||
? (a) => Buffer.from(a, 'base64').toString('utf8') | ||
: _TD | ||
? (a) => _TD.decode(_toUint8Array(a)) | ||
: (a) => btou(_atob(a)); | ||
const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == '-' ? '+' : '/')); | ||
/** | ||
* converts a Base64 string to a UTF-8 string. | ||
* @param {String} src Base64 string. Both normal and URL-safe are supported | ||
* @returns {string} UTF-8 string | ||
*/ | ||
const decode = (src) => _decode(_unURI(src)); | ||
exports.fromBase64 = decode; | ||
exports.decode = decode; | ||
/** | ||
* check if a value is a valid Base64 string | ||
* @param {String} src a value to check | ||
*/ | ||
const isValid = (src) => { | ||
if (typeof src !== 'string') | ||
return false; | ||
const s = src.replace(/\s+/g, '').replace(/={0,2}$/, ''); | ||
return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s); | ||
}; | ||
exports.isValid = isValid; | ||
// | ||
const _noEnum = (v) => { | ||
return { | ||
value: v, enumerable: false, writable: true, configurable: true | ||
}; | ||
}; | ||
/** | ||
* extend String.prototype with relevant methods | ||
*/ | ||
const extendString = function () { | ||
const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body)); | ||
_add('fromBase64', function () { return decode(this); }); | ||
_add('toBase64', function (urlsafe) { return encode(this, urlsafe); }); | ||
_add('toBase64URI', function () { return encode(this, true); }); | ||
_add('toBase64URL', function () { return encode(this, true); }); | ||
_add('toUint8Array', function () { return toUint8Array(this); }); | ||
}; | ||
exports.extendString = extendString; | ||
/** | ||
* extend Uint8Array.prototype with relevant methods | ||
*/ | ||
const extendUint8Array = function () { | ||
const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body)); | ||
_add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); }); | ||
_add('toBase64URI', function () { return fromUint8Array(this, true); }); | ||
_add('toBase64URL', function () { return fromUint8Array(this, true); }); | ||
}; | ||
exports.extendUint8Array = extendUint8Array; | ||
/** | ||
* extend Builtin prototypes with relevant methods | ||
*/ | ||
const extendBuiltins = () => { | ||
extendString(); | ||
extendUint8Array(); | ||
}; | ||
exports.extendBuiltins = extendBuiltins; | ||
const gBase64 = { | ||
version: version, | ||
VERSION: VERSION, | ||
atob: _atob, | ||
atobPolyfill: atobPolyfill, | ||
btoa: _btoa, | ||
btoaPolyfill: btoaPolyfill, | ||
fromBase64: decode, | ||
toBase64: encode, | ||
encode: encode, | ||
encodeURI: encodeURI, | ||
encodeURL: encodeURI, | ||
utob: utob, | ||
btou: btou, | ||
decode: decode, | ||
isValid: isValid, | ||
fromUint8Array: fromUint8Array, | ||
toUint8Array: toUint8Array, | ||
extendString: extendString, | ||
extendUint8Array: extendUint8Array, | ||
extendBuiltins: extendBuiltins | ||
}; | ||
exports.Base64 = gBase64; | ||
/***/ }), | ||
/***/ 508: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.ByteKit = void 0; | ||
const checker_1 = __nccwpck_require__(828); | ||
/** | ||
* Byte kit | ||
*/ | ||
class ByteKit { | ||
/** | ||
* Text to byte | ||
* @param text text | ||
*/ | ||
static textToU8A(text) { | ||
if (!checker_1.Checker.truthy(text)) | ||
return new Uint8Array([]); | ||
let bytes = []; | ||
let len, c; | ||
len = text.length; | ||
for (let i = 0; i < len; i++) { | ||
c = text.charCodeAt(i); | ||
if (c >= 0x010000 && c <= 0x10FFFF) { | ||
bytes.push(((c >> 18) & 0x07) | 0xF0); | ||
bytes.push(((c >> 12) & 0x3F) | 0x80); | ||
bytes.push(((c >> 6) & 0x3F) | 0x80); | ||
bytes.push((c & 0x3F) | 0x80); | ||
} | ||
else if (c >= 0x000800 && c <= 0x00FFFF) { | ||
bytes.push(((c >> 12) & 0x0F) | 0xE0); | ||
bytes.push(((c >> 6) & 0x3F) | 0x80); | ||
bytes.push((c & 0x3F) | 0x80); | ||
} | ||
else if (c >= 0x000080 && c <= 0x0007FF) { | ||
bytes.push(((c >> 6) & 0x1F) | 0xC0); | ||
bytes.push((c & 0x3F) | 0x80); | ||
} | ||
else { | ||
bytes.push(c & 0xFF); | ||
} | ||
} | ||
return new Uint8Array(bytes); | ||
} | ||
} | ||
exports.ByteKit = ByteKit; | ||
/***/ }), | ||
/***/ 828: | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.Checker = void 0; | ||
class Checker { | ||
static truthy(value) { | ||
if (value === undefined) | ||
return false; | ||
if (value === null) | ||
return false; | ||
if (value === '') | ||
return false; | ||
const t = typeof value; | ||
switch (t) { | ||
case 'number': | ||
if (isNaN(value)) | ||
return false; | ||
break; | ||
case 'bigint': | ||
default: | ||
return true; | ||
} | ||
} | ||
static empty(value) { | ||
if (!Checker.truthy(value)) | ||
return true; | ||
return value.length === 0; | ||
} | ||
} | ||
exports.Checker = Checker; | ||
/***/ }), | ||
/***/ 90: | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.FastGBK = void 0; | ||
// https://github.com/EtherDream/str2gbk/blob/main/index.js | ||
let table; | ||
function initGbkTable() { | ||
// https://en.wikipedia.org/wiki/GBK_(character_encoding)#Encoding | ||
const ranges = [ | ||
[0xA1, 0xA9, 0xA1, 0xFE], | ||
[0xB0, 0xF7, 0xA1, 0xFE], | ||
[0x81, 0xA0, 0x40, 0xFE], | ||
[0xAA, 0xFE, 0x40, 0xA0], | ||
[0xA8, 0xA9, 0x40, 0xA0], | ||
[0xAA, 0xAF, 0xA1, 0xFE], | ||
[0xF8, 0xFE, 0xA1, 0xFE], | ||
[0xA1, 0xA7, 0x40, 0xA0], | ||
]; | ||
const codes = new Uint16Array(23940); | ||
let i = 0; | ||
for (const [b1Begin, b1End, b2Begin, b2End] of ranges) { | ||
for (let b2 = b2Begin; b2 <= b2End; b2++) { | ||
if (b2 !== 0x7F) { | ||
for (let b1 = b1Begin; b1 <= b1End; b1++) { | ||
codes[i++] = b2 << 8 | b1; | ||
} | ||
} | ||
} | ||
} | ||
table = new Uint16Array(65536); | ||
table.fill(0xFFFF); | ||
const str = new TextDecoder('gbk').decode(codes); | ||
for (let i = 0; i < str.length; i++) { | ||
table[str.charCodeAt(i)] = codes[i]; | ||
} | ||
} | ||
// const NodeJsBufAlloc = typeof Buffer === 'function' && Buffer.allocUnsafe | ||
// | ||
// const defaultOnAlloc = NodeJsBufAlloc | ||
// ? (len) => NodeJsBufAlloc(len) | ||
// : (len) => new Uint8Array(len) | ||
const defaultOnAlloc = (len) => new Uint8Array(len); | ||
const defaultOnError = () => 63; // '?' | ||
const gbkDecoder = new TextDecoder('gbk'); | ||
class FastGBK { | ||
static decode(buffer) { | ||
return gbkDecoder.decode(buffer); | ||
} | ||
static encode(text, options) { | ||
if (!table) { | ||
initGbkTable(); | ||
} | ||
const onAlloc = options?.onAlloc ?? defaultOnAlloc; | ||
const onError = options?.onError ?? defaultOnError; | ||
const buf = onAlloc(text.length * 2); | ||
let n = 0; | ||
for (let i = 0; i < text.length; i++) { | ||
const code = text.charCodeAt(i); | ||
if (code < 0x80) { | ||
buf[n++] = code; | ||
continue; | ||
} | ||
const gbk = table[code]; | ||
if (gbk !== 0xFFFF) { | ||
buf[n++] = gbk; | ||
buf[n++] = gbk >> 8; | ||
} | ||
else if (code === 8364) { | ||
// 8364 == '€'.charCodeAt(0) | ||
// Code Page 936 has a single-byte euro sign at 0x80 | ||
buf[n++] = 0x80; | ||
} | ||
else { | ||
const ret = onError(i, text); | ||
if (ret === -1) { | ||
break; | ||
} | ||
if (ret > 0xFF) { | ||
buf[n++] = ret; | ||
buf[n++] = ret >> 8; | ||
} | ||
else { | ||
buf[n++] = ret; | ||
} | ||
} | ||
} | ||
return buf.subarray(0, n); | ||
} | ||
} | ||
exports.FastGBK = FastGBK; | ||
/***/ }), | ||
/***/ 195: | ||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
__exportStar(__nccwpck_require__(508), exports); | ||
__exportStar(__nccwpck_require__(171), exports); | ||
__exportStar(__nccwpck_require__(692), exports); | ||
__exportStar(__nccwpck_require__(641), exports); | ||
__exportStar(__nccwpck_require__(828), exports); | ||
__exportStar(__nccwpck_require__(90), exports); | ||
/***/ }), | ||
/***/ 692: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.CollectionKit = void 0; | ||
const checker_1 = __nccwpck_require__(828); | ||
/** | ||
* Collection kit | ||
*/ | ||
class CollectionKit { | ||
/** | ||
* Split array | ||
* | ||
* @param colls collections | ||
* @param size The size of result array | ||
* @return List | ||
*/ | ||
static split(colls, size) { | ||
if (checker_1.Checker.empty(colls)) | ||
return []; | ||
if (size <= 0) | ||
throw new Error('The size must > 0'); | ||
const rets = []; | ||
let items = []; | ||
for (const coll of colls) { | ||
items.push(coll); | ||
if (size == items.length) { | ||
rets.push(items); | ||
items = []; | ||
} | ||
} | ||
if (0 != items.length) | ||
rets.push(items); | ||
return rets; | ||
} | ||
/** | ||
* Part array | ||
* | ||
* @param colls collections | ||
* @param parts Part length | ||
* @return List | ||
*/ | ||
static parts(colls, parts) { | ||
if (checker_1.Checker.empty(colls)) { | ||
return []; | ||
} | ||
if (parts <= 0) | ||
throw new Error('The parts length must > 0'); | ||
if (colls.length <= parts) { | ||
return [colls]; | ||
} | ||
const rets = []; | ||
let items = []; | ||
const pnum = Math.floor(colls.length / parts); | ||
for (const coll of colls) { | ||
items.push(coll); | ||
if (items.length == pnum) { | ||
rets.push(items); | ||
if (rets.length < parts) | ||
items = []; | ||
} | ||
} | ||
return rets; | ||
} | ||
} | ||
exports.CollectionKit = CollectionKit; | ||
/***/ }), | ||
/***/ 641: | ||
/***/ ((__unused_webpack_module, exports) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.ImageKit = void 0; | ||
/** | ||
* Image kit | ||
*/ | ||
class ImageKit { | ||
/** | ||
* process image | ||
* @param canvas canvas | ||
* @param width width | ||
* @param height height | ||
*/ | ||
static processImage(canvas, width, height) { | ||
const ctx = canvas.getContext('2d'); | ||
let eWidth = Math.floor((width % 8 === 0) ? (width / 8) : (width / 8 + 1)); | ||
let currentHeight = 0; | ||
let index = 0; | ||
const area = height * eWidth; | ||
const bytes = []; // the bytes length is equals `area` | ||
for (let b1 = 0; b1 < area; b1++) { | ||
bytes[b1] = 0; | ||
} | ||
const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height); | ||
while (currentHeight < height) { | ||
// let rowData = []; // the row data length is image height | ||
let eightBitIndex = 0; | ||
for (let x = 0; x < width; x++) { | ||
eightBitIndex++; | ||
if (eightBitIndex > 8) { | ||
eightBitIndex = 1; | ||
index++; | ||
} | ||
const n = 1 << 8 - eightBitIndex; | ||
// const pixel = ctx.getImageData(x, currentHeight, 1, 1); | ||
const pixels = ImageKit.fastExtractPixel(imgData, x, currentHeight, 1, 1); | ||
const pixel = pixels[0]; | ||
// const rgba = pixel.data; | ||
const red = pixel[0]; | ||
const green = pixel[1]; | ||
const blue = pixel[2]; | ||
if ((red + green + blue) / 3 < 128) { | ||
bytes[index] = (bytes[index] | n); | ||
} | ||
} | ||
index = eWidth * (currentHeight + 1); | ||
currentHeight += 1; | ||
} | ||
return new Uint8Array(bytes); | ||
} | ||
static fastExtractPixel(imageData, x, y, w, h) { | ||
let i, j; | ||
let result = []; | ||
let r, g, b, a; | ||
const data = imageData.data; | ||
for (j = 0; j < h; j++) { | ||
let idx = (x + (y + j) * imageData.width) * 4; // get left most byte index for row at y + j | ||
for (i = 0; i < w; i++) { | ||
r = data[idx++]; | ||
g = data[idx++]; | ||
b = data[idx++]; | ||
a = data[idx++]; | ||
// do the processing | ||
result.push([r, g, b, a]); | ||
} | ||
} | ||
return result; | ||
} | ||
} | ||
exports.ImageKit = ImageKit; | ||
/***/ }), | ||
/***/ 171: | ||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.PVariableKit = void 0; | ||
const checker_1 = __nccwpck_require__(828); | ||
class PVariableKit { | ||
/** | ||
* Replace variable | ||
* @param text text | ||
* @param variable variable | ||
*/ | ||
static replace(text, variable) { | ||
if (!checker_1.Checker.truthy(text)) | ||
return text; | ||
if (!checker_1.Checker.truthy(variable)) | ||
return text; | ||
if (text.indexOf('{{') < 0 && text.indexOf('}}') < 0) | ||
return text; | ||
const regx = /[\\]?\{\{(?<varx>.*?)}}/gm; | ||
const tmpMark = '__THIS_IS_MAGIC_MARK_FOR_HACK_REGEX_MATCH__'; | ||
while (true) { | ||
const match = regx.exec(text); | ||
if (match == null) | ||
break; | ||
const originDefined = match[0]; | ||
const originVarx = originDefined.replace('{{', '') | ||
.replace('}}', ''); | ||
const varName = originVarx.trim(); | ||
const varValue = variable.get(varName) ?? ''; | ||
if (originDefined.startsWith('\\')) { | ||
const tmpDefined = originDefined.replace('\\{{', tmpMark); | ||
text = text.replace(originDefined, tmpDefined); | ||
continue; | ||
} | ||
text = text.replace(originDefined, varValue); | ||
} | ||
text = text.replace(new RegExp(tmpMark, 'g'), '{{'); | ||
return text; | ||
} | ||
} | ||
exports.PVariableKit = PVariableKit; | ||
/***/ }) | ||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __nccwpck_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ var threw = true; | ||
/******/ try { | ||
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__); | ||
/******/ threw = false; | ||
/******/ } finally { | ||
/******/ if(threw) delete __webpack_module_cache__[moduleId]; | ||
/******/ } | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
/******/ /* webpack/runtime/compat */ | ||
/******/ | ||
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; | ||
/******/ | ||
/************************************************************************/ | ||
/******/ | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ // This entry module is referenced by other modules so it can't be inlined | ||
/******/ var __webpack_exports__ = __nccwpck_require__(926); | ||
/******/ module.exports = __webpack_exports__; | ||
/******/ | ||
/******/ })() | ||
; | ||
require('./sourcemap-register.js');(()=>{"use strict";var e={391:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.FakeConnectedDevice=void 0;const n=r(145);const s=r(842);class FakeConnectedDevice{origin(){return"FAKE-DEVICE"}connectionState(){return n.ConnectionState.CONNECTED}deviceName(){return"FAKE-DEVICE"}async disconnect(){}canRead(){return true}async read(e){return s.PsdkConst.EMPTY_BYTES}async write(e){console.log("WRITE: ",e)}flush(){}}t.FakeConnectedDevice=FakeConnectedDevice},909:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});s(r(391),t);s(r(145),t)},145:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.ReadOptions=t.WroteReporter=t.ConnectionState=void 0;var r;(function(e){e["CONNECTED"]="CONNECTED";e["DISCONNECTED"]="DISCONNECTED"})(r||(t.ConnectionState=r={}));class WroteReporter{ok;binary;controlExit;exception;constructor(e,t,r,n){this.ok=e;this.binary=t;this.controlExit=r;this.exception=n}}t.WroteReporter=WroteReporter;class ReadOptions{timeout;constructor(e){this.timeout=e?.timeout}}t.ReadOptions=ReadOptions},501:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.PSDK=void 0;const n=r(526);const s=r(475);class PSDK{sversion(){return"0.2.67"}authors(){return n.PsdkConst.DEF_AUTHORS}raw(e){this.commander().pushArg(e);return this}variable(e,t){this.commander().variable(e,t);return this}command(){return this.commander().command()}clear(){this.commander().clear();return this}async write(e){const t=this.connectedDevice();if(!t)throw Error("It's seems you missing to set connectedDevice");e=e??n.WriteOptions.def();const r=this.command();const a=r.binary();const i=new s.DataWriteOperation(e,a,t);const o=await i.write();this.clear();return o}newline(){this.commander().newline();return this}push(e){this.commander().pushArg(e);return this}}t.PSDK=PSDK},267:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.BasicArg=void 0;const n=r(526);class BasicArg{newline(){return n.PsdkConst.DEF_ENABLED_NEWLINE}}t.BasicArg=BasicArg},408:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.OnlyTextHeaderArg=t.OnlyBinaryHeaderArg=t.EasyArg=void 0;const n=r(267);const s=r(687);class EasyArg extends n.BasicArg{prependClauses;appendClauses;constructor(){super();this.prependClauses=[];this.appendClauses=[]}append(e){this.appendClauses.push(...e.clauses());return this}prepend(e){this.prependClauses.push(...e.clauses());return this}clauses(){const e=this.clause();const t=[];if(e.type!==s.ClauseType.NONE){t.push(e);if(this.newline()){t.push(s.CommandClause.newline())}}return[...this.prependClauses,...t,...this.appendClauses]}clear(){this.prependClauses.splice(0,this.prependClauses.length);this.appendClauses.splice(0,this.appendClauses.length)}}t.EasyArg=EasyArg;class OnlyBinaryHeaderArg extends EasyArg{append(e){super.append(e);return this}prepend(e){super.prepend(e);return this}clause(){return s.CommandClause.binary(this.header())}newline(){return false}}t.OnlyBinaryHeaderArg=OnlyBinaryHeaderArg;class OnlyTextHeaderArg extends EasyArg{append(e){super.append(e);return this}prepend(e){super.prepend(e);return this}clause(){return s.CommandClause.text(this.header())}}t.OnlyTextHeaderArg=OnlyTextHeaderArg},75:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.RawMode=t.Raw=void 0;const n=r(408);const s=r(687);const a=r(526);class Raw extends n.EasyArg{_mode;_text;_charset;_binary;_newline=a.PsdkConst.DEF_ENABLED_NEWLINE;constructor(){super()}static text(e,t){const r=new Raw;r._mode=i.TEXT;r._text=e;r._charset=t?.charset??a.PsdkConst.DEF_CHARSET;r._newline=t?.newline??a.PsdkConst.DEF_ENABLED_NEWLINE;return r}static binary(e,t){const r=new Raw;r._mode=i.BINARY;r._binary=e;r._charset=t?.charset??a.PsdkConst.DEF_CHARSET;r._newline=t?.newline??a.PsdkConst.DEF_ENABLED_NEWLINE;return r}append(e){super.append(e);return this}prepend(e){super.prepend(e);return this}clause(){let e;switch(this._mode){case i.TEXT:e=s.CommandClause.text(this._text,this._charset);break;case i.BINARY:e=s.CommandClause.binary(this._binary);break;default:e=s.CommandClause.none();break}return e}header(){return a.PsdkConst.EMPTY_BYTES}newline(){return this._newline}}t.Raw=Raw;var i;(function(e){e["BINARY"]="BINARY";e["TEXT"]="TEXT"})(i||(t.RawMode=i={}))},697:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});s(r(267),t);s(r(408),t);s(r(75),t)},687:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});s(r(434),t);s(r(472),t);s(r(298),t);s(r(838),t);s(r(25),t);s(r(92),t)},434:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.DefaultCommand=t.BasicCommand=void 0;const n=r(526);const s=r(401);const a=r(298);const i=r(195);class BasicCommand{base64(){return s.Base64.fromUint8Array(this.binary())}}t.BasicCommand=BasicCommand;class DefaultCommand extends BasicCommand{bytes;constructor(e,t){super();let r=[];for(const s of e){switch(s.type){case a.ClauseType.TEXT:const e=i.PVariableKit.replace(s.text,t);const o=i.FastGBK.encode(e);const c=Array.prototype.slice.call(o,0);r=r.concat(c);break;case a.ClauseType.NEWLINE:case a.ClauseType.BINARY:const u=Array.from(s.binary??n.PsdkConst.EMPTY_BYTES);r=r.concat(u);break}}this.bytes=new Uint8Array(r)}binary(){return this.bytes}hex(e){return(e??n.HexOutput.def()).format(this.binary())}string(e){return i.FastGBK.decode(this.binary())}}t.DefaultCommand=DefaultCommand},298:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.CommandClause=t.ClauseType=void 0;const n=r(526);var s;(function(e){e["TEXT"]="TEXT";e["BINARY"]="BINARY";e["NEWLINE"]="NEWLINE";e["NONE"]="NONE"})(s||(t.ClauseType=s={}));class CommandClause{_type;_text;_charset;_binary;constructor(e,t,r,n){this._type=e;this._text=t;this._charset=r;this._binary=n}static text(e,t=n.PsdkConst.DEF_CHARSET){return new CommandClause(s.TEXT,e,t,undefined)}static binary(e){return new CommandClause(s.BINARY,undefined,undefined,e)}static newline(){return new CommandClause(s.NEWLINE,undefined,undefined,n.PsdkConst.DEF_NEWLINE_BINARY)}static none(){return new CommandClause(s.NONE,undefined,undefined,undefined)}get type(){return this._type}get text(){return this._text}get charset(){return this._charset}get binary(){return this._binary}}t.CommandClause=CommandClause},472:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.Commander=void 0;const n=r(298);const s=r(526);const a=r(434);class Commander{clauses;_variable;constructor(){this.clauses=[];this._variable=new Map}static make(){return new Commander}pushText(e,t){if(e.startsWith(s.PsdkConst.CRLF)){e=e.substring(2)}const r=n.CommandClause.text(e,t?.charset??s.PsdkConst.DEF_CHARSET);return this.pushClause(r,t?.newline??s.PsdkConst.DEF_ENABLED_NEWLINE)}pushBinary(e,t){const r=n.CommandClause.binary(e);return this.pushClause(r,t??s.PsdkConst.DEF_ENABLED_NEWLINE)}pushClause(e,t){this.clauses.push(e);if(t??s.PsdkConst.DEF_ENABLED_NEWLINE){this.clauses.push(n.CommandClause.newline())}return this}pushClauses(e){e.forEach((e=>this.pushClause(e,false)));return this}pushArg(e){this.pushClauses(e.clauses());return this}newline(){const e=n.CommandClause.newline();return this.pushClause(e,false)}variable(e,t){this._variable.set(e,t);return this}clear(){this.clauses.splice(0,this.clauses.length);this._variable.clear();return this}command(){return new a.DefaultCommand(this.clauses,this._variable)}}t.Commander=Commander},838:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.TextAppendat=t.Appendat=void 0;const n=r(195);class Appendat{_argument;_condition;_callback;constructor(e,t,r){this._argument=e;this._condition=t;this._callback=r}get condition(){return this._condition}callback(e){this._callback=e;return this}quote(){return this}argument(){if(!n.Checker.truthy(this._callback))return this._argument;if(!n.Checker.truthy(this._argument))return undefined;return this._callback.callback(this._argument)}}t.Appendat=Appendat;class TextAppendat extends Appendat{_quote;constructor(e,t,r){super(e,t??true,r);this._quote=false}static create(e,t){return new TextAppendat(e,t?.condition??true,new class{callback(e){const r=t?.callback;if(r){return r(e)}return e}})}callback(e){super.callback(e);return this}quote(){this._quote=true;return this}argument(){const e=super.argument();if(!n.Checker.truthy(e))return this._quote?'""':"";if(this._quote){return`"${e}"`}return e}}t.TextAppendat=TextAppendat},25:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.BinaryCommand=void 0;const n=r(298);const s=r(195);class BinaryCommand{binary;constructor(e){this.binary=e??[]}static make(){return new BinaryCommand}static with(e){const t=Array.from(e);return new BinaryCommand(t)}appendNumber(e){this.binary.push(e);return this}appendText(e,t){const r=s.FastGBK.encode(e);this.binary.push(...r);return this}appendU8A(e){const t=Array.from(e);this.binary=this.binary.concat(t);return this}output(){return new Uint8Array(this.binary)}clause(){const e=this.output();return n.CommandClause.binary(e)}}t.BinaryCommand=BinaryCommand},92:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.TSPLCommand=t.CPCLCommand=t.SingleCommand=void 0;const n=r(838);const s=r(298);const a=r(195);class SingleCommand{_arguments;_symbolAfterHeader;_symbolBetweenArguments;_header;_charset;constructor(e,t,r){this._arguments=[];this._symbolAfterHeader=e;this._symbolBetweenArguments=t;this._charset=r}get getHeader(){return this._header}get symbolAfterHeader(){return this._symbolAfterHeader}get symbolBetweenArguments(){return this._symbolBetweenArguments}header(e){this._header=e;return this}get charset(){return this._charset}append(e){if(!e.condition)return this;const t=e.argument();if(!a.Checker.truthy(t))return this;this._arguments.push(t);return this}arguments(){return this._arguments}}t.SingleCommand=SingleCommand;class BasicStringSingleCommand extends SingleCommand{constructor(e,t,r){super(e,t,r)}append(e){const t=e.argument();if(!a.Checker.truthy(t))return this;super.append(e);return this}appendText(e){return this.append(n.TextAppendat.create(e??"",{}))}appendNumber(e){if(isNaN(e))return this;return this.append(n.TextAppendat.create((e??"").toString(),{}))}output(){let e="";if(a.Checker.truthy(super.getHeader)){e+=super.getHeader;e+=super.symbolAfterHeader}const t=super.arguments();const r=t.length;let n=0;for(const s of t){n+=1;if(!a.Checker.truthy(s))continue;e+=s;if(n<r){e+=super.symbolBetweenArguments}}return e}clause(){const e=this.output();if(!a.Checker.truthy(e)){return s.CommandClause.none()}return s.CommandClause.text(e,super.charset)}}class CPCLCommand extends BasicStringSingleCommand{constructor(e,t){super(" "," ",t);super.header(e)}static with(e,t){return new CPCLCommand(e,t)}append(e){super.append(e);return this}appendText(e){super.appendText(e);return this}appendNumber(e){super.appendNumber(e);return this}}t.CPCLCommand=CPCLCommand;class TSPLCommand extends BasicStringSingleCommand{constructor(e,t){super(" ",",",t);super.header(e)}static with(e,t){return new TSPLCommand(e,t)}append(e){super.append(e);return this}appendText(e){super.appendText(e);return this}appendNumber(e){super.appendNumber(e);return this}}t.TSPLCommand=TSPLCommand},475:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.DataWriteOperation=void 0;const n=r(526);const s=r(909);const a=r(195);class DataWriteOperation{options;binary;connectedDevice;constructor(e,t,r){this.options=e;this.binary=t;this.connectedDevice=r}async write(){if(!this.options.enableChunkWrite){const e=await this.writData(this.binary);this.doCallback(e,this.binary,1,1);return e}const e=Array.from(this.binary);const t=a.CollectionKit.split(e,this.options.chunkSize);const r=t.length;let i=0;for(const e of t){i+=1;const t=new Uint8Array(e);const s=await this.writData(t);const a=this.doCallback(s,t,i,r);if(a==n.WriteControl.STOP){s.controlExit=true;return s}if(!s.ok){return s}}return new s.WroteReporter(true,this.binary,false)}doCallback(e,t,r,s){const a=this.options.callback;if(!a)return n.WriteControl.CONTINUE;const i=new n.DataWrote(t,r,s);if(e.ok){return a.success(i)}if(a.failed){a.failed(i,e.exception)}else{console.log("no custom failed callback, full exception: ",e.exception)}return n.WriteControl.STOP}async writData(e){try{await this.connectedDevice.write(e);return new s.WroteReporter(true,e,false)}catch(t){return new s.WroteReporter(false,e,false,t)}}}t.DataWriteOperation=DataWriteOperation},842:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});s(r(697),t);s(r(526),t);s(r(687),t);s(r(501),t)},157:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.HexOutput=void 0;const r=32;class HexOutput{enableFormat;spacing;maxLengthOfLine;constructor(e,t,n=r){this.enableFormat=e;this.spacing=t;this.maxLengthOfLine=n}static def(){return new HexOutput(false,false,r)}static simple(e=true){return new HexOutput(e,true,r)}static formatWithMaxLength(e){return new HexOutput(true,true,e)}format(e){const t=Array.from(e,(function(e){return("0"+(e&255).toString(16)).slice(-2)})).join("");if(!this.enableFormat){return t}let r="";const n=t.length;let s=0;for(let e=0;e<n;e++){const a=e+1;const i=t[e];r+=i;if(a%2==0&&this.spacing){if(a<n){if(s+1<this.maxLengthOfLine){r+=" "}s+=1}}if(s>=this.maxLengthOfLine){r+="\n";s=0}}return r}}t.HexOutput=HexOutput},526:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});s(r(844),t);s(r(157),t);s(r(888),t);s(r(87),t)},87:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.Lifecycle=void 0;class Lifecycle{connectedDevice;constructor(e){this.connectedDevice=e}}t.Lifecycle=Lifecycle},844:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.PsdkConst=void 0;const n=r(195);const s="\r";const a="\n";const i=`${s}${a}`;t.PsdkConst={DEF_CHARSET:"gbk",CR:s,LF:a,CRLF:i,QUOTE:'"',DEF_NEWLINE_BINARY:n.ByteKit.textToU8A(i),DEF_AUTHORS:["fewensa <osuni@protonmail.com>"],DEF_ENABLED_NEWLINE:true,DEF_WRITE_CHUNK_SIZE:512,EMPTY_BYTES:new Uint8Array([])}},888:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.WriteControl=t.DataWrote=t.DataWrite=t.IDataWriteCallback=t.WriteOptions=void 0;const n=r(844);class WriteOptions{enableChunkWrite;chunkSize;callback;constructor(e=true,t=n.PsdkConst.DEF_WRITE_CHUNK_SIZE,r){this.enableChunkWrite=e;this.chunkSize=t;this.callback=r}static def(){return new WriteOptions(true,n.PsdkConst.DEF_WRITE_CHUNK_SIZE,undefined)}}t.WriteOptions=WriteOptions;class IDataWriteCallback{failed(e,t){console.error(`Write data failed: ${t.message}`)}}t.IDataWriteCallback=IDataWriteCallback;class DataWrite{binary;currentTimes;totalTimes;constructor(e,t,r){this.binary=e;this.currentTimes=t;this.totalTimes=r}}t.DataWrite=DataWrite;class DataWrote extends DataWrite{}t.DataWrote=DataWrote;var s;(function(e){e["CONTINUE"]="CONTINUE";e["STOP"]="STOP"})(s||(t.WriteControl=s={}))},926:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});s(r(909),t);s(r(842),t);s(r(195),t)},401:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.Base64=t.extendBuiltins=t.extendUint8Array=t.extendString=t.toUint8Array=t.fromUint8Array=t.isValid=t.decode=t.btou=t.encodeURL=t.encodeURI=t.encode=t.utob=t.toBase64=t.fromBase64=t.btoaPolyfill=t.btoa=t.atobPolyfill=t.atob=t.VERSION=t.version=void 0;const r="3.7.7";t.version=r;const n=r;t.VERSION=n;const s=typeof Buffer==="function";const a=typeof TextDecoder==="function"?new TextDecoder:undefined;const i=typeof TextEncoder==="function"?new TextEncoder:undefined;const o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";const c=Array.prototype.slice.call(o);const u=(e=>{let t={};e.forEach(((e,r)=>t[e]=r));return t})(c);const l=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;const d=String.fromCharCode.bind(String);const p=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0));const _mkUriSafe=e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>e=="+"?"-":"_"));const _tidyB64=e=>e.replace(/[^A-Za-z0-9\+\/]/g,"");const btoaPolyfill=e=>{let t,r,n,s,a="";const i=e.length%3;for(let i=0;i<e.length;){if((r=e.charCodeAt(i++))>255||(n=e.charCodeAt(i++))>255||(s=e.charCodeAt(i++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|s;a+=c[t>>18&63]+c[t>>12&63]+c[t>>6&63]+c[t&63]}return i?a.slice(0,i-3)+"===".substring(i):a};t.btoaPolyfill=btoaPolyfill;const h=typeof btoa==="function"?e=>btoa(e):s?e=>Buffer.from(e,"binary").toString("base64"):btoaPolyfill;t.btoa=h;const f=s?e=>Buffer.from(e).toString("base64"):e=>{const t=4096;let r=[];for(let n=0,s=e.length;n<s;n+=t){r.push(d.apply(null,e.subarray(n,n+t)))}return h(r.join(""))};const fromUint8Array=(e,t=false)=>t?_mkUriSafe(f(e)):f(e);t.fromUint8Array=fromUint8Array;const cb_utob=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?d(192|t>>>6)+d(128|t&63):d(224|t>>>12&15)+d(128|t>>>6&63)+d(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return d(240|t>>>18&7)+d(128|t>>>12&63)+d(128|t>>>6&63)+d(128|t&63)}};const m=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;const utob=e=>e.replace(m,cb_utob);t.utob=utob;const _=s?e=>Buffer.from(e,"utf8").toString("base64"):i?e=>f(i.encode(e)):e=>h(utob(e));const encode=(e,t=false)=>t?_mkUriSafe(_(e)):_(e);t.toBase64=encode;t.encode=encode;const encodeURI=e=>encode(e,true);t.encodeURI=encodeURI;t.encodeURL=encodeURI;const y=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;const cb_btou=e=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return d((r>>>10)+55296)+d((r&1023)+56320);case 3:return d((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return d((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}};const btou=e=>e.replace(y,cb_btou);t.btou=btou;const atobPolyfill=e=>{e=e.replace(/\s+/g,"");if(!l.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,s;for(let a=0;a<e.length;){t=u[e.charAt(a++)]<<18|u[e.charAt(a++)]<<12|(n=u[e.charAt(a++)])<<6|(s=u[e.charAt(a++)]);r+=n===64?d(t>>16&255):s===64?d(t>>16&255,t>>8&255):d(t>>16&255,t>>8&255,t&255)}return r};t.atobPolyfill=atobPolyfill;const b=typeof atob==="function"?e=>atob(_tidyB64(e)):s?e=>Buffer.from(e,"base64").toString("binary"):atobPolyfill;t.atob=b;const C=s?e=>p(Buffer.from(e,"base64")):e=>p(b(e).split("").map((e=>e.charCodeAt(0))));const toUint8Array=e=>C(_unURI(e));t.toUint8Array=toUint8Array;const g=s?e=>Buffer.from(e,"base64").toString("utf8"):a?e=>a.decode(C(e)):e=>btou(b(e));const _unURI=e=>_tidyB64(e.replace(/[-_]/g,(e=>e=="-"?"+":"/")));const decode=e=>g(_unURI(e));t.fromBase64=decode;t.decode=decode;const isValid=e=>{if(typeof e!=="string")return false;const t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)};t.isValid=isValid;const _noEnum=e=>({value:e,enumerable:false,writable:true,configurable:true});const extendString=function(){const _add=(e,t)=>Object.defineProperty(String.prototype,e,_noEnum(t));_add("fromBase64",(function(){return decode(this)}));_add("toBase64",(function(e){return encode(this,e)}));_add("toBase64URI",(function(){return encode(this,true)}));_add("toBase64URL",(function(){return encode(this,true)}));_add("toUint8Array",(function(){return toUint8Array(this)}))};t.extendString=extendString;const extendUint8Array=function(){const _add=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,_noEnum(t));_add("toBase64",(function(e){return fromUint8Array(this,e)}));_add("toBase64URI",(function(){return fromUint8Array(this,true)}));_add("toBase64URL",(function(){return fromUint8Array(this,true)}))};t.extendUint8Array=extendUint8Array;const extendBuiltins=()=>{extendString();extendUint8Array()};t.extendBuiltins=extendBuiltins;const E={version:r,VERSION:n,atob:b,atobPolyfill:atobPolyfill,btoa:h,btoaPolyfill:btoaPolyfill,fromBase64:decode,toBase64:encode,encode:encode,encodeURI:encodeURI,encodeURL:encodeURI,utob:utob,btou:btou,decode:decode,isValid:isValid,fromUint8Array:fromUint8Array,toUint8Array:toUint8Array,extendString:extendString,extendUint8Array:extendUint8Array,extendBuiltins:extendBuiltins};t.Base64=E},508:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.ByteKit=void 0;const n=r(828);class ByteKit{static textToU8A(e){if(!n.Checker.truthy(e))return new Uint8Array([]);let t=[];let r,s;r=e.length;for(let n=0;n<r;n++){s=e.charCodeAt(n);if(s>=65536&&s<=1114111){t.push(s>>18&7|240);t.push(s>>12&63|128);t.push(s>>6&63|128);t.push(s&63|128)}else if(s>=2048&&s<=65535){t.push(s>>12&15|224);t.push(s>>6&63|128);t.push(s&63|128)}else if(s>=128&&s<=2047){t.push(s>>6&31|192);t.push(s&63|128)}else{t.push(s&255)}}return new Uint8Array(t)}}t.ByteKit=ByteKit},828:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.Checker=void 0;class Checker{static truthy(e){if(e===undefined)return false;if(e===null)return false;if(e==="")return false;const t=typeof e;switch(t){case"number":if(isNaN(e))return false;break;case"bigint":default:return true}}static empty(e){if(!Checker.truthy(e))return true;return e.length===0}}t.Checker=Checker},90:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.FastGBK=void 0;let r;function initGbkTable(){const e=[[161,169,161,254],[176,247,161,254],[129,160,64,254],[170,254,64,160],[168,169,64,160],[170,175,161,254],[248,254,161,254],[161,167,64,160]];const t=new Uint16Array(23940);let n=0;for(const[r,s,a,i]of e){for(let e=a;e<=i;e++){if(e!==127){for(let a=r;a<=s;a++){t[n++]=e<<8|a}}}}r=new Uint16Array(65536);r.fill(65535);const s=new TextDecoder("gbk").decode(t);for(let e=0;e<s.length;e++){r[s.charCodeAt(e)]=t[e]}}const defaultOnAlloc=e=>new Uint8Array(e);const defaultOnError=()=>63;const n=new TextDecoder("gbk");class FastGBK{static decode(e){return n.decode(e)}static encode(e,t){if(!r){initGbkTable()}const n=t?.onAlloc??defaultOnAlloc;const s=t?.onError??defaultOnError;const a=n(e.length*2);let i=0;for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<128){a[i++]=n;continue}const o=r[n];if(o!==65535){a[i++]=o;a[i++]=o>>8}else if(n===8364){a[i++]=128}else{const r=s(t,e);if(r===-1){break}if(r>255){a[i++]=r;a[i++]=r>>8}else{a[i++]=r}}}return a.subarray(0,i)}}t.FastGBK=FastGBK},195:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var s=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});s(r(508),t);s(r(171),t);s(r(692),t);s(r(641),t);s(r(828),t);s(r(90),t)},692:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.CollectionKit=void 0;const n=r(828);class CollectionKit{static split(e,t){if(n.Checker.empty(e))return[];if(t<=0)throw new Error("The size must > 0");const r=[];let s=[];for(const n of e){s.push(n);if(t==s.length){r.push(s);s=[]}}if(0!=s.length)r.push(s);return r}static parts(e,t){if(n.Checker.empty(e)){return[]}if(t<=0)throw new Error("The parts length must > 0");if(e.length<=t){return[e]}const r=[];let s=[];const a=Math.floor(e.length/t);for(const n of e){s.push(n);if(s.length==a){r.push(s);if(r.length<t)s=[]}}return r}}t.CollectionKit=CollectionKit},641:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.ImageKit=void 0;class ImageKit{static processImage(e,t,r){const n=e.getContext("2d");let s=Math.floor(t%8===0?t/8:t/8+1);let a=0;let i=0;const o=r*s;const c=[];for(let e=0;e<o;e++){c[e]=0}const u=n.getImageData(0,0,e.width,e.height);while(a<r){let e=0;for(let r=0;r<t;r++){e++;if(e>8){e=1;i++}const t=1<<8-e;const n=ImageKit.fastExtractPixel(u,r,a,1,1);const s=n[0];const o=s[0];const l=s[1];const d=s[2];if((o+l+d)/3<128){c[i]=c[i]|t}}i=s*(a+1);a+=1}return new Uint8Array(c)}static fastExtractPixel(e,t,r,n,s){let a,i;let o=[];let c,u,l,d;const p=e.data;for(i=0;i<s;i++){let s=(t+(r+i)*e.width)*4;for(a=0;a<n;a++){c=p[s++];u=p[s++];l=p[s++];d=p[s++];o.push([c,u,l,d])}}return o}}t.ImageKit=ImageKit},171:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.PVariableKit=void 0;const n=r(828);class PVariableKit{static replace(e,t){if(!n.Checker.truthy(e))return e;if(!n.Checker.truthy(t))return e;if(e.indexOf("{{")<0&&e.indexOf("}}")<0)return e;const r=/[\\]?\{\{(?<varx>.*?)}}/gm;const s="__THIS_IS_MAGIC_MARK_FOR_HACK_REGEX_MATCH__";while(true){const n=r.exec(e);if(n==null)break;const a=n[0];const i=a.replace("{{","").replace("}}","");const o=i.trim();const c=t.get(o)??"";if(a.startsWith("\\")){const t=a.replace("\\{{",s);e=e.replace(a,t);continue}e=e.replace(a,c)}e=e.replace(new RegExp(s,"g"),"{{");return e}}t.PVariableKit=PVariableKit}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var s=t[r]={exports:{}};var a=true;try{e[r].call(s.exports,s,s.exports,__nccwpck_require__);a=false}finally{if(a)delete t[r]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(926);module.exports=r})(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@psdk/frame-father", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "psdk", | ||
@@ -9,3 +9,3 @@ "main": "build/index.js", | ||
"build": "tsc", | ||
"package": "tsc && ncc build --source-map build/index.js -o dist", | ||
"package": "tsc && ncc build --source-map build/index.js -m -C -o dist", | ||
"test": "jest", | ||
@@ -31,3 +31,3 @@ "docs": "npx typedoc --out dist/docs index.ts" | ||
], | ||
"gitHead": "eff8374dc7cf4ef2c8247371578979ea40480c3b" | ||
"gitHead": "c99a41c63cdc1a56daea1d69f436421d24398c6b" | ||
} |
Sorry, the diff of this file is not supported yet
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
265028
2884
4