@lokascript/compilation-service 2.6.0 → 2.7.1
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/dist/{chunk-TDQUREQ3.js → chunk-7GECANUT.js} +2 -2
- package/dist/{chunk-OQFAWHZA.js → chunk-T7GHV2SS.js} +2 -2
- package/dist/{core-parser-adapter-VCJB52SO-TJOEWRMN.js → core-parser-adapter-VCJB52SO-KTZQFHF5.js} +2 -2
- package/dist/{dist-HIJ3NH2I.js → dist-HSJGJ5HF.js} +648 -421
- package/dist/dist-HSJGJ5HF.js.map +1 -0
- package/dist/{dist-4M6PD74Q.js → dist-NDTEGHXO.js} +3 -3
- package/dist/http.cjs +648 -421
- package/dist/http.cjs.map +1 -1
- package/dist/http.js +1 -1
- package/dist/index.cjs +648 -421
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
- package/dist/dist-HIJ3NH2I.js.map +0 -1
- /package/dist/{chunk-TDQUREQ3.js.map → chunk-7GECANUT.js.map} +0 -0
- /package/dist/{chunk-OQFAWHZA.js.map → chunk-T7GHV2SS.js.map} +0 -0
- /package/dist/{core-parser-adapter-VCJB52SO-TJOEWRMN.js.map → core-parser-adapter-VCJB52SO-KTZQFHF5.js.map} +0 -0
- /package/dist/{dist-4M6PD74Q.js.map → dist-NDTEGHXO.js.map} +0 -0
|
@@ -3956,7 +3956,7 @@ function parseColonVariable(ctx) {
|
|
|
3956
3956
|
return {
|
|
3957
3957
|
type: "identifier",
|
|
3958
3958
|
name: varToken.value,
|
|
3959
|
-
scope: "
|
|
3959
|
+
scope: "element",
|
|
3960
3960
|
start: varToken.start - 1,
|
|
3961
3961
|
end: varToken.end
|
|
3962
3962
|
};
|
|
@@ -4008,7 +4008,7 @@ function parseTargetFallback(ctx) {
|
|
|
4008
4008
|
expression: {
|
|
4009
4009
|
type: "identifier",
|
|
4010
4010
|
name: varToken.value,
|
|
4011
|
-
scope: "
|
|
4011
|
+
scope: "element",
|
|
4012
4012
|
start: varToken.start,
|
|
4013
4013
|
end: varToken.end
|
|
4014
4014
|
},
|
|
@@ -4079,6 +4079,11 @@ function parseSetCommand(ctx, identifierNode) {
|
|
|
4079
4079
|
}
|
|
4080
4080
|
ctx.advance();
|
|
4081
4081
|
const value = ctx.parseExpression() ?? ctx.parsePrimary();
|
|
4082
|
+
let scopeTarget;
|
|
4083
|
+
if (ctx.check(KEYWORDS$1.ON) && tokenLooksLikeElementTarget(ctx.peekAt(1))) {
|
|
4084
|
+
ctx.advance();
|
|
4085
|
+
scopeTarget = parseOneArgument(ctx);
|
|
4086
|
+
}
|
|
4082
4087
|
const finalArgs = [];
|
|
4083
4088
|
if (targetExpression) {
|
|
4084
4089
|
finalArgs.push(targetExpression);
|
|
@@ -4089,8 +4094,22 @@ function parseSetCommand(ctx, identifierNode) {
|
|
|
4089
4094
|
if (value) {
|
|
4090
4095
|
finalArgs.push(value);
|
|
4091
4096
|
}
|
|
4092
|
-
|
|
4097
|
+
const builder = CommandNodeBuilder.fromIdentifier(identifierNode).withArgs(...finalArgs);
|
|
4098
|
+
if (scopeTarget) {
|
|
4099
|
+
builder.withModifier("on", scopeTarget);
|
|
4100
|
+
}
|
|
4101
|
+
return builder.endingAt(ctx.getPosition()).build();
|
|
4102
|
+
}
|
|
4103
|
+
function tokenLooksLikeElementTarget(token) {
|
|
4104
|
+
if (!token)
|
|
4105
|
+
return false;
|
|
4106
|
+
if (token.kind === "selector")
|
|
4107
|
+
return true;
|
|
4108
|
+
if (token.value.startsWith("<"))
|
|
4109
|
+
return true;
|
|
4110
|
+
return ELEMENT_PRONOUNS.has(token.value);
|
|
4093
4111
|
}
|
|
4112
|
+
var ELEMENT_PRONOUNS = /* @__PURE__ */ new Set(["me", "my", "it", "its", "you", "your", "yourself"]);
|
|
4094
4113
|
function parseIncrementDecrementCommand(ctx, commandToken) {
|
|
4095
4114
|
const commandName = commandToken.value;
|
|
4096
4115
|
const isIncrement = commandName === "increment";
|
|
@@ -4135,6 +4154,7 @@ function parseIncrementDecrementCommand(ctx, commandToken) {
|
|
|
4135
4154
|
column: commandToken.column
|
|
4136
4155
|
};
|
|
4137
4156
|
const binaryExpr = createBinaryExpression(operator, target, amount, pos2);
|
|
4157
|
+
binaryExpr.coerceNumeric = true;
|
|
4138
4158
|
const toIdentifier = createIdentifier(KEYWORDS$1.TO, pos2);
|
|
4139
4159
|
const args = [targetWithScope, toIdentifier, binaryExpr];
|
|
4140
4160
|
return CommandNodeBuilder.from(commandToken).withName("set").withArgs(...args).withOriginalCommand(commandName).endingAt({ end: ctx.previous().end }).build();
|
|
@@ -4693,6 +4713,14 @@ var Parser = class _Parser {
|
|
|
4693
4713
|
this.advance();
|
|
4694
4714
|
continue;
|
|
4695
4715
|
}
|
|
4716
|
+
if (this.check("then")) {
|
|
4717
|
+
const next = this.peekAt(1);
|
|
4718
|
+
const startsFeature = next !== null && (next.value === "init" || next.value === "on" || next.value === "def" || getRegisteredFeature(next.value) !== void 0);
|
|
4719
|
+
if (startsFeature) {
|
|
4720
|
+
this.advance();
|
|
4721
|
+
continue;
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4696
4724
|
if (this.check("init")) {
|
|
4697
4725
|
this.advance();
|
|
4698
4726
|
const initBlock = this.parseTopLevelInitBlock();
|
|
@@ -5405,7 +5433,7 @@ var Parser = class _Parser {
|
|
|
5405
5433
|
return {
|
|
5406
5434
|
type: "identifier",
|
|
5407
5435
|
name: varToken.value,
|
|
5408
|
-
scope: "
|
|
5436
|
+
scope: "element",
|
|
5409
5437
|
start: varToken.start - 1,
|
|
5410
5438
|
end: varToken.end,
|
|
5411
5439
|
line: varToken.line,
|
|
@@ -5988,6 +6016,30 @@ var Parser = class _Parser {
|
|
|
5988
6016
|
return null;
|
|
5989
6017
|
}
|
|
5990
6018
|
}
|
|
6019
|
+
parseTemporalKeywordModifiers(modifiers) {
|
|
6020
|
+
if (!this.check("debounced") && !this.check("throttled")) {
|
|
6021
|
+
return;
|
|
6022
|
+
}
|
|
6023
|
+
const modToken = this.advance();
|
|
6024
|
+
const modName = modToken.value.toLowerCase();
|
|
6025
|
+
const modifierKey = modName === "debounced" ? "debounce" : "throttle";
|
|
6026
|
+
if (this.match("at")) {
|
|
6027
|
+
if (this.checkTimeExpression()) {
|
|
6028
|
+
const timeToken = this.advance();
|
|
6029
|
+
const delayMs = parseTimeToMs(timeToken.value);
|
|
6030
|
+
modifiers[modifierKey] = delayMs;
|
|
6031
|
+
debug.parse(`\u{1F527} parseEventHandler: Parsed '${modName} at ${timeToken.value}' (${delayMs}ms)`);
|
|
6032
|
+
} else if (this.matchNumber()) {
|
|
6033
|
+
const delayMs = parseInt(this.previous().value, 10);
|
|
6034
|
+
modifiers[modifierKey] = delayMs;
|
|
6035
|
+
debug.parse(`\u{1F527} parseEventHandler: Parsed '${modName} at ${delayMs}'`);
|
|
6036
|
+
} else {
|
|
6037
|
+
this.addError(`Expected time expression after '${modName} at', got: ${this.peek().value}`);
|
|
6038
|
+
}
|
|
6039
|
+
} else {
|
|
6040
|
+
this.addError(`Expected 'at' after '${modName}'`);
|
|
6041
|
+
}
|
|
6042
|
+
}
|
|
5991
6043
|
parseEventHandler() {
|
|
5992
6044
|
debug.parse(`\u{1F527} parseEventHandler: ENTRY - parsing event handler`);
|
|
5993
6045
|
const eventNames = [];
|
|
@@ -6069,27 +6121,7 @@ var Parser = class _Parser {
|
|
|
6069
6121
|
debug.parse(`\u{1F527} parseEventHandler: Warning - unknown modifier '.${modName}'`);
|
|
6070
6122
|
}
|
|
6071
6123
|
}
|
|
6072
|
-
|
|
6073
|
-
const modToken = this.advance();
|
|
6074
|
-
const modName = modToken.value.toLowerCase();
|
|
6075
|
-
const modifierKey = modName === "debounced" ? "debounce" : "throttle";
|
|
6076
|
-
if (this.match("at")) {
|
|
6077
|
-
if (this.checkTimeExpression()) {
|
|
6078
|
-
const timeToken = this.advance();
|
|
6079
|
-
const delayMs = parseTimeToMs(timeToken.value);
|
|
6080
|
-
modifiers[modifierKey] = delayMs;
|
|
6081
|
-
debug.parse(`\u{1F527} parseEventHandler: Parsed '${modName} at ${timeToken.value}' (${delayMs}ms)`);
|
|
6082
|
-
} else if (this.matchNumber()) {
|
|
6083
|
-
const delayMs = parseInt(this.previous().value, 10);
|
|
6084
|
-
modifiers[modifierKey] = delayMs;
|
|
6085
|
-
debug.parse(`\u{1F527} parseEventHandler: Parsed '${modName} at ${delayMs}'`);
|
|
6086
|
-
} else {
|
|
6087
|
-
this.addError(`Expected time expression after '${modName} at', got: ${this.peek().value}`);
|
|
6088
|
-
}
|
|
6089
|
-
} else {
|
|
6090
|
-
this.addError(`Expected 'at' after '${modName}'`);
|
|
6091
|
-
}
|
|
6092
|
-
}
|
|
6124
|
+
this.parseTemporalKeywordModifiers(modifiers);
|
|
6093
6125
|
if (firstOnceAlias) {
|
|
6094
6126
|
modifiers.once = true;
|
|
6095
6127
|
}
|
|
@@ -6106,6 +6138,7 @@ var Parser = class _Parser {
|
|
|
6106
6138
|
const targetToken = this.advance();
|
|
6107
6139
|
target = targetToken.value;
|
|
6108
6140
|
debug.parse(`\u{1F527} parseEventHandler: Parsed 'from' target: ${target} (kind: ${targetToken.kind})`);
|
|
6141
|
+
this.parseTemporalKeywordModifiers(modifiers);
|
|
6109
6142
|
}
|
|
6110
6143
|
let attributeName;
|
|
6111
6144
|
if (this.match("of")) {
|
|
@@ -7014,6 +7047,10 @@ var Parser = class _Parser {
|
|
|
7014
7047
|
}
|
|
7015
7048
|
return this.tokens[this.current];
|
|
7016
7049
|
}
|
|
7050
|
+
peekAt(offset) {
|
|
7051
|
+
const index2 = this.current + offset;
|
|
7052
|
+
return index2 >= 0 && index2 < this.tokens.length ? this.tokens[index2] : null;
|
|
7053
|
+
}
|
|
7017
7054
|
previous() {
|
|
7018
7055
|
return this.tokens[this.current - 1];
|
|
7019
7056
|
}
|
|
@@ -7211,10 +7248,7 @@ var Parser = class _Parser {
|
|
|
7211
7248
|
restorePosition: (pos2) => {
|
|
7212
7249
|
parser.current = pos2;
|
|
7213
7250
|
},
|
|
7214
|
-
peekAt: (offset) =>
|
|
7215
|
-
const index2 = parser.current + offset;
|
|
7216
|
-
return index2 >= 0 && index2 < parser.tokens.length ? parser.tokens[index2] : null;
|
|
7217
|
-
},
|
|
7251
|
+
peekAt: (offset) => parser.peekAt(offset),
|
|
7218
7252
|
getInputSlice: (start, end) => {
|
|
7219
7253
|
if (!this.originalInput)
|
|
7220
7254
|
return "";
|
|
@@ -7358,6 +7392,303 @@ function err(error) {
|
|
|
7358
7392
|
function isOk(result) {
|
|
7359
7393
|
return result.ok === true;
|
|
7360
7394
|
}
|
|
7395
|
+
var sharedGlobals = /* @__PURE__ */ new Map();
|
|
7396
|
+
var elementScopes = /* @__PURE__ */ new WeakMap();
|
|
7397
|
+
function getElementScopeMap(element) {
|
|
7398
|
+
let map = elementScopes.get(element);
|
|
7399
|
+
if (!map) {
|
|
7400
|
+
map = /* @__PURE__ */ new Map();
|
|
7401
|
+
elementScopes.set(element, map);
|
|
7402
|
+
}
|
|
7403
|
+
return map;
|
|
7404
|
+
}
|
|
7405
|
+
function resolveScopeOwner(context) {
|
|
7406
|
+
const owner = context.owner;
|
|
7407
|
+
if (owner)
|
|
7408
|
+
return owner;
|
|
7409
|
+
return context.me instanceof Element ? context.me : null;
|
|
7410
|
+
}
|
|
7411
|
+
function getElementVar(context, name) {
|
|
7412
|
+
const owner = resolveScopeOwner(context);
|
|
7413
|
+
if (!owner)
|
|
7414
|
+
return void 0;
|
|
7415
|
+
notifyLocalRead(name, context);
|
|
7416
|
+
return getElementScopeMap(owner).get(name);
|
|
7417
|
+
}
|
|
7418
|
+
function setElementVar(context, name, value) {
|
|
7419
|
+
const owner = resolveScopeOwner(context);
|
|
7420
|
+
if (!owner)
|
|
7421
|
+
return;
|
|
7422
|
+
getElementScopeMap(owner).set(name, value);
|
|
7423
|
+
notifyLocalWrite(name, value, context);
|
|
7424
|
+
}
|
|
7425
|
+
function createContext(element, globals) {
|
|
7426
|
+
return {
|
|
7427
|
+
me: element ?? null,
|
|
7428
|
+
owner: element ?? null,
|
|
7429
|
+
it: null,
|
|
7430
|
+
you: null,
|
|
7431
|
+
result: null,
|
|
7432
|
+
locals: /* @__PURE__ */ new Map(),
|
|
7433
|
+
globals: globals || sharedGlobals,
|
|
7434
|
+
flags: {
|
|
7435
|
+
halted: false,
|
|
7436
|
+
breaking: false,
|
|
7437
|
+
continuing: false,
|
|
7438
|
+
returning: false,
|
|
7439
|
+
async: false
|
|
7440
|
+
}
|
|
7441
|
+
};
|
|
7442
|
+
}
|
|
7443
|
+
function getSharedGlobals() {
|
|
7444
|
+
return sharedGlobals;
|
|
7445
|
+
}
|
|
7446
|
+
function createChildContext(parent, element) {
|
|
7447
|
+
return {
|
|
7448
|
+
me: element ?? parent.me,
|
|
7449
|
+
owner: parent.owner ?? parent.me ?? element ?? null,
|
|
7450
|
+
it: null,
|
|
7451
|
+
you: null,
|
|
7452
|
+
result: null,
|
|
7453
|
+
locals: /* @__PURE__ */ new Map(),
|
|
7454
|
+
globals: parent.globals,
|
|
7455
|
+
parent,
|
|
7456
|
+
flags: {
|
|
7457
|
+
halted: false,
|
|
7458
|
+
breaking: false,
|
|
7459
|
+
continuing: false,
|
|
7460
|
+
returning: false,
|
|
7461
|
+
async: false
|
|
7462
|
+
}
|
|
7463
|
+
};
|
|
7464
|
+
}
|
|
7465
|
+
function isHTMLElement$2(value) {
|
|
7466
|
+
return value !== null && typeof value === "object" && "nodeType" in value && value.nodeType === 1 && "tagName" in value && typeof value.tagName === "string" && "classList" in value;
|
|
7467
|
+
}
|
|
7468
|
+
function isNodeList(value) {
|
|
7469
|
+
return value !== null && typeof value === "object" && "length" in value && typeof value.length === "number" && (Symbol.iterator in value || typeof value.item === "function");
|
|
7470
|
+
}
|
|
7471
|
+
function isDocumentFragment(value) {
|
|
7472
|
+
return value !== null && typeof value === "object" && "nodeType" in value && value.nodeType === 11 && "childNodes" in value;
|
|
7473
|
+
}
|
|
7474
|
+
function convertToNumber(value) {
|
|
7475
|
+
if (value === null || value === void 0) {
|
|
7476
|
+
return 0;
|
|
7477
|
+
}
|
|
7478
|
+
if (typeof value === "number") {
|
|
7479
|
+
return isFinite(value) ? value : 0;
|
|
7480
|
+
}
|
|
7481
|
+
if (typeof value === "string") {
|
|
7482
|
+
const parsed = parseFloat(value);
|
|
7483
|
+
return parsed;
|
|
7484
|
+
}
|
|
7485
|
+
if (typeof value === "boolean") {
|
|
7486
|
+
return value ? 1 : 0;
|
|
7487
|
+
}
|
|
7488
|
+
if (Array.isArray(value)) {
|
|
7489
|
+
return value.length;
|
|
7490
|
+
}
|
|
7491
|
+
if (typeof value === "object") {
|
|
7492
|
+
if ("length" in value && typeof value.length === "number") {
|
|
7493
|
+
return value.length;
|
|
7494
|
+
}
|
|
7495
|
+
if (typeof value.valueOf === "function") {
|
|
7496
|
+
const result = value.valueOf();
|
|
7497
|
+
if (typeof result === "number") {
|
|
7498
|
+
return result;
|
|
7499
|
+
}
|
|
7500
|
+
}
|
|
7501
|
+
return NaN;
|
|
7502
|
+
}
|
|
7503
|
+
return 0;
|
|
7504
|
+
}
|
|
7505
|
+
function getVariableValue(name, context, preferredScope) {
|
|
7506
|
+
if (preferredScope === "element") {
|
|
7507
|
+
return getElementVar(context, name);
|
|
7508
|
+
}
|
|
7509
|
+
if (preferredScope === "global" && context.globals && context.globals.has(name)) {
|
|
7510
|
+
return context.globals.get(name);
|
|
7511
|
+
}
|
|
7512
|
+
if (preferredScope !== "global" && context.locals && context.locals.has(name)) {
|
|
7513
|
+
notifyLocalRead(name, context);
|
|
7514
|
+
return context.locals.get(name);
|
|
7515
|
+
}
|
|
7516
|
+
if (context.globals && context.globals.has(name)) {
|
|
7517
|
+
return context.globals.get(name);
|
|
7518
|
+
}
|
|
7519
|
+
if (context.variables && context.variables.has(name)) {
|
|
7520
|
+
return context.variables.get(name);
|
|
7521
|
+
}
|
|
7522
|
+
if (preferredScope === "global" && context.locals && context.locals.has(name)) {
|
|
7523
|
+
notifyLocalRead(name, context);
|
|
7524
|
+
return context.locals.get(name);
|
|
7525
|
+
}
|
|
7526
|
+
if (typeof window !== "undefined" && name in window) {
|
|
7527
|
+
return window[name];
|
|
7528
|
+
}
|
|
7529
|
+
if (typeof globalThis !== "undefined" && name in globalThis) {
|
|
7530
|
+
return globalThis[name];
|
|
7531
|
+
}
|
|
7532
|
+
return void 0;
|
|
7533
|
+
}
|
|
7534
|
+
function setVariableValue(name, value, context, preferredScope) {
|
|
7535
|
+
if (preferredScope === "element") {
|
|
7536
|
+
setElementVar(context, name, value);
|
|
7537
|
+
return;
|
|
7538
|
+
}
|
|
7539
|
+
if (preferredScope === "global") {
|
|
7540
|
+
setGlobal(context, name, value);
|
|
7541
|
+
if (typeof window !== "undefined") {
|
|
7542
|
+
window[name] = value;
|
|
7543
|
+
}
|
|
7544
|
+
return;
|
|
7545
|
+
}
|
|
7546
|
+
if (name.startsWith("$")) {
|
|
7547
|
+
const bare = name.slice(1);
|
|
7548
|
+
setGlobal(context, bare, value);
|
|
7549
|
+
return;
|
|
7550
|
+
}
|
|
7551
|
+
if (context.locals && context.locals.has(name)) {
|
|
7552
|
+
context.locals.set(name, value);
|
|
7553
|
+
notifyLocalWrite(name, value, context);
|
|
7554
|
+
return;
|
|
7555
|
+
}
|
|
7556
|
+
if (context.globals && context.globals.has(name)) {
|
|
7557
|
+
setGlobal(context, name, value);
|
|
7558
|
+
if (typeof window !== "undefined" && name in window) {
|
|
7559
|
+
window[name] = value;
|
|
7560
|
+
}
|
|
7561
|
+
return;
|
|
7562
|
+
}
|
|
7563
|
+
if (context.variables && context.variables.has(name)) {
|
|
7564
|
+
context.variables.set(name, value);
|
|
7565
|
+
return;
|
|
7566
|
+
}
|
|
7567
|
+
if (typeof window !== "undefined" && name in window) {
|
|
7568
|
+
window[name] = value;
|
|
7569
|
+
setGlobal(context, name, value);
|
|
7570
|
+
return;
|
|
7571
|
+
}
|
|
7572
|
+
context.locals.set(name, value);
|
|
7573
|
+
notifyLocalWrite(name, value, context);
|
|
7574
|
+
}
|
|
7575
|
+
function resolveElementRef(elementRef, context) {
|
|
7576
|
+
if (elementRef === "me") {
|
|
7577
|
+
return context.me;
|
|
7578
|
+
} else if (elementRef === "it") {
|
|
7579
|
+
return context.it;
|
|
7580
|
+
} else if (elementRef === "you") {
|
|
7581
|
+
return context.you;
|
|
7582
|
+
} else {
|
|
7583
|
+
return getVariableValue(elementRef, context);
|
|
7584
|
+
}
|
|
7585
|
+
}
|
|
7586
|
+
function getElementPropertyValue(propertyPath, context) {
|
|
7587
|
+
const parts = propertyPath.split(".");
|
|
7588
|
+
const elementRef = parts[0];
|
|
7589
|
+
const property = parts[1];
|
|
7590
|
+
const element = resolveElementRef(elementRef, context);
|
|
7591
|
+
if (!element) {
|
|
7592
|
+
return 0;
|
|
7593
|
+
}
|
|
7594
|
+
const value = element[property];
|
|
7595
|
+
return convertToNumber(value);
|
|
7596
|
+
}
|
|
7597
|
+
function setElementPropertyValue(propertyPath, value, context) {
|
|
7598
|
+
const parts = propertyPath.split(".");
|
|
7599
|
+
const elementRef = parts[0];
|
|
7600
|
+
const property = parts[1];
|
|
7601
|
+
const element = resolveElementRef(elementRef, context);
|
|
7602
|
+
if (element) {
|
|
7603
|
+
element[property] = value;
|
|
7604
|
+
}
|
|
7605
|
+
}
|
|
7606
|
+
function getCurrentNumericValue(target, property, scope, context) {
|
|
7607
|
+
if (typeof target === "number") {
|
|
7608
|
+
return target;
|
|
7609
|
+
}
|
|
7610
|
+
if (isHTMLElement$2(target)) {
|
|
7611
|
+
const element = target;
|
|
7612
|
+
if (property) {
|
|
7613
|
+
if (property.startsWith("data-") || ["id", "class", "title", "alt", "src", "href"].includes(property)) {
|
|
7614
|
+
const value = element.getAttribute(property);
|
|
7615
|
+
return convertToNumber(value);
|
|
7616
|
+
} else {
|
|
7617
|
+
const value = element[property];
|
|
7618
|
+
return convertToNumber(value);
|
|
7619
|
+
}
|
|
7620
|
+
} else {
|
|
7621
|
+
const value = element.value || element.textContent;
|
|
7622
|
+
return convertToNumber(value);
|
|
7623
|
+
}
|
|
7624
|
+
}
|
|
7625
|
+
if (typeof target === "string") {
|
|
7626
|
+
if (scope === "element") {
|
|
7627
|
+
return convertToNumber(getVariableValue(target, context, "element"));
|
|
7628
|
+
}
|
|
7629
|
+
if (scope === "global") {
|
|
7630
|
+
const value2 = getVariableValue(target, context, "global");
|
|
7631
|
+
return convertToNumber(value2);
|
|
7632
|
+
}
|
|
7633
|
+
if (target.includes(".")) {
|
|
7634
|
+
return getElementPropertyValue(target, context);
|
|
7635
|
+
}
|
|
7636
|
+
if (target === "me" && context.me) {
|
|
7637
|
+
return convertToNumber(context.me.value || 0);
|
|
7638
|
+
} else if (target === "it") {
|
|
7639
|
+
return convertToNumber(context.it || 0);
|
|
7640
|
+
} else if (target === "you" && context.you) {
|
|
7641
|
+
return convertToNumber(context.you.value || 0);
|
|
7642
|
+
}
|
|
7643
|
+
const value = getVariableValue(target, context);
|
|
7644
|
+
return convertToNumber(value);
|
|
7645
|
+
}
|
|
7646
|
+
return convertToNumber(target);
|
|
7647
|
+
}
|
|
7648
|
+
function setTargetValue(target, property, scope, newValue, context) {
|
|
7649
|
+
if (isHTMLElement$2(target)) {
|
|
7650
|
+
const element = target;
|
|
7651
|
+
if (property) {
|
|
7652
|
+
if (property.startsWith("data-") || ["id", "class", "title", "alt", "src", "href"].includes(property)) {
|
|
7653
|
+
element.setAttribute(property, String(newValue));
|
|
7654
|
+
} else {
|
|
7655
|
+
element[property] = newValue;
|
|
7656
|
+
}
|
|
7657
|
+
} else {
|
|
7658
|
+
if ("value" in element && element.value !== void 0) {
|
|
7659
|
+
element.value = String(newValue);
|
|
7660
|
+
} else {
|
|
7661
|
+
element.textContent = String(newValue);
|
|
7662
|
+
}
|
|
7663
|
+
}
|
|
7664
|
+
return;
|
|
7665
|
+
}
|
|
7666
|
+
if (typeof target === "string") {
|
|
7667
|
+
if (scope === "element") {
|
|
7668
|
+
setVariableValue(target, newValue, context, "element");
|
|
7669
|
+
return;
|
|
7670
|
+
}
|
|
7671
|
+
if (scope === "global") {
|
|
7672
|
+
setVariableValue(target, newValue, context, "global");
|
|
7673
|
+
return;
|
|
7674
|
+
}
|
|
7675
|
+
if (target.includes(".")) {
|
|
7676
|
+
setElementPropertyValue(target, newValue, context);
|
|
7677
|
+
return;
|
|
7678
|
+
}
|
|
7679
|
+
if (target === "me" && context.me) {
|
|
7680
|
+
context.me.value = newValue;
|
|
7681
|
+
return;
|
|
7682
|
+
} else if (target === "it") {
|
|
7683
|
+
Object.assign(context, { it: newValue });
|
|
7684
|
+
return;
|
|
7685
|
+
} else if (target === "you" && context.you) {
|
|
7686
|
+
context.you.value = newValue;
|
|
7687
|
+
return;
|
|
7688
|
+
}
|
|
7689
|
+
setVariableValue(target, newValue, context);
|
|
7690
|
+
}
|
|
7691
|
+
}
|
|
7361
7692
|
var ExpressionTypeRegistry = class {
|
|
7362
7693
|
constructor(config2 = {}) {
|
|
7363
7694
|
this.types = /* @__PURE__ */ new Map();
|
|
@@ -7714,7 +8045,7 @@ function isFormElement$1(el) {
|
|
|
7714
8045
|
const tag = el.tagName;
|
|
7715
8046
|
return tag === "INPUT" || tag === "SELECT" || tag === "TEXTAREA";
|
|
7716
8047
|
}
|
|
7717
|
-
function isHTMLElement$
|
|
8048
|
+
function isHTMLElement$1(el) {
|
|
7718
8049
|
return el !== null && typeof el === "object" && "nodeType" in el && el.nodeType === 1 && "style" in el;
|
|
7719
8050
|
}
|
|
7720
8051
|
function isOptionElement$1(el) {
|
|
@@ -7723,7 +8054,7 @@ function isOptionElement$1(el) {
|
|
|
7723
8054
|
function isElement(value) {
|
|
7724
8055
|
return value instanceof Element;
|
|
7725
8056
|
}
|
|
7726
|
-
function isHTMLElement
|
|
8057
|
+
function isHTMLElement(value) {
|
|
7727
8058
|
return value instanceof HTMLElement;
|
|
7728
8059
|
}
|
|
7729
8060
|
var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
@@ -7768,8 +8099,8 @@ var SPECIAL_DOM_PROPERTIES = {
|
|
|
7768
8099
|
checked: (el) => isInputElement$1(el) ? el.checked : void 0,
|
|
7769
8100
|
disabled: (el) => "disabled" in el ? el.disabled : void 0,
|
|
7770
8101
|
selected: (el) => isOptionElement$1(el) ? el.selected : void 0,
|
|
7771
|
-
tabindex: (el) => isHTMLElement$
|
|
7772
|
-
hidden: (el) => isHTMLElement$
|
|
8102
|
+
tabindex: (el) => isHTMLElement$1(el) ? el.tabIndex : void 0,
|
|
8103
|
+
hidden: (el) => isHTMLElement$1(el) ? el.hidden : void 0,
|
|
7773
8104
|
style: (el) => getComputedStyle(el),
|
|
7774
8105
|
children: (el) => Array.from(el.children),
|
|
7775
8106
|
parent: (el) => el.parentElement,
|
|
@@ -7793,7 +8124,7 @@ function collectFormValues(el) {
|
|
|
7793
8124
|
return fd;
|
|
7794
8125
|
}
|
|
7795
8126
|
function getElementStyleValue(element, styleProp) {
|
|
7796
|
-
if (!isHTMLElement
|
|
8127
|
+
if (!isHTMLElement(element))
|
|
7797
8128
|
return void 0;
|
|
7798
8129
|
if (styleProp.startsWith("computed-")) {
|
|
7799
8130
|
return getComputedStyle(element).getPropertyValue(styleProp.slice("computed-".length)) || "";
|
|
@@ -7807,7 +8138,7 @@ function getElementProperty$1(element, property) {
|
|
|
7807
8138
|
}
|
|
7808
8139
|
if (property.startsWith("computed-")) {
|
|
7809
8140
|
const cssProperty = property.slice("computed-".length);
|
|
7810
|
-
if (isHTMLElement
|
|
8141
|
+
if (isHTMLElement(element)) {
|
|
7811
8142
|
const computedStyle = getComputedStyle(element);
|
|
7812
8143
|
return computedStyle.getPropertyValue(cssProperty);
|
|
7813
8144
|
}
|
|
@@ -10032,7 +10363,7 @@ function evaluateExpressionSync(node, context) {
|
|
|
10032
10363
|
case "selector":
|
|
10033
10364
|
return evaluateSelectorSync(n, context);
|
|
10034
10365
|
case "identifier":
|
|
10035
|
-
return resolveIdentifierSync(n.name, context);
|
|
10366
|
+
return resolveIdentifierSync(n.name, context, n.scope);
|
|
10036
10367
|
case "contextReference":
|
|
10037
10368
|
return resolveContextReferenceSync(n.contextType, context);
|
|
10038
10369
|
case "arrayLiteral":
|
|
@@ -10062,7 +10393,7 @@ function evaluateExpressionSync(node, context) {
|
|
|
10062
10393
|
throw new NotSyncEvaluable(n?.type ?? "unknown");
|
|
10063
10394
|
}
|
|
10064
10395
|
}
|
|
10065
|
-
function resolveIdentifierSync(name, context) {
|
|
10396
|
+
function resolveIdentifierSync(name, context, scope) {
|
|
10066
10397
|
if (name === "me" || name === "my" || name === "I")
|
|
10067
10398
|
return context.me;
|
|
10068
10399
|
if (name === "you" || name === "your" || name === "yourself")
|
|
@@ -10073,6 +10404,8 @@ function resolveIdentifierSync(name, context) {
|
|
|
10073
10404
|
return typeof window !== "undefined" ? window : globalThis;
|
|
10074
10405
|
if (name === "document")
|
|
10075
10406
|
return typeof document !== "undefined" ? document : void 0;
|
|
10407
|
+
if (scope === "element")
|
|
10408
|
+
return getElementVar(context, name);
|
|
10076
10409
|
if (context.locals?.has(name))
|
|
10077
10410
|
return context.locals.get(name);
|
|
10078
10411
|
if (context.globals?.has(name))
|
|
@@ -10199,6 +10532,9 @@ async function evaluateIdentifier(node, context) {
|
|
|
10199
10532
|
notifyGlobalRead(name, context);
|
|
10200
10533
|
return context.globals.get(name);
|
|
10201
10534
|
}
|
|
10535
|
+
if (node.scope === "element") {
|
|
10536
|
+
return getElementVar(context, name);
|
|
10537
|
+
}
|
|
10202
10538
|
if (context.locals && context.locals.has(name)) {
|
|
10203
10539
|
notifyLocalRead(name, context);
|
|
10204
10540
|
return context.locals.get(name);
|
|
@@ -10232,6 +10568,8 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
10232
10568
|
setGlobal(context, name.slice(1), value);
|
|
10233
10569
|
} else if (leftNode.scope === "global") {
|
|
10234
10570
|
setGlobal(context, name, value);
|
|
10571
|
+
} else if (leftNode.scope === "element") {
|
|
10572
|
+
setElementVar(context, name, value);
|
|
10235
10573
|
} else {
|
|
10236
10574
|
if (!context.locals)
|
|
10237
10575
|
context.locals = /* @__PURE__ */ new Map();
|
|
@@ -10305,14 +10643,26 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
10305
10643
|
const L = node.ignoringCase ? applyCI(left) : left;
|
|
10306
10644
|
const R = node.ignoringCase ? applyCI(right) : right;
|
|
10307
10645
|
switch (operator) {
|
|
10308
|
-
case "+":
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10646
|
+
case "+": {
|
|
10647
|
+
let addLeft = left;
|
|
10648
|
+
let addRight = right;
|
|
10649
|
+
if (node.coerceNumeric) {
|
|
10650
|
+
if (typeof addLeft === "string")
|
|
10651
|
+
addLeft = convertToNumber(addLeft);
|
|
10652
|
+
if (typeof addRight === "string")
|
|
10653
|
+
addRight = convertToNumber(addRight);
|
|
10654
|
+
}
|
|
10655
|
+
if (typeof addLeft === "string" || typeof addRight === "string") {
|
|
10656
|
+
return String(addLeft ?? "") + String(addRight ?? "");
|
|
10657
|
+
}
|
|
10658
|
+
if (Array.isArray(addLeft)) {
|
|
10659
|
+
return Array.isArray(addRight) ? [...addLeft, ...addRight] : [...addLeft, addRight];
|
|
10660
|
+
}
|
|
10661
|
+
return unwrapTypedResult(await getExpr(context, "addition").evaluate(context, {
|
|
10662
|
+
left: addLeft,
|
|
10663
|
+
right: addRight
|
|
10664
|
+
}));
|
|
10665
|
+
}
|
|
10316
10666
|
case "-":
|
|
10317
10667
|
return unwrapTypedResult(await getExpr(context, "subtraction").evaluate(context, { left, right }));
|
|
10318
10668
|
case "*":
|
|
@@ -11150,45 +11500,6 @@ var CleanupRegistry = class {
|
|
|
11150
11500
|
this.debugMode = enabled;
|
|
11151
11501
|
}
|
|
11152
11502
|
};
|
|
11153
|
-
var sharedGlobals = /* @__PURE__ */ new Map();
|
|
11154
|
-
function createContext(element, globals) {
|
|
11155
|
-
return {
|
|
11156
|
-
me: element ?? null,
|
|
11157
|
-
it: null,
|
|
11158
|
-
you: null,
|
|
11159
|
-
result: null,
|
|
11160
|
-
locals: /* @__PURE__ */ new Map(),
|
|
11161
|
-
globals: globals || sharedGlobals,
|
|
11162
|
-
flags: {
|
|
11163
|
-
halted: false,
|
|
11164
|
-
breaking: false,
|
|
11165
|
-
continuing: false,
|
|
11166
|
-
returning: false,
|
|
11167
|
-
async: false
|
|
11168
|
-
}
|
|
11169
|
-
};
|
|
11170
|
-
}
|
|
11171
|
-
function getSharedGlobals() {
|
|
11172
|
-
return sharedGlobals;
|
|
11173
|
-
}
|
|
11174
|
-
function createChildContext(parent, element) {
|
|
11175
|
-
return {
|
|
11176
|
-
me: element ?? parent.me,
|
|
11177
|
-
it: null,
|
|
11178
|
-
you: null,
|
|
11179
|
-
result: null,
|
|
11180
|
-
locals: /* @__PURE__ */ new Map(),
|
|
11181
|
-
globals: parent.globals,
|
|
11182
|
-
parent,
|
|
11183
|
-
flags: {
|
|
11184
|
-
halted: false,
|
|
11185
|
-
breaking: false,
|
|
11186
|
-
continuing: false,
|
|
11187
|
-
returning: false,
|
|
11188
|
-
async: false
|
|
11189
|
-
}
|
|
11190
|
-
};
|
|
11191
|
-
}
|
|
11192
11503
|
var EventSourceRegistry = class {
|
|
11193
11504
|
constructor() {
|
|
11194
11505
|
this.sources = /* @__PURE__ */ new Map();
|
|
@@ -11411,6 +11722,7 @@ var ContextBridge = class {
|
|
|
11411
11722
|
static toTyped(context) {
|
|
11412
11723
|
return {
|
|
11413
11724
|
me: context.me,
|
|
11725
|
+
...context.owner !== void 0 && { owner: context.owner },
|
|
11414
11726
|
it: context.it,
|
|
11415
11727
|
you: context.you,
|
|
11416
11728
|
result: context.result,
|
|
@@ -12333,6 +12645,7 @@ var RuntimeBase = class _RuntimeBase {
|
|
|
12333
12645
|
debug.runtime(`BEHAVIOR: Found behavior, eventHandlers count: ${behavior.eventHandlers?.length || 0}`);
|
|
12334
12646
|
const baseBehaviorContext = {
|
|
12335
12647
|
me: element,
|
|
12648
|
+
owner: element,
|
|
12336
12649
|
you: null,
|
|
12337
12650
|
it: null,
|
|
12338
12651
|
result: null,
|
|
@@ -16286,20 +16599,11 @@ function meta(config2) {
|
|
|
16286
16599
|
function createFactory(CommandClass) {
|
|
16287
16600
|
return () => new CommandClass();
|
|
16288
16601
|
}
|
|
16289
|
-
function isHTMLElement(value) {
|
|
16290
|
-
return value !== null && typeof value === "object" && "nodeType" in value && value.nodeType === 1 && "tagName" in value && typeof value.tagName === "string" && "classList" in value;
|
|
16291
|
-
}
|
|
16292
|
-
function isNodeList(value) {
|
|
16293
|
-
return value !== null && typeof value === "object" && "length" in value && typeof value.length === "number" && (Symbol.iterator in value || typeof value.item === "function");
|
|
16294
|
-
}
|
|
16295
|
-
function isDocumentFragment(value) {
|
|
16296
|
-
return value !== null && typeof value === "object" && "nodeType" in value && value.nodeType === 11 && "childNodes" in value;
|
|
16297
|
-
}
|
|
16298
16602
|
function withCmd(commandName, message) {
|
|
16299
16603
|
return commandName ? `[${commandName}] ${message}` : message;
|
|
16300
16604
|
}
|
|
16301
16605
|
function resolveElement(target, context, commandName) {
|
|
16302
|
-
if (isHTMLElement(target)) {
|
|
16606
|
+
if (isHTMLElement$2(target)) {
|
|
16303
16607
|
return target;
|
|
16304
16608
|
}
|
|
16305
16609
|
if (!target) {
|
|
@@ -16318,7 +16622,7 @@ function resolveElement(target, context, commandName) {
|
|
|
16318
16622
|
return asHTMLElement(context.me);
|
|
16319
16623
|
}
|
|
16320
16624
|
if (trimmed === "it") {
|
|
16321
|
-
if (!isHTMLElement(context.it)) {
|
|
16625
|
+
if (!isHTMLElement$2(context.it)) {
|
|
16322
16626
|
throw new Error(withCmd(commandName, 'Context reference "it" is not an HTMLElement'));
|
|
16323
16627
|
}
|
|
16324
16628
|
return context.it;
|
|
@@ -16337,7 +16641,7 @@ function resolveElement(target, context, commandName) {
|
|
|
16337
16641
|
if (!element) {
|
|
16338
16642
|
throw new Error(withCmd(commandName, `Element not found with selector: ${trimmed}`));
|
|
16339
16643
|
}
|
|
16340
|
-
if (!isHTMLElement(element)) {
|
|
16644
|
+
if (!isHTMLElement$2(element)) {
|
|
16341
16645
|
throw new Error(withCmd(commandName, `Element found but is not an HTMLElement: ${trimmed}`));
|
|
16342
16646
|
}
|
|
16343
16647
|
return element;
|
|
@@ -16346,12 +16650,12 @@ function resolveElement(target, context, commandName) {
|
|
|
16346
16650
|
}
|
|
16347
16651
|
function resolveElements(target, context) {
|
|
16348
16652
|
if (Array.isArray(target)) {
|
|
16349
|
-
return target.filter(isHTMLElement);
|
|
16653
|
+
return target.filter(isHTMLElement$2);
|
|
16350
16654
|
}
|
|
16351
16655
|
if (isNodeList(target)) {
|
|
16352
|
-
return Array.from(target).filter(isHTMLElement);
|
|
16656
|
+
return Array.from(target).filter(isHTMLElement$2);
|
|
16353
16657
|
}
|
|
16354
|
-
if (isHTMLElement(target)) {
|
|
16658
|
+
if (isHTMLElement$2(target)) {
|
|
16355
16659
|
return [target];
|
|
16356
16660
|
}
|
|
16357
16661
|
if (!target) {
|
|
@@ -16359,18 +16663,18 @@ function resolveElements(target, context) {
|
|
|
16359
16663
|
if (!me) {
|
|
16360
16664
|
return [];
|
|
16361
16665
|
}
|
|
16362
|
-
return isHTMLElement(me) ? [me] : [];
|
|
16666
|
+
return isHTMLElement$2(me) ? [me] : [];
|
|
16363
16667
|
}
|
|
16364
16668
|
if (typeof target === "string") {
|
|
16365
16669
|
const trimmed = target.trim();
|
|
16366
16670
|
if (trimmed === "me") {
|
|
16367
|
-
return context.me && isHTMLElement(context.me) ? [context.me] : [];
|
|
16671
|
+
return context.me && isHTMLElement$2(context.me) ? [context.me] : [];
|
|
16368
16672
|
}
|
|
16369
16673
|
if (trimmed === "it") {
|
|
16370
|
-
return isHTMLElement(context.it) ? [context.it] : [];
|
|
16674
|
+
return isHTMLElement$2(context.it) ? [context.it] : [];
|
|
16371
16675
|
}
|
|
16372
16676
|
if (trimmed === "you") {
|
|
16373
|
-
return context.you && isHTMLElement(context.you) ? [context.you] : [];
|
|
16677
|
+
return context.you && isHTMLElement$2(context.you) ? [context.you] : [];
|
|
16374
16678
|
}
|
|
16375
16679
|
const doc = context.me?.ownerDocument ?? (typeof document !== "undefined" ? document : null);
|
|
16376
16680
|
if (doc) {
|
|
@@ -16379,13 +16683,13 @@ function resolveElements(target, context) {
|
|
|
16379
16683
|
selector = selector.slice(1, -2).trim();
|
|
16380
16684
|
}
|
|
16381
16685
|
const elements = doc.querySelectorAll(selector);
|
|
16382
|
-
return Array.from(elements).filter(isHTMLElement);
|
|
16686
|
+
return Array.from(elements).filter(isHTMLElement$2);
|
|
16383
16687
|
}
|
|
16384
16688
|
}
|
|
16385
16689
|
return [];
|
|
16386
16690
|
}
|
|
16387
16691
|
function asHTMLElement(value) {
|
|
16388
|
-
if (isHTMLElement(value)) {
|
|
16692
|
+
if (isHTMLElement$2(value)) {
|
|
16389
16693
|
return value;
|
|
16390
16694
|
}
|
|
16391
16695
|
throw new Error("Value is not an HTMLElement");
|
|
@@ -16396,21 +16700,21 @@ function resolvePossessive(possessive, context, commandName) {
|
|
|
16396
16700
|
case "me":
|
|
16397
16701
|
if (!context.me)
|
|
16398
16702
|
throw new Error(withCmd(commandName, 'No "me" element in context'));
|
|
16399
|
-
if (!isHTMLElement(context.me))
|
|
16703
|
+
if (!isHTMLElement$2(context.me))
|
|
16400
16704
|
throw new Error(withCmd(commandName, "context.me is not an HTMLElement"));
|
|
16401
16705
|
return context.me;
|
|
16402
16706
|
case "its":
|
|
16403
16707
|
case "it":
|
|
16404
16708
|
if (!context.it)
|
|
16405
16709
|
throw new Error(withCmd(commandName, 'No "it" value in context'));
|
|
16406
|
-
if (!isHTMLElement(context.it))
|
|
16710
|
+
if (!isHTMLElement$2(context.it))
|
|
16407
16711
|
throw new Error(withCmd(commandName, "context.it is not an HTMLElement"));
|
|
16408
16712
|
return context.it;
|
|
16409
16713
|
case "your":
|
|
16410
16714
|
case "you":
|
|
16411
16715
|
if (!context.you)
|
|
16412
16716
|
throw new Error(withCmd(commandName, 'No "you" element in context'));
|
|
16413
|
-
if (!isHTMLElement(context.you))
|
|
16717
|
+
if (!isHTMLElement$2(context.you))
|
|
16414
16718
|
throw new Error(withCmd(commandName, "context.you is not an HTMLElement"));
|
|
16415
16719
|
return context.you;
|
|
16416
16720
|
default:
|
|
@@ -16439,7 +16743,7 @@ async function resolveTargetsFromArgs(args, evaluator, context, commandName, opt
|
|
|
16439
16743
|
if (!context.me) {
|
|
16440
16744
|
throw new Error(`${commandName} command: no target specified and context.me is null`);
|
|
16441
16745
|
}
|
|
16442
|
-
if (!isHTMLElement(context.me)) {
|
|
16746
|
+
if (!isHTMLElement$2(context.me)) {
|
|
16443
16747
|
throw new Error(`${commandName} command: context.me must be an HTMLElement`);
|
|
16444
16748
|
}
|
|
16445
16749
|
return [context.me];
|
|
@@ -16450,13 +16754,13 @@ async function resolveTargetsFromArgs(args, evaluator, context, commandName, opt
|
|
|
16450
16754
|
if (evaluated === "" || typeof evaluated === "string" && evaluated.trim() === "") {
|
|
16451
16755
|
continue;
|
|
16452
16756
|
}
|
|
16453
|
-
if (isHTMLElement(evaluated)) {
|
|
16757
|
+
if (isHTMLElement$2(evaluated)) {
|
|
16454
16758
|
targets.push(evaluated);
|
|
16455
16759
|
} else if (isNodeList(evaluated)) {
|
|
16456
|
-
const elements = Array.from(evaluated).filter(isHTMLElement);
|
|
16760
|
+
const elements = Array.from(evaluated).filter(isHTMLElement$2);
|
|
16457
16761
|
targets.push(...elements);
|
|
16458
16762
|
} else if (Array.isArray(evaluated)) {
|
|
16459
|
-
const elements = evaluated.filter(isHTMLElement);
|
|
16763
|
+
const elements = evaluated.filter(isHTMLElement$2);
|
|
16460
16764
|
targets.push(...elements);
|
|
16461
16765
|
} else if (typeof evaluated === "string") {
|
|
16462
16766
|
try {
|
|
@@ -16469,7 +16773,7 @@ async function resolveTargetsFromArgs(args, evaluator, context, commandName, opt
|
|
|
16469
16773
|
throw new Error("DOM not available - cannot resolve element selector");
|
|
16470
16774
|
}
|
|
16471
16775
|
const selected = doc.querySelectorAll(selector);
|
|
16472
|
-
const elements = Array.from(selected).filter(isHTMLElement);
|
|
16776
|
+
const elements = Array.from(selected).filter(isHTMLElement$2);
|
|
16473
16777
|
targets.push(...elements);
|
|
16474
16778
|
} catch (error) {
|
|
16475
16779
|
throw new Error(`Invalid CSS selector: "${evaluated}" - ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -16484,7 +16788,7 @@ async function resolveTargetsFromArgs(args, evaluator, context, commandName, opt
|
|
|
16484
16788
|
if (!context.me) {
|
|
16485
16789
|
throw new Error(`${commandName} command: no target specified and context.me is null`);
|
|
16486
16790
|
}
|
|
16487
|
-
if (!isHTMLElement(context.me)) {
|
|
16791
|
+
if (!isHTMLElement$2(context.me)) {
|
|
16488
16792
|
throw new Error(`${commandName} command: context.me must be an HTMLElement`);
|
|
16489
16793
|
}
|
|
16490
16794
|
return [context.me];
|
|
@@ -16510,7 +16814,7 @@ var VisibilityCommandBase = class {
|
|
|
16510
16814
|
const typed = input;
|
|
16511
16815
|
if (!Array.isArray(typed.targets))
|
|
16512
16816
|
return false;
|
|
16513
|
-
if (!typed.targets.every((t) => isHTMLElement(t)))
|
|
16817
|
+
if (!typed.targets.every((t) => isHTMLElement$2(t)))
|
|
16514
16818
|
return false;
|
|
16515
16819
|
if (typed.mode !== "show" && typed.mode !== "hide")
|
|
16516
16820
|
return false;
|
|
@@ -16564,7 +16868,7 @@ var HideCommand = (() => {
|
|
|
16564
16868
|
const typed = input;
|
|
16565
16869
|
if (!Array.isArray(typed.targets))
|
|
16566
16870
|
return false;
|
|
16567
|
-
if (!typed.targets.every((t) => isHTMLElement(t)))
|
|
16871
|
+
if (!typed.targets.every((t) => isHTMLElement$2(t)))
|
|
16568
16872
|
return false;
|
|
16569
16873
|
return true;
|
|
16570
16874
|
}
|
|
@@ -16608,7 +16912,7 @@ var ShowCommand = (() => {
|
|
|
16608
16912
|
const typed = input;
|
|
16609
16913
|
if (!Array.isArray(typed.targets))
|
|
16610
16914
|
return false;
|
|
16611
|
-
if (!typed.targets.every((t) => isHTMLElement(t)))
|
|
16915
|
+
if (!typed.targets.every((t) => isHTMLElement$2(t)))
|
|
16612
16916
|
return false;
|
|
16613
16917
|
if (typeof typed.defaultDisplay !== "string")
|
|
16614
16918
|
return false;
|
|
@@ -16957,7 +17261,7 @@ async function evaluateFirstArg(firstArg, evaluator, context) {
|
|
|
16957
17261
|
};
|
|
16958
17262
|
}
|
|
16959
17263
|
function isValidTargetArray(targets) {
|
|
16960
|
-
return Array.isArray(targets) && targets.length > 0 && targets.every((t) => isHTMLElement(t));
|
|
17264
|
+
return Array.isArray(targets) && targets.length > 0 && targets.every((t) => isHTMLElement$2(t));
|
|
16961
17265
|
}
|
|
16962
17266
|
function isValidStringArray(arr, minLength = 1) {
|
|
16963
17267
|
return Array.isArray(arr) && arr.length >= minLength && arr.every((item) => typeof item === "string" && item.length > 0);
|
|
@@ -17144,13 +17448,13 @@ var RemoveCommand = (() => {
|
|
|
17144
17448
|
throw new Error("remove command requires an argument");
|
|
17145
17449
|
}
|
|
17146
17450
|
const { value: firstValue } = await this.evaluateFirst(raw.args[0], evaluator, context);
|
|
17147
|
-
if (isHTMLElement(firstValue)) {
|
|
17451
|
+
if (isHTMLElement$2(firstValue)) {
|
|
17148
17452
|
return { type: "element", targets: [firstValue] };
|
|
17149
17453
|
}
|
|
17150
|
-
if (Array.isArray(firstValue) && firstValue.length > 0 && isHTMLElement(firstValue[0])) {
|
|
17454
|
+
if (Array.isArray(firstValue) && firstValue.length > 0 && isHTMLElement$2(firstValue[0])) {
|
|
17151
17455
|
return {
|
|
17152
17456
|
type: "element",
|
|
17153
|
-
targets: firstValue.filter((el) => isHTMLElement(el))
|
|
17457
|
+
targets: firstValue.filter((el) => isHTMLElement$2(el))
|
|
17154
17458
|
};
|
|
17155
17459
|
}
|
|
17156
17460
|
if (typeof firstValue === "string") {
|
|
@@ -17507,7 +17811,7 @@ function isEmpty(value) {
|
|
|
17507
17811
|
function isPlainObject(value) {
|
|
17508
17812
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
17509
17813
|
return false;
|
|
17510
|
-
if (isHTMLElement(value) || value instanceof Node)
|
|
17814
|
+
if (isHTMLElement$2(value) || value instanceof Node)
|
|
17511
17815
|
return false;
|
|
17512
17816
|
const proto = Object.getPrototypeOf(value);
|
|
17513
17817
|
return proto === Object.prototype || proto === null;
|
|
@@ -17563,7 +17867,7 @@ async function resolvePropertyTargetFromNode(node, evaluator, context) {
|
|
|
17563
17867
|
let element = await evaluator.evaluate(node.target, context);
|
|
17564
17868
|
if (Array.isArray(element))
|
|
17565
17869
|
element = element[0];
|
|
17566
|
-
if (!isHTMLElement(element))
|
|
17870
|
+
if (!isHTMLElement$2(element))
|
|
17567
17871
|
return null;
|
|
17568
17872
|
return { element, property };
|
|
17569
17873
|
}
|
|
@@ -17574,7 +17878,7 @@ async function resolvePropertyTargetFromAccessNode(node, evaluator, context) {
|
|
|
17574
17878
|
let element = await evaluator.evaluate(node.object, context);
|
|
17575
17879
|
if (Array.isArray(element))
|
|
17576
17880
|
element = element[0];
|
|
17577
|
-
if (!isHTMLElement(element))
|
|
17881
|
+
if (!isHTMLElement$2(element))
|
|
17578
17882
|
return null;
|
|
17579
17883
|
return { element, property };
|
|
17580
17884
|
}
|
|
@@ -17603,7 +17907,7 @@ async function resolveAnyPropertyTarget(node, evaluator, context) {
|
|
|
17603
17907
|
let element = await evaluator.evaluate(objectNode, context);
|
|
17604
17908
|
if (Array.isArray(element))
|
|
17605
17909
|
element = element[0];
|
|
17606
|
-
if (!isHTMLElement(element))
|
|
17910
|
+
if (!isHTMLElement$2(element))
|
|
17607
17911
|
return null;
|
|
17608
17912
|
const propertyName = propertyNode?.name || propertyNode?.value;
|
|
17609
17913
|
if (!propertyName)
|
|
@@ -17703,7 +18007,7 @@ async function parseTemporalModifiers(modifiers, evaluator, context) {
|
|
|
17703
18007
|
function detectExpressionType(firstValue, firstArg) {
|
|
17704
18008
|
const firstArgName = firstArg?.name;
|
|
17705
18009
|
const isBareTag = isBareSmartElementNode(firstArg);
|
|
17706
|
-
if (isHTMLElement(firstValue) || Array.isArray(firstValue) && firstValue.every((el) => isHTMLElement(el))) {
|
|
18010
|
+
if (isHTMLElement$2(firstValue) || Array.isArray(firstValue) && firstValue.every((el) => isHTMLElement$2(el))) {
|
|
17707
18011
|
return { type: "element", expression: "" };
|
|
17708
18012
|
}
|
|
17709
18013
|
if (isBareTag && firstArgName) {
|
|
@@ -17847,13 +18151,13 @@ var ToggleCommand = (() => {
|
|
|
17847
18151
|
}
|
|
17848
18152
|
case "element": {
|
|
17849
18153
|
let elements;
|
|
17850
|
-
if (isHTMLElement(firstValue)) {
|
|
18154
|
+
if (isHTMLElement$2(firstValue)) {
|
|
17851
18155
|
elements = [firstValue];
|
|
17852
|
-
} else if (Array.isArray(firstValue) && firstValue.every((el) => isHTMLElement(el))) {
|
|
18156
|
+
} else if (Array.isArray(firstValue) && firstValue.every((el) => isHTMLElement$2(el))) {
|
|
17853
18157
|
elements = firstValue;
|
|
17854
18158
|
} else if (expression) {
|
|
17855
18159
|
const selected = document.querySelectorAll(expression);
|
|
17856
|
-
elements = Array.from(selected).filter((el) => isHTMLElement(el));
|
|
18160
|
+
elements = Array.from(selected).filter((el) => isHTMLElement$2(el));
|
|
17857
18161
|
} else {
|
|
17858
18162
|
elements = await resolveTargetsFromArgs([firstArg], evaluator, context, "toggle", resolveOpts, raw.modifiers);
|
|
17859
18163
|
}
|
|
@@ -18155,23 +18459,23 @@ var PutCommand = (() => {
|
|
|
18155
18459
|
}
|
|
18156
18460
|
async resolveTargets(sel, ctx) {
|
|
18157
18461
|
if (!sel || sel === "me") {
|
|
18158
|
-
if (!ctx.me || !isHTMLElement(ctx.me))
|
|
18462
|
+
if (!ctx.me || !isHTMLElement$2(ctx.me))
|
|
18159
18463
|
throw new Error("put: no target and context.me is null");
|
|
18160
18464
|
return [ctx.me];
|
|
18161
18465
|
}
|
|
18162
|
-
const els = Array.from(document.querySelectorAll(sel)).filter((e) => isHTMLElement(e));
|
|
18466
|
+
const els = Array.from(document.querySelectorAll(sel)).filter((e) => isHTMLElement$2(e));
|
|
18163
18467
|
if (!els.length)
|
|
18164
18468
|
throw new Error(`No elements: "${sel}"`);
|
|
18165
18469
|
return els;
|
|
18166
18470
|
}
|
|
18167
18471
|
parseValue(v2) {
|
|
18168
|
-
if (isHTMLElement(v2))
|
|
18472
|
+
if (isHTMLElement$2(v2))
|
|
18169
18473
|
return v2;
|
|
18170
18474
|
return v2 == null ? "" : String(v2);
|
|
18171
18475
|
}
|
|
18172
18476
|
insertContent(target, content, pos2) {
|
|
18173
18477
|
if (pos2 === "replace") {
|
|
18174
|
-
if (isHTMLElement(content)) {
|
|
18478
|
+
if (isHTMLElement$2(content)) {
|
|
18175
18479
|
target.innerHTML = "";
|
|
18176
18480
|
target.appendChild(content);
|
|
18177
18481
|
} else {
|
|
@@ -18183,7 +18487,7 @@ var PutCommand = (() => {
|
|
|
18183
18487
|
}
|
|
18184
18488
|
return;
|
|
18185
18489
|
}
|
|
18186
|
-
if (isHTMLElement(content)) {
|
|
18490
|
+
if (isHTMLElement$2(content)) {
|
|
18187
18491
|
const el = content;
|
|
18188
18492
|
switch (pos2) {
|
|
18189
18493
|
case "beforebegin":
|
|
@@ -18208,14 +18512,14 @@ var PutCommand = (() => {
|
|
|
18208
18512
|
}
|
|
18209
18513
|
}
|
|
18210
18514
|
resolveEvaluatedAsElements(ev) {
|
|
18211
|
-
if (isHTMLElement(ev))
|
|
18515
|
+
if (isHTMLElement$2(ev))
|
|
18212
18516
|
return [ev];
|
|
18213
18517
|
if (Array.isArray(ev)) {
|
|
18214
|
-
const elements = ev.filter(isHTMLElement);
|
|
18518
|
+
const elements = ev.filter(isHTMLElement$2);
|
|
18215
18519
|
return elements.length > 0 ? elements : null;
|
|
18216
18520
|
}
|
|
18217
18521
|
if (typeof NodeList !== "undefined" && ev instanceof NodeList) {
|
|
18218
|
-
const elements = Array.from(ev).filter(isHTMLElement);
|
|
18522
|
+
const elements = Array.from(ev).filter(isHTMLElement$2);
|
|
18219
18523
|
return elements.length > 0 ? elements : null;
|
|
18220
18524
|
}
|
|
18221
18525
|
return null;
|
|
@@ -18286,210 +18590,6 @@ var PutCommand = (() => {
|
|
|
18286
18590
|
return _classThis;
|
|
18287
18591
|
})();
|
|
18288
18592
|
var createPutCommand = createFactory(PutCommand);
|
|
18289
|
-
function convertToNumber(value) {
|
|
18290
|
-
if (value === null || value === void 0) {
|
|
18291
|
-
return 0;
|
|
18292
|
-
}
|
|
18293
|
-
if (typeof value === "number") {
|
|
18294
|
-
return isFinite(value) ? value : 0;
|
|
18295
|
-
}
|
|
18296
|
-
if (typeof value === "string") {
|
|
18297
|
-
const parsed = parseFloat(value);
|
|
18298
|
-
return parsed;
|
|
18299
|
-
}
|
|
18300
|
-
if (typeof value === "boolean") {
|
|
18301
|
-
return value ? 1 : 0;
|
|
18302
|
-
}
|
|
18303
|
-
if (Array.isArray(value)) {
|
|
18304
|
-
return value.length;
|
|
18305
|
-
}
|
|
18306
|
-
if (typeof value === "object") {
|
|
18307
|
-
if ("length" in value && typeof value.length === "number") {
|
|
18308
|
-
return value.length;
|
|
18309
|
-
}
|
|
18310
|
-
if (typeof value.valueOf === "function") {
|
|
18311
|
-
const result = value.valueOf();
|
|
18312
|
-
if (typeof result === "number") {
|
|
18313
|
-
return result;
|
|
18314
|
-
}
|
|
18315
|
-
}
|
|
18316
|
-
return NaN;
|
|
18317
|
-
}
|
|
18318
|
-
return 0;
|
|
18319
|
-
}
|
|
18320
|
-
function getVariableValue(name, context, preferredScope) {
|
|
18321
|
-
if (preferredScope === "global" && context.globals && context.globals.has(name)) {
|
|
18322
|
-
return context.globals.get(name);
|
|
18323
|
-
}
|
|
18324
|
-
if (preferredScope !== "global" && context.locals && context.locals.has(name)) {
|
|
18325
|
-
notifyLocalRead(name, context);
|
|
18326
|
-
return context.locals.get(name);
|
|
18327
|
-
}
|
|
18328
|
-
if (context.globals && context.globals.has(name)) {
|
|
18329
|
-
return context.globals.get(name);
|
|
18330
|
-
}
|
|
18331
|
-
if (context.variables && context.variables.has(name)) {
|
|
18332
|
-
return context.variables.get(name);
|
|
18333
|
-
}
|
|
18334
|
-
if (preferredScope === "global" && context.locals && context.locals.has(name)) {
|
|
18335
|
-
notifyLocalRead(name, context);
|
|
18336
|
-
return context.locals.get(name);
|
|
18337
|
-
}
|
|
18338
|
-
if (typeof window !== "undefined" && name in window) {
|
|
18339
|
-
return window[name];
|
|
18340
|
-
}
|
|
18341
|
-
if (typeof globalThis !== "undefined" && name in globalThis) {
|
|
18342
|
-
return globalThis[name];
|
|
18343
|
-
}
|
|
18344
|
-
return void 0;
|
|
18345
|
-
}
|
|
18346
|
-
function setVariableValue(name, value, context, preferredScope) {
|
|
18347
|
-
if (preferredScope === "global") {
|
|
18348
|
-
setGlobal(context, name, value);
|
|
18349
|
-
if (typeof window !== "undefined") {
|
|
18350
|
-
window[name] = value;
|
|
18351
|
-
}
|
|
18352
|
-
return;
|
|
18353
|
-
}
|
|
18354
|
-
if (name.startsWith("$")) {
|
|
18355
|
-
const bare = name.slice(1);
|
|
18356
|
-
setGlobal(context, bare, value);
|
|
18357
|
-
return;
|
|
18358
|
-
}
|
|
18359
|
-
if (context.locals && context.locals.has(name)) {
|
|
18360
|
-
context.locals.set(name, value);
|
|
18361
|
-
notifyLocalWrite(name, value, context);
|
|
18362
|
-
return;
|
|
18363
|
-
}
|
|
18364
|
-
if (context.globals && context.globals.has(name)) {
|
|
18365
|
-
setGlobal(context, name, value);
|
|
18366
|
-
if (typeof window !== "undefined" && name in window) {
|
|
18367
|
-
window[name] = value;
|
|
18368
|
-
}
|
|
18369
|
-
return;
|
|
18370
|
-
}
|
|
18371
|
-
if (context.variables && context.variables.has(name)) {
|
|
18372
|
-
context.variables.set(name, value);
|
|
18373
|
-
return;
|
|
18374
|
-
}
|
|
18375
|
-
if (typeof window !== "undefined" && name in window) {
|
|
18376
|
-
window[name] = value;
|
|
18377
|
-
setGlobal(context, name, value);
|
|
18378
|
-
return;
|
|
18379
|
-
}
|
|
18380
|
-
context.locals.set(name, value);
|
|
18381
|
-
notifyLocalWrite(name, value, context);
|
|
18382
|
-
}
|
|
18383
|
-
function resolveElementRef(elementRef, context) {
|
|
18384
|
-
if (elementRef === "me") {
|
|
18385
|
-
return context.me;
|
|
18386
|
-
} else if (elementRef === "it") {
|
|
18387
|
-
return context.it;
|
|
18388
|
-
} else if (elementRef === "you") {
|
|
18389
|
-
return context.you;
|
|
18390
|
-
} else {
|
|
18391
|
-
return getVariableValue(elementRef, context);
|
|
18392
|
-
}
|
|
18393
|
-
}
|
|
18394
|
-
function getElementPropertyValue(propertyPath, context) {
|
|
18395
|
-
const parts = propertyPath.split(".");
|
|
18396
|
-
const elementRef = parts[0];
|
|
18397
|
-
const property = parts[1];
|
|
18398
|
-
const element = resolveElementRef(elementRef, context);
|
|
18399
|
-
if (!element) {
|
|
18400
|
-
return 0;
|
|
18401
|
-
}
|
|
18402
|
-
const value = element[property];
|
|
18403
|
-
return convertToNumber(value);
|
|
18404
|
-
}
|
|
18405
|
-
function setElementPropertyValue(propertyPath, value, context) {
|
|
18406
|
-
const parts = propertyPath.split(".");
|
|
18407
|
-
const elementRef = parts[0];
|
|
18408
|
-
const property = parts[1];
|
|
18409
|
-
const element = resolveElementRef(elementRef, context);
|
|
18410
|
-
if (element) {
|
|
18411
|
-
element[property] = value;
|
|
18412
|
-
}
|
|
18413
|
-
}
|
|
18414
|
-
function getCurrentNumericValue(target, property, scope, context) {
|
|
18415
|
-
if (typeof target === "number") {
|
|
18416
|
-
return target;
|
|
18417
|
-
}
|
|
18418
|
-
if (isHTMLElement(target)) {
|
|
18419
|
-
const element = target;
|
|
18420
|
-
if (property) {
|
|
18421
|
-
if (property.startsWith("data-") || ["id", "class", "title", "alt", "src", "href"].includes(property)) {
|
|
18422
|
-
const value = element.getAttribute(property);
|
|
18423
|
-
return convertToNumber(value);
|
|
18424
|
-
} else {
|
|
18425
|
-
const value = element[property];
|
|
18426
|
-
return convertToNumber(value);
|
|
18427
|
-
}
|
|
18428
|
-
} else {
|
|
18429
|
-
const value = element.value || element.textContent;
|
|
18430
|
-
return convertToNumber(value);
|
|
18431
|
-
}
|
|
18432
|
-
}
|
|
18433
|
-
if (typeof target === "string") {
|
|
18434
|
-
if (scope === "global") {
|
|
18435
|
-
const value2 = getVariableValue(target, context, "global");
|
|
18436
|
-
return convertToNumber(value2);
|
|
18437
|
-
}
|
|
18438
|
-
if (target.includes(".")) {
|
|
18439
|
-
return getElementPropertyValue(target, context);
|
|
18440
|
-
}
|
|
18441
|
-
if (target === "me" && context.me) {
|
|
18442
|
-
return convertToNumber(context.me.value || 0);
|
|
18443
|
-
} else if (target === "it") {
|
|
18444
|
-
return convertToNumber(context.it || 0);
|
|
18445
|
-
} else if (target === "you" && context.you) {
|
|
18446
|
-
return convertToNumber(context.you.value || 0);
|
|
18447
|
-
}
|
|
18448
|
-
const value = getVariableValue(target, context);
|
|
18449
|
-
return convertToNumber(value);
|
|
18450
|
-
}
|
|
18451
|
-
return convertToNumber(target);
|
|
18452
|
-
}
|
|
18453
|
-
function setTargetValue(target, property, scope, newValue, context) {
|
|
18454
|
-
if (isHTMLElement(target)) {
|
|
18455
|
-
const element = target;
|
|
18456
|
-
if (property) {
|
|
18457
|
-
if (property.startsWith("data-") || ["id", "class", "title", "alt", "src", "href"].includes(property)) {
|
|
18458
|
-
element.setAttribute(property, String(newValue));
|
|
18459
|
-
} else {
|
|
18460
|
-
element[property] = newValue;
|
|
18461
|
-
}
|
|
18462
|
-
} else {
|
|
18463
|
-
if ("value" in element && element.value !== void 0) {
|
|
18464
|
-
element.value = String(newValue);
|
|
18465
|
-
} else {
|
|
18466
|
-
element.textContent = String(newValue);
|
|
18467
|
-
}
|
|
18468
|
-
}
|
|
18469
|
-
return;
|
|
18470
|
-
}
|
|
18471
|
-
if (typeof target === "string") {
|
|
18472
|
-
if (scope === "global") {
|
|
18473
|
-
setVariableValue(target, newValue, context, "global");
|
|
18474
|
-
return;
|
|
18475
|
-
}
|
|
18476
|
-
if (target.includes(".")) {
|
|
18477
|
-
setElementPropertyValue(target, newValue, context);
|
|
18478
|
-
return;
|
|
18479
|
-
}
|
|
18480
|
-
if (target === "me" && context.me) {
|
|
18481
|
-
context.me.value = newValue;
|
|
18482
|
-
return;
|
|
18483
|
-
} else if (target === "it") {
|
|
18484
|
-
Object.assign(context, { it: newValue });
|
|
18485
|
-
return;
|
|
18486
|
-
} else if (target === "you" && context.you) {
|
|
18487
|
-
context.you.value = newValue;
|
|
18488
|
-
return;
|
|
18489
|
-
}
|
|
18490
|
-
setVariableValue(target, newValue, context);
|
|
18491
|
-
}
|
|
18492
|
-
}
|
|
18493
18593
|
var HTML_ESCAPE = {
|
|
18494
18594
|
"&": "&",
|
|
18495
18595
|
"<": "<",
|
|
@@ -18551,15 +18651,15 @@ function createElementFromHTML(html) {
|
|
|
18551
18651
|
const template = document.createElement("template");
|
|
18552
18652
|
template.innerHTML = html.trim();
|
|
18553
18653
|
const fromTemplate = template.content.firstElementChild;
|
|
18554
|
-
if (fromTemplate && isHTMLElement(fromTemplate))
|
|
18654
|
+
if (fromTemplate && isHTMLElement$2(fromTemplate))
|
|
18555
18655
|
return fromTemplate;
|
|
18556
18656
|
const wrapper = document.createElement("div");
|
|
18557
18657
|
wrapper.innerHTML = html.trim();
|
|
18558
18658
|
const child = wrapper.firstElementChild;
|
|
18559
|
-
return child && isHTMLElement(child) ? child : wrapper;
|
|
18659
|
+
return child && isHTMLElement$2(child) ? child : wrapper;
|
|
18560
18660
|
}
|
|
18561
18661
|
function createClassInstance(className, args, context) {
|
|
18562
|
-
if (isHTMLElement(className))
|
|
18662
|
+
if (isHTMLElement$2(className))
|
|
18563
18663
|
return className;
|
|
18564
18664
|
const name = String(className);
|
|
18565
18665
|
let Constructor;
|
|
@@ -18675,7 +18775,7 @@ var EmptyCommand = (() => {
|
|
|
18675
18775
|
const typed = input;
|
|
18676
18776
|
if (!Array.isArray(typed.targets))
|
|
18677
18777
|
return false;
|
|
18678
|
-
return typed.targets.every((t) => isHTMLElement(t));
|
|
18778
|
+
return typed.targets.every((t) => isHTMLElement$2(t));
|
|
18679
18779
|
}
|
|
18680
18780
|
};
|
|
18681
18781
|
__setFunctionName(_classThis, "EmptyCommand");
|
|
@@ -18771,7 +18871,7 @@ var OpenCommand = (() => {
|
|
|
18771
18871
|
const typed = input;
|
|
18772
18872
|
if (!Array.isArray(typed.targets))
|
|
18773
18873
|
return false;
|
|
18774
|
-
if (!typed.targets.every((t) => isHTMLElement(t)))
|
|
18874
|
+
if (!typed.targets.every((t) => isHTMLElement$2(t)))
|
|
18775
18875
|
return false;
|
|
18776
18876
|
return typed.dialogMode === "modal" || typed.dialogMode === "non-modal";
|
|
18777
18877
|
}
|
|
@@ -18831,7 +18931,7 @@ var CloseCommand = (() => {
|
|
|
18831
18931
|
const typed = input;
|
|
18832
18932
|
if (!Array.isArray(typed.targets))
|
|
18833
18933
|
return false;
|
|
18834
|
-
return typed.targets.every((t) => isHTMLElement(t));
|
|
18934
|
+
return typed.targets.every((t) => isHTMLElement$2(t));
|
|
18835
18935
|
}
|
|
18836
18936
|
};
|
|
18837
18937
|
__setFunctionName(_classThis, "CloseCommand");
|
|
@@ -18894,7 +18994,7 @@ var SelectCommand = (() => {
|
|
|
18894
18994
|
const typed = input;
|
|
18895
18995
|
if (!Array.isArray(typed.targets))
|
|
18896
18996
|
return false;
|
|
18897
|
-
return typed.targets.every((t) => isHTMLElement(t));
|
|
18997
|
+
return typed.targets.every((t) => isHTMLElement$2(t));
|
|
18898
18998
|
}
|
|
18899
18999
|
};
|
|
18900
19000
|
__setFunctionName(_classThis, "SelectCommand");
|
|
@@ -18939,7 +19039,7 @@ var ResetCommand = (() => {
|
|
|
18939
19039
|
const typed = input;
|
|
18940
19040
|
if (!Array.isArray(typed.targets))
|
|
18941
19041
|
return false;
|
|
18942
|
-
return typed.targets.every((t) => isHTMLElement(t));
|
|
19042
|
+
return typed.targets.every((t) => isHTMLElement$2(t));
|
|
18943
19043
|
}
|
|
18944
19044
|
};
|
|
18945
19045
|
__setFunctionName(_classThis, "ResetCommand");
|
|
@@ -19598,8 +19698,8 @@ var STRATEGY_KEYWORDS = {
|
|
|
19598
19698
|
outermorph: "morphOuter"
|
|
19599
19699
|
};
|
|
19600
19700
|
function executeSwap(target, content, strategy, morphOptions) {
|
|
19601
|
-
const contentStr = content !== null && !isHTMLElement(content) ? content : "";
|
|
19602
|
-
const contentEl = isHTMLElement(content) ? content : null;
|
|
19701
|
+
const contentStr = content !== null && !isHTMLElement$2(content) ? content : "";
|
|
19702
|
+
const contentEl = isHTMLElement$2(content) ? content : null;
|
|
19603
19703
|
switch (strategy) {
|
|
19604
19704
|
case "morph":
|
|
19605
19705
|
if (content !== null) {
|
|
@@ -19699,7 +19799,7 @@ function extractContent(value) {
|
|
|
19699
19799
|
if (value === null || value === void 0) {
|
|
19700
19800
|
return null;
|
|
19701
19801
|
}
|
|
19702
|
-
if (isHTMLElement(value)) {
|
|
19802
|
+
if (isHTMLElement$2(value)) {
|
|
19703
19803
|
return value;
|
|
19704
19804
|
}
|
|
19705
19805
|
if (isDocumentFragment(value)) {
|
|
@@ -19862,7 +19962,7 @@ var SwapCommand = (() => {
|
|
|
19862
19962
|
let targetSelector = null;
|
|
19863
19963
|
if (typeof targetArg === "string") {
|
|
19864
19964
|
targetSelector = targetArg;
|
|
19865
|
-
} else if (isHTMLElement(targetArg)) {
|
|
19965
|
+
} else if (isHTMLElement$2(targetArg)) {
|
|
19866
19966
|
return {
|
|
19867
19967
|
targets: [targetArg],
|
|
19868
19968
|
content: extractContent(contentArg),
|
|
@@ -19997,7 +20097,7 @@ var MorphCommand = (() => {
|
|
|
19997
20097
|
let targets;
|
|
19998
20098
|
if (typeof targetArg === "string") {
|
|
19999
20099
|
targets = await resolveTargets(targetArg, context);
|
|
20000
|
-
} else if (isHTMLElement(targetArg)) {
|
|
20100
|
+
} else if (isHTMLElement$2(targetArg)) {
|
|
20001
20101
|
targets = [targetArg];
|
|
20002
20102
|
} else {
|
|
20003
20103
|
throw new Error("[HyperFixi] morph: target must be a selector or element");
|
|
@@ -20557,7 +20657,7 @@ function extractPartials(html) {
|
|
|
20557
20657
|
function executePartialSwap(partial, morphOptions) {
|
|
20558
20658
|
const { target, strategy, content } = partial;
|
|
20559
20659
|
const targetElement = document.querySelector(target);
|
|
20560
|
-
if (!targetElement || !isHTMLElement(targetElement)) {
|
|
20660
|
+
if (!targetElement || !isHTMLElement$2(targetElement)) {
|
|
20561
20661
|
return { success: false, error: `Target "${target}" not found` };
|
|
20562
20662
|
}
|
|
20563
20663
|
try {
|
|
@@ -20671,7 +20771,7 @@ var ProcessPartialsCommand = (() => {
|
|
|
20671
20771
|
let html;
|
|
20672
20772
|
if (typeof contentArg === "string") {
|
|
20673
20773
|
html = contentArg;
|
|
20674
|
-
} else if (isHTMLElement(contentArg)) {
|
|
20774
|
+
} else if (isHTMLElement$2(contentArg)) {
|
|
20675
20775
|
html = contentArg.outerHTML;
|
|
20676
20776
|
} else if (contentArg && typeof contentArg.text === "function") {
|
|
20677
20777
|
html = await contentArg.text();
|
|
@@ -21208,7 +21308,7 @@ var FetchCommand = (() => {
|
|
|
21208
21308
|
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
21209
21309
|
const fragment = document.createDocumentFragment();
|
|
21210
21310
|
Array.from(doc.body.childNodes).forEach((n) => fragment.appendChild(n.cloneNode(true)));
|
|
21211
|
-
if (fragment.childNodes.length === 1 && isHTMLElement(fragment.firstChild))
|
|
21311
|
+
if (fragment.childNodes.length === 1 && isHTMLElement$2(fragment.firstChild))
|
|
21212
21312
|
return fragment.firstChild;
|
|
21213
21313
|
return fragment;
|
|
21214
21314
|
}
|
|
@@ -21244,6 +21344,7 @@ var SetCommand = (() => {
|
|
|
21244
21344
|
}
|
|
21245
21345
|
const firstArg = raw.args[0];
|
|
21246
21346
|
const argName = firstArg?.name || firstArg?.value;
|
|
21347
|
+
const argScope = firstArg?.scope;
|
|
21247
21348
|
const firstArgType = firstArg?.type;
|
|
21248
21349
|
if (firstArgType) {
|
|
21249
21350
|
const writer = getRegisteredNodeWriter(firstArgType);
|
|
@@ -21319,11 +21420,11 @@ var SetCommand = (() => {
|
|
|
21319
21420
|
return { type: "property", element, property: match[2], value: value2 };
|
|
21320
21421
|
}
|
|
21321
21422
|
}
|
|
21322
|
-
if (isHTMLElement(firstValue)) {
|
|
21423
|
+
if (isHTMLElement$2(firstValue)) {
|
|
21323
21424
|
const value2 = await this.extractValue(raw, evaluator, context);
|
|
21324
21425
|
return { type: "property", element: firstValue, property: "textContent", value: value2 };
|
|
21325
21426
|
}
|
|
21326
|
-
if (Array.isArray(firstValue) && firstValue.length > 0 && isHTMLElement(firstValue[0])) {
|
|
21427
|
+
if (Array.isArray(firstValue) && firstValue.length > 0 && isHTMLElement$2(firstValue[0])) {
|
|
21327
21428
|
const value2 = await this.extractValue(raw, evaluator, context);
|
|
21328
21429
|
return { type: "property", element: firstValue[0], property: "textContent", value: value2 };
|
|
21329
21430
|
}
|
|
@@ -21333,12 +21434,19 @@ var SetCommand = (() => {
|
|
|
21333
21434
|
throw new Error(`set command target must be a string or object literal${hint}`);
|
|
21334
21435
|
}
|
|
21335
21436
|
const value = await this.extractValue(raw, evaluator, context);
|
|
21336
|
-
|
|
21437
|
+
const scope = argScope === "element" || argScope === "global" ? argScope : void 0;
|
|
21438
|
+
return { type: "variable", name: firstValue, value, scope };
|
|
21337
21439
|
}
|
|
21338
21440
|
async execute(input, context) {
|
|
21339
21441
|
switch (input.type) {
|
|
21340
21442
|
case "variable":
|
|
21341
|
-
|
|
21443
|
+
if (input.scope === "element") {
|
|
21444
|
+
setElementVar(context, input.name, input.value);
|
|
21445
|
+
} else if (input.scope === "global") {
|
|
21446
|
+
setVariableValue(input.name, input.value, context, "global");
|
|
21447
|
+
} else {
|
|
21448
|
+
setVariableValue(input.name, input.value, context);
|
|
21449
|
+
}
|
|
21342
21450
|
if (input.name === "result" || input.name === "it") {
|
|
21343
21451
|
Object.assign(context, { [input.name]: input.value });
|
|
21344
21452
|
}
|
|
@@ -21407,7 +21515,7 @@ var SetCommand = (() => {
|
|
|
21407
21515
|
async evaluateToElement(node, evaluator, context) {
|
|
21408
21516
|
const value = await evaluator.evaluate(node, context);
|
|
21409
21517
|
const el = Array.isArray(value) ? value[0] : value;
|
|
21410
|
-
return isHTMLElement(el) ? el : null;
|
|
21518
|
+
return isHTMLElement$2(el) ? el : null;
|
|
21411
21519
|
}
|
|
21412
21520
|
async tryParseMemberExpression(firstArg, raw, evaluator, context) {
|
|
21413
21521
|
const objectNode = firstArg.object;
|
|
@@ -21494,11 +21602,11 @@ var SetCommand = (() => {
|
|
|
21494
21602
|
case "variable":
|
|
21495
21603
|
return typeof obj.name === "string" && "value" in obj;
|
|
21496
21604
|
case "attribute":
|
|
21497
|
-
return typeof obj.name === "string" && Array.isArray(obj.elements) && obj.elements.every(isHTMLElement) && "value" in obj;
|
|
21605
|
+
return typeof obj.name === "string" && Array.isArray(obj.elements) && obj.elements.every(isHTMLElement$2) && "value" in obj;
|
|
21498
21606
|
case "property":
|
|
21499
|
-
return typeof obj.property === "string" && isHTMLElement(obj.element) && "value" in obj;
|
|
21607
|
+
return typeof obj.property === "string" && isHTMLElement$2(obj.element) && "value" in obj;
|
|
21500
21608
|
case "style":
|
|
21501
|
-
return typeof obj.property === "string" && obj.property !== "" && isHTMLElement(obj.element) && typeof obj.value === "string";
|
|
21609
|
+
return typeof obj.property === "string" && obj.property !== "" && isHTMLElement$2(obj.element) && typeof obj.value === "string";
|
|
21502
21610
|
case "object-literal":
|
|
21503
21611
|
return obj.properties !== null && typeof obj.properties === "object" && Array.isArray(obj.targets) && obj.targets.length > 0;
|
|
21504
21612
|
default:
|
|
@@ -21716,7 +21824,7 @@ var ClearCommand = (() => {
|
|
|
21716
21824
|
if (firstArg && (firstArgType === "variable" || firstArgType === "identifier" && typeof firstArgName === "string")) {
|
|
21717
21825
|
try {
|
|
21718
21826
|
const evaluated = await evaluator.evaluate(firstArg, context);
|
|
21719
|
-
if (isHTMLElement(evaluated) || Array.isArray(evaluated)) {
|
|
21827
|
+
if (isHTMLElement$2(evaluated) || Array.isArray(evaluated)) {
|
|
21720
21828
|
} else {
|
|
21721
21829
|
return { type: "variable", name: firstArgName };
|
|
21722
21830
|
}
|
|
@@ -21751,7 +21859,7 @@ var ClearCommand = (() => {
|
|
|
21751
21859
|
return typeof typed.name === "string";
|
|
21752
21860
|
if (typed.type === "form-fields") {
|
|
21753
21861
|
const targets = typed.targets;
|
|
21754
|
-
return Array.isArray(targets) && targets.every((t) => isHTMLElement(t));
|
|
21862
|
+
return Array.isArray(targets) && targets.every((t) => isHTMLElement$2(t));
|
|
21755
21863
|
}
|
|
21756
21864
|
return false;
|
|
21757
21865
|
}
|
|
@@ -21910,23 +22018,23 @@ var EventDispatchCommand = (() => {
|
|
|
21910
22018
|
targets.push(context.it);
|
|
21911
22019
|
continue;
|
|
21912
22020
|
}
|
|
21913
|
-
if (isHTMLElement(val)) {
|
|
22021
|
+
if (isHTMLElement$2(val)) {
|
|
21914
22022
|
targets.push(val);
|
|
21915
22023
|
continue;
|
|
21916
22024
|
}
|
|
21917
22025
|
if (val instanceof NodeList) {
|
|
21918
|
-
targets.push(...Array.from(val).filter(isHTMLElement));
|
|
22026
|
+
targets.push(...Array.from(val).filter(isHTMLElement$2));
|
|
21919
22027
|
continue;
|
|
21920
22028
|
}
|
|
21921
22029
|
if (Array.isArray(val)) {
|
|
21922
|
-
targets.push(...val.filter(isHTMLElement));
|
|
22030
|
+
targets.push(...val.filter(isHTMLElement$2));
|
|
21923
22031
|
continue;
|
|
21924
22032
|
}
|
|
21925
22033
|
if (typeof val === "string") {
|
|
21926
22034
|
const els = document.querySelectorAll(val);
|
|
21927
22035
|
if (els.length === 0)
|
|
21928
22036
|
throw new Error(`No elements found: "${val}"`);
|
|
21929
|
-
targets.push(...Array.from(els).filter(isHTMLElement));
|
|
22037
|
+
targets.push(...Array.from(els).filter(isHTMLElement$2));
|
|
21930
22038
|
continue;
|
|
21931
22039
|
}
|
|
21932
22040
|
if (val && typeof val === "object" && "addEventListener" in val) {
|
|
@@ -22231,14 +22339,14 @@ var GoCommand = (() => {
|
|
|
22231
22339
|
return document.body;
|
|
22232
22340
|
if (str === "html" && typeof document !== "undefined")
|
|
22233
22341
|
return document.documentElement;
|
|
22234
|
-
if (str === "me" && isHTMLElement(context.me))
|
|
22342
|
+
if (str === "me" && isHTMLElement$2(context.me))
|
|
22235
22343
|
return context.me;
|
|
22236
|
-
if (str === "it" && isHTMLElement(context.it))
|
|
22344
|
+
if (str === "it" && isHTMLElement$2(context.it))
|
|
22237
22345
|
return context.it;
|
|
22238
|
-
if (str === "you" && isHTMLElement(context.you))
|
|
22346
|
+
if (str === "you" && isHTMLElement$2(context.you))
|
|
22239
22347
|
return context.you;
|
|
22240
22348
|
const variable = getVariableValue(str, context);
|
|
22241
|
-
if (isHTMLElement(variable))
|
|
22349
|
+
if (isHTMLElement$2(variable))
|
|
22242
22350
|
return variable;
|
|
22243
22351
|
if (typeof document !== "undefined") {
|
|
22244
22352
|
try {
|
|
@@ -22494,18 +22602,18 @@ var ScrollCommand = (() => {
|
|
|
22494
22602
|
}
|
|
22495
22603
|
if (typeof a !== "string" || skip.has(a))
|
|
22496
22604
|
continue;
|
|
22497
|
-
if (a === "me" && isHTMLElement(context.me))
|
|
22605
|
+
if (a === "me" && isHTMLElement$2(context.me))
|
|
22498
22606
|
return context.me;
|
|
22499
|
-
if (a === "it" && isHTMLElement(context.it))
|
|
22607
|
+
if (a === "it" && isHTMLElement$2(context.it))
|
|
22500
22608
|
return context.it;
|
|
22501
|
-
if (a === "you" && isHTMLElement(context.you))
|
|
22609
|
+
if (a === "you" && isHTMLElement$2(context.you))
|
|
22502
22610
|
return context.you;
|
|
22503
22611
|
if (a === "body" && typeof document !== "undefined")
|
|
22504
22612
|
return document.body;
|
|
22505
22613
|
if (a === "html" && typeof document !== "undefined")
|
|
22506
22614
|
return document.documentElement;
|
|
22507
22615
|
const variable = getVariableValue(a, context);
|
|
22508
|
-
if (isHTMLElement(variable))
|
|
22616
|
+
if (isHTMLElement$2(variable))
|
|
22509
22617
|
return variable;
|
|
22510
22618
|
if (typeof document !== "undefined") {
|
|
22511
22619
|
try {
|
|
@@ -23335,7 +23443,7 @@ var FocusCommand = (() => {
|
|
|
23335
23443
|
const typed = input;
|
|
23336
23444
|
if (!Array.isArray(typed.targets))
|
|
23337
23445
|
return false;
|
|
23338
|
-
return typed.targets.every((t) => isHTMLElement(t));
|
|
23446
|
+
return typed.targets.every((t) => isHTMLElement$2(t));
|
|
23339
23447
|
}
|
|
23340
23448
|
};
|
|
23341
23449
|
__setFunctionName(_classThis, "FocusCommand");
|
|
@@ -23375,7 +23483,7 @@ var BlurCommand = (() => {
|
|
|
23375
23483
|
const typed = input;
|
|
23376
23484
|
if (!Array.isArray(typed.targets))
|
|
23377
23485
|
return false;
|
|
23378
|
-
return typed.targets.every((t) => isHTMLElement(t));
|
|
23486
|
+
return typed.targets.every((t) => isHTMLElement$2(t));
|
|
23379
23487
|
}
|
|
23380
23488
|
};
|
|
23381
23489
|
__setFunctionName(_classThis, "BlurCommand");
|
|
@@ -23440,14 +23548,14 @@ var AppendCommand = (() => {
|
|
|
23440
23548
|
}
|
|
23441
23549
|
if (target === "me" || target === "it" || target === "you") {
|
|
23442
23550
|
const ctxTarget = this.resolveContextRef(target, context);
|
|
23443
|
-
if (isHTMLElement(ctxTarget)) {
|
|
23551
|
+
if (isHTMLElement$2(ctxTarget)) {
|
|
23444
23552
|
ctxTarget.innerHTML += contentStr;
|
|
23445
23553
|
return { result: ctxTarget, targetType: "element", target: ctxTarget };
|
|
23446
23554
|
}
|
|
23447
23555
|
}
|
|
23448
23556
|
const current = getVariableValue(target, context);
|
|
23449
23557
|
if (current !== void 0) {
|
|
23450
|
-
if (isHTMLElement(current)) {
|
|
23558
|
+
if (isHTMLElement$2(current)) {
|
|
23451
23559
|
current.innerHTML += contentStr;
|
|
23452
23560
|
return { result: current, targetType: "element", target: current };
|
|
23453
23561
|
}
|
|
@@ -23465,7 +23573,7 @@ var AppendCommand = (() => {
|
|
|
23465
23573
|
} else if (Array.isArray(target)) {
|
|
23466
23574
|
target.push(content);
|
|
23467
23575
|
return { result: target, targetType: "array" };
|
|
23468
|
-
} else if (isHTMLElement(target)) {
|
|
23576
|
+
} else if (isHTMLElement$2(target)) {
|
|
23469
23577
|
target.innerHTML += contentStr;
|
|
23470
23578
|
return { result: target, targetType: "element", target };
|
|
23471
23579
|
} else {
|
|
@@ -23527,7 +23635,7 @@ var TransitionCommand = (() => {
|
|
|
23527
23635
|
let property;
|
|
23528
23636
|
let target;
|
|
23529
23637
|
const firstArg = await evaluator.evaluate(raw.args[0], context);
|
|
23530
|
-
if (isHTMLElement(firstArg) || typeof firstArg === "string" && /^[#.]|^(?:me|it|you)$/.test(firstArg)) {
|
|
23638
|
+
if (isHTMLElement$2(firstArg) || typeof firstArg === "string" && /^[#.]|^(?:me|it|you)$/.test(firstArg)) {
|
|
23531
23639
|
target = firstArg;
|
|
23532
23640
|
property = String(await evaluator.evaluate(raw.args[1], context));
|
|
23533
23641
|
} else {
|
|
@@ -23622,7 +23730,7 @@ var MeasureCommand = (() => {
|
|
|
23622
23730
|
const name = first.name.toLowerCase();
|
|
23623
23731
|
if (name === "me" || name === "it" || name === "you") {
|
|
23624
23732
|
const ev = await evaluator.evaluate(first, context);
|
|
23625
|
-
if (isHTMLElement(ev)) {
|
|
23733
|
+
if (isHTMLElement$2(ev)) {
|
|
23626
23734
|
target = ev;
|
|
23627
23735
|
if (raw.args.length > 1) {
|
|
23628
23736
|
const s = raw.args[1];
|
|
@@ -23634,7 +23742,7 @@ var MeasureCommand = (() => {
|
|
|
23634
23742
|
}
|
|
23635
23743
|
} else {
|
|
23636
23744
|
const ev = await evaluator.evaluate(first, context);
|
|
23637
|
-
if (isHTMLElement(ev) || typeof ev === "string" && /^[#.]/.test(ev)) {
|
|
23745
|
+
if (isHTMLElement$2(ev) || typeof ev === "string" && /^[#.]/.test(ev)) {
|
|
23638
23746
|
target = ev;
|
|
23639
23747
|
if (raw.args.length > 1) {
|
|
23640
23748
|
const s = raw.args[1];
|
|
@@ -23754,7 +23862,7 @@ var SettleCommand = (() => {
|
|
|
23754
23862
|
let timeout;
|
|
23755
23863
|
if (raw.args && raw.args.length > 0) {
|
|
23756
23864
|
const firstArg = await evaluator.evaluate(raw.args[0], context);
|
|
23757
|
-
if (isHTMLElement(firstArg) || typeof firstArg === "string" && (firstArg.startsWith("#") || firstArg.startsWith(".") || firstArg === "me" || firstArg === "it" || firstArg === "you")) {
|
|
23865
|
+
if (isHTMLElement$2(firstArg) || typeof firstArg === "string" && (firstArg.startsWith("#") || firstArg.startsWith(".") || firstArg === "me" || firstArg === "it" || firstArg === "you")) {
|
|
23758
23866
|
target = firstArg;
|
|
23759
23867
|
}
|
|
23760
23868
|
}
|
|
@@ -24092,7 +24200,7 @@ var DefaultCommand = (() => {
|
|
|
24092
24200
|
}
|
|
24093
24201
|
return this.defaultVariable(context, target, value);
|
|
24094
24202
|
}
|
|
24095
|
-
if (isHTMLElement(target)) {
|
|
24203
|
+
if (isHTMLElement$2(target)) {
|
|
24096
24204
|
return this.defaultElementValue(context, target, value);
|
|
24097
24205
|
}
|
|
24098
24206
|
throw new Error(`Invalid target type: ${typeof target}`);
|
|
@@ -24487,10 +24595,10 @@ var CopyCommand = (() => {
|
|
|
24487
24595
|
extractText(source, format, context) {
|
|
24488
24596
|
if (typeof source === "string")
|
|
24489
24597
|
return source;
|
|
24490
|
-
if (isHTMLElement(source)) {
|
|
24598
|
+
if (isHTMLElement$2(source)) {
|
|
24491
24599
|
return format === "html" ? source.outerHTML : source.textContent || "";
|
|
24492
24600
|
}
|
|
24493
|
-
if (source === context.me && isHTMLElement(context.me)) {
|
|
24601
|
+
if (source === context.me && isHTMLElement$2(context.me)) {
|
|
24494
24602
|
const el = context.me;
|
|
24495
24603
|
return format === "html" ? el.outerHTML : el.textContent || "";
|
|
24496
24604
|
}
|
|
@@ -24516,7 +24624,7 @@ var CopyCommand = (() => {
|
|
|
24516
24624
|
}
|
|
24517
24625
|
}
|
|
24518
24626
|
dispatchCopyEvent(context, eventName, detail) {
|
|
24519
|
-
if (isHTMLElement(context.me)) {
|
|
24627
|
+
if (isHTMLElement$2(context.me)) {
|
|
24520
24628
|
const event = new CustomEvent(eventName, { detail, bubbles: true, cancelable: false });
|
|
24521
24629
|
context.me.dispatchEvent(event);
|
|
24522
24630
|
}
|
|
@@ -24856,7 +24964,7 @@ var BeepCommand = (() => {
|
|
|
24856
24964
|
return "undefined";
|
|
24857
24965
|
if (Array.isArray(value))
|
|
24858
24966
|
return "array";
|
|
24859
|
-
if (isHTMLElement(value))
|
|
24967
|
+
if (isHTMLElement$2(value))
|
|
24860
24968
|
return "HTMLElement";
|
|
24861
24969
|
if (value instanceof Element)
|
|
24862
24970
|
return "Element";
|
|
@@ -24878,7 +24986,7 @@ var BeepCommand = (() => {
|
|
|
24878
24986
|
if (Array.isArray(value)) {
|
|
24879
24987
|
return `Array(${value.length}) [${value.slice(0, 3).map((v2) => this.getRepresentation(v2)).join(", ")}${value.length > 3 ? "..." : ""}]`;
|
|
24880
24988
|
}
|
|
24881
|
-
if (isHTMLElement(value)) {
|
|
24989
|
+
if (isHTMLElement$2(value)) {
|
|
24882
24990
|
const el = value;
|
|
24883
24991
|
const tag = el.tagName.toLowerCase();
|
|
24884
24992
|
const id = el.id ? `#${el.id}` : "";
|
|
@@ -25015,16 +25123,16 @@ var InstallCommand = class _InstallCommand {
|
|
|
25015
25123
|
resolveTarget(target, context) {
|
|
25016
25124
|
if (target === void 0 || target === null) {
|
|
25017
25125
|
const me = context.me || context.locals.get("me");
|
|
25018
|
-
if (isHTMLElement(me)) {
|
|
25126
|
+
if (isHTMLElement$2(me)) {
|
|
25019
25127
|
return [me];
|
|
25020
25128
|
}
|
|
25021
25129
|
throw new Error('No target specified and "me" is not available in context');
|
|
25022
25130
|
}
|
|
25023
|
-
if (isHTMLElement(target)) {
|
|
25131
|
+
if (isHTMLElement$2(target)) {
|
|
25024
25132
|
return [target];
|
|
25025
25133
|
}
|
|
25026
25134
|
if (Array.isArray(target)) {
|
|
25027
|
-
const elements = target.filter((t) => isHTMLElement(t));
|
|
25135
|
+
const elements = target.filter((t) => isHTMLElement$2(t));
|
|
25028
25136
|
if (elements.length === 0) {
|
|
25029
25137
|
throw new Error("Target array contains no valid HTMLElements");
|
|
25030
25138
|
}
|
|
@@ -25033,14 +25141,14 @@ var InstallCommand = class _InstallCommand {
|
|
|
25033
25141
|
if (typeof target === "string") {
|
|
25034
25142
|
if (target === "me") {
|
|
25035
25143
|
const me = context.me || context.locals.get("me");
|
|
25036
|
-
if (isHTMLElement(me)) {
|
|
25144
|
+
if (isHTMLElement$2(me)) {
|
|
25037
25145
|
return [me];
|
|
25038
25146
|
}
|
|
25039
25147
|
throw new Error('"me" is not available in context');
|
|
25040
25148
|
}
|
|
25041
25149
|
if (typeof document !== "undefined") {
|
|
25042
25150
|
const elements = document.querySelectorAll(target);
|
|
25043
|
-
const htmlElements = Array.from(elements).filter((el) => isHTMLElement(el));
|
|
25151
|
+
const htmlElements = Array.from(elements).filter((el) => isHTMLElement$2(el));
|
|
25044
25152
|
if (htmlElements.length === 0) {
|
|
25045
25153
|
throw new Error(`No elements found matching selector: "${target}"`);
|
|
25046
25154
|
}
|
|
@@ -25049,7 +25157,7 @@ var InstallCommand = class _InstallCommand {
|
|
|
25049
25157
|
throw new Error("document is not available (not in browser environment)");
|
|
25050
25158
|
}
|
|
25051
25159
|
if (target && typeof target === "object" && "length" in target) {
|
|
25052
|
-
const elements = Array.from(target).filter((t) => isHTMLElement(t));
|
|
25160
|
+
const elements = Array.from(target).filter((t) => isHTMLElement$2(t));
|
|
25053
25161
|
if (elements.length === 0) {
|
|
25054
25162
|
throw new Error("Target collection contains no valid HTMLElements");
|
|
25055
25163
|
}
|
|
@@ -25057,7 +25165,7 @@ var InstallCommand = class _InstallCommand {
|
|
|
25057
25165
|
}
|
|
25058
25166
|
if (typeof target === "object" && "element" in target) {
|
|
25059
25167
|
const element = target.element;
|
|
25060
|
-
if (isHTMLElement(element)) {
|
|
25168
|
+
if (isHTMLElement$2(element)) {
|
|
25061
25169
|
return [element];
|
|
25062
25170
|
}
|
|
25063
25171
|
}
|
|
@@ -31819,20 +31927,6 @@ function withDefaultExtractors(tokenizer) {
|
|
|
31819
31927
|
tokenizer.registerExtractors(getDefaultExtractors$1());
|
|
31820
31928
|
return tokenizer;
|
|
31821
31929
|
}
|
|
31822
|
-
function createUnicodeRangeClassifier(ranges) {
|
|
31823
|
-
return (char) => {
|
|
31824
|
-
const code = char.charCodeAt(0);
|
|
31825
|
-
return ranges.some(([start, end]) => code >= start && code <= end);
|
|
31826
|
-
};
|
|
31827
|
-
}
|
|
31828
|
-
function combineClassifiers(...classifiers) {
|
|
31829
|
-
return (char) => classifiers.some((fn) => fn(char));
|
|
31830
|
-
}
|
|
31831
|
-
function createLatinCharClassifiers(letterPattern) {
|
|
31832
|
-
const isLetter = (char) => letterPattern.test(char);
|
|
31833
|
-
const isIdentifierChar = (char) => isLetter(char) || /[0-9_-]/.test(char);
|
|
31834
|
-
return { isLetter, isIdentifierChar };
|
|
31835
|
-
}
|
|
31836
31930
|
var SIMPLE_TOKENIZER_OPERATOR_SET = new Set(DEFAULT_OPERATORS$1);
|
|
31837
31931
|
var MARKER_CONCEPT_NORMALIZEDS = /* @__PURE__ */ new Set([
|
|
31838
31932
|
// Role-marker role names (profile.roleMarkers normalizeds)
|
|
@@ -32567,6 +32661,115 @@ function createSimpleTokenizer(config2) {
|
|
|
32567
32661
|
}
|
|
32568
32662
|
return new SimpleTokenizer();
|
|
32569
32663
|
}
|
|
32664
|
+
function mergeRoleMarkers(slice, vocab) {
|
|
32665
|
+
const merged = {};
|
|
32666
|
+
const add = (role, marker) => {
|
|
32667
|
+
if (!marker?.primary) {
|
|
32668
|
+
delete merged[role];
|
|
32669
|
+
return;
|
|
32670
|
+
}
|
|
32671
|
+
merged[role] = {
|
|
32672
|
+
primary: marker.primary,
|
|
32673
|
+
...marker.alternatives?.length && { alternatives: [...marker.alternatives] },
|
|
32674
|
+
...marker.position && { position: marker.position }
|
|
32675
|
+
};
|
|
32676
|
+
};
|
|
32677
|
+
for (const [role, marker] of Object.entries(slice.roleMarkers ?? {})) add(role, marker);
|
|
32678
|
+
for (const [role, marker] of Object.entries(vocab.roleMarkerOverrides ?? {})) add(role, marker);
|
|
32679
|
+
return merged;
|
|
32680
|
+
}
|
|
32681
|
+
function buildPatternProfile(slice, vocab) {
|
|
32682
|
+
const keywords = {};
|
|
32683
|
+
for (const [action, translation] of Object.entries(vocab.keywords)) {
|
|
32684
|
+
keywords[action] = {
|
|
32685
|
+
primary: translation.primary,
|
|
32686
|
+
...translation.alternatives?.length && { alternatives: [...translation.alternatives] }
|
|
32687
|
+
};
|
|
32688
|
+
}
|
|
32689
|
+
const roleMarkers = mergeRoleMarkers(slice, vocab);
|
|
32690
|
+
return {
|
|
32691
|
+
code: slice.code,
|
|
32692
|
+
wordOrder: slice.wordOrder,
|
|
32693
|
+
keywords,
|
|
32694
|
+
...Object.keys(roleMarkers).length > 0 && { roleMarkers }
|
|
32695
|
+
};
|
|
32696
|
+
}
|
|
32697
|
+
function defaultCaseInsensitive(script) {
|
|
32698
|
+
return script === void 0 || script === "latin" || script === "cyrillic";
|
|
32699
|
+
}
|
|
32700
|
+
function buildDomainTokenizer(slice, vocab, options = {}) {
|
|
32701
|
+
const roleMarkers = mergeRoleMarkers(slice, vocab);
|
|
32702
|
+
const keywords = /* @__PURE__ */ new Set();
|
|
32703
|
+
for (const translation of Object.values(vocab.keywords)) {
|
|
32704
|
+
keywords.add(translation.primary);
|
|
32705
|
+
for (const alt of translation.alternatives ?? []) keywords.add(alt);
|
|
32706
|
+
}
|
|
32707
|
+
for (const marker of Object.values(roleMarkers)) {
|
|
32708
|
+
keywords.add(marker.primary);
|
|
32709
|
+
for (const alt of marker.alternatives ?? []) keywords.add(alt);
|
|
32710
|
+
}
|
|
32711
|
+
for (const particle of slice.tokenization?.particles ?? []) keywords.add(particle);
|
|
32712
|
+
for (const extra of vocab.tokenizerKeywords ?? []) keywords.add(extra);
|
|
32713
|
+
const profileKeywords = {};
|
|
32714
|
+
for (const [action, translation] of Object.entries(vocab.keywords)) {
|
|
32715
|
+
profileKeywords[action] = {
|
|
32716
|
+
primary: translation.primary,
|
|
32717
|
+
...translation.alternatives?.length && { alternatives: [...translation.alternatives] },
|
|
32718
|
+
normalized: translation.normalized ?? action
|
|
32719
|
+
};
|
|
32720
|
+
}
|
|
32721
|
+
const keywordProfile = {
|
|
32722
|
+
keywords: profileKeywords,
|
|
32723
|
+
...Object.keys(roleMarkers).length > 0 && { roleMarkers }
|
|
32724
|
+
};
|
|
32725
|
+
const customExtractors = [
|
|
32726
|
+
...options.customExtractors ?? [],
|
|
32727
|
+
...slice.script === "latin" ? [new LatinExtendedIdentifierExtractor()] : []
|
|
32728
|
+
];
|
|
32729
|
+
return createSimpleTokenizer({
|
|
32730
|
+
language: slice.code,
|
|
32731
|
+
direction: slice.direction ?? "ltr",
|
|
32732
|
+
keywords: [...keywords],
|
|
32733
|
+
...vocab.keywordExtras?.length && { keywordExtras: vocab.keywordExtras.map((e) => ({ ...e })) },
|
|
32734
|
+
keywordProfile,
|
|
32735
|
+
includeOperators: options.includeOperators ?? false,
|
|
32736
|
+
caseInsensitive: options.caseInsensitive ?? defaultCaseInsensitive(slice.script),
|
|
32737
|
+
...customExtractors.length > 0 && { customExtractors }
|
|
32738
|
+
});
|
|
32739
|
+
}
|
|
32740
|
+
function buildLanguageConfig(slice, vocab, meta2 = {}) {
|
|
32741
|
+
const name = meta2.name ?? slice.name ?? slice.code;
|
|
32742
|
+
return {
|
|
32743
|
+
code: slice.code,
|
|
32744
|
+
name,
|
|
32745
|
+
nativeName: meta2.nativeName ?? slice.nativeName ?? name,
|
|
32746
|
+
tokenizer: meta2.tokenizer ?? buildDomainTokenizer(slice, vocab, meta2.tokenizerOptions),
|
|
32747
|
+
patternProfile: buildPatternProfile(slice, vocab),
|
|
32748
|
+
...meta2.grammarProfile && { grammarProfile: meta2.grammarProfile }
|
|
32749
|
+
};
|
|
32750
|
+
}
|
|
32751
|
+
function deriveRoleMarkers(slice, roleMapping) {
|
|
32752
|
+
const derived = {};
|
|
32753
|
+
for (const [domainRole, semanticRole] of Object.entries(roleMapping)) {
|
|
32754
|
+
const marker = slice.roleMarkers?.[semanticRole];
|
|
32755
|
+
if (marker?.primary) derived[domainRole] = marker.primary;
|
|
32756
|
+
}
|
|
32757
|
+
return derived;
|
|
32758
|
+
}
|
|
32759
|
+
function createUnicodeRangeClassifier(ranges) {
|
|
32760
|
+
return (char) => {
|
|
32761
|
+
const code = char.charCodeAt(0);
|
|
32762
|
+
return ranges.some(([start, end]) => code >= start && code <= end);
|
|
32763
|
+
};
|
|
32764
|
+
}
|
|
32765
|
+
function combineClassifiers(...classifiers) {
|
|
32766
|
+
return (char) => classifiers.some((fn) => fn(char));
|
|
32767
|
+
}
|
|
32768
|
+
function createLatinCharClassifiers(letterPattern) {
|
|
32769
|
+
const isLetter = (char) => letterPattern.test(char);
|
|
32770
|
+
const isIdentifierChar = (char) => isLetter(char) || /[0-9_-]/.test(char);
|
|
32771
|
+
return { isLetter, isIdentifierChar };
|
|
32772
|
+
}
|
|
32570
32773
|
function noChange(word) {
|
|
32571
32774
|
return { stem: word, confidence: 1 };
|
|
32572
32775
|
}
|
|
@@ -33122,7 +33325,10 @@ var index$2 = /* @__PURE__ */ Object.freeze({
|
|
|
33122
33325
|
WhitespaceExtractor,
|
|
33123
33326
|
accumulateBlocks,
|
|
33124
33327
|
buildDisambiguation,
|
|
33328
|
+
buildDomainTokenizer,
|
|
33125
33329
|
buildFeedback,
|
|
33330
|
+
buildLanguageConfig,
|
|
33331
|
+
buildPatternProfile,
|
|
33126
33332
|
buildPhrase,
|
|
33127
33333
|
buildTablesFromProfiles,
|
|
33128
33334
|
combineClassifiers,
|
|
@@ -33153,6 +33359,7 @@ var index$2 = /* @__PURE__ */ Object.freeze({
|
|
|
33153
33359
|
createUnicodeRangeClassifier,
|
|
33154
33360
|
defineCommand,
|
|
33155
33361
|
defineRole,
|
|
33362
|
+
deriveRoleMarkers,
|
|
33156
33363
|
detectWordOrders,
|
|
33157
33364
|
extractCssSelector: extractCssSelector$1,
|
|
33158
33365
|
extractNumber,
|
|
@@ -72313,6 +72520,19 @@ init_tl();
|
|
|
72313
72520
|
init_turkish();
|
|
72314
72521
|
init_ukrainian();
|
|
72315
72522
|
init_vietnamese();
|
|
72523
|
+
function getKeywordTranslations(keyword, languages) {
|
|
72524
|
+
const codes = languages ?? Object.keys(KNOWN_PROFILES);
|
|
72525
|
+
const translations = {};
|
|
72526
|
+
for (const code of codes) {
|
|
72527
|
+
const translation = KNOWN_PROFILES[code]?.keywords[keyword];
|
|
72528
|
+
if (translation) translations[code] = translation;
|
|
72529
|
+
}
|
|
72530
|
+
return translations;
|
|
72531
|
+
}
|
|
72532
|
+
function getRoleMarkers(language, role) {
|
|
72533
|
+
const markers = KNOWN_PROFILES[language]?.roleMarkers ?? {};
|
|
72534
|
+
return role ? markers[role] : markers;
|
|
72535
|
+
}
|
|
72316
72536
|
init_command_schemas();
|
|
72317
72537
|
init_pattern_generator();
|
|
72318
72538
|
init_schema_validator();
|
|
@@ -73212,6 +73432,7 @@ var index$1 = /* @__PURE__ */ Object.freeze({
|
|
|
73212
73432
|
getEventHandlerPatternsForLanguage,
|
|
73213
73433
|
getGeneratorSummary,
|
|
73214
73434
|
getHyperscriptExtractors,
|
|
73435
|
+
getKeywordTranslations,
|
|
73215
73436
|
getLoadedLanguages,
|
|
73216
73437
|
getPatternById,
|
|
73217
73438
|
getPatternStats,
|
|
@@ -73220,6 +73441,7 @@ var index$1 = /* @__PURE__ */ Object.freeze({
|
|
|
73220
73441
|
getPutPatternsForLanguage,
|
|
73221
73442
|
getRegisteredLanguages,
|
|
73222
73443
|
getRegisteredMappers,
|
|
73444
|
+
getRoleMarkers,
|
|
73223
73445
|
getSchema,
|
|
73224
73446
|
getSchemasByCategory,
|
|
73225
73447
|
getSupportedCommands,
|
|
@@ -73378,9 +73600,9 @@ function createHistorySwap(config2) {
|
|
|
73378
73600
|
const resolveTarget = () => {
|
|
73379
73601
|
if (typeof target === "string") {
|
|
73380
73602
|
const element = document.querySelector(target);
|
|
73381
|
-
return isHTMLElement(element) ? element : null;
|
|
73603
|
+
return isHTMLElement$2(element) ? element : null;
|
|
73382
73604
|
}
|
|
73383
|
-
return isHTMLElement(target) ? target : null;
|
|
73605
|
+
return isHTMLElement$2(target) ? target : null;
|
|
73384
73606
|
};
|
|
73385
73607
|
const handlePopstate = async (_event) => {
|
|
73386
73608
|
const targetElement = resolveTarget();
|
|
@@ -73491,9 +73713,9 @@ function createBoosted(config2) {
|
|
|
73491
73713
|
}
|
|
73492
73714
|
if (typeof target === "string") {
|
|
73493
73715
|
const element = document.querySelector(target);
|
|
73494
|
-
return isHTMLElement(element) ? element : null;
|
|
73716
|
+
return isHTMLElement$2(element) ? element : null;
|
|
73495
73717
|
}
|
|
73496
|
-
return isHTMLElement(target) ? target : null;
|
|
73718
|
+
return isHTMLElement$2(target) ? target : null;
|
|
73497
73719
|
};
|
|
73498
73720
|
const boost = async (url, method = "GET", body = null) => {
|
|
73499
73721
|
const targetElement = resolveTarget();
|
|
@@ -74254,7 +74476,8 @@ var config = {
|
|
|
74254
74476
|
language: "en",
|
|
74255
74477
|
confidenceThreshold: DEFAULT_CONFIDENCE_THRESHOLD,
|
|
74256
74478
|
logAll: false,
|
|
74257
|
-
conversions: conversionConfig.conversions
|
|
74479
|
+
conversions: conversionConfig.conversions,
|
|
74480
|
+
onCompileError: null
|
|
74258
74481
|
};
|
|
74259
74482
|
async function getOrCreateBridge() {
|
|
74260
74483
|
if (!bridgeInstance) {
|
|
@@ -81741,6 +81964,8 @@ export {
|
|
|
81741
81964
|
formatIssuesAsStrings,
|
|
81742
81965
|
formatResultSummary,
|
|
81743
81966
|
fromCoreAST,
|
|
81967
|
+
getElementScopeMap,
|
|
81968
|
+
getElementVar,
|
|
81744
81969
|
getParserExtensionRegistry,
|
|
81745
81970
|
getPartialValidationConfig,
|
|
81746
81971
|
hyperscript,
|
|
@@ -81748,8 +81973,10 @@ export {
|
|
|
81748
81973
|
lokascript,
|
|
81749
81974
|
parse$1 as parse,
|
|
81750
81975
|
resetPartialValidationConfig,
|
|
81976
|
+
resolveScopeOwner,
|
|
81977
|
+
setElementVar,
|
|
81751
81978
|
setGlobal,
|
|
81752
81979
|
toCoreAST,
|
|
81753
81980
|
validatePartialContent
|
|
81754
81981
|
};
|
|
81755
|
-
//# sourceMappingURL=dist-
|
|
81982
|
+
//# sourceMappingURL=dist-HSJGJ5HF.js.map
|