@fraqjs/fraq 0.13.1 → 0.13.3

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/index.d.mts CHANGED
@@ -5542,6 +5542,7 @@ type RouteActivation =
5542
5542
  }
5543
5543
  | {
5544
5544
  type: 'mention';
5545
+ prefix?: string;
5545
5546
  }
5546
5547
  | {
5547
5548
  type: 'prefix';
package/dist/index.mjs CHANGED
@@ -316,7 +316,7 @@ var Router = class Router {
316
316
  for (const branch of this.branchesFrom(session, [], { includeHidden: true })) {
317
317
  const literalActivationIndex = branch.type === "rawPattern" ? Object.values(branch.rawPattern.pattern).findIndex((parameter) => parameter.capturer.typeInstruction.type === "literal") : -1;
318
318
  let activationInputs = DEFAULT_ACTIVATIONS;
319
- if (branch.type === "command" || literalActivationIndex !== -1) {
319
+ if (branch.type === "command" || literalActivationIndex !== -1 || branch.path.length > 0) {
320
320
  const descriptor = this.describeBranch(branch);
321
321
  const activations = this.activationResolver(descriptor, session) ?? DEFAULT_ACTIVATIONS;
322
322
  activationInputs = Array.isArray(activations) ? activations : [activations];
@@ -366,12 +366,14 @@ var Router = class Router {
366
366
  consumeActivation(tokenizer, activation, session) {
367
367
  switch (activation.type) {
368
368
  case "direct": return true;
369
- case "mention": return tokenizer.consumeMention(session.selfId);
369
+ case "mention":
370
+ if (!tokenizer.consumeMention(session.selfId)) return false;
371
+ return activation.prefix === void 0 || tokenizer.consumeTextPrefix(activation.prefix);
370
372
  case "prefix": return tokenizer.consumeTextPrefix(activation.prefix);
371
373
  }
372
374
  }
373
375
  matchBranch(branch, tokenizer, activation, session, literalActivationIndex) {
374
- if (branch.type === "command" && !this.consumeActivation(tokenizer, activation, session)) return;
376
+ if ((branch.type === "command" || branch.type === "rawPattern" && branch.path.length > 0 && literalActivationIndex === -1) && !this.consumeActivation(tokenizer, activation, session)) return;
375
377
  if (!this.matchPath(branch.path, tokenizer)) return;
376
378
  switch (branch.type) {
377
379
  case "command": return this.matchCommand(branch.command, tokenizer, branch.path, activation);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fraqjs/fraq",
3
3
  "type": "module",
4
- "version": "0.13.1",
4
+ "version": "0.13.3",
5
5
  "description": "Milky Bot framework",
6
6
  "files": [
7
7
  "dist"