Skip to content

Commit

Permalink
v0fix: fixed a few export issues, added more import paths
Browse files Browse the repository at this point in the history
Added direct export paths to be able to import .js files directly instead
of through barrel index.js files which are best avoided when using vite.
  • Loading branch information
AlansCodeLog committed May 19, 2024
1 parent 5b698e8 commit 77f240d
Show file tree
Hide file tree
Showing 30 changed files with 83 additions and 40 deletions.
26 changes: 23 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,50 @@
"types": "./dist/ast/index.d.ts",
"import": "./dist/ast/index.js"
},
"./ast/*": {
"types": "./dist/ast/*",
"import": "./dist/ast/*"
},
"./grammar": {
"types": "./dist/grammar/index.d.ts",
"import": "./dist/grammar/index.js"
},
"./grammar/*": {
"types": "./dist/grammar/*",
"import": "./dist/grammar/*"
},
"./helpers": {
"types": "./dist/helpers/index.d.ts",
"import": "./dist/helpers/index.js"
},
"./helpers/*": {
"types": "./dist/helpers/*",
"import": "./dist/helpers/*"
},
"./methods": {
"types": "./dist/methods/index.d.ts",
"import": "./dist/methods/index.js"
},
"./types": {
"types": "./dist/types/index.d.ts",
"import": "./dist/types/index.js"
"./methods/*": {
"types": "./dist/methods/*",
"import": "./dist/methods/*"
},
"./utils": {
"types": "./dist/utils/index.d.ts",
"import": "./dist/utils/index.js"
},
"./utils/*": {
"types": "./dist/utils/*",
"import": "./dist/utils/*"
},
"./examples": {
"types": "./dist/examples/index.d.ts",
"import": "./dist/examples/index.js"
},
"./examples/*": {
"types": "./dist/examples/*",
"import": "./dist/examples/*"
},
"./*": {
"types": "./dist/*",
"import": "./dist/*"
Expand Down
2 changes: 1 addition & 1 deletion src/ast/builders/array.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Mutable } from "@alanscodelog/utils"
import type { Mutable } from "@alanscodelog/utils/types"

import { token } from "./token.js"

Expand Down
2 changes: 1 addition & 1 deletion src/ast/builders/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated Index */
/* Autogenerated Index [Ignore] */

export { array } from "./array.js"
export { condition } from "./condition.js"
Expand Down
2 changes: 1 addition & 1 deletion src/ast/builders/token.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray } from "@alanscodelog/utils"
import { isArray } from "@alanscodelog/utils/isArray"

import { pos } from "./pos.js"

Expand Down
2 changes: 1 addition & 1 deletion src/ast/classes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated Index */
/* Autogenerated Index [Ignore] */

export { ArrayNode } from "./ArrayNode.js"
export { Condition } from "./Condition.js"
Expand Down
4 changes: 2 additions & 2 deletions src/ast/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Autogenerated Index */

export * as builders from "./builders/index.js"
export * as classes from "./classes/index.js"
/* Autogenerated Index */

export { token } from "./handlers.js"
4 changes: 4 additions & 0 deletions src/examples/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Autogenerated Index */

export { ShortcutContextParser } from "./shortcutContextParser.js"
export { valueComparer } from "./advancedValueComparer.js"
3 changes: 2 additions & 1 deletion src/grammar/ParserBase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */

import { isArray, unreachable } from "@alanscodelog/utils"
import { isArray } from "@alanscodelog/utils/isArray"
import { unreachable } from "@alanscodelog/utils/unreachable"
import { EmbeddedActionsParser, EOF, type IToken, tokenMatcher } from "chevrotain"

import type { createTokens } from "./createTokens.js"
Expand Down
3 changes: 2 additions & 1 deletion src/grammar/createTokens.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable camelcase */
import { escapeRegex, isBlank } from "@alanscodelog/utils"
import { escapeRegex } from "@alanscodelog/utils/escapeRegex"
import { isBlank } from "@alanscodelog/utils/isBlank"
import { createToken, Lexer, type TokenType } from "chevrotain"

import type { FullParserOptions } from "../types/parser.js"
Expand Down
6 changes: 4 additions & 2 deletions src/helpers/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Keys } from "@alanscodelog/utils"
import { crop, indent, pretty } from "@alanscodelog/utils"
import { crop } from "@alanscodelog/utils/crop"
import { indent } from "@alanscodelog/utils/indent"
import { pretty } from "@alanscodelog/utils/pretty"
import type { Keys } from "@alanscodelog/utils/types"

