feat(ui): finalize E-TIB modernization with footer redesign, video optimization, and TS fixes
Former-commit-id: 67ac02c8404cc66893fdf97308574701cca6000c
This commit is contained in:
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// Note: types exposed from `index.d.ts`.
|
||||
export { mdxExpression } from './lib/syntax.js';
|
||||
Generated
Vendored
+201
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* @import {Options} from 'micromark-extension-mdx-expression'
|
||||
* @import {AcornOptions} from 'micromark-util-events-to-acorn'
|
||||
* @import {Extension, State, TokenizeContext, Tokenizer} from 'micromark-util-types'
|
||||
*/
|
||||
|
||||
import { factoryMdxExpression } from 'micromark-factory-mdx-expression';
|
||||
import { factorySpace } from 'micromark-factory-space';
|
||||
import { markdownLineEnding, markdownSpace } from 'micromark-util-character';
|
||||
/**
|
||||
* Create an extension for `micromark` to enable MDX expression syntax.
|
||||
*
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {Extension}
|
||||
* Extension for `micromark` that can be passed in `extensions` to enable MDX
|
||||
* expression syntax.
|
||||
*/
|
||||
export function mdxExpression(options) {
|
||||
const options_ = options || {};
|
||||
const addResult = options_.addResult;
|
||||
const acorn = options_.acorn;
|
||||
// Hidden: `micromark-extension-mdx-jsx` supports expressions in tags,
|
||||
// and one of them is only “spread” elements.
|
||||
// It also has expressions that are not allowed to be empty (`<x y={}/>`).
|
||||
// Instead of duplicating code there, this are two small hidden feature here
|
||||
// to test that behavior.
|
||||
const spread = options_.spread;
|
||||
let allowEmpty = options_.allowEmpty;
|
||||
/** @type {AcornOptions} */
|
||||
let acornOptions;
|
||||
if (allowEmpty === null || allowEmpty === undefined) {
|
||||
allowEmpty = true;
|
||||
}
|
||||
if (acorn) {
|
||||
if (!acorn.parseExpressionAt) {
|
||||
throw new Error('Expected a proper `acorn` instance passed in as `options.acorn`');
|
||||
}
|
||||
acornOptions = Object.assign({
|
||||
ecmaVersion: 2024,
|
||||
sourceType: 'module'
|
||||
}, options_.acornOptions);
|
||||
} else if (options_.acornOptions || options_.addResult) {
|
||||
throw new Error('Expected an `acorn` instance passed in as `options.acorn`');
|
||||
}
|
||||
return {
|
||||
flow: {
|
||||
[123]: {
|
||||
name: 'mdxFlowExpression',
|
||||
tokenize: tokenizeFlowExpression,
|
||||
concrete: true
|
||||
}
|
||||
},
|
||||
text: {
|
||||
[123]: {
|
||||
name: 'mdxTextExpression',
|
||||
tokenize: tokenizeTextExpression
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* MDX expression (flow).
|
||||
*
|
||||
* ```markdown
|
||||
* > | {Math.PI}
|
||||
* ^^^^^^^^^
|
||||
* ```
|
||||
*
|
||||
* @this {TokenizeContext}
|
||||
* @type {Tokenizer}
|
||||
*/
|
||||
function tokenizeFlowExpression(effects, ok, nok) {
|
||||
const self = this;
|
||||
return start;
|
||||
|
||||
/**
|
||||
* Start of an MDX expression (flow).
|
||||
*
|
||||
* ```markdown
|
||||
* > | {Math.PI}
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function start(code) {
|
||||
// To do: in `markdown-rs`, constructs need to parse the indent themselves.
|
||||
// This should also be introduced in `micromark-js`.
|
||||
|
||||
return before(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* After optional whitespace, before expression.
|
||||
*
|
||||
* ```markdown
|
||||
* > | {Math.PI}
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function before(code) {
|
||||
return factoryMdxExpression.call(self, effects, after, 'mdxFlowExpression', 'mdxFlowExpressionMarker', 'mdxFlowExpressionChunk', acorn, acornOptions, addResult, spread, allowEmpty)(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* After expression.
|
||||
*
|
||||
* ```markdown
|
||||
* > | {Math.PI}
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function after(code) {
|
||||
return markdownSpace(code) ? factorySpace(effects, end, "whitespace")(code) : end(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* After expression, after optional whitespace.
|
||||
*
|
||||
* ```markdown
|
||||
* > | {Math.PI}␠␊
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function end(code) {
|
||||
// We want to allow tags directly after expressions.
|
||||
//
|
||||
// This case is useful:
|
||||
//
|
||||
// ```mdx
|
||||
// <a>{b}</a>
|
||||
// ```
|
||||
//
|
||||
// This case is not (very?) useful:
|
||||
//
|
||||
// ```mdx
|
||||
// {a}<b/>
|
||||
// ```
|
||||
//
|
||||
// …but it would be tougher than needed to disallow.
|
||||
//
|
||||
// To allow that, here we call the flow construct of
|
||||
// `micromark-extension-mdx-jsx`, and there we call this one.
|
||||
//
|
||||
// It would introduce a cyclical interdependency if we test JSX and
|
||||
// expressions here.
|
||||
// Because the JSX extension already uses parts of this monorepo, we
|
||||
// instead test it there.
|
||||
const lessThanValue = self.parser.constructs.flow[60];
|
||||
const constructs = Array.isArray(lessThanValue) ? lessThanValue : /* c8 ignore next 3 -- always a list when normalized. */
|
||||
lessThanValue ? [lessThanValue] : [];
|
||||
const jsxTag = constructs.find(function (d) {
|
||||
return d.name === 'mdxJsxFlowTag';
|
||||
});
|
||||
|
||||
/* c8 ignore next 3 -- this is tested in `micromark-extension-mdx-jsx` */
|
||||
if (code === 60 && jsxTag) {
|
||||
return effects.attempt(jsxTag, end, nok)(code);
|
||||
}
|
||||
return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MDX expression (text).
|
||||
*
|
||||
* ```markdown
|
||||
* > | a {Math.PI} c.
|
||||
* ^^^^^^^^^
|
||||
* ```
|
||||
*
|
||||
* @this {TokenizeContext}
|
||||
* @type {Tokenizer}
|
||||
*/
|
||||
function tokenizeTextExpression(effects, ok) {
|
||||
const self = this;
|
||||
return start;
|
||||
|
||||
/**
|
||||
* Start of an MDX expression (text).
|
||||
*
|
||||
* ```markdown
|
||||
* > | a {Math.PI} c.
|
||||
* ^
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* @type {State}
|
||||
*/
|
||||
function start(code) {
|
||||
return factoryMdxExpression.call(self, effects, ok, 'mdxTextExpression', 'mdxTextExpressionMarker', 'mdxTextExpressionChunk', acorn, acornOptions, addResult, spread, allowEmpty, true)(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+96
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"bugs": "https://github.com/micromark/micromark-extension-mdx-expression/issues",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/estree": "^1.0.0",
|
||||
"devlop": "^1.0.0",
|
||||
"micromark-factory-mdx-expression": "^2.0.0",
|
||||
"micromark-factory-space": "^2.0.0",
|
||||
"micromark-util-character": "^2.0.0",
|
||||
"micromark-util-events-to-acorn": "^2.0.0",
|
||||
"micromark-util-symbol": "^2.0.0",
|
||||
"micromark-util-types": "^2.0.0"
|
||||
},
|
||||
"description": "micromark extension to support MDX or MDX JS expressions",
|
||||
"exports": {
|
||||
"development": "./dev/index.js",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"files": [
|
||||
"dev/",
|
||||
"index.d.ts",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"type": "GitHub Sponsors",
|
||||
"url": "https://github.com/sponsors/unifiedjs"
|
||||
},
|
||||
{
|
||||
"type": "OpenCollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
"ecmascript",
|
||||
"es",
|
||||
"expression",
|
||||
"javascript",
|
||||
"js",
|
||||
"markdown",
|
||||
"mdxjs",
|
||||
"mdx",
|
||||
"micromark-extension",
|
||||
"micromark",
|
||||
"unified"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "micromark-extension-mdx-expression",
|
||||
"repository": "https://github.com/micromark/micromark-extension-mdx-expression/tree/main/packages/micromark-extension-mdx-expression",
|
||||
"scripts": {
|
||||
"build": "micromark-build"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"strict": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "3.0.1",
|
||||
"xo": {
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"**/*.d.ts"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/array-type": [
|
||||
"error",
|
||||
{
|
||||
"default": "generic"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
"extendDefaults": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/consistent-type-definitions": [
|
||||
"error",
|
||||
"interface"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"logical-assignment-operators": "off",
|
||||
"unicorn/no-this-assignment": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
Vendored
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../micromark-factory-mdx-expression@2.0.3/node_modules/micromark-factory-mdx-expression
|
||||
Generated
Vendored
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../micromark-factory-space@2.0.1/node_modules/micromark-factory-space
|
||||
Generated
Vendored
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../micromark-util-character@2.1.1/node_modules/micromark-util-character
|
||||
Reference in New Issue
Block a user