poe-code 14.0.67 → 14.0.68

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.
Files changed (38) hide show
  1. package/dist/index.js +89 -57
  2. package/dist/index.js.map +2 -2
  3. package/dist/metafile.json +1 -1
  4. package/package.json +1 -1
  5. package/packages/safe-js/dist/chunks/{chunk-7WQTLP7D.js → chunk-6IZRC5HI.js} +2 -2
  6. package/packages/safe-js/dist/chunks/{chunk-F6FZXBQR.js → chunk-WL74XSIE.js} +90 -58
  7. package/packages/safe-js/dist/chunks/chunk-WL74XSIE.js.map +7 -0
  8. package/packages/safe-js/dist/cli.js +2 -2
  9. package/packages/safe-js/dist/core.js +1 -1
  10. package/packages/safe-js/dist/index.js +2 -2
  11. package/packages/safe-js/dist/index.js.map +2 -2
  12. package/packages/safe-js/dist/interp/interpreter.js +51 -21
  13. package/packages/safe-js/dist/lint/rules/AS-async-not-needed.js +2 -2
  14. package/packages/safe-js/dist/lint/rules/AS-destructure-null-default.js +1 -1
  15. package/packages/safe-js/dist/lint/rules/AS-export-import-meta.js +3 -3
  16. package/packages/safe-js/dist/lint/rules/AS-floating-promise.js +4 -3
  17. package/packages/safe-js/dist/lint/rules/AS-frontmatter-field-unused.js +1 -1
  18. package/packages/safe-js/dist/lint/rules/AS-jsdoc-type.js +1 -1
  19. package/packages/safe-js/dist/lint/rules/AS-large-literal.js +1 -1
  20. package/packages/safe-js/dist/lint/rules/AS-missing-async.js +2 -2
  21. package/packages/safe-js/dist/lint/rules/AS-mutating-frozen.js +1 -1
  22. package/packages/safe-js/dist/lint/rules/AS-needless-template.js +1 -1
  23. package/packages/safe-js/dist/lint/rules/AS-shadow-global.js +1 -1
  24. package/packages/safe-js/dist/lint/rules/AS-unbounded-loop.js +1 -1
  25. package/packages/safe-js/dist/lint/rules/AS-unreachable.js +1 -1
  26. package/packages/safe-js/dist/lint/rules/AS-unused-import.js +7 -3
  27. package/packages/safe-js/dist/lint/rules/AS003.js +4 -4
  28. package/packages/safe-js/dist/lint/rules/AS006-007.js +7 -3
  29. package/packages/safe-js/dist/lint/rules/AS009.js +1 -1
  30. package/packages/safe-js/dist/lint/rules/AS010.js +1 -1
  31. package/packages/safe-js/dist/lint/rules/AS011.js +1 -1
  32. package/packages/safe-js/dist/lint/rules/AS015.js +1 -1
  33. package/packages/safe-js/dist/loader/find-exported.d.ts +2 -2
  34. package/packages/safe-js/dist/parse/parse-export.d.ts +4 -4
  35. package/packages/safe-js/dist/parse/parser.d.ts +1 -1
  36. package/packages/safe-js/dist/parse/parser.js +10 -3
  37. package/packages/safe-js/dist/chunks/chunk-F6FZXBQR.js.map +0 -7
  38. /package/packages/safe-js/dist/chunks/{chunk-7WQTLP7D.js.map → chunk-6IZRC5HI.js.map} +0 -0