// @ts-expect-error todo
import { repository, version } from "../package.js"
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/general/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated Index */
/* Autogenerated Index [Ignore] */

export { applyBoolean } from "./applyBoolean.js"
export { applyPrefix } from "./applyPrefix.js"
Expand Down
5 changes: 3 additions & 2 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Autogenerated Index [Ignore] */

export * as general from "./general/index.js"
export * as parser from "./parser/index.js"

/* Autogenerated Index [Ignore] */

export { BooleanParserLibraryError } from "./errors.js"
3 changes: 2 additions & 1 deletion src/helpers/parser/checkParserOpts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isBlank, pushIfNotIn } from "@alanscodelog/utils"
import { isBlank } from "@alanscodelog/utils/isBlank"
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn"

import { ERROR_CODES } from "../../types/errors.js"
import type { FullParserOptions, ParserOptions } from "../../types/parser.js"
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/parser/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated Index */
/* Autogenerated Index [Ignore] */

export { assignParents } from "./assignParents.js"
export { checkParserOpts } from "./checkParserOpts.js"
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Manually Generated Index */

export * as ast from "./ast/classes/index.js"
export * as grammar from "./grammar/index.js"
export { Parser } from "./parser.js"
Expand Down
2 changes: 1 addition & 1 deletion src/methods/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { unreachable } from "@alanscodelog/utils"
import { unreachable } from "@alanscodelog/utils/unreachable"

import { ConditionNode } from "../ast/classes/ConditionNode.js"
import { VariableNode } from "../ast/classes/VariableNode.js"
Expand Down
2 changes: 1 addition & 1 deletion src/methods/autoreplace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { insert } from "@alanscodelog/utils"
import { insert } from "@alanscodelog/utils/insert"

import type { Completion } from "../types/autocomplete.js"

Expand Down
4 changes: 2 additions & 2 deletions src/methods/autosuggest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DeepPartial } from "@alanscodelog/utils"
import { unreachable } from "@alanscodelog/utils"
import { unreachable } from "@alanscodelog/utils/unreachable"
import type { DeepPartial } from "@alanscodelog/utils/types"

import { pos } from "../ast/builders/pos.js"
import { ArrayNode } from "../ast/classes/ArrayNode.js"
Expand Down
4 changes: 3 additions & 1 deletion src/methods/evaluate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { type AddParameters, get, unreachable } from "@alanscodelog/utils"
import { get } from "@alanscodelog/utils/get"
import { type AddParameters } from "@alanscodelog/utils/types"
import { unreachable } from "@alanscodelog/utils/unreachable"

import { Condition } from "../ast/classes/Condition.js"
import { Expression } from "../ast/classes/Expression.js"
Expand Down
3 changes: 2 additions & 1 deletion src/methods/getIndexes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-labels */

import { type AddParameters, unreachable } from "@alanscodelog/utils"
import { type AddParameters } from "@alanscodelog/utils/types"
import { unreachable } from "@alanscodelog/utils/unreachable"

import { Condition } from "../ast/classes/Condition.js"
import { Expression } from "../ast/classes/Expression.js"
Expand Down
5 changes: 2 additions & 3 deletions src/methods/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type AddParameters, unreachable } from "@alanscodelog/utils"
import { type AddParameters } from "@alanscodelog/utils/types"
import { unreachable } from "@alanscodelog/utils/unreachable"

