@devscholar/vbs-engine-js 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/vbs-engine.js +28 -20
- package/dist/vbs-engine.js.map +1 -1
- package/dist/vbs-engine.umd.cjs +3 -3
- package/dist/vbs-engine.umd.cjs.map +1 -1
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ npx vite examples/index.html
|
|
|
35
35
|
Run the Node.js demo that shows how to use VBScript with Node.js modules:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
|
|
38
|
+
node --experimental-transform-types examples/node-demo.ts
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
This example demonstrates:
|
|
@@ -115,7 +115,7 @@ const greeting = engine.eval('"Hello, " & name & "!"');
|
|
|
115
115
|
console.log(greeting); // "Hello, World!"
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
Run with `
|
|
118
|
+
Run with `node --experimental-transform-types examples/node-demo.ts`.
|
|
119
119
|
|
|
120
120
|
## API Reference
|
|
121
121
|
|
package/dist/vbs-engine.js
CHANGED
|
@@ -5084,11 +5084,19 @@ function ft(r, e) {
|
|
|
5084
5084
|
}
|
|
5085
5085
|
function Y(r) {
|
|
5086
5086
|
const e = r.getAttribute("language"), t = r.getAttribute("type");
|
|
5087
|
-
return e?.toLowerCase() === "vbscript" || t?.toLowerCase() === "text/vbscript" || t?.toLowerCase() === "application/x-vbscript";
|
|
5087
|
+
return e?.toLowerCase() === "vbscript" || t?.toLowerCase() === "text/vbscript" || t?.toLowerCase() === "text/vbs" || t?.toLowerCase() === "application/x-vbscript";
|
|
5088
5088
|
}
|
|
5089
|
-
function yt(r
|
|
5089
|
+
function yt(r) {
|
|
5090
|
+
let e = r.textContent ?? "";
|
|
5091
|
+
if (e = e.trim(), e.startsWith("<!--")) {
|
|
5092
|
+
const t = e.indexOf("//-->");
|
|
5093
|
+
t !== -1 ? e = e.substring(4, t).trim() : e.endsWith("-->") && (e = e.substring(4, e.length - 3).trim());
|
|
5094
|
+
}
|
|
5095
|
+
return e;
|
|
5096
|
+
}
|
|
5097
|
+
function mt(r, e, t) {
|
|
5090
5098
|
if (!Y(e)) return;
|
|
5091
|
-
const s = e
|
|
5099
|
+
const s = yt(e), n = e.getAttribute("for"), a = e.getAttribute("event");
|
|
5092
5100
|
if (n && a)
|
|
5093
5101
|
$(r, n, a, s);
|
|
5094
5102
|
else
|
|
@@ -5117,10 +5125,10 @@ function $(r, e, t, s) {
|
|
|
5117
5125
|
a();
|
|
5118
5126
|
}) : setTimeout(a, 0));
|
|
5119
5127
|
}
|
|
5120
|
-
function
|
|
5128
|
+
function gt(r, e) {
|
|
5121
5129
|
if (typeof document > "u") return;
|
|
5122
5130
|
document.querySelectorAll("script").forEach((s) => {
|
|
5123
|
-
|
|
5131
|
+
mt(r, s, e);
|
|
5124
5132
|
});
|
|
5125
5133
|
}
|
|
5126
5134
|
function H(r, e) {
|
|
@@ -5144,13 +5152,13 @@ function H(r, e) {
|
|
|
5144
5152
|
}
|
|
5145
5153
|
}
|
|
5146
5154
|
}
|
|
5147
|
-
function
|
|
5155
|
+
function vt(r) {
|
|
5148
5156
|
if (typeof document > "u") return;
|
|
5149
5157
|
document.querySelectorAll("*").forEach((t) => {
|
|
5150
5158
|
H(r, t);
|
|
5151
5159
|
});
|
|
5152
5160
|
}
|
|
5153
|
-
function
|
|
5161
|
+
function bt(r) {
|
|
5154
5162
|
if (r in globalThis) {
|
|
5155
5163
|
const t = globalThis[r];
|
|
5156
5164
|
if (t && typeof t.addEventListener == "function")
|
|
@@ -5184,7 +5192,7 @@ function V(r, e) {
|
|
|
5184
5192
|
for (const [n] of s) {
|
|
5185
5193
|
const a = n.toLowerCase().indexOf("_on");
|
|
5186
5194
|
if (a > 0) {
|
|
5187
|
-
const i = n.substring(0, a), o = n.substring(a + 3), c =
|
|
5195
|
+
const i = n.substring(0, a), o = n.substring(a + 3), c = bt(i);
|
|
5188
5196
|
if (c) {
|
|
5189
5197
|
const p = o.toLowerCase();
|
|
5190
5198
|
if (e.has(n)) {
|
|
@@ -5203,7 +5211,7 @@ function V(r, e) {
|
|
|
5203
5211
|
}
|
|
5204
5212
|
}
|
|
5205
5213
|
}
|
|
5206
|
-
function
|
|
5214
|
+
function dt(r) {
|
|
5207
5215
|
r.forEach(({ target: e, handler: t }, s) => {
|
|
5208
5216
|
const n = s.toLowerCase().indexOf("_on");
|
|
5209
5217
|
if (n > 0) {
|
|
@@ -5212,7 +5220,7 @@ function bt(r) {
|
|
|
5212
5220
|
}
|
|
5213
5221
|
}), r.clear();
|
|
5214
5222
|
}
|
|
5215
|
-
function
|
|
5223
|
+
function St(r, e, t) {
|
|
5216
5224
|
const s = new MutationObserver((n) => {
|
|
5217
5225
|
n.forEach((a) => {
|
|
5218
5226
|
a.addedNodes.forEach((i) => {
|
|
@@ -5253,20 +5261,20 @@ function dt(r, e, t) {
|
|
|
5253
5261
|
subtree: !0
|
|
5254
5262
|
}), { observer: s };
|
|
5255
5263
|
}
|
|
5256
|
-
function
|
|
5264
|
+
function wt(r) {
|
|
5257
5265
|
r.observer.disconnect();
|
|
5258
5266
|
}
|
|
5259
|
-
function
|
|
5267
|
+
function xt(r, e) {
|
|
5260
5268
|
const t = { originalSetTimeout: null, originalSetInterval: null }, s = { originalEval: null };
|
|
5261
5269
|
let n = { navigateHandler: null, clickHandler: null }, a = null;
|
|
5262
5270
|
const i = /* @__PURE__ */ new Map();
|
|
5263
|
-
return r._registerFunction("MsgBox", Qe()), r._registerFunction("InputBox", tt()), r._registerFunction("CreateObject", ht), r._registerFunction("GetObject", ft), e.overrideJsEvalFunctions && (t.originalSetTimeout = re(r).originalSetTimeout, t.originalSetInterval = re(r).originalSetInterval, s.originalEval = ct(r).originalEval), e.parseVbsProtocol && (n = ut(r)), e.parseScriptElement &&
|
|
5271
|
+
return r._registerFunction("MsgBox", Qe()), r._registerFunction("InputBox", tt()), r._registerFunction("CreateObject", ht), r._registerFunction("GetObject", ft), e.overrideJsEvalFunctions && (t.originalSetTimeout = re(r).originalSetTimeout, t.originalSetInterval = re(r).originalSetInterval, s.originalEval = ct(r).originalEval), e.parseVbsProtocol && (n = ut(r)), e.parseScriptElement && gt(r), e.parseInlineEventAttributes && vt(r), e.injectGlobalThis && e.parseEventSubNames && V(r, i), (e.parseScriptElement || e.parseInlineEventAttributes) && (a = St(r, e, i)), document.readyState === "loading" && document.addEventListener("DOMContentLoaded", () => {
|
|
5264
5272
|
e.injectGlobalThis && e.parseEventSubNames && V(r, i);
|
|
5265
5273
|
}), () => {
|
|
5266
|
-
a &&
|
|
5274
|
+
a && wt(a), dt(i), (n.navigateHandler || n.clickHandler) && pt(n), e.overrideJsEvalFunctions && (ot(t), lt(s));
|
|
5267
5275
|
};
|
|
5268
5276
|
}
|
|
5269
|
-
class
|
|
5277
|
+
class Et {
|
|
5270
5278
|
interpreter;
|
|
5271
5279
|
options;
|
|
5272
5280
|
browserCleanup = null;
|
|
@@ -5284,7 +5292,7 @@ class xt {
|
|
|
5284
5292
|
}, this.interpreter = new it(), this.interpreter.getContext().evaluate = (t) => this.interpreter.evaluate(t), this.interpreter.getContext().execute = (t) => this.interpreter.executeInCurrentScope(t), this.interpreter.getContext().executeGlobal = (t) => this.interpreter.executeInGlobalScope(t), this.options.maxExecutionTime > 0 && this.setMaxExecutionTime(this.options.maxExecutionTime), this.options.mode === "browser" && typeof window < "u" && this.initializeBrowserMode();
|
|
5285
5293
|
}
|
|
5286
5294
|
initializeBrowserMode() {
|
|
5287
|
-
this.browserCleanup =
|
|
5295
|
+
this.browserCleanup = xt(this, this.options);
|
|
5288
5296
|
}
|
|
5289
5297
|
setMaxExecutionTime(e) {
|
|
5290
5298
|
this.interpreter.setMaxExecutionTime(e), this.interpreter.getContext().checkTimeout = () => this.interpreter.checkTimeout();
|
|
@@ -5501,12 +5509,12 @@ class xt {
|
|
|
5501
5509
|
}
|
|
5502
5510
|
}
|
|
5503
5511
|
}
|
|
5504
|
-
function
|
|
5505
|
-
return new
|
|
5512
|
+
function Ct(r) {
|
|
5513
|
+
return new Et().eval(r);
|
|
5506
5514
|
}
|
|
5507
5515
|
export {
|
|
5508
|
-
|
|
5509
|
-
|
|
5516
|
+
Et as VbsEngine,
|
|
5517
|
+
Ct as evalVbscript,
|
|
5510
5518
|
T as jsToVb,
|
|
5511
5519
|
D as vbToJs
|
|
5512
5520
|
};
|