@hyperfixi/core 2.7.1 → 2.8.0
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/api/hyperscript-api.d.ts +1 -0
- package/dist/ast-utils/index.js +1910 -233
- package/dist/ast-utils/index.mjs +1910 -233
- package/dist/behaviors/index.js +10 -1
- package/dist/behaviors/index.mjs +10 -1
- package/dist/bundle-generator/index.d.ts +1 -1
- package/dist/bundle-generator/index.js +77 -68
- package/dist/bundle-generator/index.mjs +76 -69
- package/dist/bundle-generator/template-capabilities.d.ts +2 -0
- package/dist/chunks/bridge-DHj-SYm2.js +2 -0
- package/dist/chunks/browser-modular-D1m0Eikh.js +2 -0
- package/dist/chunks/{index-i_j9Z-1e.js → index-CuPeasRm.js} +2 -2
- package/dist/commands/index.js +127 -6
- package/dist/commands/index.mjs +127 -6
- package/dist/compatibility/browser-modular.d.ts +2 -2
- package/dist/expressions/index.d.ts +1 -1
- package/dist/htmx/hcon.d.ts +9 -0
- package/dist/htmx/htmx-translator.d.ts +1 -0
- package/dist/hyperfixi-browser-classic-i18n.js +1 -1
- package/dist/hyperfixi-browser-minimal.js +1 -1
- package/dist/hyperfixi-browser-standard.js +1 -1
- package/dist/hyperfixi-browser.js +1 -1
- package/dist/hyperfixi-classic-i18n.js +1 -1
- package/dist/hyperfixi-hx-v4.js +1 -1
- package/dist/hyperfixi-hx.js +1 -1
- package/dist/hyperfixi-hybrid-complete.js +1 -1
- package/dist/hyperfixi-hybrid-hx.js +1 -1
- package/dist/hyperfixi-minimal.js +1 -1
- package/dist/hyperfixi-multilingual.js +1 -1
- package/dist/hyperfixi-standard.js +1 -1
- package/dist/hyperfixi.js +1 -1
- package/dist/hyperfixi.mjs +1 -1
- package/dist/index.js +4527 -536
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +4527 -536
- package/dist/lib/dom-globals-shim.d.ts +2 -0
- package/dist/lokascript-browser-classic-i18n.js +1 -1
- package/dist/lokascript-browser-minimal.js +1 -1
- package/dist/lokascript-browser-standard.js +1 -1
- package/dist/lokascript-browser.js +1 -1
- package/dist/lokascript-hybrid-complete.js +1 -1
- package/dist/lokascript-hybrid-hx.js +1 -1
- package/dist/lokascript-multilingual.js +1 -1
- package/dist/lse/index.d.ts +7 -7
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.js +31 -14
- package/dist/metadata.mjs +31 -14
- package/dist/multilingual/index.js +8 -1
- package/dist/multilingual/index.mjs +8 -1
- package/dist/parser/command-parsers/animation-commands.d.ts +2 -2
- package/dist/parser/command-parsers/async-commands.d.ts +2 -2
- package/dist/parser/command-parsers/dom-commands.d.ts +5 -5
- package/dist/parser/command-parsers/navigation-commands.d.ts +4 -0
- package/dist/parser/command-parsers/utility-commands.d.ts +2 -1
- package/dist/parser/command-parsers/variable-commands.d.ts +2 -2
- package/dist/parser/full-parser.js +117 -5
- package/dist/parser/full-parser.mjs +117 -5
- package/dist/parser/semantic-integration.d.ts +1 -0
- package/dist/performance/integration.d.ts +1 -1
- package/dist/registry/index.js +117 -5
- package/dist/registry/index.mjs +117 -5
- package/package.json +13 -20
- package/dist/chunks/bridge-lZbOVRDD.js +0 -2
- package/dist/chunks/browser-modular-DegkWQ8d.js +0 -2
- package/dist/compatibility/browser-bundle-animation-generated.d.ts +0 -16
- package/dist/compatibility/browser-bundle-forms-generated.d.ts +0 -16
- package/dist/compatibility/browser-bundle-minimal-generated.d.ts +0 -16
|
@@ -107,6 +107,7 @@ const COMPOUND_COMMANDS = new Set([
|
|
|
107
107
|
'halt',
|
|
108
108
|
'measure',
|
|
109
109
|
'js',
|
|
110
|
+
'go',
|
|
110
111
|
'tell',
|
|
111
112
|
'pick',
|
|
112
113
|
'start',
|
|
@@ -1569,9 +1570,6 @@ class SemanticIntegrationAdapter {
|
|
|
1569
1570
|
case 'responseType':
|
|
1570
1571
|
modifiers['as'] = exprNode;
|
|
1571
1572
|
break;
|
|
1572
|
-
case 'method':
|
|
1573
|
-
modifiers['method'] = exprNode;
|
|
1574
|
-
break;
|
|
1575
1573
|
case 'style':
|
|
1576
1574
|
modifiers['with'] = exprNode;
|
|
1577
1575
|
break;
|
|
@@ -4226,6 +4224,117 @@ function parseIncrementDecrementCommand(ctx, commandToken) {
|
|
|
4226
4224
|
.build();
|
|
4227
4225
|
}
|
|
4228
4226
|
|
|
4227
|
+
const GO_KEYWORDS = new Set([
|
|
4228
|
+
'to',
|
|
4229
|
+
'the',
|
|
4230
|
+
'url',
|
|
4231
|
+
'of',
|
|
4232
|
+
'in',
|
|
4233
|
+
'new',
|
|
4234
|
+
'window',
|
|
4235
|
+
'top',
|
|
4236
|
+
'middle',
|
|
4237
|
+
'bottom',
|
|
4238
|
+
'left',
|
|
4239
|
+
'center',
|
|
4240
|
+
'right',
|
|
4241
|
+
'smoothly',
|
|
4242
|
+
'instantly',
|
|
4243
|
+
'back',
|
|
4244
|
+
'forward',
|
|
4245
|
+
]);
|
|
4246
|
+
const GO_URL_STOP = new Set([
|
|
4247
|
+
'in',
|
|
4248
|
+
'then',
|
|
4249
|
+
'and',
|
|
4250
|
+
'else',
|
|
4251
|
+
'end',
|
|
4252
|
+
'otherwise',
|
|
4253
|
+
'when',
|
|
4254
|
+
'where',
|
|
4255
|
+
'catch',
|
|
4256
|
+
'finally',
|
|
4257
|
+
]);
|
|
4258
|
+
function isGoURLTerminator(ctx) {
|
|
4259
|
+
return ctx.isAtEnd() || GO_URL_STOP.has(ctx.peek().value);
|
|
4260
|
+
}
|
|
4261
|
+
function stringNode(value, tok) {
|
|
4262
|
+
return {
|
|
4263
|
+
type: 'string',
|
|
4264
|
+
value,
|
|
4265
|
+
start: tok.start,
|
|
4266
|
+
end: tok.end,
|
|
4267
|
+
line: tok.line,
|
|
4268
|
+
column: tok.column,
|
|
4269
|
+
};
|
|
4270
|
+
}
|
|
4271
|
+
function isNakedURLStart(ctx) {
|
|
4272
|
+
const tok = ctx.peek();
|
|
4273
|
+
if (tok.value === '/')
|
|
4274
|
+
return true;
|
|
4275
|
+
if (ctx.checkIdentifierLike()) {
|
|
4276
|
+
const next = ctx.peekAt(1);
|
|
4277
|
+
return !!next && next.value === ':' && next.start === tok.end;
|
|
4278
|
+
}
|
|
4279
|
+
return false;
|
|
4280
|
+
}
|
|
4281
|
+
function parseGoCommand(ctx, identifierNode) {
|
|
4282
|
+
const args = [];
|
|
4283
|
+
while (!isCommandBoundary(ctx, ['when', 'where', 'catch', 'finally'])) {
|
|
4284
|
+
const tok = ctx.peek();
|
|
4285
|
+
const canonical = ctx.resolveKeyword(tok.value).toLowerCase();
|
|
4286
|
+
if (GO_KEYWORDS.has(canonical)) {
|
|
4287
|
+
ctx.advance();
|
|
4288
|
+
args.push(stringNode(canonical, tok));
|
|
4289
|
+
continue;
|
|
4290
|
+
}
|
|
4291
|
+
if (isNakedURLStart(ctx)) {
|
|
4292
|
+
const url = parseBareURLPath(ctx, isGoURLTerminator);
|
|
4293
|
+
if (url) {
|
|
4294
|
+
args.push(url);
|
|
4295
|
+
continue;
|
|
4296
|
+
}
|
|
4297
|
+
ctx.advance();
|
|
4298
|
+
args.push(stringNode(tok.value, tok));
|
|
4299
|
+
continue;
|
|
4300
|
+
}
|
|
4301
|
+
if (tok.value === '+' || tok.value === '-') {
|
|
4302
|
+
ctx.advance();
|
|
4303
|
+
args.push(stringNode(tok.value, tok));
|
|
4304
|
+
continue;
|
|
4305
|
+
}
|
|
4306
|
+
if (tok.kind === 'number') {
|
|
4307
|
+
ctx.advance();
|
|
4308
|
+
const next = ctx.peek();
|
|
4309
|
+
if (!ctx.isAtEnd() && next.value === 'px' && next.start === tok.end) {
|
|
4310
|
+
const px = ctx.advance();
|
|
4311
|
+
args.push(stringNode(`${tok.value}px`, { ...tok, end: px.end }));
|
|
4312
|
+
}
|
|
4313
|
+
else {
|
|
4314
|
+
args.push({
|
|
4315
|
+
type: 'literal',
|
|
4316
|
+
value: Number(tok.value),
|
|
4317
|
+
raw: tok.value,
|
|
4318
|
+
start: tok.start,
|
|
4319
|
+
end: tok.end,
|
|
4320
|
+
line: tok.line,
|
|
4321
|
+
column: tok.column,
|
|
4322
|
+
});
|
|
4323
|
+
}
|
|
4324
|
+
continue;
|
|
4325
|
+
}
|
|
4326
|
+
const before = ctx.current;
|
|
4327
|
+
args.push(ctx.parsePrimary());
|
|
4328
|
+
if (ctx.current === before) {
|
|
4329
|
+
break;
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
return CommandNodeBuilder.fromIdentifier(identifierNode)
|
|
4333
|
+
.withArgs(...args)
|
|
4334
|
+
.endingAt(ctx.getPosition())
|
|
4335
|
+
.build();
|
|
4336
|
+
}
|
|
4337
|
+
|
|
4229
4338
|
function parseCompoundCommand(ctx, identifierNode) {
|
|
4230
4339
|
const commandName = identifierNode.name.toLowerCase();
|
|
4231
4340
|
switch (commandName) {
|
|
@@ -4246,6 +4355,8 @@ function parseCompoundCommand(ctx, identifierNode) {
|
|
|
4246
4355
|
return parseMeasureCommand(ctx, identifierNode);
|
|
4247
4356
|
case 'js':
|
|
4248
4357
|
return parseJsCommand(ctx, identifierNode);
|
|
4358
|
+
case 'go':
|
|
4359
|
+
return parseGoCommand(ctx, identifierNode);
|
|
4249
4360
|
case 'tell':
|
|
4250
4361
|
return parseTellCommand(ctx, identifierNode);
|
|
4251
4362
|
case 'pick':
|
|
@@ -4325,10 +4436,10 @@ function isFetchURLTerminator(ctx) {
|
|
|
4325
4436
|
return (['as', 'with', '{', 'then', 'end', 'else', 'otherwise', ')'].includes(val) ||
|
|
4326
4437
|
isCommandBoundary(ctx));
|
|
4327
4438
|
}
|
|
4328
|
-
function parseBareURLPath(ctx) {
|
|
4439
|
+
function parseBareURLPath(ctx, isTerminator = isFetchURLTerminator) {
|
|
4329
4440
|
const startPos = ctx.savePosition();
|
|
4330
4441
|
let path = '';
|
|
4331
|
-
while (!ctx.isAtEnd() && !
|
|
4442
|
+
while (!ctx.isAtEnd() && !isTerminator(ctx)) {
|
|
4332
4443
|
path += ctx.advance().value;
|
|
4333
4444
|
}
|
|
4334
4445
|
if (!path || path === '/') {
|
|
@@ -6858,6 +6969,7 @@ class Parser {
|
|
|
6858
6969
|
'closest',
|
|
6859
6970
|
'js',
|
|
6860
6971
|
'tell',
|
|
6972
|
+
'fetch',
|
|
6861
6973
|
];
|
|
6862
6974
|
if (this.semanticAdapter && !skipSemanticParsing.includes(commandName.toLowerCase())) {
|
|
6863
6975
|
const remainingInput = this.getRemainingInput();
|
|
@@ -23,7 +23,7 @@ export declare function queryWithCache(selector: string): Element | null;
|
|
|
23
23
|
export declare function queryAllWithCache(selector: string): Element[];
|
|
24
24
|
export declare function matchesWithCache(element: Element, selector: string): boolean;
|
|
25
25
|
export declare function wrapExpressionForPerformance(expression: ExpressionImplementation): ExpressionImplementation;
|
|
26
|
-
export declare function tokenizeWithPerformance(input: string): import("
|
|
26
|
+
export declare function tokenizeWithPerformance(input: string): import("..").Token[];
|
|
27
27
|
export declare function performCleanup(): void;
|
|
28
28
|
export declare function enableAutoCleanup(intervalMs?: number): void;
|
|
29
29
|
export declare function disableAutoCleanup(): void;
|
package/dist/registry/index.js
CHANGED
|
@@ -446,6 +446,7 @@ const COMPOUND_COMMANDS = new Set([
|
|
|
446
446
|
'halt',
|
|
447
447
|
'measure',
|
|
448
448
|
'js',
|
|
449
|
+
'go',
|
|
449
450
|
'tell',
|
|
450
451
|
'pick',
|
|
451
452
|
'start',
|
|
@@ -5126,9 +5127,6 @@ class SemanticIntegrationAdapter {
|
|
|
5126
5127
|
case 'responseType':
|
|
5127
5128
|
modifiers['as'] = exprNode;
|
|
5128
5129
|
break;
|
|
5129
|
-
case 'method':
|
|
5130
|
-
modifiers['method'] = exprNode;
|
|
5131
|
-
break;
|
|
5132
5130
|
case 'style':
|
|
5133
5131
|
modifiers['with'] = exprNode;
|
|
5134
5132
|
break;
|
|
@@ -7274,6 +7272,117 @@ function parseIncrementDecrementCommand(ctx, commandToken) {
|
|
|
7274
7272
|
.build();
|
|
7275
7273
|
}
|
|
7276
7274
|
|
|
7275
|
+
const GO_KEYWORDS = new Set([
|
|
7276
|
+
'to',
|
|
7277
|
+
'the',
|
|
7278
|
+
'url',
|
|
7279
|
+
'of',
|
|
7280
|
+
'in',
|
|
7281
|
+
'new',
|
|
7282
|
+
'window',
|
|
7283
|
+
'top',
|
|
7284
|
+
'middle',
|
|
7285
|
+
'bottom',
|
|
7286
|
+
'left',
|
|
7287
|
+
'center',
|
|
7288
|
+
'right',
|
|
7289
|
+
'smoothly',
|
|
7290
|
+
'instantly',
|
|
7291
|
+
'back',
|
|
7292
|
+
'forward',
|
|
7293
|
+
]);
|
|
7294
|
+
const GO_URL_STOP = new Set([
|
|
7295
|
+
'in',
|
|
7296
|
+
'then',
|
|
7297
|
+
'and',
|
|
7298
|
+
'else',
|
|
7299
|
+
'end',
|
|
7300
|
+
'otherwise',
|
|
7301
|
+
'when',
|
|
7302
|
+
'where',
|
|
7303
|
+
'catch',
|
|
7304
|
+
'finally',
|
|
7305
|
+
]);
|
|
7306
|
+
function isGoURLTerminator(ctx) {
|
|
7307
|
+
return ctx.isAtEnd() || GO_URL_STOP.has(ctx.peek().value);
|
|
7308
|
+
}
|
|
7309
|
+
function stringNode(value, tok) {
|
|
7310
|
+
return {
|
|
7311
|
+
type: 'string',
|
|
7312
|
+
value,
|
|
7313
|
+
start: tok.start,
|
|
7314
|
+
end: tok.end,
|
|
7315
|
+
line: tok.line,
|
|
7316
|
+
column: tok.column,
|
|
7317
|
+
};
|
|
7318
|
+
}
|
|
7319
|
+
function isNakedURLStart(ctx) {
|
|
7320
|
+
const tok = ctx.peek();
|
|
7321
|
+
if (tok.value === '/')
|
|
7322
|
+
return true;
|
|
7323
|
+
if (ctx.checkIdentifierLike()) {
|
|
7324
|
+
const next = ctx.peekAt(1);
|
|
7325
|
+
return !!next && next.value === ':' && next.start === tok.end;
|
|
7326
|
+
}
|
|
7327
|
+
return false;
|
|
7328
|
+
}
|
|
7329
|
+
function parseGoCommand(ctx, identifierNode) {
|
|
7330
|
+
const args = [];
|
|
7331
|
+
while (!isCommandBoundary(ctx, ['when', 'where', 'catch', 'finally'])) {
|
|
7332
|
+
const tok = ctx.peek();
|
|
7333
|
+
const canonical = ctx.resolveKeyword(tok.value).toLowerCase();
|
|
7334
|
+
if (GO_KEYWORDS.has(canonical)) {
|
|
7335
|
+
ctx.advance();
|
|
7336
|
+
args.push(stringNode(canonical, tok));
|
|
7337
|
+
continue;
|
|
7338
|
+
}
|
|
7339
|
+
if (isNakedURLStart(ctx)) {
|
|
7340
|
+
const url = parseBareURLPath(ctx, isGoURLTerminator);
|
|
7341
|
+
if (url) {
|
|
7342
|
+
args.push(url);
|
|
7343
|
+
continue;
|
|
7344
|
+
}
|
|
7345
|
+
ctx.advance();
|
|
7346
|
+
args.push(stringNode(tok.value, tok));
|
|
7347
|
+
continue;
|
|
7348
|
+
}
|
|
7349
|
+
if (tok.value === '+' || tok.value === '-') {
|
|
7350
|
+
ctx.advance();
|
|
7351
|
+
args.push(stringNode(tok.value, tok));
|
|
7352
|
+
continue;
|
|
7353
|
+
}
|
|
7354
|
+
if (tok.kind === 'number') {
|
|
7355
|
+
ctx.advance();
|
|
7356
|
+
const next = ctx.peek();
|
|
7357
|
+
if (!ctx.isAtEnd() && next.value === 'px' && next.start === tok.end) {
|
|
7358
|
+
const px = ctx.advance();
|
|
7359
|
+
args.push(stringNode(`${tok.value}px`, { ...tok, end: px.end }));
|
|
7360
|
+
}
|
|
7361
|
+
else {
|
|
7362
|
+
args.push({
|
|
7363
|
+
type: 'literal',
|
|
7364
|
+
value: Number(tok.value),
|
|
7365
|
+
raw: tok.value,
|
|
7366
|
+
start: tok.start,
|
|
7367
|
+
end: tok.end,
|
|
7368
|
+
line: tok.line,
|
|
7369
|
+
column: tok.column,
|
|
7370
|
+
});
|
|
7371
|
+
}
|
|
7372
|
+
continue;
|
|
7373
|
+
}
|
|
7374
|
+
const before = ctx.current;
|
|
7375
|
+
args.push(ctx.parsePrimary());
|
|
7376
|
+
if (ctx.current === before) {
|
|
7377
|
+
break;
|
|
7378
|
+
}
|
|
7379
|
+
}
|
|
7380
|
+
return CommandNodeBuilder.fromIdentifier(identifierNode)
|
|
7381
|
+
.withArgs(...args)
|
|
7382
|
+
.endingAt(ctx.getPosition())
|
|
7383
|
+
.build();
|
|
7384
|
+
}
|
|
7385
|
+
|
|
7277
7386
|
function parseCompoundCommand(ctx, identifierNode) {
|
|
7278
7387
|
const commandName = identifierNode.name.toLowerCase();
|
|
7279
7388
|
switch (commandName) {
|
|
@@ -7294,6 +7403,8 @@ function parseCompoundCommand(ctx, identifierNode) {
|
|
|
7294
7403
|
return parseMeasureCommand(ctx, identifierNode);
|
|
7295
7404
|
case 'js':
|
|
7296
7405
|
return parseJsCommand(ctx, identifierNode);
|
|
7406
|
+
case 'go':
|
|
7407
|
+
return parseGoCommand(ctx, identifierNode);
|
|
7297
7408
|
case 'tell':
|
|
7298
7409
|
return parseTellCommand(ctx, identifierNode);
|
|
7299
7410
|
case 'pick':
|
|
@@ -7373,10 +7484,10 @@ function isFetchURLTerminator(ctx) {
|
|
|
7373
7484
|
return (['as', 'with', '{', 'then', 'end', 'else', 'otherwise', ')'].includes(val) ||
|
|
7374
7485
|
isCommandBoundary(ctx));
|
|
7375
7486
|
}
|
|
7376
|
-
function parseBareURLPath(ctx) {
|
|
7487
|
+
function parseBareURLPath(ctx, isTerminator = isFetchURLTerminator) {
|
|
7377
7488
|
const startPos = ctx.savePosition();
|
|
7378
7489
|
let path = '';
|
|
7379
|
-
while (!ctx.isAtEnd() && !
|
|
7490
|
+
while (!ctx.isAtEnd() && !isTerminator(ctx)) {
|
|
7380
7491
|
path += ctx.advance().value;
|
|
7381
7492
|
}
|
|
7382
7493
|
if (!path || path === '/') {
|
|
@@ -9906,6 +10017,7 @@ class Parser {
|
|
|
9906
10017
|
'closest',
|
|
9907
10018
|
'js',
|
|
9908
10019
|
'tell',
|
|
10020
|
+
'fetch',
|
|
9909
10021
|
];
|
|
9910
10022
|
if (this.semanticAdapter && !skipSemanticParsing.includes(commandName.toLowerCase())) {
|
|
9911
10023
|
const remainingInput = this.getRemainingInput();
|
package/dist/registry/index.mjs
CHANGED
|
@@ -444,6 +444,7 @@ const COMPOUND_COMMANDS = new Set([
|
|
|
444
444
|
'halt',
|
|
445
445
|
'measure',
|
|
446
446
|
'js',
|
|
447
|
+
'go',
|
|
447
448
|
'tell',
|
|
448
449
|
'pick',
|
|
449
450
|
'start',
|
|
@@ -5124,9 +5125,6 @@ class SemanticIntegrationAdapter {
|
|
|
5124
5125
|
case 'responseType':
|
|
5125
5126
|
modifiers['as'] = exprNode;
|
|
5126
5127
|
break;
|
|
5127
|
-
case 'method':
|
|
5128
|
-
modifiers['method'] = exprNode;
|
|
5129
|
-
break;
|
|
5130
5128
|
case 'style':
|
|
5131
5129
|
modifiers['with'] = exprNode;
|
|
5132
5130
|
break;
|
|
@@ -7272,6 +7270,117 @@ function parseIncrementDecrementCommand(ctx, commandToken) {
|
|
|
7272
7270
|
.build();
|
|
7273
7271
|
}
|
|
7274
7272
|
|
|
7273
|
+
const GO_KEYWORDS = new Set([
|
|
7274
|
+
'to',
|
|
7275
|
+
'the',
|
|
7276
|
+
'url',
|
|
7277
|
+
'of',
|
|
7278
|
+
'in',
|
|
7279
|
+
'new',
|
|
7280
|
+
'window',
|
|
7281
|
+
'top',
|
|
7282
|
+
'middle',
|
|
7283
|
+
'bottom',
|
|
7284
|
+
'left',
|
|
7285
|
+
'center',
|
|
7286
|
+
'right',
|
|
7287
|
+
'smoothly',
|
|
7288
|
+
'instantly',
|
|
7289
|
+
'back',
|
|
7290
|
+
'forward',
|
|
7291
|
+
]);
|
|
7292
|
+
const GO_URL_STOP = new Set([
|
|
7293
|
+
'in',
|
|
7294
|
+
'then',
|
|
7295
|
+
'and',
|
|
7296
|
+
'else',
|
|
7297
|
+
'end',
|
|
7298
|
+
'otherwise',
|
|
7299
|
+
'when',
|
|
7300
|
+
'where',
|
|
7301
|
+
'catch',
|
|
7302
|
+
'finally',
|
|
7303
|
+
]);
|
|
7304
|
+
function isGoURLTerminator(ctx) {
|
|
7305
|
+
return ctx.isAtEnd() || GO_URL_STOP.has(ctx.peek().value);
|
|
7306
|
+
}
|
|
7307
|
+
function stringNode(value, tok) {
|
|
7308
|
+
return {
|
|
7309
|
+
type: 'string',
|
|
7310
|
+
value,
|
|
7311
|
+
start: tok.start,
|
|
7312
|
+
end: tok.end,
|
|
7313
|
+
line: tok.line,
|
|
7314
|
+
column: tok.column,
|
|
7315
|
+
};
|
|
7316
|
+
}
|
|
7317
|
+
function isNakedURLStart(ctx) {
|
|
7318
|
+
const tok = ctx.peek();
|
|
7319
|
+
if (tok.value === '/')
|
|
7320
|
+
return true;
|
|
7321
|
+
if (ctx.checkIdentifierLike()) {
|
|
7322
|
+
const next = ctx.peekAt(1);
|
|
7323
|
+
return !!next && next.value === ':' && next.start === tok.end;
|
|
7324
|
+
}
|
|
7325
|
+
return false;
|
|
7326
|
+
}
|
|
7327
|
+
function parseGoCommand(ctx, identifierNode) {
|
|
7328
|
+
const args = [];
|
|
7329
|
+
while (!isCommandBoundary(ctx, ['when', 'where', 'catch', 'finally'])) {
|
|
7330
|
+
const tok = ctx.peek();
|
|
7331
|
+
const canonical = ctx.resolveKeyword(tok.value).toLowerCase();
|
|
7332
|
+
if (GO_KEYWORDS.has(canonical)) {
|
|
7333
|
+
ctx.advance();
|
|
7334
|
+
args.push(stringNode(canonical, tok));
|
|
7335
|
+
continue;
|
|
7336
|
+
}
|
|
7337
|
+
if (isNakedURLStart(ctx)) {
|
|
7338
|
+
const url = parseBareURLPath(ctx, isGoURLTerminator);
|
|
7339
|
+
if (url) {
|
|
7340
|
+
args.push(url);
|
|
7341
|
+
continue;
|
|
7342
|
+
}
|
|
7343
|
+
ctx.advance();
|
|
7344
|
+
args.push(stringNode(tok.value, tok));
|
|
7345
|
+
continue;
|
|
7346
|
+
}
|
|
7347
|
+
if (tok.value === '+' || tok.value === '-') {
|
|
7348
|
+
ctx.advance();
|
|
7349
|
+
args.push(stringNode(tok.value, tok));
|
|
7350
|
+
continue;
|
|
7351
|
+
}
|
|
7352
|
+
if (tok.kind === 'number') {
|
|
7353
|
+
ctx.advance();
|
|
7354
|
+
const next = ctx.peek();
|
|
7355
|
+
if (!ctx.isAtEnd() && next.value === 'px' && next.start === tok.end) {
|
|
7356
|
+
const px = ctx.advance();
|
|
7357
|
+
args.push(stringNode(`${tok.value}px`, { ...tok, end: px.end }));
|
|
7358
|
+
}
|
|
7359
|
+
else {
|
|
7360
|
+
args.push({
|
|
7361
|
+
type: 'literal',
|
|
7362
|
+
value: Number(tok.value),
|
|
7363
|
+
raw: tok.value,
|
|
7364
|
+
start: tok.start,
|
|
7365
|
+
end: tok.end,
|
|
7366
|
+
line: tok.line,
|
|
7367
|
+
column: tok.column,
|
|
7368
|
+
});
|
|
7369
|
+
}
|
|
7370
|
+
continue;
|
|
7371
|
+
}
|
|
7372
|
+
const before = ctx.current;
|
|
7373
|
+
args.push(ctx.parsePrimary());
|
|
7374
|
+
if (ctx.current === before) {
|
|
7375
|
+
break;
|
|
7376
|
+
}
|
|
7377
|
+
}
|
|
7378
|
+
return CommandNodeBuilder.fromIdentifier(identifierNode)
|
|
7379
|
+
.withArgs(...args)
|
|
7380
|
+
.endingAt(ctx.getPosition())
|
|
7381
|
+
.build();
|
|
7382
|
+
}
|
|
7383
|
+
|
|
7275
7384
|
function parseCompoundCommand(ctx, identifierNode) {
|
|
7276
7385
|
const commandName = identifierNode.name.toLowerCase();
|
|
7277
7386
|
switch (commandName) {
|
|
@@ -7292,6 +7401,8 @@ function parseCompoundCommand(ctx, identifierNode) {
|
|
|
7292
7401
|
return parseMeasureCommand(ctx, identifierNode);
|
|
7293
7402
|
case 'js':
|
|
7294
7403
|
return parseJsCommand(ctx, identifierNode);
|
|
7404
|
+
case 'go':
|
|
7405
|
+
return parseGoCommand(ctx, identifierNode);
|
|
7295
7406
|
case 'tell':
|
|
7296
7407
|
return parseTellCommand(ctx, identifierNode);
|
|
7297
7408
|
case 'pick':
|
|
@@ -7371,10 +7482,10 @@ function isFetchURLTerminator(ctx) {
|
|
|
7371
7482
|
return (['as', 'with', '{', 'then', 'end', 'else', 'otherwise', ')'].includes(val) ||
|
|
7372
7483
|
isCommandBoundary(ctx));
|
|
7373
7484
|
}
|
|
7374
|
-
function parseBareURLPath(ctx) {
|
|
7485
|
+
function parseBareURLPath(ctx, isTerminator = isFetchURLTerminator) {
|
|
7375
7486
|
const startPos = ctx.savePosition();
|
|
7376
7487
|
let path = '';
|
|
7377
|
-
while (!ctx.isAtEnd() && !
|
|
7488
|
+
while (!ctx.isAtEnd() && !isTerminator(ctx)) {
|
|
7378
7489
|
path += ctx.advance().value;
|
|
7379
7490
|
}
|
|
7380
7491
|
if (!path || path === '/') {
|
|
@@ -9904,6 +10015,7 @@ class Parser {
|
|
|
9904
10015
|
'closest',
|
|
9905
10016
|
'js',
|
|
9906
10017
|
'tell',
|
|
10018
|
+
'fetch',
|
|
9907
10019
|
];
|
|
9908
10020
|
if (this.semanticAdapter && !skipSemanticParsing.includes(commandName.toLowerCase())) {
|
|
9909
10021
|
const remainingInput = this.getRemainingInput();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperfixi/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Multilingual, tree-shakeable hyperscript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -218,8 +218,6 @@
|
|
|
218
218
|
"test:quick": "npm run build:browser && bash ../../scripts/vitest-run.sh --reporter=dot",
|
|
219
219
|
"test:prod": "NODE_ENV=production node production-test-runner.js --quiet",
|
|
220
220
|
"test:prod:verbose": "node production-test-runner.js",
|
|
221
|
-
"lint": "eslint src/**/*.ts",
|
|
222
|
-
"lint:fix": "eslint src/**/*.ts --fix",
|
|
223
221
|
"typecheck": "tsc --noEmit",
|
|
224
222
|
"clean": "rm -rf dist",
|
|
225
223
|
"analyze:usage": "node scripts/analyze-usage.mjs",
|
|
@@ -230,31 +228,26 @@
|
|
|
230
228
|
"update:sizes:auto": "tsx scripts/update-bundle-sizes.ts --update"
|
|
231
229
|
},
|
|
232
230
|
"devDependencies": {
|
|
233
|
-
"@playwright/test": "^1.
|
|
231
|
+
"@playwright/test": "^1.61.1",
|
|
234
232
|
"@rollup/plugin-alias": "^6.0.0",
|
|
235
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
233
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
236
234
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
237
235
|
"@rollup/plugin-replace": "^6.0.3",
|
|
238
236
|
"@rollup/plugin-terser": "^1.0.0",
|
|
239
237
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
240
|
-
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
241
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
242
238
|
"@vitest/coverage-v8": "^4.0.17",
|
|
243
239
|
"@vitest/ui": "^4.0.17",
|
|
244
|
-
"better-sqlite3": "^12.
|
|
240
|
+
"better-sqlite3": "^12.11.1",
|
|
245
241
|
"esbuild": "^0.28.0",
|
|
246
|
-
"
|
|
247
|
-
"eslint-config-prettier": "^9.0.0",
|
|
248
|
-
"eslint-plugin-prettier": "^5.0.0",
|
|
249
|
-
"happy-dom": "^20.8.9",
|
|
242
|
+
"happy-dom": "^20.10.6",
|
|
250
243
|
"http-server": "^14.1.1",
|
|
251
244
|
"jsdom": "^29.0.2",
|
|
252
245
|
"prettier": "^3.0.0",
|
|
253
|
-
"rollup": "^4.
|
|
246
|
+
"rollup": "^4.62.2",
|
|
254
247
|
"rollup-plugin-visualizer": "^7.0.0",
|
|
255
|
-
"tsx": "^4.
|
|
248
|
+
"tsx": "^4.23.1",
|
|
256
249
|
"typescript": "^5.8.3",
|
|
257
|
-
"vite": "^
|
|
250
|
+
"vite": "^8.1.4",
|
|
258
251
|
"vitest": "^4.1.5",
|
|
259
252
|
"zod": "^3.25.76"
|
|
260
253
|
},
|
|
@@ -285,14 +278,14 @@
|
|
|
285
278
|
"access": "public"
|
|
286
279
|
},
|
|
287
280
|
"dependencies": {
|
|
288
|
-
"@lokascript/intent": "^2.
|
|
289
|
-
"@lokascript/semantic": "^2.
|
|
290
|
-
"morphlex": "^1.0
|
|
281
|
+
"@lokascript/intent": "^2.8.0",
|
|
282
|
+
"@lokascript/semantic": "^2.8.0",
|
|
283
|
+
"morphlex": "^1.4.0",
|
|
291
284
|
"tslib": "^2.8.1"
|
|
292
285
|
},
|
|
293
286
|
"peerDependencies": {
|
|
294
|
-
"@hyperfixi/patterns-reference": "^2.
|
|
295
|
-
"@lokascript/framework": "^2.
|
|
287
|
+
"@hyperfixi/patterns-reference": "^2.8.0",
|
|
288
|
+
"@lokascript/framework": "^2.8.0"
|
|
296
289
|
},
|
|
297
290
|
"peerDependenciesMeta": {
|
|
298
291
|
"@hyperfixi/patterns-reference": {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{D as n,d as i}from"./browser-modular-DegkWQ8d.js";import"./feature-sockets-CrYvjZ4j.js";let e=null;async function t(){return e||(e=await import("./browser-modular-DegkWQ8d.js").then(function(n){return n.n})),e}class a{constructor(i={}){this._initialized=!1,this.config={confidenceThreshold:i.confidenceThreshold??n,fallbackOnLowConfidence:i.fallbackOnLowConfidence??!0}}async initialize(){await t(),this._initialized=!0}isInitialized(){return this._initialized}async transform(n,i,e){if(this.isInitialized()||await this.initialize(),i===e)return{output:n,usedSemantic:!1,confidence:1,sourceLang:i,targetLang:e};const a=await t();try{const t=a.translate(n,i,e);if(t!==n)return{output:t,usedSemantic:!0,confidence:.9,sourceLang:i,targetLang:e}}catch{}return{output:n,usedSemantic:!1,confidence:0,sourceLang:i,targetLang:e}}async parse(n,i){this.isInitialized()||await this.initialize();return(await t()).parseSemantic(n,i).node??null}async render(n,i){return(await t()).render(n,i)}async parseToAST(n,i){this.isInitialized()||await this.initialize();const e=await t(),a=e.parseSemantic(n,i);if(a.confidence>=this.config.confidenceThreshold&&a.node)try{return e.buildAST(a.node).ast}catch(n){}return null}async parseToASTWithDetails(n,i){this.isInitialized()||await this.initialize();const e=await t(),a=e.parseSemantic(n,i);if(a.confidence>=this.config.confidenceThreshold&&a.node)try{const n=e.buildAST(a.node);return{ast:n.ast,usedDirectPath:!0,confidence:a.confidence,lang:i,fallbackText:null,warnings:n.warnings}}catch{}if(a.node&&this.config.fallbackOnLowConfidence){const n=e.render(a.node,"en");return{ast:null,usedDirectPath:!1,confidence:a.confidence,lang:i,fallbackText:n}}return{ast:null,usedDirectPath:!1,confidence:a.confidence,lang:i,fallbackText:null}}async getAllTranslations(n,i){const e=(await t()).getSupportedLanguages(),a={};for(const t of e)a[t]=await this.transform(n,i,t);return a}}export{a as SemanticGrammarBridge};
|
|
2
|
-
//# sourceMappingURL=bridge-lZbOVRDD.js.map
|