@r_masseater/y8 0.0.0-stage → 0.1.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/LICENSE +87 -0
- package/README.md +49 -2
- package/dist/app-D5BcM070.mjs +458 -0
- package/dist/app-D5BcM070.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +19 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index-AoTF_uMY.d.mts +10 -0
- package/dist/index-CS7Sntk8.d.mts +90 -0
- package/dist/index-Dvd9WB0d.d.mts +25 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.mjs +3 -0
- package/dist/kuromojin.d.mts +3 -0
- package/dist/kuromojin.mjs +1 -0
- package/dist/split-morphemes-BS74IEHA.mjs +282 -0
- package/dist/split-morphemes-BS74IEHA.mjs.map +1 -0
- package/dist/vite.d.mts +7 -0
- package/dist/vite.mjs +1 -0
- package/logo.svg +15 -0
- package/package.json +97 -3
- package/skills/lint-markdown/SKILL.md +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-D5BcM070.mjs","names":["SEPARATOR","Str","settingOf","Rec","Arr","Str","Arr","Rec","Fn","Arr","SEPARATOR","diagnosticOf","Rec","Arr","Str","Arr","Arr","diagnosticOf","Rec","Arr","Rec","Str","Arr","Arr","Arr"],"sources":["../src/entities/rule/model/agnix.ts","../src/entities/rule/model/define.ts","../src/entities/rule/model/resolve.ts","../src/entities/rule/model/override.ts","../src/app/format.ts","../src/features/map-agent-diagnostics/model/map.ts","../src/features/read-project/model/project.ts","../src/features/run-compat-rules/model/compat.ts","../src/features/run-rules/model/document.ts","../src/features/run-rules/model/frontmatter.ts","../src/features/run-rules/model/run.ts","../src/app/lint.ts","../src/app/section.ts"],"sourcesContent":["import type { Plugin } from \"#/shared/config/index.ts\";\n\nexport const agnix: Plugin = { agentConfig: true };\n","import type { Plugin, Rule } from \"#/shared/config/index.ts\";\n\nexport const defineRule = (rule: Rule): Rule => rule;\n\nexport const definePlugin = (plugin: Plugin): Plugin => plugin;\n","import { settingOf } from \"@masseater.dev/lint-host\";\nimport type { Setting } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Match, Option, Record as Rec, String as Str, pipe } from \"effect\";\n\nimport type {\n Diagnostic,\n MarkdownlintRule,\n Y8Config,\n Plugin,\n Rule,\n Severity,\n} from \"#/shared/config/index.ts\";\n\nexport const BUILTIN = \"markdownlint\";\n\nconst SEPARATOR = \"/\";\nconst START = 0;\n\nexport type { Setting } from \"@masseater.dev/lint-host\";\n\nexport const reportedSeverity = (setting: Setting): Diagnostic[\"severity\"] =>\n Match.value(setting.severity).pipe(\n Match.when(\"warn\", (): Diagnostic[\"severity\"] => \"warn\"),\n Match.orElse((): Diagnostic[\"severity\"] => \"error\"),\n );\n\nexport interface ScriptRule {\n readonly id: string;\n readonly rule: Rule;\n readonly setting: Setting;\n}\n\nexport interface CompatRule {\n readonly id: string;\n readonly rule: MarkdownlintRule;\n readonly setting: Setting;\n}\n\nexport interface AgentRules {\n readonly plugin: string;\n readonly disabled: readonly string[];\n readonly settings: Readonly<Record<string, Setting>>;\n}\n\nexport interface Resolved {\n readonly core: Readonly<Record<string, unknown>>;\n readonly scripts: readonly ScriptRule[];\n readonly compat: readonly CompatRule[];\n readonly agent: Option.Option<AgentRules>;\n}\n\ninterface RuleId {\n readonly plugin: string;\n readonly name: string;\n}\n\ntype PluginEntry = readonly [string, Plugin];\n\nconst ruleIdOf = (id: string): RuleId =>\n pipe(\n Str.indexOf(SEPARATOR)(id),\n Option.match({\n onNone: (): RuleId => ({ plugin: BUILTIN, name: id }),\n onSome: (slash): RuleId => ({\n plugin: Str.slice(START, slash)(id),\n name: Str.slice(slash + SEPARATOR.length)(id),\n }),\n }),\n );\n\nconst isOn = (setting: Setting): boolean => setting.severity !== \"off\";\n\nconst coreSeverity = (severity: Severity): string =>\n Match.value(severity).pipe(\n Match.when(\"warn\", () => \"warning\"),\n Match.orElse(() => \"error\"),\n );\n\nconst coreEntry = (setting: Setting): unknown =>\n Match.value(setting.severity).pipe(\n Match.when(\"off\", (): unknown => false),\n Match.orElse((severity): unknown => ({ ...setting.options, severity: coreSeverity(severity) })),\n );\n\nconst ENABLED: Setting = settingOf(\"error\");\n\nconst configured =\n (config: Y8Config, plugin: string) =>\n (name: string): Option.Option<Setting> =>\n pipe(config.rules ?? {}, Rec.get(`${plugin}${SEPARATOR}${name}`), Option.map(settingOf));\n\nconst scriptRules =\n (config: Y8Config) =>\n ([plugin, value]: PluginEntry): readonly ScriptRule[] =>\n pipe(\n Rec.toEntries(value.rules ?? {}),\n Arr.map(([name, rule]): ScriptRule => ({\n id: `${plugin}${SEPARATOR}${name}`,\n rule,\n setting: Option.getOrElse(configured(config, plugin)(name), () => ENABLED),\n })),\n Arr.filter(({ setting }) => isOn(setting)),\n );\n\nconst compatRule =\n (config: Y8Config, plugin: string) =>\n (rule: MarkdownlintRule): Option.Option<CompatRule> =>\n pipe(\n Arr.head(rule.names),\n Option.map((name): CompatRule => ({\n id: `${plugin}${SEPARATOR}${name}`,\n rule,\n setting: pipe(\n rule.names,\n Arr.findFirst(configured(config, plugin)),\n Option.getOrElse(() => ENABLED),\n ),\n })),\n );\n\nconst compatRules =\n (config: Y8Config) =>\n ([plugin, value]: PluginEntry): readonly CompatRule[] =>\n pipe(\n value.markdownlintRules ?? [],\n Arr.flatMap((rule) => Option.toArray(compatRule(config, plugin)(rule))),\n Arr.filter(({ setting }) => isOn(setting)),\n );\n\nconst builtinEntries = (config: Y8Config): Readonly<Record<string, unknown>> =>\n pipe(\n Rec.toEntries(config.rules ?? {}),\n Arr.map(([id, entry]) => ({ ...ruleIdOf(id), setting: settingOf(entry) })),\n Arr.filter(({ plugin }) => plugin === BUILTIN),\n Arr.map(({ name, setting }): readonly [string, unknown] => [name, coreEntry(setting)]),\n Rec.fromEntries,\n );\n\nconst agentSettings = (config: Y8Config, plugin: string): Readonly<Record<string, Setting>> =>\n pipe(\n Rec.toEntries(config.rules ?? {}),\n Arr.map(([id, entry]) => ({ ...ruleIdOf(id), setting: settingOf(entry) })),\n Arr.filter((rule) => rule.plugin === plugin),\n Arr.map(({ name, setting }): readonly [string, Setting] => [name, setting]),\n Rec.fromEntries,\n );\n\nconst agentRules =\n (config: Y8Config) =>\n ([plugin]: PluginEntry): AgentRules => {\n const settings = agentSettings(config, plugin);\n return {\n plugin,\n settings,\n disabled: pipe(\n Rec.toEntries(settings),\n Arr.filter(([, setting]) => !isOn(setting)),\n Arr.map(([name]) => name),\n ),\n };\n };\n\nexport const resolve = (config: Y8Config): Resolved => {\n const plugins = Rec.toEntries(config.plugins ?? {});\n return {\n core: { default: true, ...builtinEntries(config) },\n scripts: pipe(plugins, Arr.flatMap(scriptRules(config))),\n compat: pipe(plugins, Arr.flatMap(compatRules(config))),\n agent: pipe(\n plugins,\n Arr.findFirst(([, value]) => value.agentConfig === true),\n Option.map(agentRules(config)),\n ),\n };\n};\n\nexport const unknownPlugins = (config: Y8Config): readonly string[] =>\n pipe(\n config.overrides ?? [],\n Arr.flatMap((override) => Rec.keys(override.rules)),\n Arr.appendAll(Rec.keys(config.rules ?? {})),\n Arr.map((id) => ruleIdOf(id).plugin),\n Arr.filter((plugin) => plugin !== BUILTIN && !Rec.has(config.plugins ?? {}, plugin)),\n Arr.dedupe,\n );\n","import { Array as Arr, Function as Fn, Option, Record as Rec, String as Str, pipe } from \"effect\";\nimport { minimatch } from \"minimatch\";\n\nimport type { Override, RuleEntry, Y8Config } from \"#/shared/config/index.ts\";\n\nconst NEGATION = \"!\";\nconst KEY_SEPARATOR = \",\";\nconst DATA_FIRST_ARITY = 2;\n\nexport interface FileGroup {\n readonly config: Y8Config;\n readonly files: readonly string[];\n}\n\ntype Rules = Readonly<Record<string, RuleEntry>>;\n\ninterface Member {\n readonly path: string;\n readonly indexes: readonly number[];\n}\n\nconst isNegated = Str.startsWith(NEGATION);\n\nconst isIncluded = (pattern: string): boolean => !isNegated(pattern);\n\nconst matchesAny =\n (path: string) =>\n (patterns: readonly string[]): boolean =>\n pipe(\n patterns,\n Arr.some((pattern) => minimatch(path, pattern, { dot: true })),\n );\n\nconst excludedOf = (override: Override): readonly string[] =>\n pipe(override.files, Arr.filter(isNegated), Arr.map(Str.slice(NEGATION.length)));\n\nconst applies =\n (path: string) =>\n (override: Override): boolean =>\n pipe(override.files, Arr.filter(isIncluded), matchesAny(path)) &&\n !matchesAny(path)(excludedOf(override));\n\nconst matchingIndexes = (config: Y8Config, path: string): readonly number[] =>\n pipe(\n config.overrides ?? [],\n Arr.flatMap((override, index) =>\n Option.toArray(Option.liftPredicate(index, () => applies(path)(override))),\n ),\n );\n\nconst entriesOf = (override: Override): readonly (readonly [string, RuleEntry])[] =>\n Rec.toEntries(override.rules);\n\nconst rulesWith = (base: Rules, overrides: readonly Override[]): Rules =>\n pipe(overrides, Arr.flatMap(entriesOf), Arr.prependAll(Rec.toEntries(base)), Rec.fromEntries);\n\nconst overridesAt =\n (overrides: readonly Override[]) =>\n (indexes: readonly number[]): readonly Override[] =>\n pipe(\n indexes,\n Arr.flatMap((index) => Option.toArray(Arr.get(overrides, index))),\n );\n\nconst configWith = (config: Y8Config, indexes: readonly number[]): Y8Config => {\n const { overrides = [], ...base } = config;\n return { ...base, rules: rulesWith(base.rules ?? {}, overridesAt(overrides)(indexes)) };\n};\n\nconst keyOf = (member: Member): string =>\n pipe(member.indexes, Arr.map(String), Arr.join(KEY_SEPARATOR));\n\nconst groupOf =\n (config: Y8Config) =>\n (members: Arr.NonEmptyReadonlyArray<Member>): FileGroup => ({\n config: configWith(config, Arr.headNonEmpty(members).indexes),\n files: pipe(\n members,\n Arr.map((member) => member.path),\n ),\n });\n\nexport const groupByOverrides: {\n (files: readonly string[]): (config: Y8Config) => readonly FileGroup[];\n (config: Y8Config, files: readonly string[]): readonly FileGroup[];\n} = Fn.dual(DATA_FIRST_ARITY, (config: Y8Config, files: readonly string[]): readonly FileGroup[] =>\n pipe(\n files,\n Arr.map((path): Member => ({ path, indexes: matchingIndexes(config, path) })),\n Arr.groupBy(keyOf),\n Rec.values,\n Arr.map(groupOf(config)),\n ),\n);\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport type { Diagnostic } from \"#/shared/config/index.ts\";\n\nexport const diagnosticDetail = (diagnostic: Diagnostic): string =>\n pipe(\n [diagnostic.detail, diagnostic.context],\n Arr.flatMap((part) => Option.toArray(Option.fromNullishOr(part))),\n Arr.filter((part) => part !== \"\"),\n Arr.map((part) => ` [${part}]`),\n Arr.join(\"\"),\n );\n\nexport const format = (diagnostic: Diagnostic): string => {\n const column = pipe(\n Option.fromNullishOr(diagnostic.column),\n Option.map((value) => `:${String(value)}`),\n Option.getOrElse(() => \"\"),\n );\n return `${diagnostic.path}:${String(diagnostic.line)}${column} ${diagnostic.severity} ${diagnostic.rule} ${diagnostic.message}${diagnosticDetail(diagnostic)}`;\n};\n","import { present } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Match, Option, Record as Rec, pipe } from \"effect\";\n\nimport { reportedSeverity } from \"#/entities/rule/index.ts\";\nimport type { AgentRules } from \"#/entities/rule/index.ts\";\nimport type { Diagnostic } from \"#/shared/config/index.ts\";\nimport type { AgentDiagnostic, NativeResult } from \"#/shared/native/index.ts\";\n\nconst SEPARATOR = \"/\";\n\nconst levelSeverity = (diagnostic: AgentDiagnostic): Diagnostic[\"severity\"] =>\n Match.value(diagnostic.level).pipe(\n Match.when(\"error\", (): Diagnostic[\"severity\"] => \"error\"),\n Match.orElse((): Diagnostic[\"severity\"] => \"warn\"),\n );\n\nconst diagnosticOf =\n (rules: AgentRules, path: string) =>\n (diagnostic: AgentDiagnostic): Diagnostic => ({\n path,\n line: diagnostic.line,\n column: diagnostic.column,\n rule: `${rules.plugin}${SEPARATOR}${diagnostic.rule}`,\n message: diagnostic.message,\n severity: pipe(\n Rec.get(rules.settings, diagnostic.rule),\n Option.match({ onNone: () => levelSeverity(diagnostic), onSome: reportedSeverity }),\n ),\n ...present(Option.fromNullishOr(diagnostic.suggestion), (detail) => ({ detail })),\n });\n\nexport const agentDiagnosticsOf =\n (rules: AgentRules) =>\n (result: NativeResult): readonly Diagnostic[] =>\n pipe(result.agentDiagnostics ?? [], Arr.map(diagnosticOf(rules, result.path)));\n","import { Array as Arr, Effect, Option, Predicate, Schema, String as Str, pipe } from \"effect\";\n\nimport type { PackageManifest, Project } from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport { native } from \"#/shared/native/index.ts\";\n\nconst MANIFEST = \"package.json\";\nconst SEPARATOR = \"/\";\nconst ONE = 1;\n\nconst ancestorsOf = (file: string): readonly string[] => {\n const parts = Str.split(file, SEPARATOR);\n return Arr.makeBy(parts.length, (index) =>\n pipe(parts, Arr.take(parts.length - ONE - index), Arr.join(SEPARATOR)),\n );\n};\n\nconst manifestFileOf = (directory: string): string =>\n pipe([directory, MANIFEST], Arr.filter(Str.isNonEmpty), Arr.join(SEPARATOR));\n\nconst decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));\n\nconst manifestFrom =\n (directory: string) =>\n (text: string | null): Option.Option<PackageManifest> =>\n pipe(\n Option.fromNullishOr(text),\n Option.flatMap(decodeJson),\n Option.filter(Predicate.isObject),\n Option.map((data): PackageManifest => ({ directory, data })),\n );\n\nexport interface ProjectInput {\n readonly root: string;\n readonly projectFiles: readonly string[];\n readonly files: readonly string[];\n}\n\nconst prefixOf = (directory: string): string =>\n pipe(\n Option.liftPredicate(directory, Str.isNonEmpty),\n Option.map((value) => `${value}${SEPARATOR}`),\n Option.getOrElse(() => \"\"),\n );\n\nconst isUnder = (directory: string): ((path: string) => boolean) =>\n Str.startsWith(prefixOf(directory));\n\nexport const readProject = Effect.fn(\"y8.project\")(function* readProject(input: ProjectInput) {\n const listed: ReadonlySet<string> = new Set([...input.projectFiles, ...input.files]);\n const all = Arr.fromIterable(listed);\n const directories = pipe(\n input.files,\n Arr.flatMap(ancestorsOf),\n Arr.dedupe,\n Arr.filter((directory) => listed.has(manifestFileOf(directory))),\n );\n const addon = yield* native;\n const texts = yield* Effect.try({\n try: () => addon.readTexts(input.root, pipe(directories, Arr.map(manifestFileOf))),\n catch: failedWith(\"y8 could not read package.json\"),\n });\n const manifests: ReadonlyMap<string, PackageManifest> = new Map(\n pipe(\n Arr.zip(directories, texts),\n Arr.flatMap(([directory, text]) => Option.toArray(manifestFrom(directory)(text))),\n Arr.map((manifest): readonly [string, PackageManifest] => [manifest.directory, manifest]),\n ),\n );\n return {\n exists: (path): boolean => listed.has(path) || pipe(all, Arr.some(isUnder(path))),\n under: (directory): readonly string[] => pipe(all, Arr.filter(isUnder(directory))),\n manifestOf: (file): PackageManifest | undefined =>\n pipe(\n ancestorsOf(file),\n Arr.findFirst((directory) => Option.fromNullishOr(manifests.get(directory))),\n Option.getOrUndefined,\n ),\n } satisfies Project;\n});\n","import { present } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Effect, Option, Predicate, Record as Rec, pipe } from \"effect\";\n\nimport { reportedSeverity } from \"#/entities/rule/index.ts\";\nimport type { CompatRule } from \"#/entities/rule/index.ts\";\nimport type { Diagnostic } from \"#/shared/config/index.ts\";\nimport { Y8Error, failedWith } from \"#/shared/lib/errors.ts\";\nimport type { SourceFile } from \"#/shared/native/index.ts\";\n\ninterface MarkdownlintError {\n readonly lineNumber: number;\n readonly ruleNames: readonly string[];\n readonly ruleDescription: string;\n readonly errorDetail?: string | null;\n readonly errorContext?: string | null;\n readonly errorRange?: readonly [number, number] | null;\n}\n\ninterface MarkdownlintOptions {\n readonly strings: Readonly<Record<string, string>>;\n readonly config: Readonly<Record<string, unknown>>;\n readonly customRules: readonly unknown[];\n}\n\ninterface MarkdownlintModule {\n readonly lint: (\n options: MarkdownlintOptions,\n ) => Promise<Readonly<Record<string, readonly MarkdownlintError[]>>>;\n}\n\nexport interface CompatInput {\n readonly files: readonly SourceFile[];\n readonly rules: readonly CompatRule[];\n}\n\nconst MARKDOWNLINT = \"markdownlint/promise\";\n\nconst isMarkdownlint = (value: unknown): value is MarkdownlintModule =>\n Predicate.hasProperty(value, \"lint\") && Predicate.isFunction(value.lint);\n\nconst load = Effect.tryPromise({\n try: (): Promise<unknown> => import(MARKDOWNLINT),\n catch: failedWith(\"markdownlint custom rules need the markdownlint package installed\"),\n}).pipe(\n Effect.filterOrFail(isMarkdownlint, () =>\n Y8Error.make({ message: `${MARKDOWNLINT} does not export lint` }),\n ),\n);\n\nconst ruleOf = (\n rules: readonly CompatRule[],\n error: MarkdownlintError,\n): Option.Option<CompatRule> =>\n pipe(\n Arr.head(error.ruleNames),\n Option.flatMap((name) =>\n pipe(\n rules,\n Arr.findFirst(({ rule }) => pipe(rule.names, Arr.contains(name))),\n ),\n ),\n );\n\nconst rangeFields = (\n error: MarkdownlintError,\n): Partial<{ readonly column: number; readonly length: number }> =>\n present(Option.fromNullishOr(error.errorRange), ([column, length]) => ({ column, length }));\n\nconst diagnosticOf =\n (path: string, rules: readonly CompatRule[]) =>\n (error: MarkdownlintError): Option.Option<Diagnostic> =>\n pipe(\n ruleOf(rules, error),\n Option.map((rule): Diagnostic => ({\n path,\n line: error.lineNumber,\n rule: rule.id,\n message: error.ruleDescription,\n severity: reportedSeverity(rule.setting),\n ...rangeFields(error),\n ...present(Option.fromNullishOr(error.errorDetail), (detail) => ({ detail })),\n ...present(Option.fromNullishOr(error.errorContext), (context) => ({ context })),\n })),\n );\n\nconst settingOf = (rule: CompatRule): unknown =>\n pipe(\n rule.setting.options,\n Option.liftPredicate((options) => !Rec.isEmptyRecord(options)),\n Option.getOrElse((): unknown => true),\n );\n\nconst configOf = (rules: readonly CompatRule[]): Readonly<Record<string, unknown>> =>\n pipe(\n rules,\n Arr.flatMap((rule) =>\n pipe(\n Arr.head(rule.rule.names),\n Option.map((name): readonly [string, unknown] => [name, settingOf(rule)]),\n Option.toArray,\n ),\n ),\n Rec.fromEntries,\n );\n\nconst optionsOf = (input: CompatInput): MarkdownlintOptions => ({\n strings: pipe(\n input.files,\n Arr.map(({ path, text }): readonly [string, string] => [path, text]),\n Rec.fromEntries,\n ),\n config: { default: false, ...configOf(input.rules) },\n customRules: pipe(\n input.rules,\n Arr.map(({ rule }) => rule),\n ),\n});\n\nconst diagnosticsOf =\n (rules: readonly CompatRule[]) =>\n ([path, errors]: readonly [string, readonly MarkdownlintError[]]): readonly Diagnostic[] =>\n pipe(\n errors,\n Arr.flatMap((found) => Option.toArray(diagnosticOf(path, rules)(found))),\n );\n\nconst run = Effect.fn(\"y8.markdownlint_rules\")(function* run(input: CompatInput) {\n const markdownlint = yield* load;\n const results = yield* Effect.tryPromise({\n try: () => markdownlint.lint(optionsOf(input)),\n catch: failedWith(\"a markdownlint custom rule failed\"),\n });\n return pipe(Rec.toEntries(results), Arr.flatMap(diagnosticsOf(input.rules)));\n});\n\nexport const runCompatRules = (input: CompatInput): Effect.Effect<readonly Diagnostic[], Y8Error> =>\n Arr.match(input.rules, {\n onEmpty: () => Effect.succeed([]),\n onNonEmpty: () => run(input),\n });\n","import { Array as Arr, Match, Option, pipe } from \"effect\";\n\nimport type { MarkdownNode, Position } from \"#/shared/config/index.ts\";\nimport { FIELD, NODE_WORDS, TAGS } from \"#/shared/native/index.ts\";\nimport type { NodeType, SourceView } from \"#/shared/native/index.ts\";\n\nconst NONE = 0;\nconst ROOT = 0;\nconst NEXT = 1;\nconst SET = 1;\nconst TITLE = 1;\nconst LABEL = 2;\n\nconst LINKS = [\n \"inline\",\n \"reference\",\n \"collapsed\",\n \"shortcut\",\n \"autolink\",\n \"email\",\n \"wiki\",\n] as const;\n\nexport interface Document {\n readonly root: MarkdownNode;\n readonly textOf: (node: MarkdownNode) => string;\n readonly positionOf: (offset: number) => Position;\n}\n\ntype Data = Readonly<Record<string, unknown>>;\n\ninterface Fields {\n readonly view: SourceView;\n readonly type: NodeType;\n readonly first: number;\n readonly second: number;\n}\n\nconst linkData = ({ view, first, second }: Fields): Data => ({\n link: pipe(\n LINKS,\n Arr.get(first),\n Option.getOrElse(() => LINKS[NONE]),\n ),\n destination: view.stringAt(second),\n title: view.stringAt(second + TITLE),\n label: view.stringAt(second + LABEL),\n});\n\nconst listData = ({ first, second }: Fields): Data => ({\n ordered: first === SET,\n ...pipe(\n Option.some(second),\n Option.filter((value) => value !== NONE),\n Option.match({\n onNone: (): Data => ({}),\n onSome: (value): Data => ({ start: value - NEXT }),\n }),\n ),\n});\n\nconst dataOf = (fields: Fields): Data =>\n Match.value(fields.type).pipe(\n Match.when(\"heading\", (): Data => ({ level: fields.first, setext: fields.second === SET })),\n Match.when(\"codeBlock\", (): Data => ({\n fenced: fields.first === SET,\n info: fields.view.stringAt(fields.second),\n })),\n Match.when(\"list\", () => listData(fields)),\n Match.whenOr(\"footnoteDefinition\", \"footnoteReference\", (): Data => ({\n label: fields.view.stringAt(fields.first),\n })),\n Match.whenOr(\"link\", \"image\", () => linkData(fields)),\n Match.when(\"math\", (): Data => ({ display: fields.first === SET })),\n Match.when(\"taskListMarker\", (): Data => ({ checked: fields.first === SET })),\n Match.orElse((): Data => ({})),\n );\n\nexport const once = <Value>(make: () => Value): (() => Value) => {\n const made: Value[] = [];\n return () =>\n pipe(\n Arr.head(made),\n Option.getOrElse(() => {\n const value = make();\n made.push(value);\n return value;\n }),\n );\n};\n\ninterface Tree {\n readonly at: (id: number) => MarkdownNode;\n readonly field: (id: number, field: number) => number;\n}\n\nconst linked =\n (tree: Tree) =>\n (plusOne: number): Option.Option<MarkdownNode> =>\n pipe(\n Option.some(plusOne),\n Option.filter((value) => value !== NONE),\n Option.map((value) => tree.at(value - NEXT)),\n );\n\nconst childrenOf = (tree: Tree, id: number): readonly MarkdownNode[] => {\n const found: MarkdownNode[] = [];\n for (\n let child = tree.field(id, FIELD.firstChild);\n child !== NONE;\n child = tree.field(child - NEXT, FIELD.nextSibling)\n ) {\n found.push(tree.at(child - NEXT));\n }\n return found;\n};\n\nconst nodeOf = (tree: Tree, view: SourceView, id: number): MarkdownNode => {\n const type = pipe(\n TAGS,\n Arr.get(tree.field(id, FIELD.tag)),\n Option.getOrElse((): NodeType => \"other\"),\n );\n const children = once(() => childrenOf(tree, id));\n const data = once(() =>\n dataOf({\n view,\n type,\n first: tree.field(id, FIELD.first),\n second: tree.field(id, FIELD.second),\n }),\n );\n return {\n type,\n id,\n start: tree.field(id, FIELD.start),\n end: tree.field(id, FIELD.end),\n get parent() {\n return pipe(linked(tree)(tree.field(id, FIELD.parent)), Option.getOrUndefined);\n },\n get children() {\n return children();\n },\n get data() {\n return data();\n },\n };\n};\n\nconst treeOf = (view: SourceView): Tree => {\n const made = new Map<number, MarkdownNode>();\n const tree: Tree = {\n field: (id, field) => view.nodes[id * NODE_WORDS + field] ?? NONE,\n at: (id) =>\n pipe(\n Option.fromNullishOr(made.get(id)),\n Option.getOrElse(() => {\n const node = nodeOf(tree, view, id);\n made.set(id, node);\n return node;\n }),\n ),\n };\n return tree;\n};\n\nconst positionIn =\n (view: SourceView) =>\n (offset: number): Position => {\n const line = Math.max(\n view.lineStarts.findLastIndex((start) => start <= offset),\n ROOT,\n );\n const start = view.lineStarts[line] ?? NONE;\n return { line: line + NEXT, column: view.slice(start, offset).length + NEXT };\n };\n\nexport const documentOf = (view: SourceView): Option.Option<Document> =>\n pipe(\n Option.some(view),\n Option.filter(({ nodeCount }) => nodeCount !== NONE),\n Option.map((source): Document => ({\n root: treeOf(source).at(ROOT),\n textOf: (node) => source.slice(node.start, node.end),\n positionOf: positionIn(source),\n })),\n );\n","import { Option, Predicate, Record as Rec, pipe } from \"effect\";\nimport { parse } from \"yaml\";\n\nimport type { Frontmatter } from \"#/shared/config/index.ts\";\n\nconst BLOCK = /^---\\r?\\n(?<body>[\\s\\S]*?)\\r?\\n---(?:\\r?\\n|$)/u;\n\nconst parsed = (body: string): Option.Option<unknown> =>\n Option.liftThrowable((): unknown => parse(body))();\n\nexport const frontmatterOf = (text: string): Frontmatter | undefined =>\n pipe(\n Option.fromNullishOr(BLOCK.exec(text)),\n Option.flatMap((match) => Option.fromNullishOr(match.groups)),\n Option.flatMap(Rec.get(\"body\")),\n Option.flatMap(parsed),\n Option.filter(Predicate.isObject),\n Option.getOrUndefined,\n );\n","import { present } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport { reportedSeverity } from \"#/entities/rule/index.ts\";\nimport type { ScriptRule } from \"#/entities/rule/index.ts\";\nimport type { Diagnostic, MarkdownNode, Project, Report, Visitors } from \"#/shared/config/index.ts\";\nimport type { SourceView } from \"#/shared/native/index.ts\";\n\nimport { documentOf, once } from \"./document.ts\";\nimport type { Document } from \"./document.ts\";\nimport { frontmatterOf } from \"./frontmatter.ts\";\n\nconst EXIT = \":exit\";\nconst FIRST_LINE = 1;\nconst LINE_BREAK = /\\r\\n|\\r|\\n/u;\n\nexport interface ScriptInput {\n readonly path: string;\n readonly source: SourceView;\n readonly rules: readonly ScriptRule[];\n readonly project: Project;\n}\n\ntype Handler = (node: MarkdownNode) => void;\n\nconst handlerOf = (visitor: Visitors, key: keyof Visitors): Option.Option<Handler> =>\n Option.fromNullishOr(visitor[key]);\n\nconst visit = (visitors: readonly Visitors[], key: keyof Visitors, node: MarkdownNode): void => {\n for (const visitor of visitors) {\n for (const handler of Option.toArray(handlerOf(visitor, key))) {\n handler(node);\n }\n }\n};\n\nconst walk = (visitors: readonly Visitors[], node: MarkdownNode): void => {\n visit(visitors, node.type, node);\n for (const child of node.children) {\n walk(visitors, child);\n }\n visit(visitors, `${node.type}${EXIT}`, node);\n};\n\ntype Extras = Partial<{\n readonly column: number;\n readonly length: number;\n readonly detail: string;\n}>;\n\nconst extras = (report: Report, position: Option.Option<{ readonly column: number }>): Extras => ({\n ...present(\n pipe(\n Option.fromNullishOr(report.column),\n Option.orElse(() =>\n pipe(\n position,\n Option.map(({ column }) => column),\n ),\n ),\n ),\n (column) => ({ column }),\n ),\n ...present(Option.fromNullishOr(report.length), (length) => ({ length })),\n ...present(Option.fromNullishOr(report.detail), (detail) => ({ detail })),\n});\n\nconst diagnosticOf =\n (path: string, document: Document, rule: ScriptRule) =>\n (report: Report): Diagnostic => {\n const position = pipe(\n Option.fromNullishOr(report.node),\n Option.map((node) => document.positionOf(node.start)),\n );\n const line = pipe(\n Option.fromNullishOr(report.line),\n Option.orElse(() =>\n pipe(\n position,\n Option.map(({ line: at }) => at),\n ),\n ),\n Option.getOrElse(() => FIRST_LINE),\n );\n return {\n path,\n line,\n rule: rule.id,\n message: report.message,\n severity: reportedSeverity(rule.setting),\n ...extras(report, position),\n };\n };\n\nconst runOn = (input: ScriptInput, document: Document): readonly Diagnostic[] => {\n const found: Diagnostic[] = [];\n const text = input.source.text();\n const lines = once(() => Str.split(text, LINE_BREAK));\n const frontmatter = once(() => frontmatterOf(text));\n const visitors = pipe(\n input.rules,\n Arr.map((rule) => {\n const toDiagnostic = diagnosticOf(input.path, document, rule);\n return rule.rule.create({\n filename: input.path,\n get frontmatter() {\n return frontmatter();\n },\n exists: input.project.exists,\n filesUnder: input.project.under,\n manifest: input.project.manifestOf(input.path),\n text,\n get lines() {\n return lines();\n },\n options: rule.setting.options,\n root: document.root,\n textOf: document.textOf,\n positionOf: document.positionOf,\n report: (report) => {\n found.push(toDiagnostic(report));\n },\n });\n }),\n );\n walk(visitors, document.root);\n return found;\n};\n\nexport const runScriptRules = (input: ScriptInput): readonly Diagnostic[] =>\n pipe(\n documentOf(input.source),\n Option.filter(() => Arr.isReadonlyArrayNonEmpty(input.rules)),\n Option.map((document) => runOn(input, document)),\n Option.getOrElse((): readonly Diagnostic[] => []),\n );\n","import { callAddon, present, sortByPosition, traceparent } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Effect, Match, Option, pipe } from \"effect\";\n\nimport { BUILTIN, groupByOverrides, resolve, unknownPlugins } from \"#/entities/rule/index.ts\";\nimport type { FileGroup, Resolved } from \"#/entities/rule/index.ts\";\nimport { agentDiagnosticsOf } from \"#/features/map-agent-diagnostics/index.ts\";\nimport { readProject } from \"#/features/read-project/index.ts\";\nimport { runCompatRules } from \"#/features/run-compat-rules/index.ts\";\nimport { runScriptRules } from \"#/features/run-rules/index.ts\";\nimport type { Diagnostic, Project, Y8Config } from \"#/shared/config/index.ts\";\nimport { Y8Error, failedWith } from \"#/shared/lib/errors.ts\";\nimport { native, sourceView } from \"#/shared/native/index.ts\";\nimport type {\n NativeDiagnostic,\n NativeOptions,\n NativeResult,\n SourceFile,\n SourceView,\n} from \"#/shared/native/index.ts\";\n\nexport interface LintInput {\n readonly root: string;\n readonly files: readonly string[];\n readonly projectFiles?: readonly string[];\n readonly config?: Y8Config;\n}\n\ntype RangeFields = Partial<{ readonly column: number; readonly length: number }>;\n\nconst rangeOf = (diagnostic: NativeDiagnostic): RangeFields =>\n present(Option.fromNullishOr(diagnostic.range), ([column, length]) => ({ column, length }));\n\nconst severityOf = (diagnostic: NativeDiagnostic): Diagnostic[\"severity\"] =>\n Match.value(diagnostic.severity).pipe(\n Match.when(\"warning\", (): Diagnostic[\"severity\"] => \"warn\"),\n Match.orElse((): Diagnostic[\"severity\"] => \"error\"),\n );\n\nconst fromNative =\n (path: string) =>\n (diagnostic: NativeDiagnostic): Diagnostic => ({\n path,\n line: diagnostic.line,\n rule: `${BUILTIN}/${Option.getOrElse(Arr.head(diagnostic.ruleNames), () => \"\")}`,\n message: diagnostic.description,\n severity: severityOf(diagnostic),\n ...rangeOf(diagnostic),\n ...present(Option.fromNullishOr(diagnostic.detail), (detail) => ({ detail })),\n ...present(Option.fromNullishOr(diagnostic.context), (context) => ({ context })),\n });\n\nconst needsText = (resolved: Resolved): boolean =>\n Arr.isReadonlyArrayNonEmpty(resolved.scripts) || Arr.isReadonlyArrayNonEmpty(resolved.compat);\n\nconst nativeOptions = (\n root: string,\n resolved: Resolved,\n config: Y8Config,\n): Effect.Effect<NativeOptions> =>\n traceparent.pipe(\n Effect.map((parent): NativeOptions => ({\n config: resolved.core,\n inlineConfig: config.inlineConfig ?? true,\n keepTree: Arr.isReadonlyArrayNonEmpty(resolved.scripts),\n keepSource: needsText(resolved),\n ...present(parent, (value) => ({ traceparent: value })),\n ...present(resolved.agent, ({ disabled }) => ({ agnix: { root, disabled } })),\n })),\n );\n\nconst viewOf = (result: NativeResult): Option.Option<SourceView> =>\n pipe(Option.fromNullishOr(result.source), Option.map(sourceView));\n\nconst sourceOf = (result: NativeResult): Option.Option<SourceFile> =>\n pipe(\n viewOf(result),\n Option.map((view): SourceFile => ({ path: result.path, text: view.text() })),\n );\n\nconst scriptedOne =\n (resolved: Resolved, project: Project) =>\n (result: NativeResult): readonly Diagnostic[] =>\n pipe(\n viewOf(result),\n Option.map((source) =>\n runScriptRules({\n path: result.path,\n source,\n rules: resolved.scripts,\n project,\n }),\n ),\n Option.getOrElse((): readonly Diagnostic[] => []),\n );\n\nconst builtinOf = (result: NativeResult): readonly Diagnostic[] =>\n pipe(result.diagnostics, Arr.map(fromNative(result.path)));\n\nconst checkPlugins = (config: Y8Config): Effect.Effect<void, Y8Error> =>\n Arr.match(unknownPlugins(config), {\n onEmpty: () => Effect.void,\n onNonEmpty: (names) =>\n Effect.fail(\n Y8Error.make({\n message: `rules name plugins that are not configured: ${Arr.join(names, \", \")}`,\n }),\n ),\n });\n\nconst lintGroup = (\n root: string,\n project: Project,\n): ((group: FileGroup) => Effect.Effect<readonly Diagnostic[], Y8Error>) =>\n Effect.fn(\"y8.lint.group\")(function* group(input: FileGroup) {\n const resolved = resolve(input.config);\n const options = yield* nativeOptions(root, resolved, input.config);\n const results = yield* callAddon({\n addon: native,\n name: \"y8\",\n files: input.files.length,\n call: (addon) => addon.lintPaths(root, input.files, options),\n failWith: failedWith,\n });\n const compat = yield* runCompatRules({\n files: pipe(\n results,\n Arr.flatMap((result) => Option.toArray(sourceOf(result))),\n ),\n rules: resolved.compat,\n });\n const builtin = pipe(results, Arr.flatMap(builtinOf));\n const scripted = yield* Effect.sync(() =>\n pipe(results, Arr.flatMap(scriptedOne(resolved, project))),\n ).pipe(\n Effect.withSpan(\"y8.script_rules\", {\n attributes: { \"y8.files\": results.length, \"y8.rules\": resolved.scripts.length },\n }),\n );\n const agent = Option.match(resolved.agent, {\n onNone: (): readonly Diagnostic[] => [],\n onSome: (rules) => pipe(results, Arr.flatMap(agentDiagnosticsOf(rules))),\n });\n return [...builtin, ...scripted, ...compat, ...agent];\n });\n\nexport const lint = Effect.fn(\"y8.lint\")(function* lint(input: LintInput) {\n const config = input.config ?? {};\n yield* checkPlugins(config);\n const project = yield* readProject({\n root: input.root,\n files: input.files,\n projectFiles: input.projectFiles ?? [],\n });\n const found = yield* Effect.forEach(\n groupByOverrides(config, input.files),\n lintGroup(input.root, project),\n { concurrency: 1 },\n );\n return sortByPosition<Diagnostic>(Arr.flatten(found));\n});\n","import { Array as Arr, Option, Predicate, pipe } from \"effect\";\n\nimport type { Y8Config } from \"#/shared/config/index.ts\";\n\nconst MARKDOWN = \"*.md\";\n\nconst hasSection = (value: unknown): value is { readonly y8: Y8Config } =>\n Predicate.hasProperty(value, \"y8\") && Predicate.isObject(value.y8);\n\nexport const y8Section = (config: unknown): Y8Config =>\n pipe(\n Option.liftPredicate(config, hasSection),\n Option.map((value) => value.y8),\n Option.getOrElse((): Y8Config => ({})),\n );\n\nexport interface PathspecInput {\n readonly config: Y8Config;\n readonly patterns?: readonly string[];\n}\n\nexport const markdownPathspecs = ({\n config,\n patterns = [MARKDOWN],\n}: PathspecInput): readonly string[] => [\n ...patterns,\n ...pipe(\n config.ignores ?? [],\n Arr.map((glob) => `:(glob,exclude)${glob}`),\n ),\n];\n"],"mappings":";;;;;AAEA,MAAa,QAAgB,EAAE,aAAa,KAAK;;ACAjD,MAAa,cAAc,SAAqB;AAEhD,MAAa,gBAAgB,WAA2B;;ACSxD,MAAa,UAAU;AAEvB,MAAMA,cAAY;AAClB,MAAM,QAAQ;AAId,MAAa,oBAAoB,YAC/B,MAAM,MAAM,QAAQ,QAAQ,CAAC,CAAC,KAC5B,MAAM,KAAK,cAAsC,MAAM,GACvD,MAAM,aAAqC,OAAO,CACpD;AAkCF,MAAM,YAAY,OAChB,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AAM,gBAAgB,CAAC;CACvC,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,QAC1B,iBAAiB,QAAQ,MAAM,KAAK,GACpC,UAAU,MAAM,MAAM,OAAO,GAC7B,EAAE,aAAa,EAAE,CACnB;CACA,OAAO,eAA2BA,MAAI,QAAQ,KAAK,CAAC;AACtD,CAAC;;AC3JD,MAAM,WAAW;AAEjB,MAAM,cAAc,UAClB,UAAU,YAAY,OAAO,IAAI,KAAK,UAAU,SAAS,MAAM,EAAE;AAEnE,MAAa,aAAa,WACxB,KACE,OAAO,cAAc,QAAQ,UAAU,GACvC,OAAO,KAAK,UAAU,MAAM,EAAE,GAC9B,OAAO,iBAA2B,CAAC,EAAE,CACvC;AAOF,MAAa,qBAAqB,EAChC,QACA,WAAW,CAAC,QAAQ,QACkB,CACtC,GAAG,UACH,GAAG,KACD,OAAO,WAAW,CAAC,GACnBC,MAAI,KAAK,SAAS,kBAAkB,MAAM,CAC5C,CACF"}
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { l as failedWith, p as runCli$1 } from "./split-morphemes-BS74IEHA.mjs";
|
|
3
|
+
import { a as format, n as y8Section, r as lint, t as markdownPathspecs } from "./app-D5BcM070.mjs";
|
|
4
|
+
// src/app/cli.ts
|
|
5
|
+
const runCli = () => {
|
|
6
|
+
runCli$1({
|
|
7
|
+
name: "y8",
|
|
8
|
+
section: y8Section,
|
|
9
|
+
pathspecs: markdownPathspecs,
|
|
10
|
+
lint,
|
|
11
|
+
format,
|
|
12
|
+
failWith: failedWith
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
// bin/y8.ts
|
|
16
|
+
runCli();
|
|
17
|
+
export {};
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/app/cli.ts","../bin/y8.ts"],"sourcesContent":["import { runCli as runLinter } from \"@masseater.dev/lint-host\";\n\nimport { failedWith } from \"#/shared/lib/errors.ts\";\n\nimport { format, lint } from \"./index.ts\";\nimport { markdownPathspecs, y8Section } from \"./section.ts\";\n\nexport const runCli = (): void => {\n runLinter({\n name: \"y8\",\n section: y8Section,\n pathspecs: markdownPathspecs,\n lint,\n format,\n failWith: failedWith,\n });\n};\n","#!/usr/bin/env node\nimport { runCli } from \"#/app/cli.ts\";\n\nrunCli();\n"],"mappings":";;;;AAOA,MAAa,eAAqB;CAChC,SAAU;EACR,MAAM;EACN,SAAS;EACT,WAAW;EACX;EACA;EACA,UAAU;CACZ,CAAC;AACH;;ACbA,OAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as Morpheme } from "./index-Dvd9WB0d.mjs";
|
|
2
|
+
interface Tokenizer {
|
|
3
|
+
readonly tokenize: (text: string) => readonly Morpheme[];
|
|
4
|
+
readonly tokenizeForSentence: (text: string) => readonly Morpheme[];
|
|
5
|
+
}
|
|
6
|
+
declare const morphemesOf: (text: string) => readonly Morpheme[];
|
|
7
|
+
declare const getTokenizer: () => Promise<Tokenizer>;
|
|
8
|
+
declare const tokenize: (text: string) => Promise<readonly Morpheme[]>;
|
|
9
|
+
export { tokenize as i, getTokenizer as n, morphemesOf as r, Tokenizer as t };
|
|
10
|
+
//# sourceMappingURL=index-AoTF_uMY.d.mts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { n as NodeType } from "./index-Dvd9WB0d.mjs";
|
|
2
|
+
import { Effect, Option } from "effect";
|
|
3
|
+
type Severity = "off" | "warn" | "error";
|
|
4
|
+
type RuleOptions = Readonly<Record<string, unknown>>;
|
|
5
|
+
type RuleEntry = Severity | readonly [Severity] | readonly [Severity, RuleOptions];
|
|
6
|
+
interface Position {
|
|
7
|
+
readonly line: number;
|
|
8
|
+
readonly column: number;
|
|
9
|
+
}
|
|
10
|
+
interface MarkdownNode {
|
|
11
|
+
readonly type: NodeType;
|
|
12
|
+
readonly id: number;
|
|
13
|
+
readonly start: number;
|
|
14
|
+
readonly end: number;
|
|
15
|
+
readonly parent: MarkdownNode | undefined;
|
|
16
|
+
readonly children: readonly MarkdownNode[];
|
|
17
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
18
|
+
}
|
|
19
|
+
interface Report {
|
|
20
|
+
readonly message: string;
|
|
21
|
+
readonly node?: MarkdownNode;
|
|
22
|
+
readonly line?: number;
|
|
23
|
+
readonly column?: number;
|
|
24
|
+
readonly length?: number;
|
|
25
|
+
readonly detail?: string;
|
|
26
|
+
}
|
|
27
|
+
type Frontmatter = Readonly<Record<string, unknown>>;
|
|
28
|
+
interface PackageManifest {
|
|
29
|
+
readonly directory: string;
|
|
30
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
31
|
+
}
|
|
32
|
+
interface RuleContext {
|
|
33
|
+
readonly filename: string;
|
|
34
|
+
readonly frontmatter: Frontmatter | undefined;
|
|
35
|
+
readonly exists: (path: string) => boolean;
|
|
36
|
+
readonly filesUnder: (directory: string) => readonly string[];
|
|
37
|
+
readonly manifest: PackageManifest | undefined;
|
|
38
|
+
readonly text: string;
|
|
39
|
+
readonly lines: readonly string[];
|
|
40
|
+
readonly options: RuleOptions;
|
|
41
|
+
readonly root: MarkdownNode;
|
|
42
|
+
readonly textOf: (node: MarkdownNode) => string;
|
|
43
|
+
readonly positionOf: (offset: number) => Position;
|
|
44
|
+
readonly report: (report: Report) => void;
|
|
45
|
+
}
|
|
46
|
+
type Visitors = Readonly<Partial<Record<NodeType | `${NodeType}:exit`, (node: MarkdownNode) => void>>>;
|
|
47
|
+
interface Rule {
|
|
48
|
+
readonly meta: {
|
|
49
|
+
readonly description: string;
|
|
50
|
+
readonly tags?: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
readonly create: (context: RuleContext) => Visitors;
|
|
53
|
+
}
|
|
54
|
+
interface MarkdownlintRule {
|
|
55
|
+
readonly names: readonly string[];
|
|
56
|
+
readonly description: string;
|
|
57
|
+
readonly tags: readonly string[];
|
|
58
|
+
readonly parser: string;
|
|
59
|
+
readonly function: unknown;
|
|
60
|
+
readonly [field: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
interface Plugin {
|
|
63
|
+
readonly rules?: Readonly<Record<string, Rule>>;
|
|
64
|
+
readonly markdownlintRules?: readonly MarkdownlintRule[];
|
|
65
|
+
readonly agentConfig?: boolean;
|
|
66
|
+
}
|
|
67
|
+
interface Override {
|
|
68
|
+
readonly files: readonly string[];
|
|
69
|
+
readonly rules: Readonly<Record<string, RuleEntry>>;
|
|
70
|
+
}
|
|
71
|
+
interface Y8Config {
|
|
72
|
+
readonly plugins?: Readonly<Record<string, Plugin>>;
|
|
73
|
+
readonly rules?: Readonly<Record<string, RuleEntry>>;
|
|
74
|
+
readonly ignores?: readonly string[];
|
|
75
|
+
readonly inlineConfig?: boolean;
|
|
76
|
+
readonly overrides?: readonly Override[];
|
|
77
|
+
}
|
|
78
|
+
interface Diagnostic {
|
|
79
|
+
readonly path: string;
|
|
80
|
+
readonly line: number;
|
|
81
|
+
readonly column?: number;
|
|
82
|
+
readonly length?: number;
|
|
83
|
+
readonly rule: string;
|
|
84
|
+
readonly message: string;
|
|
85
|
+
readonly detail?: string;
|
|
86
|
+
readonly context?: string;
|
|
87
|
+
readonly severity: Exclude<Severity, "off">;
|
|
88
|
+
}
|
|
89
|
+
export { Override as a, Position as c, RuleContext as d, Visitors as f, Severity as g, RuleOptions as h, MarkdownlintRule as i, Report as l, RuleEntry as m, Frontmatter as n, PackageManifest as o, Y8Config as p, MarkdownNode as r, Plugin as s, Diagnostic as t, Rule as u };
|
|
90
|
+
//# sourceMappingURL=index-CS7Sntk8.d.mts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
declare const Y8Error_base: Schema.Class<Y8Error, Schema.TaggedStruct<"Y8Error", {
|
|
3
|
+
readonly message: Schema.String;
|
|
4
|
+
}>, import("effect/Cause").YieldableError & {
|
|
5
|
+
readonly brand: unique symbol;
|
|
6
|
+
}>;
|
|
7
|
+
declare class Y8Error extends Y8Error_base {}
|
|
8
|
+
type NodeType = "document" | "paragraph" | "heading" | "blockQuote" | "codeBlock" | "htmlBlock" | "list" | "listItem" | "footnoteDefinition" | "table" | "tableHead" | "tableRow" | "tableCell" | "emphasis" | "strong" | "strikethrough" | "link" | "image" | "text" | "code" | "html" | "inlineHtml" | "softBreak" | "hardBreak" | "thematicBreak" | "math" | "mathBlock" | "footnoteReference" | "taskListMarker" | "other";
|
|
9
|
+
interface Morpheme {
|
|
10
|
+
readonly word_id: number;
|
|
11
|
+
readonly word_type: "KNOWN" | "UNKNOWN";
|
|
12
|
+
readonly surface_form: string;
|
|
13
|
+
readonly pos: string;
|
|
14
|
+
readonly pos_detail_1: string;
|
|
15
|
+
readonly pos_detail_2: string;
|
|
16
|
+
readonly pos_detail_3: string;
|
|
17
|
+
readonly conjugated_type: string;
|
|
18
|
+
readonly conjugated_form: string;
|
|
19
|
+
readonly basic_form: string;
|
|
20
|
+
readonly reading?: string;
|
|
21
|
+
readonly pronunciation?: string;
|
|
22
|
+
readonly word_position: number;
|
|
23
|
+
}
|
|
24
|
+
export { NodeType as n, Y8Error as r, Morpheme as t };
|
|
25
|
+
//# sourceMappingURL=index-Dvd9WB0d.d.mts.map
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { a as Override, c as Position, d as RuleContext, f as Visitors, g as Severity, h as RuleOptions, i as MarkdownlintRule, l as Report, m as RuleEntry, n as Frontmatter, o as PackageManifest, p as Y8Config, r as MarkdownNode, s as Plugin, t as Diagnostic, u as Rule } from "./index-CS7Sntk8.mjs";
|
|
2
|
+
import { r as Y8Error, t as Morpheme } from "./index-Dvd9WB0d.mjs";
|
|
3
|
+
import { i as tokenize, r as morphemesOf } from "./index-AoTF_uMY.mjs";
|
|
4
|
+
import { Effect, Option } from "effect";
|
|
5
|
+
export declare const agnix: Plugin;
|
|
6
|
+
export declare const defineRule: (rule: Rule) => Rule;
|
|
7
|
+
export declare const definePlugin: (plugin: Plugin) => Plugin;
|
|
8
|
+
export declare const diagnosticDetail: (diagnostic: Diagnostic) => string;
|
|
9
|
+
export declare const format: (diagnostic: Diagnostic) => string;
|
|
10
|
+
interface LintInput {
|
|
11
|
+
readonly root: string;
|
|
12
|
+
readonly files: readonly string[];
|
|
13
|
+
readonly projectFiles?: readonly string[];
|
|
14
|
+
readonly config?: Y8Config;
|
|
15
|
+
}
|
|
16
|
+
export declare const lint: (input: LintInput) => Effect.Effect<Diagnostic[], Y8Error, never>;
|
|
17
|
+
export declare const y8Section: (config: unknown) => Y8Config;
|
|
18
|
+
interface PathspecInput {
|
|
19
|
+
readonly config: Y8Config;
|
|
20
|
+
readonly patterns?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export declare const markdownPathspecs: ({ config, patterns }: PathspecInput) => readonly string[];
|
|
23
|
+
export { type Diagnostic, type Frontmatter, type LintInput, type MarkdownNode, type MarkdownlintRule, type Morpheme, type Override, type PackageManifest, type PathspecInput, type Plugin, type Position, type Report, type Rule, type RuleContext, type RuleEntry, type RuleOptions, type Severity, type Visitors, type Y8Config, Y8Error, morphemesOf, tokenize };
|
|
24
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as format, c as agnix, i as diagnosticDetail, n as y8Section, o as definePlugin, r as lint, s as defineRule, t as markdownPathspecs } from "./app-D5BcM070.mjs";
|
|
2
|
+
import { c as Y8Error, n as morphemesOf, r as tokenize } from "./split-morphemes-BS74IEHA.mjs";
|
|
3
|
+
export { Y8Error, agnix, definePlugin, defineRule, diagnosticDetail, format, lint, markdownPathspecs, morphemesOf, tokenize, y8Section };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as getTokenizer, r as tokenize } from "./split-morphemes-BS74IEHA.mjs";
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { Array, Boolean, Console, Effect, FileSystem, Function, Layer, Match, Option, Order, Path, Predicate, Record, Schema, String as String$1, pipe } from "effect";
|
|
3
|
+
import { NodeServices } from "@effect/platform-node";
|
|
4
|
+
import { runMain } from "@effect/platform-node/NodeRuntime";
|
|
5
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
6
|
+
import { FetchHttpClient } from "effect/http";
|
|
7
|
+
import { Otlp, OtlpSerialization } from "effect/observability";
|
|
8
|
+
import { resolveConfigFromFile } from "vite-plus";
|
|
9
|
+
// ../lint-host/src/entities/rule/model/setting.ts
|
|
10
|
+
const NO_OPTIONS = {};
|
|
11
|
+
const settingOf = (entry) => Match.value(entry).pipe(Match.when(Match.string, (severity) => ({
|
|
12
|
+
severity,
|
|
13
|
+
options: NO_OPTIONS
|
|
14
|
+
})), Match.orElse(([severity, options]) => ({
|
|
15
|
+
severity,
|
|
16
|
+
options: options ?? NO_OPTIONS
|
|
17
|
+
})));
|
|
18
|
+
// ../lint-host/src/shared/lib/target.ts
|
|
19
|
+
const abiOf = (platform) => Match.value(platform).pipe(Match.when("linux", () => "-gnu"), Match.when("win32", () => "-msvc"), Match.orElse(() => ""));
|
|
20
|
+
const platformTarget = `${process.platform}-${process.arch}${abiOf(process.platform)}`;
|
|
21
|
+
const addonFileOf = (binary) => `${binary}.${platformTarget}.node`;
|
|
22
|
+
// ../lint-host/src/features/build-addon/model/build.ts
|
|
23
|
+
const taggedError$1 = Schema.TaggedError;
|
|
24
|
+
var AddonBuildFailed = class extends taggedError$1()("AddonBuildFailed", { message: Schema.String }) {};
|
|
25
|
+
const LIBRARY = {
|
|
26
|
+
linux: (name) => `lib${name}.so`,
|
|
27
|
+
darwin: (name) => `lib${name}.dylib`,
|
|
28
|
+
win32: (name) => `${name}.dll`
|
|
29
|
+
};
|
|
30
|
+
const SUCCESS = 0;
|
|
31
|
+
const cargo = Effect.fn("cargo")(function* cargo(crate, workspace) {
|
|
32
|
+
const exitCode = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make("cargo", [
|
|
33
|
+
"build",
|
|
34
|
+
"--release",
|
|
35
|
+
"--locked",
|
|
36
|
+
"-p",
|
|
37
|
+
crate
|
|
38
|
+
], {
|
|
39
|
+
cwd: workspace,
|
|
40
|
+
stdout: "inherit",
|
|
41
|
+
stderr: "inherit"
|
|
42
|
+
}));
|
|
43
|
+
const failure = AddonBuildFailed.make({ message: `cargo exited with ${String(exitCode)}` });
|
|
44
|
+
yield* Effect.when(Effect.fail(failure), Effect.sync(() => Number(exitCode) !== SUCCESS));
|
|
45
|
+
});
|
|
46
|
+
Effect.fn("buildAddon")(function* build(options) {
|
|
47
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
48
|
+
const path = yield* Path.Path;
|
|
49
|
+
const library = yield* Effect.fromOption(Record.get(LIBRARY, process.platform)).pipe(Effect.mapError(() => AddonBuildFailed.make({ message: `no native build for ${process.platform}` })));
|
|
50
|
+
yield* cargo(options.crate, options.workspaceDir);
|
|
51
|
+
const output = path.join(options.packageDir, "native");
|
|
52
|
+
yield* fileSystem.makeDirectory(output, { recursive: true });
|
|
53
|
+
const built = library(String$1.replaceAll("-", "_")(options.crate));
|
|
54
|
+
yield* fileSystem.copyFile(path.join(options.workspaceDir, "target", "release", built), path.join(output, addonFileOf(options.binary)));
|
|
55
|
+
});
|
|
56
|
+
// ../lint-host/src/features/load-addon/model/load.ts
|
|
57
|
+
const loadAddon = ({ packageName, binary, from, isAddon, failWith }) => {
|
|
58
|
+
const requireFrom = createRequire(from);
|
|
59
|
+
const loadFrom = (specifier) => Effect.try({
|
|
60
|
+
try: () => requireFrom(specifier),
|
|
61
|
+
catch: failWith(`could not load ${specifier}`)
|
|
62
|
+
});
|
|
63
|
+
return loadFrom(`${packageName}-${platformTarget}`).pipe(Effect.catchCause(() => loadFrom(`${packageName}/native/${addonFileOf(binary)}`)), Effect.filterOrFail(isAddon, (found) => failWith(`no ${binary} addon for ${platformTarget}`)(found)));
|
|
64
|
+
};
|
|
65
|
+
const callAddon = ({ addon, name, files, call, failWith }) => addon.pipe(Effect.flatMap((loaded) => Effect.try({
|
|
66
|
+
try: () => call(loaded),
|
|
67
|
+
catch: failWith(`${name} could not lint`)
|
|
68
|
+
}).pipe(Effect.tap(() => Effect.promise(() => loaded.flushTelemetry())))), Effect.withSpan(`${name}.native`, { attributes: { [`${name}.files`]: files } }));
|
|
69
|
+
// ../lint-host/src/features/run-cli/model/cli.ts
|
|
70
|
+
const CONFIG_FILES = [
|
|
71
|
+
"vite.config.ts",
|
|
72
|
+
"vite.config.mts",
|
|
73
|
+
"vite.config.js",
|
|
74
|
+
"vite.config.mjs"
|
|
75
|
+
];
|
|
76
|
+
const FAILED = 1;
|
|
77
|
+
const ARGUMENTS_START = 2;
|
|
78
|
+
const configOf = (cli, root) => Effect.gen(function* readConfig() {
|
|
79
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
80
|
+
const path = yield* Path.Path;
|
|
81
|
+
const found = yield* pipe(CONFIG_FILES, Array.map((name) => path.join(root, name)), Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))));
|
|
82
|
+
const loaded = yield* Option.match(Array.head(found), {
|
|
83
|
+
onNone: () => Effect.succeed({}),
|
|
84
|
+
onSome: (file) => Effect.tryPromise({
|
|
85
|
+
try: () => resolveConfigFromFile(file),
|
|
86
|
+
catch: cli.failWith(`could not load ${file}`)
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
return cli.section(loaded);
|
|
90
|
+
}).pipe(Effect.withSpan(`${cli.name}.config`));
|
|
91
|
+
const trackedFiles = (root, pathspecs) => Effect.gen(function* listFiles() {
|
|
92
|
+
const output = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).string(ChildProcess.make("git", [
|
|
93
|
+
"ls-files",
|
|
94
|
+
"-co",
|
|
95
|
+
"--exclude-standard",
|
|
96
|
+
"-z",
|
|
97
|
+
"--",
|
|
98
|
+
...pathspecs
|
|
99
|
+
], { cwd: root }));
|
|
100
|
+
return pipe(String$1.split(output, "\0"), Array.filter(String$1.isNonEmpty));
|
|
101
|
+
});
|
|
102
|
+
const requestOf = (config, patterns) => Array.match(patterns, {
|
|
103
|
+
onEmpty: () => ({ config }),
|
|
104
|
+
onNonEmpty: (given) => ({
|
|
105
|
+
config,
|
|
106
|
+
patterns: given
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
const hasError = (found) => pipe(found, Array.some(({ severity }) => severity === "error"));
|
|
110
|
+
const mainOf = (cli) => Effect.gen(function* main() {
|
|
111
|
+
const root = process.cwd();
|
|
112
|
+
const config = yield* configOf(cli, root);
|
|
113
|
+
const patterns = process.argv.slice(ARGUMENTS_START);
|
|
114
|
+
const files = yield* trackedFiles(root, cli.pathspecs(requestOf(config, patterns))).pipe(Effect.withSpan(`${cli.name}.files`));
|
|
115
|
+
const projectFiles = yield* trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`));
|
|
116
|
+
const found = yield* cli.lint({
|
|
117
|
+
root,
|
|
118
|
+
files,
|
|
119
|
+
projectFiles,
|
|
120
|
+
config
|
|
121
|
+
});
|
|
122
|
+
yield* Array.match(found, {
|
|
123
|
+
onEmpty: () => Effect.void,
|
|
124
|
+
onNonEmpty: (all) => Console.log(pipe(all, Array.map(cli.format), Array.join("\n")))
|
|
125
|
+
});
|
|
126
|
+
yield* Effect.when(Effect.sync(() => {
|
|
127
|
+
process.exitCode = FAILED;
|
|
128
|
+
}), Effect.sync(() => hasError(found)));
|
|
129
|
+
});
|
|
130
|
+
const runCli = (cli) => {
|
|
131
|
+
const services = Otlp.layerFromConfig({ resource: { serviceName: cli.name } }).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer), Layer.provideMerge(NodeServices.layer));
|
|
132
|
+
runMain(mainOf(cli).pipe(Effect.provide(services)));
|
|
133
|
+
};
|
|
134
|
+
const present = Function.dual(2, (value, build) => Option.match(value, {
|
|
135
|
+
onNone: () => ({}),
|
|
136
|
+
onSome: build
|
|
137
|
+
}));
|
|
138
|
+
// ../lint-host/src/shared/lib/trace.ts
|
|
139
|
+
const SAMPLED = "01";
|
|
140
|
+
const NOT_SAMPLED = "00";
|
|
141
|
+
const flagsOf = (sampled) => Boolean.match(sampled, {
|
|
142
|
+
onFalse: () => NOT_SAMPLED,
|
|
143
|
+
onTrue: () => SAMPLED
|
|
144
|
+
});
|
|
145
|
+
const traceparent = Effect.currentSpan.pipe(Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`), Effect.option);
|
|
146
|
+
const byPosition = Order.combine(Order.mapInput(Order.String, (found) => found.path), Order.mapInput(Order.Number, (found) => found.line));
|
|
147
|
+
const sortByPosition = (found) => Array.sort(found, byPosition);
|
|
148
|
+
// src/shared/lib/errors.ts
|
|
149
|
+
const taggedError = Schema.TaggedError;
|
|
150
|
+
var Y8Error = class extends taggedError()("Y8Error", { message: Schema.String }) {};
|
|
151
|
+
const failedWith = (message) => (cause) => Y8Error.make({ message: `${message}: ${String(cause)}` });
|
|
152
|
+
// src/shared/native/source.ts
|
|
153
|
+
const WORD = 4;
|
|
154
|
+
const EMPTY = 0;
|
|
155
|
+
const HEADER_WORDS = 5;
|
|
156
|
+
const HEADER = {
|
|
157
|
+
nodes: 0,
|
|
158
|
+
strings: 1,
|
|
159
|
+
lines: 2,
|
|
160
|
+
text: 3
|
|
161
|
+
};
|
|
162
|
+
const STRING_WORDS = 2;
|
|
163
|
+
const LENGTH = 1;
|
|
164
|
+
const FIELD = {
|
|
165
|
+
tag: 0,
|
|
166
|
+
start: 1,
|
|
167
|
+
end: 2,
|
|
168
|
+
parent: 3,
|
|
169
|
+
firstChild: 4,
|
|
170
|
+
nextSibling: 5,
|
|
171
|
+
first: 6,
|
|
172
|
+
second: 7
|
|
173
|
+
};
|
|
174
|
+
const TAGS = [
|
|
175
|
+
"document",
|
|
176
|
+
"paragraph",
|
|
177
|
+
"heading",
|
|
178
|
+
"blockQuote",
|
|
179
|
+
"codeBlock",
|
|
180
|
+
"htmlBlock",
|
|
181
|
+
"list",
|
|
182
|
+
"listItem",
|
|
183
|
+
"footnoteDefinition",
|
|
184
|
+
"table",
|
|
185
|
+
"tableHead",
|
|
186
|
+
"tableRow",
|
|
187
|
+
"tableCell",
|
|
188
|
+
"emphasis",
|
|
189
|
+
"strong",
|
|
190
|
+
"strikethrough",
|
|
191
|
+
"link",
|
|
192
|
+
"image",
|
|
193
|
+
"text",
|
|
194
|
+
"code",
|
|
195
|
+
"html",
|
|
196
|
+
"inlineHtml",
|
|
197
|
+
"softBreak",
|
|
198
|
+
"hardBreak",
|
|
199
|
+
"thematicBreak",
|
|
200
|
+
"math",
|
|
201
|
+
"mathBlock",
|
|
202
|
+
"footnoteReference",
|
|
203
|
+
"taskListMarker",
|
|
204
|
+
"other"
|
|
205
|
+
];
|
|
206
|
+
const decoder = new TextDecoder();
|
|
207
|
+
const padded = (length) => Math.ceil(length / WORD) * WORD;
|
|
208
|
+
const aligned = (buffer) => Option.match(Option.liftPredicate(buffer, ({ byteOffset }) => byteOffset % WORD === EMPTY), {
|
|
209
|
+
onNone: () => Uint8Array.from(buffer),
|
|
210
|
+
onSome: (value) => value
|
|
211
|
+
});
|
|
212
|
+
const wordAt = (words, index) => words[index] ?? EMPTY;
|
|
213
|
+
const decode = (from, start, end) => decoder.decode(from.subarray(start, end));
|
|
214
|
+
const wordsOf = (buffer) => (at, count) => new Uint32Array(buffer.buffer, buffer.byteOffset + at * WORD, count);
|
|
215
|
+
const layoutOf = (header) => ({
|
|
216
|
+
nodeCount: wordAt(header, HEADER.nodes),
|
|
217
|
+
stringCount: wordAt(header, HEADER.strings),
|
|
218
|
+
lineCount: wordAt(header, HEADER.lines),
|
|
219
|
+
textLength: wordAt(header, HEADER.text)
|
|
220
|
+
});
|
|
221
|
+
const sourceView = (raw) => {
|
|
222
|
+
const buffer = aligned(raw);
|
|
223
|
+
const words = wordsOf(buffer);
|
|
224
|
+
const { nodeCount, stringCount, lineCount, textLength } = layoutOf(words(EMPTY, HEADER_WORDS));
|
|
225
|
+
const stringsAt = HEADER_WORDS + nodeCount * 8;
|
|
226
|
+
const linesAt = stringsAt + stringCount * STRING_WORDS;
|
|
227
|
+
const textAt = (linesAt + lineCount) * WORD;
|
|
228
|
+
const bytes = buffer.subarray(textAt, textAt + textLength);
|
|
229
|
+
const strings = words(stringsAt, stringCount * STRING_WORDS);
|
|
230
|
+
const blob = buffer.subarray(textAt + padded(textLength));
|
|
231
|
+
return {
|
|
232
|
+
nodeCount,
|
|
233
|
+
nodes: words(HEADER_WORDS, nodeCount * 8),
|
|
234
|
+
lineStarts: words(linesAt, lineCount),
|
|
235
|
+
text: () => decoder.decode(bytes),
|
|
236
|
+
slice: (start, end) => decode(bytes, start, end),
|
|
237
|
+
stringAt: (index) => {
|
|
238
|
+
const offset = wordAt(strings, index * STRING_WORDS);
|
|
239
|
+
return decode(blob, offset, offset + wordAt(strings, index * STRING_WORDS + LENGTH));
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
// src/shared/native/index.ts
|
|
244
|
+
const NATIVE_FUNCTIONS = [
|
|
245
|
+
"lint",
|
|
246
|
+
"lintPaths",
|
|
247
|
+
"flushTelemetry",
|
|
248
|
+
"readTexts",
|
|
249
|
+
"tokenize"
|
|
250
|
+
];
|
|
251
|
+
const hasFunction = (value) => (name) => Predicate.hasProperty(value, name) && Predicate.isFunction(value[name]);
|
|
252
|
+
const isNative = (value) => pipe(NATIVE_FUNCTIONS, Array.every(hasFunction(value)));
|
|
253
|
+
const native = loadAddon({
|
|
254
|
+
packageName: "@r_masseater/y8",
|
|
255
|
+
binary: "y8",
|
|
256
|
+
from: import.meta.url,
|
|
257
|
+
isAddon: isNative,
|
|
258
|
+
failWith: failedWith
|
|
259
|
+
});
|
|
260
|
+
// src/features/split-morphemes/model/tokenize.ts
|
|
261
|
+
const CACHE_SIZE = 1e4;
|
|
262
|
+
const NO_MORPHEMES = [];
|
|
263
|
+
const addon = Effect.cached(native).pipe(Effect.runSync);
|
|
264
|
+
const cache = /* @__PURE__ */ new Map();
|
|
265
|
+
const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
|
|
266
|
+
const isMorphemes = (value) => Array.isArray(value);
|
|
267
|
+
const parsed = (json) => pipe(decodeJson(json), Option.filter(isMorphemes), Option.getOrElse(() => NO_MORPHEMES));
|
|
268
|
+
const remember = (text, morphemes) => {
|
|
269
|
+
if (cache.size >= CACHE_SIZE) cache.clear();
|
|
270
|
+
cache.set(text, morphemes);
|
|
271
|
+
return morphemes;
|
|
272
|
+
};
|
|
273
|
+
const morphemesOf = (text) => pipe(Option.fromUndefinedOr(cache.get(text)), Option.getOrElse(() => remember(text, parsed(pipe(addon, Effect.runSync).tokenize(text)))));
|
|
274
|
+
const tokenizer = {
|
|
275
|
+
tokenize: morphemesOf,
|
|
276
|
+
tokenizeForSentence: morphemesOf
|
|
277
|
+
};
|
|
278
|
+
const getTokenizer = () => Promise.resolve(tokenizer);
|
|
279
|
+
const tokenize = (text) => Promise.resolve(morphemesOf(text));
|
|
280
|
+
export { FIELD as a, Y8Error as c, traceparent as d, present as f, settingOf as h, native as i, failedWith as l, callAddon as m, morphemesOf as n, TAGS as o, runCli as p, tokenize as r, sourceView as s, getTokenizer as t, sortByPosition as u };
|
|
281
|
+
|
|
282
|
+
//# sourceMappingURL=split-morphemes-BS74IEHA.mjs.map
|