Comparing version 0.1.3 to 0.1.4
@@ -16,2 +16,3 @@ import { __awaiter } from "tslib"; | ||
let wasmFilePromise; | ||
// eslint-disable-next-line sonarjs/cognitive-complexity | ||
function processor(textOrAst, { filepath, originalText, keepComments = true, stopAt, variant, useTabs = false, tabWidth = 2, indent = useTabs ? 0 : tabWidth, binaryNextLine = true, switchCaseIndent = true, spaceRedirects = true, keepPadding = false, minify = false, functionNextLine = false, } = {}) { | ||
@@ -30,3 +31,2 @@ return __awaiter(this, void 0, void 0, function* () { | ||
'-uid=' + uid, | ||
'-text=' + textOrAst, | ||
'-keepComments=' + keepComments, | ||
@@ -44,3 +44,5 @@ '-indent=' + indent, | ||
} | ||
let isAst = false; | ||
if (typeof textOrAst !== 'string') { | ||
isAst = true; | ||
argv.push('-ast=ast'); | ||
@@ -50,5 +52,2 @@ if (originalText == null) { | ||
} | ||
else { | ||
argv.push('-originalText=' + originalText); | ||
} | ||
} | ||
@@ -64,2 +63,10 @@ if (stopAt != null) { | ||
const wasm = result.instance; | ||
if (!Go.__shProcessing) { | ||
Go.__shProcessing = {}; | ||
} | ||
Go.__shProcessing[uid] = { | ||
Text: isAst ? originalText : textOrAst, | ||
Data: null, | ||
Error: null, | ||
}; | ||
yield go.run(wasm); | ||
@@ -66,0 +73,0 @@ const processed = Go.__shProcessing[uid]; |
@@ -71,5 +71,6 @@ export declare enum LangVariant { | ||
} | ||
export interface ParseResult { | ||
export interface ShProcessing { | ||
Text: string | null; | ||
Data: File | string | null; | ||
Error: IParseError | string | null; | ||
} |
{ | ||
"name": "sh-syntax", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"type": "module", | ||
@@ -15,6 +15,11 @@ "description": "A WASM shell parser and formatter with bash support, based on mvdan/sh", | ||
"exports": { | ||
"import": "./lib/index.js", | ||
"require": "./lib/index.cjs", | ||
"browser": "./lib/browser.js", | ||
"types": "./lib/index.d.ts" | ||
".": { | ||
"import": "./lib/index.js", | ||
"require": "./lib/index.cjs", | ||
"browser": "./lib/browser.js", | ||
"types": "./lib/index.d.ts" | ||
}, | ||
"./package.json": "./package.json", | ||
"./vendors/wasm_exec": "./vendors/wasm_exec.js", | ||
"./vendors/wasm_exec.js": "./vendors/wasm_exec.js" | ||
}, | ||
@@ -33,3 +38,3 @@ "types": "./lib/index.d.ts", | ||
"devDependencies": { | ||
"@1stg/lib-config": "^5.4.0", | ||
"@1stg/lib-config": "^5.5.0", | ||
"@changesets/changelog-github": "^0.4.4", | ||
@@ -36,0 +41,0 @@ "@changesets/cli": "^2.22.0", |
@@ -0,11 +1,13 @@ | ||
/* eslint-disable unicorn/filename-case */ | ||
import _fs from 'fs' | ||
import type { IParseError, ParseResult } from 'sh-syntax' | ||
import type { IParseError, ShProcessing } from 'sh-syntax' | ||
declare global { | ||
namespace globalThis { | ||
// eslint-disable-next-line no-var | ||
var fs: typeof _fs | ||
class Go { | ||
static readonly __shProcessing: Record<string, ParseResult> | ||
static __shProcessing?: Record<string, ShProcessing> | ||
@@ -12,0 +14,0 @@ _pendingEvent: { id: number } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2987369
1420