@@ -39,7 +39,7 @@ class AS006007Scanner {
39
39
  this.visitVariableDeclaration(node.declaration);
40
40
  return;
41
41
  case "ExportDefaultDeclaration":
42
- if (node.declaration.type === "ClassDeclaration")
42
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration")
43
43
  this.visitStatement(node.declaration);
44
44
  else
45
45
  this.visitExpression(node.declaration);
@@ -495,11 +495,15 @@ class AS006007Scanner {
495
495
  bindings.push(...this.collectDeclarationBindings(declaration));
496
496
  }
497
497
  for (const statement of body) {
498
+ if (statement.type === "ExportDefaultDeclaration" && (statement.declaration.type === "FunctionDeclaration" || statement.declaration.type === "ClassDeclaration") && statement.declaration.id !== undefined) {
499
+ bindings.push({ ...this.createBinding(statement.declaration.id, "let"), code: undefined });
500
+ continue;
501
+ }
498
502
  if (statement.type === "ImportDeclaration") {
499
503
  bindings.push(...this.collectImportBindings(statement));
500
504
  continue;
501
505
  }
502
- if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
506
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== undefined) {
503
507
  bindings.push(this.createBinding(statement.id, "let"));
504
508
  continue;
505
509
  }
@@ -516,7 +520,7 @@ class AS006007Scanner {
516
520
  collectBlockBindings(body) {
517
521
  const bindings = [];
518
522
  for (const statement of body) {
519
- if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
523
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== undefined) {
520
524
  bindings.push(this.createBinding(statement.id, "let"));
521
525
  }
522
526
  if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
@@ -72,7 +72,7 @@ class AS009Scanner {
72
72
  this.visitVariableDeclaration(node.declaration);
73
73
  return;
74
74
  case "ExportDefaultDeclaration":
75
- if (node.declaration.type === "ClassDeclaration")
75
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration")
76
76
  this.visitStatement(node.declaration);
77
77
  else
78
78
  this.visitExpression(node.declaration);
@@ -84,7 +84,7 @@ class AS010Scanner {
84
84
  this.visitVariableDeclaration(node.declaration);
85
85
  return;
86
86
  case "ExportDefaultDeclaration":
87
- if (node.declaration.type === "ClassDeclaration")
87
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration")
88
88
  this.visitStatement(node.declaration);
89
89
  else
90
90
  this.visitExpression(node.declaration);
@@ -68,7 +68,7 @@ class AS011Scanner {
68
68
  this.visitVariableDeclaration(node.declaration);
69
69
  return;
70
70
  case "ExportDefaultDeclaration":
71
- if (node.declaration.type === "ClassDeclaration")
71
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration")
72
72
  this.visitStatement(node.declaration);
73
73
  else
74
74
  this.visitExpression(node.declaration);
@@ -65,7 +65,7 @@ class AS015Scanner {
65
65
  this.visitVariableDeclaration(node.declaration);
66
66
  return;
67
67
  case "ExportDefaultDeclaration":
68
- if (node.declaration.type === "ClassDeclaration")
68
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration")
69
69
  this.visitStatement(node.declaration);
70
70
  else
71
71
  this.visitExpression(node.declaration);
@@ -1,2 +1,2 @@
1
- import type { ClassDeclaration, Expression, Module } from "../parse/parser.js";
2
- export declare function findExportedConstInitializer(module: Module, name: string): Expression | ClassDeclaration | undefined;
1
+ import type { ClassDeclaration, Expression, FunctionDeclaration, Module } from "../parse/parser.js";
2
+ export declare function findExportedConstInitializer(module: Module, name: string): Expression | ClassDeclaration | FunctionDeclaration | undefined;
@@ -1,5 +1,5 @@
1
1
  import type { Token } from "./tokenizer.js";
2
- import type { ClassDeclaration, Expression, Module, SourceSpan, VariableDeclaration, VariableDeclarator } from "./parser.js";
2
+ import type { ClassDeclaration, Expression, FunctionDeclaration, Module, SourceSpan, VariableDeclaration, VariableDeclarator } from "./parser.js";
3
3
  export type ExportNamedDeclaration = {
4
4
  nodeId?: number;
5
5
  type: "ExportNamedDeclaration";
@@ -9,7 +9,7 @@ export type ExportNamedDeclaration = {
9
9
  export type ExportDefaultDeclaration = {
10
10
  nodeId?: number;
11
11
  type: "ExportDefaultDeclaration";
12
- declaration: Expression | ClassDeclaration;
12
+ declaration: Expression | ClassDeclaration | FunctionDeclaration;
13
13
  span: SourceSpan;
14
14
  };
15
15
  export type ExtractedNamedExport = {
@@ -22,7 +22,7 @@ export type ExtractedNamedExport = {
22
22
  export type ExtractedDefaultExport = {
23
23
  type: "default";
24
24
  name: "default";
25
- declaration: Expression | ClassDeclaration;
25
+ declaration: Expression | ClassDeclaration | FunctionDeclaration;
26
26
  statement: ExportDefaultDeclaration;
27
27
  span: SourceSpan;
28
28
  };
@@ -33,4 +33,4 @@ export declare class ExportExtractionError extends Error {
33
33
  }
34
34
  export declare function extractTopLevelExports(module: Module): ExtractedTopLevelExport[];
35
35
  export declare function createExportNamedDeclaration(exportToken: Token, declaration: VariableDeclaration): ExportNamedDeclaration;
36
- export declare function createExportDefaultDeclaration(exportToken: Token, declaration: Expression | ClassDeclaration): ExportDefaultDeclaration;
36
+ export declare function createExportDefaultDeclaration(exportToken: Token, declaration: Expression | ClassDeclaration | FunctionDeclaration): ExportDefaultDeclaration;
@@ -236,7 +236,7 @@ export type FunctionDeclaration = BaseNode & {
236
236
  async: boolean;
237
237
  body: BlockStatement;
238
238
  generator: boolean;
239
- id: Identifier;
239
+ id?: Identifier;
240
240
  params: ArrowFunctionExpression["params"];
241
241
  };
242
242
  export type FunctionExpression = BaseNode & {
@@ -866,6 +866,11 @@ class Parser {
866
866
  }
867
867
  parseExportDefaultDeclaration(exportToken) {
868
868
  this.index += 1;
869
+ if (this.currentToken().value === "function" ||
870
+ (this.currentToken().value === "async" && this.peekToken(1).value === "function" &&
871
+ !hasLineBreakBetween(this.currentToken(), this.peekToken(1)))) {
872
+ return createExportDefaultDeclaration(exportToken, this.parseFunctionDeclaration(true));
873
+ }
869
874
  if (this.currentToken().value === "class") {
870
875
  const named = isIdentifierLikeToken(this.peekToken(1)) && this.peekToken(1).value !== "extends";
871
876
  return createExportDefaultDeclaration(exportToken, this.parseClass(named));
@@ -919,15 +924,17 @@ class Parser {
919
924
  span: createSpan(kindToken.start, declarations[declarations.length - 1].span.end)
920
925
  };
921
926
  }
922
- parseFunctionDeclaration() {
927
+ parseFunctionDeclaration(defaultExport = false) {
923
928
  const asyncToken = this.consumeKeyword("async");
924
929
  const functionToken = this.expectKeyword("function");
925
930
  const generatorToken = this.consumePunctuator("*");
926
931
  if (asyncToken !== undefined && generatorToken !== undefined) {
927
932
  throw new Error(`async function* is not supported at line ${asyncToken.start.line}, column ${asyncToken.start.column}.`);
928
933
  }
929
- const id = this.parseBindingIdentifier();
930
- this.declareBinding(id, "function");
934
+ const id = defaultExport && this.currentToken().value === "("
935
+ ? undefined : this.parseBindingIdentifier();
936
+ if (id !== undefined)
937
+ this.declareBinding(id, defaultExport ? "lexical" : "function");
931
938
  const generator = generatorToken !== undefined;
932
939
  const { params, body } = this.parseFunctionParts(generator, ordinaryFunctionContext);
933
940
  return this.withFunctionSource({