file_path stringlengths 3 280 | file_language stringclasses 66
values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108
values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
src/root.client.js | JavaScript | import {Suspense} from 'react'
export function Root(props) {
const {response} = props
return (
<Suspense fallback={null}>
<Content />
</Suspense>
)
function Content() {
return response.readRoot()
}
}
| wooorm/server-components-mdx-demo | 123 | React server components + MDX | JavaScript | wooorm | Titus | |
complex-types.d.ts | TypeScript | export type Components = import('mdx/types').MDXComponents
/**
* Props passed to the `MdxContent` component.
* Could be anything.
* The `components` prop is special: it defines what to use for components
* inside the content.
*/
export type MdxContentProps = import('mdx/types').MDXProps
/**
* A function compone... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
esbuild.js | JavaScript | export {esbuild as default} from './lib/integration/esbuild.js'
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
esm-loader.js | JavaScript | import {createLoader} from './lib/integration/node.js'
const {load, getFormat, transformSource} = createLoader()
export {load, getFormat, transformSource}
export {createLoader} from './lib/integration/node.js'
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
index.js | JavaScript | /// <reference types="./registry" />
export {createProcessor} from './lib/core.js'
export {compile, compileSync} from './lib/compile.js'
export {evaluate, evaluateSync} from './lib/evaluate.js'
export {run, runSync} from './lib/run.js'
export {nodeTypes} from './lib/node-types.js'
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/compile.js | JavaScript | /**
* @typedef {import('vfile').VFileCompatible} VFileCompatible
* @typedef {import('vfile').VFile} VFile
* @typedef {import('./core.js').PluginOptions} PluginOptions
* @typedef {import('./core.js').BaseProcessorOptions} BaseProcessorOptions
* @typedef {Omit<BaseProcessorOptions, 'format'>} CoreProcessorOptions
*... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/condition.browser.js | JavaScript | export const development = false
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/condition.js | JavaScript | import process from 'node:process'
export const development = process.env.NODE_ENV === 'development'
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/core.js | JavaScript | /**
* @typedef {import('unified').Processor} Processor
* @typedef {import('unified').PluggableList} PluggableList
* @typedef {import('remark-rehype').Options} RemarkRehypeOptions
* @typedef {import('./plugin/recma-document.js').RecmaDocumentOptions} RecmaDocumentOptions
* @typedef {import('./plugin/recma-stringify... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/evaluate.js | JavaScript | /**
* @typedef {import('vfile').VFileCompatible} VFileCompatible
* @typedef {import('./util/resolve-evaluate-options.js').EvaluateOptions} EvaluateOptions
* @typedef {import('mdx/types').MDXModule} MDXModule
*/
import {compile, compileSync} from './compile.js'
import {run, runSync} from './run.js'
import {resolveE... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/integration/esbuild.js | JavaScript | /**
* @typedef {import('esbuild').Plugin} Plugin
* @typedef {import('esbuild').PluginBuild} PluginBuild
* @typedef {import('esbuild').OnLoadArgs} OnLoadArgs
* @typedef {import('esbuild').OnLoadResult} OnLoadResult
* @typedef {import('esbuild').OnResolveArgs} OnResolveArgs
* @typedef {import('esbuild').Message} Me... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/integration/node.js | JavaScript | /**
* @typedef {import('../compile.js').CompileOptions} CompileOptions
*
* @typedef LoaderOptions
* @property {boolean} [fixRuntimeWithoutExportMap=true]
* Several JSX runtimes, notably React and Emotion, don’t yet have a proper
* export map set up.
* Export maps are needed to map `xxx/jsx-runtime` to an a... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/integration/require.cjs | JavaScript | 'use strict'
const fs = require('fs')
let deasync
try {
deasync = require('deasync')
} catch {
throw new Error(
'Could not load optional dependency `deasync`\nPlease manually install it'
)
}
const {runSync} = deasync(load)('../run.js')
const {createFormatAwareProcessors} = deasync(load)(
'../util/create... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/integration/rollup.js | JavaScript | /**
* @typedef {import('@rollup/pluginutils').FilterPattern} FilterPattern
* @typedef {import('rollup').Plugin} Plugin
* @typedef {Omit<import('../compile.js').CompileOptions, 'SourceMapGenerator'>} CompileOptions
*
* @typedef RollupPluginOptions
* @property {FilterPattern} [include] List of picomatch patterns to... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/integration/webpack.js | JavaScript | /**
* @typedef {import('vfile').VFileCompatible} VFileCompatible
* @typedef {import('vfile').VFile} VFile
* @typedef {import('webpack').LoaderContext<unknown>} LoaderContext
* @typedef {import('../compile.js').CompileOptions} CompileOptions
* @typedef {Pick<CompileOptions, 'SourceMapGenerator'>} Defaults
* @typed... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/node-types.js | JavaScript | // List of node types made by `mdast-util-mdx`, which have to be passed
// through untouched from the mdast tree to the hast tree.
export const nodeTypes = [
'mdxFlowExpression',
'mdxJsxFlowElement',
'mdxJsxTextElement',
'mdxTextExpression',
'mdxjsEsm'
]
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/plugin/recma-document.js | JavaScript | /**
* @typedef {import('estree-jsx').Directive} Directive
* @typedef {import('estree-jsx').ExportDefaultDeclaration} ExportDefaultDeclaration
* @typedef {import('estree-jsx').ExportSpecifier} ExportSpecifier
* @typedef {import('estree-jsx').ExportNamedDeclaration} ExportNamedDeclaration
* @typedef {import('estree-... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/plugin/recma-jsx-build.js | JavaScript | /**
* @typedef {import('estree-jsx').Program} Program
*
* @typedef RecmaJsxBuildOptions
* @property {'program'|'function-body'} [outputFormat='program'] Whether to keep the import of the automatic runtime or get it from `arguments[0]` instead
*/
import {buildJsx} from 'estree-util-build-jsx'
import {specifiersToD... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/plugin/recma-jsx-rewrite.js | JavaScript | /**
* @typedef {import('estree-jsx').Node} Node
* @typedef {import('estree-jsx').Expression} Expression
* @typedef {import('estree-jsx').Function} ESFunction
* @typedef {import('estree-jsx').ImportSpecifier} ImportSpecifier
* @typedef {import('estree-jsx').JSXElement} JSXElement
* @typedef {import('estree-jsx').J... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/plugin/recma-stringify.js | JavaScript | /**
* @typedef {import('estree-jsx').Node} Node
* @typedef {import('estree-jsx').Program} Program
* @typedef {import('estree-jsx').JSXAttribute} JSXAttribute
* @typedef {import('estree-jsx').JSXClosingElement} JSXClosingElement
* @typedef {import('estree-jsx').JSXClosingFragment} JSXClosingFragment
* @typedef {im... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/plugin/rehype-recma.js | JavaScript | /**
* @typedef {import('estree-jsx').Program} Program
* @typedef {import('hast').Root} Root
*/
import {toEstree} from 'hast-util-to-estree'
/**
* A plugin to transform an HTML (hast) tree to a JS (estree).
* `hast-util-to-estree` does all the work for us!
*
* @type {import('unified').Plugin<Array<void>, Root, ... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/plugin/rehype-remove-raw.js | JavaScript | /**
* @typedef {import('hast').Root} Root
*/
import {visit} from 'unist-util-visit'
/**
* A tiny plugin that removes raw HTML.
* This is needed if the format is `md` and `rehype-raw` was not used to parse
* dangerous HTML into nodes.
*
* @type {import('unified').Plugin<Array<void>, Root>}
*/
export function r... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/plugin/remark-mark-and-unravel.js | JavaScript | /**
* @typedef {import('mdast').Root} Root
* @typedef {import('mdast').Content} Content
* @typedef {Root|Content} Node
* @typedef {Extract<Node, import('unist').Parent>} Parent
*
* @typedef {import('./remark-mdx.js')} DoNotTouchAsThisImportIncludesMdxInTree
*/
import {visit} from 'unist-util-visit'
/**
* A ti... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/plugin/remark-mdx.js | JavaScript | /**
* @typedef {import('mdast').Root} Root
* @typedef {import('micromark-extension-mdxjs').Options} MicromarkOptions
* @typedef {import('mdast-util-mdx').ToMarkdownOptions} ToMarkdownOptions
* @typedef {MicromarkOptions & ToMarkdownOptions} Options
*
* @typedef {import('mdast-util-mdx')} DoNotTouchAsThisImportInc... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/run.js | JavaScript | /**
* @typedef {import('vfile').VFile} VFile
*/
/** @type {new (code: string, ...args: Array<unknown>) => Function} **/
const AsyncFunction = Object.getPrototypeOf(run).constructor
/**
* Asynchronously run code.
*
* @param {{toString(): string}} file JS document to run
* @param {unknown} options
* @return {Pro... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/create-format-aware-processors.js | JavaScript | /**
* @typedef {import('vfile').VFileCompatible} VFileCompatible
* @typedef {import('vfile').VFile} VFile
* @typedef {import('unified').Processor} Processor
* @typedef {import('../compile.js').CompileOptions} CompileOptions
*/
import {createProcessor} from '../core.js'
import {md, mdx} from './extnames.js'
import... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/estree-util-create.js | JavaScript | /**
* @typedef {import('estree-jsx').Node} Node
*/
/**
* @template {Node} N
* @param {Node} template
* @param {N} node
* @returns {N}
*/
export function create(template, node) {
/** @type {Array<keyof template>} */
// @ts-expect-error: `start`, `end`, `comments` are custom Acorn fields.
const fields = ['s... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/estree-util-declaration-to-expression.js | JavaScript | /**
* @typedef {import('estree-jsx').Declaration} Declaration
* @typedef {import('estree-jsx').Expression} Expression
*/
/**
* Turn a declaration into an expression.
* Doesn’t work for variable declarations, but that’s fine for our use case
* because currently we’re using this utility for export default declarat... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/estree-util-is-declaration.js | JavaScript | /**
* @typedef {import('estree-jsx').Declaration} Declaration
*/
/**
* @param {unknown} node
* @returns {node is Declaration}
*/
export function isDeclaration(node) {
/** @type {string} */
// @ts-expect-error Hush typescript, looks like `type` is available.
const type = node && typeof node === 'object' && n... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/estree-util-specifiers-to-declarations.js | JavaScript | /**
* @typedef {import('estree-jsx').Identifier} Identifier
* @typedef {import('estree-jsx').ImportSpecifier} ImportSpecifier
* @typedef {import('estree-jsx').ImportDefaultSpecifier} ImportDefaultSpecifier
* @typedef {import('estree-jsx').ImportNamespaceSpecifier} ImportNamespaceSpecifier
* @typedef {import('estre... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/estree-util-to-binary-addition.js | JavaScript | /**
* @typedef {import('estree-jsx').Expression} Expression
*/
/**
* @param {Array<Expression>} expressions
*/
export function toBinaryAddition(expressions) {
let index = -1
/** @type {Expression|undefined} */
let left
while (++index < expressions.length) {
const right = expressions[index]
left = ... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/estree-util-to-id-or-member-expression.js | JavaScript | /**
* @typedef {import('estree-jsx').Identifier} Identifier
* @typedef {import('estree-jsx').Literal} Literal
* @typedef {import('estree-jsx').JSXIdentifier} JSXIdentifier
* @typedef {import('estree-jsx').MemberExpression} MemberExpression
* @typedef {import('estree-jsx').JSXMemberExpression} JSXMemberExpression
... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/extnames-to-regex.js | JavaScript | /**
* Utility to turn a list of extnames (*with* dots) into an expression.
*
* @param {Array<string>} extnames List of extnames
* @returns {RegExp} Regex matching them
*/
export function extnamesToRegex(extnames) {
// eslint-disable-next-line security/detect-non-literal-regexp
return new RegExp(
'\\.(' + e... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/extnames.js | JavaScript | // @ts-expect-error: untyped.
import markdownExtensions from 'markdown-extensions'
export const mdx = ['.mdx']
/** @type {Array<string>} */
export const md = markdownExtensions.map((/** @type {string} */ d) => '.' + d)
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/resolve-evaluate-options.js | JavaScript | /**
* @typedef {import('../core.js').ProcessorOptions} ProcessorOptions
*
* @typedef RuntimeOptions
* @property {*} Fragment Symbol to use for fragments
* @property {*} jsx Function to generate an element with static children
* @property {*} jsxs Function to generate an element with dynamic children
*
* @typede... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
lib/util/resolve-file-and-options.js | JavaScript | /**
* @typedef {import('vfile').VFileCompatible} VFileCompatible
* @typedef {import('../core.js').ProcessorOptions} ProcessorOptions
* @typedef {import('../compile.js').CompileOptions} CompileOptions
*/
import {VFile} from 'vfile'
import {md} from './extnames.js'
/**
* Create a file and options from a given `vfi... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
register.cjs | JavaScript | 'use strict'
const runtime = require('react/jsx-runtime')
const register = require('./lib/integration/require.cjs')
register({...runtime})
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
registry.d.ts | TypeScript | /* eslint-disable @typescript-eslint/naming-convention */
declare module '*.mdx' {
import {MDXProps} from 'mdx/types'
/**
* MDX Content.
*
* @see https://v2.mdxjs.com/mdx/
*/
export default function MDXContent(props: MDXProps): JSX.Element
}
declare module '*.md' {
/**
* Markdown content.
*... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
rollup.js | JavaScript | export {rollup as default} from './lib/integration/rollup.js'
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
script/benchmark.js | JavaScript | import {promises as fs} from 'node:fs'
import {transformSync as babel} from '@babel/core'
import marky from 'marky'
import gfm from 'remark-gfm'
import {sync as mdx1} from 'mdx1'
import {sync as mdx2} from 'mdx2'
import {compileSync as xdm} from '../index.js'
main()
async function main() {
/** @type {string} */
l... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/babel.js | JavaScript | /**
* @typedef {import('@babel/parser').ParserOptions} ParserOptions
* @typedef {import('estree-jsx').Program} Program
* @typedef {import('mdx/types').MDXContent} MDXContent
*/
import {promises as fs} from 'node:fs'
import path from 'node:path'
import test from 'tape'
import parser from '@babel/parser'
import {tra... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/context/components.js | JavaScript | import React from 'react'
/**
* @param {Record<string, unknown>} props
*/
export function Pill(props) {
return React.createElement('span', {...props, style: {color: 'red'}})
}
/**
* @param {Record<string, unknown>} props
*/
export function Layout(props) {
return React.createElement('div', {...props, style: {c... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/context/data.js | JavaScript | export const number = 3.14
export const object = {a: 1, b: 2}
export const array = [1, 2]
export default 2 * number
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/core.js | JavaScript | /**
* @typedef {import('hast').Root} Root
* @typedef {import('../lib/compile.js').VFileCompatible} VFileCompatible
* @typedef {import('mdx/types').MDXContent} MDXContent
* @typedef {import('mdx/types').MDXModule} MDXModule
* @typedef {import('mdx/types').MDXComponents} Components
*/
import path from 'node:path'
... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/esbuild.js | JavaScript | /**
* @typedef {import('esbuild').BuildFailure} BuildFailure
* @typedef {import('esbuild').Message} Message
* @typedef {import('unist').Parent} Parent
* @typedef {import('vfile').VFile} VFile
* @typedef {import('mdx/types').MDXContent} MDXContent
*/
import {promises as fs} from 'node:fs'
import path from 'node:p... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/esm-loader.js | JavaScript | /**
* @typedef {import('mdx/types').MDXContent} MDXContent
*/
import path from 'node:path'
import {promises as fs} from 'node:fs'
import test from 'tape'
import React from 'react'
import {renderToStaticMarkup} from 'react-dom/server'
test('xdm (ESM loader)', async (t) => {
const base = path.resolve(path.join('tes... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/evaluate.js | JavaScript | import * as provider from '@mdx-js/react'
import React from 'react'
import * as runtime from 'react/jsx-runtime'
import {renderToStaticMarkup} from 'react-dom/server'
import test from 'tape'
import {evaluate, evaluateSync, compile} from '../index.js'
test('xdm (evaluate)', async (t) => {
t.throws(
() => {
... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/index.js | JavaScript | import './babel.js'
import './core.js'
import './esbuild.js'
import './esm-loader.js'
import './evaluate.js'
import './rollup.js'
import './source-map.js'
import './vue.js'
// Can’t test webpack on Node 17 for now:
// <https://github.com/webpack/webpack/issues/14532>
// import './webpack.js'
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/react-18-esm-loader.js | JavaScript | import {createLoader} from '../esm-loader.js'
// Load is for Node 17+, the rest for 12, 14, 16.
const {load, getFormat, transformSource} = createLoader({
fixRuntimeWithoutExportMap: false
})
export {load, getFormat, transformSource}
| wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/register.cjs | JavaScript | /**
* @typedef {import('mdx/types').MDXContent} MDXContent
*/
'use strict'
const path = require('path')
const fs = require('fs').promises
const test = require('tape')
const React = require('react')
const {renderToStaticMarkup} = require('react-dom/server')
require('../register.cjs')
test('xdm (register)', async (... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/rollup.js | JavaScript | /**
* @typedef {import('mdx/types').MDXContent} MDXContent
*/
import path from 'node:path'
import {promises as fs} from 'node:fs'
import test from 'tape'
import {rollup} from 'rollup'
import React from 'react'
import {renderToStaticMarkup} from 'react-dom/server'
import rollupXdm from '../rollup.js'
test('xdm (roll... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/source-map.js | JavaScript | /**
* @typedef {import('mdx/types').MDXContent} MDXContent
*/
import {promises as fs} from 'node:fs'
import path from 'node:path'
import {Buffer} from 'node:buffer'
import React from 'react'
import {renderToStaticMarkup} from 'react-dom/server'
import {SourceMapGenerator} from 'source-map'
import test from 'tape'
im... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/vue.js | JavaScript | /**
* @typedef {import('vue').SetupContext} SetupContext
* @typedef {import('mdx/types').MDXContent} MDXContent
*/
import path from 'node:path'
import {promises as fs} from 'node:fs'
import test from 'tape'
import {transformAsync as babel} from '@babel/core'
import * as vue from 'vue'
import {renderToString} from '... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
test/webpack.js | JavaScript | /**
* @typedef {import('mdx/types').MDXContent} MDXContent
*/
import {promisify} from 'node:util'
import path from 'node:path'
import {promises as fs} from 'node:fs'
import test from 'tape'
import webpack from 'webpack'
import React from 'react'
import {renderToStaticMarkup} from 'react-dom/server'
test('xdm (webpa... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
webpack.cjs | JavaScript | 'use strict'
/**
* Webpack loader
*
* @remarks
* To do: once webpack supports ESM loaders, remove this wrapper.
*
* @param {string} code
*/
module.exports = function (code) {
const callback = this.async()
// Note that `import()` caches, so this should be fast enough.
import('./lib/integration/webpack.js')... | wooorm/xdm | 597 | Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins | JavaScript | wooorm | Titus | |
schema.graphql | GraphQL | type Account @entity {
id: ID!
address: String
}
type Nominator @entity {
id: ID!
stash: String
currentValidators: [ValidatorJSON]
submittedIn: BigInt
bond: BigInt
}
type NominatorJSON @jsonField {
stash: String
bond: BigInt
}
type Validator @entity{
id: ID!
stash: String
selfStake: BigInt
... | wpank/subql | 2 | TypeScript | wpank | Will | ||
src/index.ts | TypeScript | //Exports all handler functions
export * from './mappings/Nominate'
import "@polkadot/api-augment"
| wpank/subql | 2 | TypeScript | wpank | Will | ||
src/mappings/Nominate.ts | TypeScript | import { SubstrateExtrinsic } from '@subql/types';
import {Nomination, Nominator, Validator, ValidatorNomination} from "../types";
const { decodeAddress, encodeAddress } = require('@polkadot/keyring');
const { hexToU8a, isHex } = require('@polkadot/util');
// Process a staking.nominate transaction
export async functio... | wpank/subql | 2 | TypeScript | wpank | Will | ||
controllers/activities/create.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
const Joi = require('@hapi/joi')
module.exports = {
description: 'Create a new activity',
tags: ['api', 'activity'],
handler: async function (request, h) {
const userId = request.auth.credentials.id
if (request.payload.activity_id) {
const alias = a... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/activities/get.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
const Joi = require('@hapi/joi')
module.exports = {
description: 'Get activity by id',
tags: ['api', 'activity'],
handler: async function (request) {
const activity = await this.db.activities.with_alias({
id: request.params.id,
user_id: request.aut... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/activities/history.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
const Joi = require('@hapi/joi')
module.exports = {
description: 'Get workout history for an activity by id',
tags: ['api', 'activity'],
handler: async function (request) {
const params = { ...request.params, user_id: request.auth.credentials.id }
const ac... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/activities/list.js | JavaScript | 'use strict'
const Joi = require('@hapi/joi')
module.exports = {
description: 'Get activities for logged in user',
tags: ['api', 'activity'],
handler: async function (request) {
const params = { ...request.query, id: request.auth.credentials.id }
params.page = (params.page - 1) * params.limit
const ... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/activities/promote.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
module.exports = {
description: 'Promote an activity to main activity',
tags: ['api', 'activity'],
handler: async function (request) {
const activity = await this.db.activities.findOne({
id: request.params.id,
user_id: request.auth.credentials.id
... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/activities/suggest.js | JavaScript | 'use strict'
const Joi = require('@hapi/joi')
module.exports = {
description: 'Search activities by name',
tags: ['api', 'activity'],
handler: async function (request) {
const userId = request.auth.credentials.id
const activity = await this.db.activities.search_alias({
user_id: userId,
name... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/admin/users/list.js | JavaScript | 'use strict'
module.exports = {
description: 'Get all users',
tags: ['admin'],
handler: async function () {
const result = await this.db.users.summary()
return result
},
auth: {
scope: 'admin'
}
}
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/heartbeat.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
module.exports = {
description: 'Heartbeat',
handler: async function (request, h) {
const count = await this.db.users.count()
// $lab:coverage:off$
if (count.count > -1) {
return h.response('ok').type('text/plain')
}
throw Boom.internal('... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/invites/validate.js | JavaScript | 'use strict'
const Config = require('getconfig')
const Boom = require('@hapi/boom')
const Joi = require('@hapi/joi')
module.exports = {
description: 'Check invite validity',
tags: ['api', 'user'],
handler: async function (request) {
const params = { ...request.params, claimed_by: null }
const invite = a... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/confirm.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
const Joi = require('@hapi/joi')
module.exports = {
description: 'Confirm email',
tags: ['api', 'user'],
handler: async function (request) {
const validation = await this.db.validations.confirm({
user_id: request.auth.credentials.id,
token: request... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/delete.js | JavaScript | 'use strict'
const Joi = require('@hapi/joi')
module.exports = {
description: 'Delete user',
notes:
'The query parameter "confirm" is meant to aid clients in confirming with the end user that they really want to do this',
tags: ['user'],
handler: async function (request, h) {
await this.db.users.destr... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/invites.js | JavaScript | 'use strict'
const Joi = require('@hapi/joi')
module.exports = {
description: 'Invites for currently logged in user',
tags: ['api', 'user'],
handler: function (request) {
if (!request.auth.credentials.validated) {
return []
}
const result = this.db.invites.find({
user_id: request.auth.c... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/login.js | JavaScript | 'use strict'
const Bcrypt = require('bcrypt')
const Boom = require('@hapi/boom')
const Config = require('getconfig')
const Joi = require('@hapi/joi')
const JWT = require('jsonwebtoken')
module.exports = {
description: 'Authenticates a user and returns a JWT',
tags: ['api', 'user'],
handler: async function (requ... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/logout.js | JavaScript | 'use strict'
module.exports = {
description: 'Log the current user out and invalidate all of their tokens',
tags: ['api', 'user'],
handler: async function (request, h) {
await this.db.users.updateOne(
{ id: request.auth.credentials.id },
{ logout: new Date() }
)
return h.response().code(... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/recover.js | JavaScript | 'use strict'
const Joi = require('@hapi/joi')
const AWS = require('../../lib/aws')
const Config = require('getconfig')
module.exports = {
description: 'Request password recovery',
tags: ['api', 'user'],
handler: async function (request, h) {
const existingRecovery = await this.db.recoveries.fresh(request.pa... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/reset.js | JavaScript | 'use strict'
const Bcrypt = require('bcrypt')
const Boom = require('@hapi/boom')
const Config = require('getconfig')
const Joi = require('@hapi/joi')
const JWT = require('jsonwebtoken')
module.exports = {
description: 'Reset password using recovery token',
notes: 'Logs out any existing sessions',
tags: ['user']... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/self.js | JavaScript | 'use strict'
module.exports = {
description: 'Currently logged in user',
tags: ['api', 'user'],
handler: function (request) {
const user = request.auth.credentials
return user
}
}
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/signup.js | JavaScript | 'use strict'
const Bcrypt = require('bcrypt')
const Boom = require('@hapi/boom')
const Config = require('getconfig')
const JWT = require('jsonwebtoken')
const Joi = require('@hapi/joi')
module.exports = {
description: 'Sign up',
tags: ['api', 'user'],
handler: async function (request, h) {
const invite = aw... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/update.js | JavaScript | 'use strict'
const Bcrypt = require('bcrypt')
const Boom = require('@hapi/boom')
const Config = require('getconfig')
const Joi = require('@hapi/joi')
module.exports = {
description: 'Update user info',
tags: ['api', 'user'],
handler: async function (request) {
const credentials = request.auth.credentials
... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/users/validate.js | JavaScript | 'use strict'
const AWS = require('../../lib/aws')
const Config = require('getconfig')
module.exports = {
description: 'Request email validation',
tags: ['api', 'user'],
handler: async function (request, h) {
const existingValidation = await this.db.validations.fresh({
user_id: request.auth.credentials... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/workouts/all.js | JavaScript | 'use strict'
module.exports = {
description: 'Get a summary of all of a user\'s workouts',
tags: ['api', 'workout'],
handler: async function (request) {
const result = await this.db.workouts.summary({
user_id: request.auth.credentials.id
})
return result
}
}
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/workouts/create.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
const Utils = require('../../lib/utils')
module.exports = {
description: 'Create a new workout',
tags: ['api', 'workout'],
handler: async function (request, h) {
const existing = await this.db.workouts.findOne({
date: request.payload.date,
user_id... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/workouts/delete.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
const Joi = require('@hapi/joi')
module.exports = {
description: 'Delete a workout',
tags: ['api', 'workout'],
handler: async function (request, h) {
const existing = await this.db.workouts.findOne({
id: request.params.id,
user_id: request.auth.cre... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/workouts/get.js | JavaScript | 'use strict'
const Joi = require('@hapi/joi')
const Boom = require('@hapi/boom')
module.exports = {
description: 'Get a workout by id',
tags: ['api', 'workout'],
handler: async function (request) {
const attrs = { ...request.params, user_id: request.auth.credentials.id }
const workout = await this.db.wo... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/workouts/public.js | JavaScript | 'use strict'
const Joi = require('@hapi/joi')
const Boom = require('@hapi/boom')
module.exports = {
description: 'Get a public workout by id',
tags: ['api', 'workout'],
handler: async function (request) {
const workout = await this.db.workouts.public(request.params)
if (!workout) {
throw Boom.not... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
controllers/workouts/update.js | JavaScript | 'use strict'
const Boom = require('@hapi/boom')
const Joi = require('@hapi/joi')
const Utils = require('../../lib/utils')
module.exports = {
description: 'Update a new workout',
tags: ['api', 'workout'],
handler: async function (request) {
const existingId = await this.db.workouts.findOne({
id: reque... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/activities/for_user.sql | SQL | SELECT
activities.*,
CASE WHEN count(aliases) = 0 THEN '[]'::json ELSE json_agg(aliases) END AS aliases
FROM
activities
LEFT JOIN
activities AS aliases on activities.id = aliases.activity_id
WHERE
activities.user_id = ${id}
AND
activities.activity_id is null
GROUP BY activities.id
ORDER BY activities.name... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/activities/for_user_count.sql | SQL | ---
returns: one
---
SELECT
count(activities.id)::integer as count
FROM
activities
WHERE
activities.user_id = ${id}
AND
activities.activity_id is null
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/activities/history.sql | SQL | SELECT
workouts.name as workout_name,
to_char(workouts.date, 'YYYY-MM-DD') as workout_date,
workout_activities.comment,
workout_activities.sets
FROM
workouts,
jsonb_to_recordset(workouts.activities) AS workout_activities(id uuid, comment text, sets jsonb)
WHERE
workouts.user_id = ${user_id}
AND (
... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/activities/history_count.sql | SQL | ---
returns: one
---
SELECT
count(workouts.id)::integer as count
FROM
workouts,
jsonb_to_recordset(workouts.activities) AS workout_activities(id uuid, comment text, sets jsonb)
WHERE
workouts.user_id = ${user_id}
AND (
workout_activities.id = ${id}
OR
workout_activities.id in (
SELECT id
... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/activities/search.sql | SQL | SELECT
id,
CASE WHEN activity_id IS NULL THEN id
ELSE activity_id
END as activity_id,
name,
1 - ts_rank(to_tsvector('english', name), to_tsquery(${name})) as rank
FROM activities
WHERE
user_id = ${user_id}
AND
to_tsvector('english', name) @@ to_tsquery(${name})
ORDER BY rank DESC
LIMIT 5
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/activities/search_alias.sql | SQL | ---
returns: one || none
---
SELECT
activities.id,
activities.activity_id,
activities.name,
aliases.name AS alias
FROM
activities
LEFT JOIN
activities AS aliases on activities.activity_id = aliases.id
WHERE
activities.user_id = ${user_id}
AND
activities.name = ${name}
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/activities/with_alias.sql | SQL | ---
returns: one || none
---
SELECT
activities.id,
activities.activity_id,
activities.name,
aliases.name AS alias
FROM
activities
LEFT JOIN
activities AS aliases on activities.activity_id = aliases.id
WHERE
activities.user_id = ${user_id}
AND
activities.id = ${id}
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/activities/with_aliases.sql | SQL | ---
returns: one || none
---
SELECT
activities.*,
CASE WHEN count(aliases) = 0 THEN '[]'::json ELSE json_agg(aliases) END AS aliases
FROM
activities
LEFT JOIN
activities AS aliases on activities.id = aliases.activity_id
WHERE
activities.user_id = ${user_id}
AND
activities.id = ${id}
GROUP BY activities.... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/recoveries/fresh.sql | SQL | ---
returns: one || none
---
SELECT *
FROM recoveries
WHERE
email = ${email}
AND
created_at > now() - interval '3 hours'
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/users/active.sql | SQL | ---
returns: one || none
---
SELECT
users.id,
users.name,
users.email,
users.logout,
users.validated,
users.scope,
users.preferences
FROM users WHERE
users.active = TRUE AND
lower(users.email)=lower($1);
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/users/count.sql | SQL | ---
returns: one
---
SELECT count(0)::integer as count from users;
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/users/summary.sql | SQL | SELECT
users.id,
users.name,
users.email,
users.active,
users.validated,
(SELECT count(workouts.id)::integer from workouts where workouts.user_id = users.id) as workouts,
(SELECT count(activities.id)::integer from activities where activities.user_id = users.id) as activities,
(SELECT count(invites.token... | wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/validations/confirm.sql | SQL | ---
returns: one || none
---
SELECT *
FROM validations
WHERE
user_id = ${user_id}
AND
token = ${token}
AND
created_at > now() - interval '1 day'
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/validations/fresh.sql | SQL | ---
returns: one || none
---
SELECT *
FROM validations
WHERE
user_id = ${user_id}
AND
created_at > now() - interval '15 minutes'
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/workouts/public.sql | SQL | ---
returns: one || none
---
SELECT
workouts.*,
users.name as user_name
FROM
workouts
JOIN
users ON users.id = workouts.user_id
WHERE
workouts.id = ${id}
AND (
(
users.preferences->>'visible' = 'true'
AND
workouts.visible IS NULL
)
OR workouts.visible = true
)
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar | |
db/workouts/summary.sql | SQL | SELECT
workouts.id,
name,
to_char(workouts.date, 'YYYY-MM-DD') as date,
jsonb_array_length(workouts.activities) as activities
FROM workouts
WHERE user_id = ${user_id}
GROUP BY workouts.id
| wraithgar/api.lift.zone | 1 | API for lift.zone | JavaScript | wraithgar | Gar |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.