Skip to content

Commit

Permalink
fix: enter a new era
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah committed Mar 9, 2023
1 parent 22bd269 commit fbf88a9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/index-browser.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './lib/ooxast-util-parse-bib-browser'
export * from './lib/ooxast-util-parse-bib-browser.js'
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './lib/ooxast-util-parse-bib'
export * from './lib/ooxast-util-parse-bib.js'
10 changes: 5 additions & 5 deletions src/lib/bib-to-csl-browser.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Data as CSL } from 'csl-json'
import { callAnystyleApi } from './anystyle-api'
import { findBib } from './find-bib'
import { fixBib } from './fix-csl'
import { Options } from './ooxast-util-parse-bib'
import { callAnystyleApi } from './anystyle-api.js'
import { findBib } from './find-bib.js'
import { fixBib } from './fix-csl.js'
import { Options } from './ooxast-util-parse-bib.js'
import { Node } from 'ooxast'

export async function bibToCSLBrowser(
tree: Node,
options: Omit<Options, 'anystylePath'> & { apiUrl: string }
options: Omit<Options, 'anystylePath'> & { apiUrl: string },
): Promise<CSL[]> {
const { apiUrl, apiParams, headers } = options
const bib = findBib(tree)
Expand Down
10 changes: 5 additions & 5 deletions src/lib/bib-to-csl-node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { callAnystyleApi } from './anystyle-api'
import { findBib } from './find-bib'
import { fixBib } from './fix-csl'
import { Options } from './ooxast-util-parse-bib'
import { callAnystyleApi } from './anystyle-api.js'
import { findBib } from './find-bib.js'
import { fixBib } from './fix-csl.js'
import { Options } from './ooxast-util-parse-bib.js'
import { Data as CSL } from 'csl-json'
import { Node } from 'ooxast'

Expand All @@ -12,7 +12,7 @@ export async function bibToCSL(tree: Node, options: Options): Promise<CSL[]> {
const refs = bib.join('\n')

if (!apiUrl || (!apiUrl && typeof window !== 'undefined')) {
const { callAnystyleCLI } = await import('./anystyle-cli')
const { callAnystyleCLI } = await import('./anystyle-cli.js')
const parsedBib = await callAnystyleCLI(refs, anyStylePath)
return fixBib(parsedBib)
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ooxast-util-parse-bib-browser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Node } from 'ooxast'
import { consolidate } from 'csl-consolidate'
import { bibToCSLBrowser } from './bib-to-csl-browser'
import { bibToCSLBrowser } from './bib-to-csl-browser.js'
export interface Options {
apiUrl: string
apiParams?: { param: string }
Expand Down
16 changes: 4 additions & 12 deletions src/lib/ooxast-util-parse-bib.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ import { docxToVFile } from 'docx-to-vfile'
import reoffParse from 'reoff-parse'
import { readFile } from 'fs/promises'
import { unified } from 'unified'
import {
callAnystyleApi,
callAnystyleCLI,
findBib,
bibToCSL,
parseBib,
} from './ooxast-util-parse-bib'
import { toString } from 'xast-util-to-string'
import { writeFileSync } from 'fs'
import { parseBib } from './ooxast-util-parse-bib.js'
import { findBib } from './find-bib.js'
import { bibToCSL } from './bib-to-csl-node.js'

async function getTree() {
// If in node, get the correct docx uintarray like so
const docxBuff = await readFile(
new URL('/../fixtures/index.docx', import.meta.url)
)
const docxBuff = await readFile(new URL('/../fixtures/index.docx', import.meta.url))
const docxArr = new Uint8Array(docxBuff)

// if in the browser, find some way
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ooxast-util-parse-bib.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Node } from 'ooxast'
import { consolidate } from 'csl-consolidate'
import { bibToCSL } from './bib-to-csl-node'
import { bibToCSL } from './bib-to-csl-node.js'
export interface Options {
apiUrl?: string
apiParams?: { param: string }
Expand Down

0 comments on commit fbf88a9

Please sign in to comment.