import { ArrayNode } from "../ast/classes/ArrayNode.js"
import { Condition } from "../ast/classes/Condition.js"
Expand All @@ -24,8 +25,6 @@ const OPPOSITE = {
export class NormalizeMixin<T extends {}> {
/**
* Normalizes the ast by applying {@link GroupNode GroupNodes} and converting {@link ConditionNode ConditionNodes} to {@link NormalizedConditionNode NormalizedConditionNodes}.
*
* To do this, a
*/
normalize<TType extends string, TValue>(ast: ParserResults): Condition<TType, TValue> | Expression<TType, TValue> {
// @ts-expect-error private method
Expand Down
4 changes: 3 additions & 1 deletion src/methods/validate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { type AddParameters, get, isArray } from "@alanscodelog/utils"
import { get } from "@alanscodelog/utils/get"
import { isArray } from "@alanscodelog/utils/isArray"
import { type AddParameters } from "@alanscodelog/utils/types"

import { ArrayNode } from "../ast/classes/ArrayNode.js"
import { ConditionNode } from "../ast/classes/ConditionNode.js"
Expand Down
5 changes: 3 additions & 2 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* Docs work like normal (on methods). From the outside, users of the library cannot even tell the class is composed of mixins.
*/

import type { Mixin } from "@alanscodelog/utils"
import { isWhitespace, mixin } from "@alanscodelog/utils"
import { isWhitespace } from "@alanscodelog/utils/isWhitespace"
import { mixin } from "@alanscodelog/utils/mixin"
import type { Mixin } from "@alanscodelog/utils/types"
import { createSyntaxDiagramsCode, type ILexingResult, type Lexer } from "chevrotain"

import { token as tokenHandler } from "./ast/handlers.js"
Expand Down
2 changes: 1 addition & 1 deletion src/types/ast.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyFunction } from "@alanscodelog/utils"
import type { AnyFunction } from "@alanscodelog/utils/types"

import type { ArrayNode } from "../ast/classes/ArrayNode.js"
import type { ConditionNode } from "../ast/classes/ConditionNode.js"
Expand Down
2 changes: 1 addition & 1 deletion src/types/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DeepPartial } from "@alanscodelog/utils"
import type { DeepPartial } from "@alanscodelog/utils/types"
import type { ILexingError, IRecognitionException, IToken } from "chevrotain"

import type { ParserOptions } from "./parser.js"
Expand Down
9 changes: 6 additions & 3 deletions src/types/parser.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { DeepRequired, MakeRequired } from "@alanscodelog/utils"
import type { DeepRequired, MakeRequired } from "@alanscodelog/utils/types"

import type { Position, TOKEN_TYPE } from "./ast.js"

import type { ArrayNode, Condition, ConditionNode, ValidToken, VariableNode } from "../ast/classes/index.js"

import type { ArrayNode } from "../ast/classes/ArrayNode.js"
import type { Condition } from "../ast/classes/Condition.js"
import type { ConditionNode } from "../ast/classes/ConditionNode.js"
import type { ValidToken } from "../ast/classes/ValidToken.js"
import type { VariableNode } from "../ast/classes/VariableNode.js"

// #partially-synced
export type FullParserOptions<T extends {} = {}> = MakeRequired<
Expand Down
2 changes: 1 addition & 1 deletion src/utils/extractTokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { unreachable } from "@alanscodelog/utils"
import { unreachable } from "@alanscodelog/utils/unreachable"

import { ArrayNode } from "../ast/classes/ArrayNode.js"
import { ConditionNode } from "../ast/classes/ConditionNode.js"
Expand Down
3 changes: 2 additions & 1 deletion src/utils/getCursorInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isArray, unreachable } from "@alanscodelog/utils"
import { isArray } from "@alanscodelog/utils/isArray"
import { unreachable } from "@alanscodelog/utils/unreachable"

import { extractTokens } from "./extractTokens.js"

Expand Down
2 changes: 1 addition & 1 deletion src/utils/getOppositeDelimiter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { unreachable } from "@alanscodelog/utils"
import { unreachable } from "@alanscodelog/utils/unreachable"

import { isBracket } from "./isBracket.js"
import { isDelimiter } from "./isDelimiter.js"
Expand Down
7 changes: 5 additions & 2 deletions src/utils/prettyAst.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-disable prefer-rest-params */
import { type AddParameters, colors as color } from "@alanscodelog/utils"
import { isBlank, unreachable } from "@alanscodelog/utils"
import * as color from "@alanscodelog/utils/colors"
import { type AddParameters } from "@alanscodelog/utils/types"
import { isBlank} from "@alanscodelog/utils/isBlank"
import { unreachable } from "@alanscodelog/utils/unreachable"


import { ArrayNode, ConditionNode, ErrorToken, ExpressionNode, GroupNode, ValidToken, VariableNode } from "../ast/classes/index.js"
import { type AnyToken, type ParserResults, TOKEN_TYPE } from "../types/ast.js"
Expand Down

0 comments on commit 77f240d

Please sign in to comment.