@atscript/typescript 0.1.9 → 0.1.11

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/cli.cjs CHANGED
@@ -228,6 +228,7 @@ var TypeRenderer = class TypeRenderer extends BaseRenderer {
228
228
  pre() {
229
229
  this.writeln("// prettier-ignore-start");
230
230
  this.writeln("/* eslint-disable */");
231
+ this.writeln("/* oxlint-disable */");
231
232
  this.writeln(`/// <reference path="./${this.doc.name}" />`);
232
233
  this.writeln("/**");
233
234
  this.writeln(" * 🪄 This file was generated by Atscript");
@@ -519,12 +520,14 @@ var Validator = class {
519
520
  * @param safe - If `true`, returns `false` on failure instead of throwing.
520
521
  * @returns `true` if the value matches the type definition.
521
522
  * @throws {ValidatorError} When validation fails and `safe` is not `true`.
522
- */ validate(value, safe) {
523
+ */ validate(value, safe, context) {
523
524
  this.push("");
524
525
  this.errors = [];
525
526
  this.stackErrors = [];
527
+ this.context = context;
526
528
  const passed = this.validateSafe(this.def, value);
527
529
  this.pop(!passed);
530
+ this.context = undefined;
528
531
  if (!passed) {
529
532
  if (safe) return false;
530
533
  this.throw();
@@ -814,6 +817,7 @@ else {
814
817
  /** Validation errors collected during the last {@link validate} call. */ _define_property$2(this, "errors", void 0);
815
818
  _define_property$2(this, "stackErrors", void 0);
816
819
  _define_property$2(this, "stackPath", void 0);
820
+ _define_property$2(this, "context", void 0);
817
821
  this.def = def;
818
822
  this.errors = [];
819
823
  this.stackErrors = [];
@@ -1049,6 +1053,7 @@ var JsRenderer = class extends BaseRenderer {
1049
1053
  pre() {
1050
1054
  this.writeln("// prettier-ignore-start");
1051
1055
  this.writeln("/* eslint-disable */");
1056
+ this.writeln("/* oxlint-disable */");
1052
1057
  const imports = ["defineAnnotatedType as $", "annotate as $a"];
1053
1058
  if (resolveJsonSchemaMode(this.opts) === "lazy") imports.push("buildJsonSchema as $$");
1054
1059
  this.writeln(`import { ${imports.join(", ")} } from "@atscript/typescript/utils"`);
@@ -1640,7 +1645,7 @@ else return t.optional ? `${t.type} | true` : t.type;
1640
1645
  }
1641
1646
  let renderedTags = Array.from(tags).map((f) => `"${escapeQuotes(f)}"`).join(" | ");
1642
1647
  output.push({
1643
- content: "// prettier-ignore-start\n/* eslint-disable */\n/**\n * 🪄 This file was generated by Atscript\n * It is generated based on annotations used in this project\n * Do not edit this file!\n *\n * Use `npx asc -f dts` command to re-generate this file\n */\nexport {}\n\ndeclare global {\n interface AtscriptMetadata {\n " + rendered.join("\n ") + "\n }\n" + " type AtscriptPrimitiveTags = " + renderedTags + "\n" + "}\n" + "// prettier-ignore-end",
1648
+ content: "// prettier-ignore-start\n/* eslint-disable */\n/* oxlint-disable */\n/**\n * 🪄 This file was generated by Atscript\n * It is generated based on annotations used in this project\n * Do not edit this file!\n *\n * Use `npx asc -f dts` command to re-generate this file\n */\nexport {}\n\ndeclare global {\n interface AtscriptMetadata {\n " + rendered.join("\n ") + "\n }\n" + " type AtscriptPrimitiveTags = " + renderedTags + "\n" + "}\n" + "// prettier-ignore-end",
1644
1649
  fileName: "atscript.d.ts",
1645
1650
  source: "",
1646
1651
  target: path.default.join(repo.root, "atscript.d.ts")
package/dist/index.cjs CHANGED
@@ -225,6 +225,7 @@ var TypeRenderer = class TypeRenderer extends BaseRenderer {
225
225
  pre() {
226
226
  this.writeln("// prettier-ignore-start");
227
227
  this.writeln("/* eslint-disable */");
228
+ this.writeln("/* oxlint-disable */");
228
229
  this.writeln(`/// <reference path="./${this.doc.name}" />`);
229
230
  this.writeln("/**");
230
231
  this.writeln(" * 🪄 This file was generated by Atscript");
@@ -516,12 +517,14 @@ var Validator = class {
516
517
  * @param safe - If `true`, returns `false` on failure instead of throwing.
517
518
  * @returns `true` if the value matches the type definition.
518
519
  * @throws {ValidatorError} When validation fails and `safe` is not `true`.
519
- */ validate(value, safe) {
520
+ */ validate(value, safe, context) {
520
521
  this.push("");
521
522
  this.errors = [];
522
523
  this.stackErrors = [];
524
+ this.context = context;
523
525
  const passed = this.validateSafe(this.def, value);
524
526
  this.pop(!passed);
527
+ this.context = undefined;
525
528
  if (!passed) {
526
529
  if (safe) return false;
527
530
  this.throw();
@@ -811,6 +814,7 @@ else {
811
814
  /** Validation errors collected during the last {@link validate} call. */ _define_property$1(this, "errors", void 0);
812
815
  _define_property$1(this, "stackErrors", void 0);
813
816
  _define_property$1(this, "stackPath", void 0);
817
+ _define_property$1(this, "context", void 0);
814
818
  this.def = def;
815
819
  this.errors = [];
816
820
  this.stackErrors = [];
@@ -1046,6 +1050,7 @@ var JsRenderer = class extends BaseRenderer {
1046
1050
  pre() {
1047
1051
  this.writeln("// prettier-ignore-start");
1048
1052
  this.writeln("/* eslint-disable */");
1053
+ this.writeln("/* oxlint-disable */");
1049
1054
  const imports = ["defineAnnotatedType as $", "annotate as $a"];
1050
1055
  if (resolveJsonSchemaMode(this.opts) === "lazy") imports.push("buildJsonSchema as $$");
1051
1056
  this.writeln(`import { ${imports.join(", ")} } from "@atscript/typescript/utils"`);
@@ -1637,7 +1642,7 @@ else return t.optional ? `${t.type} | true` : t.type;
1637
1642
  }
1638
1643
  let renderedTags = Array.from(tags).map((f) => `"${escapeQuotes(f)}"`).join(" | ");
1639
1644
  output.push({
1640
- content: "// prettier-ignore-start\n/* eslint-disable */\n/**\n * 🪄 This file was generated by Atscript\n * It is generated based on annotations used in this project\n * Do not edit this file!\n *\n * Use `npx asc -f dts` command to re-generate this file\n */\nexport {}\n\ndeclare global {\n interface AtscriptMetadata {\n " + rendered.join("\n ") + "\n }\n" + " type AtscriptPrimitiveTags = " + renderedTags + "\n" + "}\n" + "// prettier-ignore-end",
1645
+ content: "// prettier-ignore-start\n/* eslint-disable */\n/* oxlint-disable */\n/**\n * 🪄 This file was generated by Atscript\n * It is generated based on annotations used in this project\n * Do not edit this file!\n *\n * Use `npx asc -f dts` command to re-generate this file\n */\nexport {}\n\ndeclare global {\n interface AtscriptMetadata {\n " + rendered.join("\n ") + "\n }\n" + " type AtscriptPrimitiveTags = " + renderedTags + "\n" + "}\n" + "// prettier-ignore-end",
1641
1646
  fileName: "atscript.d.ts",
1642
1647
  source: "",
1643
1648
  target: path.default.join(repo.root, "atscript.d.ts")
package/dist/index.mjs CHANGED
@@ -201,6 +201,7 @@ var TypeRenderer = class TypeRenderer extends BaseRenderer {
201
201
  pre() {
202
202
  this.writeln("// prettier-ignore-start");
203
203
  this.writeln("/* eslint-disable */");
204
+ this.writeln("/* oxlint-disable */");
204
205
  this.writeln(`/// <reference path="./${this.doc.name}" />`);
205
206
  this.writeln("/**");
206
207
  this.writeln(" * 🪄 This file was generated by Atscript");
@@ -492,12 +493,14 @@ var Validator = class {
492
493
  * @param safe - If `true`, returns `false` on failure instead of throwing.
493
494
  * @returns `true` if the value matches the type definition.
494
495
  * @throws {ValidatorError} When validation fails and `safe` is not `true`.
495
- */ validate(value, safe) {
496
+ */ validate(value, safe, context) {
496
497
  this.push("");
497
498
  this.errors = [];
498
499
  this.stackErrors = [];
500
+ this.context = context;
499
501
  const passed = this.validateSafe(this.def, value);
500
502
  this.pop(!passed);
503
+ this.context = undefined;
501
504
  if (!passed) {
502
505
  if (safe) return false;
503
506
  this.throw();
@@ -787,6 +790,7 @@ else {
787
790
  /** Validation errors collected during the last {@link validate} call. */ _define_property$1(this, "errors", void 0);
788
791
  _define_property$1(this, "stackErrors", void 0);
789
792
  _define_property$1(this, "stackPath", void 0);
793
+ _define_property$1(this, "context", void 0);
790
794
  this.def = def;
791
795
  this.errors = [];
792
796
  this.stackErrors = [];
@@ -1022,6 +1026,7 @@ var JsRenderer = class extends BaseRenderer {
1022
1026
  pre() {
1023
1027
  this.writeln("// prettier-ignore-start");
1024
1028
  this.writeln("/* eslint-disable */");
1029
+ this.writeln("/* oxlint-disable */");
1025
1030
  const imports = ["defineAnnotatedType as $", "annotate as $a"];
1026
1031
  if (resolveJsonSchemaMode(this.opts) === "lazy") imports.push("buildJsonSchema as $$");
1027
1032
  this.writeln(`import { ${imports.join(", ")} } from "@atscript/typescript/utils"`);
@@ -1613,7 +1618,7 @@ else return t.optional ? `${t.type} | true` : t.type;
1613
1618
  }
1614
1619
  let renderedTags = Array.from(tags).map((f) => `"${escapeQuotes(f)}"`).join(" | ");
1615
1620
  output.push({
1616
- content: "// prettier-ignore-start\n/* eslint-disable */\n/**\n * 🪄 This file was generated by Atscript\n * It is generated based on annotations used in this project\n * Do not edit this file!\n *\n * Use `npx asc -f dts` command to re-generate this file\n */\nexport {}\n\ndeclare global {\n interface AtscriptMetadata {\n " + rendered.join("\n ") + "\n }\n" + " type AtscriptPrimitiveTags = " + renderedTags + "\n" + "}\n" + "// prettier-ignore-end",
1621
+ content: "// prettier-ignore-start\n/* eslint-disable */\n/* oxlint-disable */\n/**\n * 🪄 This file was generated by Atscript\n * It is generated based on annotations used in this project\n * Do not edit this file!\n *\n * Use `npx asc -f dts` command to re-generate this file\n */\nexport {}\n\ndeclare global {\n interface AtscriptMetadata {\n " + rendered.join("\n ") + "\n }\n" + " type AtscriptPrimitiveTags = " + renderedTags + "\n" + "}\n" + "// prettier-ignore-end",
1617
1622
  fileName: "atscript.d.ts",
1618
1623
  source: "",
1619
1624
  target: path.join(repo.root, "atscript.d.ts")
package/dist/utils.cjs CHANGED
@@ -72,12 +72,14 @@ var Validator = class {
72
72
  * @param safe - If `true`, returns `false` on failure instead of throwing.
73
73
  * @returns `true` if the value matches the type definition.
74
74
  * @throws {ValidatorError} When validation fails and `safe` is not `true`.
75
- */ validate(value, safe) {
75
+ */ validate(value, safe, context) {
76
76
  this.push("");
77
77
  this.errors = [];
78
78
  this.stackErrors = [];
79
+ this.context = context;
79
80
  const passed = this.validateSafe(this.def, value);
80
81
  this.pop(!passed);
82
+ this.context = undefined;
81
83
  if (!passed) {
82
84
  if (safe) return false;
83
85
  this.throw();
@@ -367,6 +369,7 @@ else {
367
369
  /** Validation errors collected during the last {@link validate} call. */ _define_property(this, "errors", void 0);
368
370
  _define_property(this, "stackErrors", void 0);
369
371
  _define_property(this, "stackPath", void 0);
372
+ _define_property(this, "context", void 0);
370
373
  this.def = def;
371
374
  this.errors = [];
372
375
  this.stackErrors = [];
package/dist/utils.d.ts CHANGED
@@ -25,6 +25,7 @@ interface TValidatorPluginContext {
25
25
  validateAnnotatedType: Validator<any>['validateAnnotatedType'];
26
26
  error: Validator<any>['error'];
27
27
  path: Validator<any>['path'];
28
+ context: unknown;
28
29
  }
29
30
  /**
30
31
  * Validates values against an {@link TAtscriptAnnotatedType} definition.
@@ -59,6 +60,7 @@ declare class Validator<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedTyp
59
60
  errors: TError[];
60
61
  protected stackErrors: TError[][];
61
62
  protected stackPath: string[];
63
+ protected context: unknown;
62
64
  protected isLimitExceeded(): boolean;
63
65
  protected push(name: string): void;
64
66
  protected pop(saveErrors: boolean): TError[] | undefined;
@@ -76,7 +78,7 @@ declare class Validator<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedTyp
76
78
  * @returns `true` if the value matches the type definition.
77
79
  * @throws {ValidatorError} When validation fails and `safe` is not `true`.
78
80
  */
79
- validate<TT = DataType>(value: any, safe?: boolean): value is TT;
81
+ validate<TT = DataType>(value: any, safe?: boolean, context?: unknown): value is TT;
80
82
  protected validateSafe(def: TAtscriptAnnotatedType, value: any): boolean;
81
83
  protected get path(): string;
82
84
  protected validateAnnotatedType(def: TAtscriptAnnotatedType, value: any): boolean;
package/dist/utils.mjs CHANGED
@@ -71,12 +71,14 @@ var Validator = class {
71
71
  * @param safe - If `true`, returns `false` on failure instead of throwing.
72
72
  * @returns `true` if the value matches the type definition.
73
73
  * @throws {ValidatorError} When validation fails and `safe` is not `true`.
74
- */ validate(value, safe) {
74
+ */ validate(value, safe, context) {
75
75
  this.push("");
76
76
  this.errors = [];
77
77
  this.stackErrors = [];
78
+ this.context = context;
78
79
  const passed = this.validateSafe(this.def, value);
79
80
  this.pop(!passed);
81
+ this.context = undefined;
80
82
  if (!passed) {
81
83
  if (safe) return false;
82
84
  this.throw();
@@ -366,6 +368,7 @@ else {
366
368
  /** Validation errors collected during the last {@link validate} call. */ _define_property(this, "errors", void 0);
367
369
  _define_property(this, "stackErrors", void 0);
368
370
  _define_property(this, "stackPath", void 0);
371
+ _define_property(this, "context", void 0);
369
372
  this.def = def;
370
373
  this.errors = [];
371
374
  this.stackErrors = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/typescript",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Atscript: typescript-gen support.",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -70,7 +70,7 @@
70
70
  "homepage": "https://github.com/moostjs/atscript/tree/main/packages/typescript#readme",
71
71
  "license": "ISC",
72
72
  "peerDependencies": {
73
- "@atscript/core": "^0.1.9"
73
+ "@atscript/core": "^0.1.11"
74
74
  },
75
75
  "dependencies": {
76
76
  "@moostjs/event-cli": "^0.5.32",