@orgajs/orgx 1.0.7 → 2.0.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.org +22 -0
- package/dist/index.d.ts +11 -5
- package/dist/lib/compile.d.ts +45 -0
- package/dist/lib/condition.browser.d.ts +1 -0
- package/dist/lib/condition.d.ts +1 -0
- package/dist/lib/core.d.ts +57 -0
- package/dist/lib/evaluate.d.ts +27 -0
- package/dist/lib/plugin/recma-document.d.ts +63 -0
- package/dist/lib/plugin/recma-jsx-build.d.ts +14 -0
- package/dist/lib/plugin/recma-jsx-rewrite.d.ts +50 -0
- package/dist/lib/plugin/recma-stringify.d.ts +13 -0
- package/dist/lib/plugin/rehype-recma.d.ts +49 -0
- package/dist/lib/run.d.ts +26 -0
- package/dist/lib/util/estree-util-create.d.ts +13 -0
- package/dist/lib/util/estree-util-declaration-to-expression.d.ts +19 -0
- package/dist/lib/util/estree-util-is-declaration.d.ts +15 -0
- package/dist/lib/util/estree-util-specifiers-to-declarations.d.ts +14 -0
- package/dist/lib/util/estree-util-to-binary-addition.d.ts +8 -0
- package/dist/lib/util/estree-util-to-id-or-member-expression.d.ts +11 -0
- package/dist/lib/util/render-error.d.ts +2 -0
- package/dist/lib/util/resolve-evaluate-options.d.ts +66 -0
- package/dist/lib/util/resolve-file-and-options.d.ts +16 -0
- package/index.js +14 -0
- package/lib/compile.js +54 -0
- package/lib/condition.browser.js +1 -0
- package/lib/condition.js +3 -0
- package/lib/core.js +100 -0
- package/lib/evaluate.js +41 -0
- package/lib/plugin/recma-document.js +607 -0
- package/lib/plugin/recma-jsx-build.js +53 -0
- package/lib/plugin/recma-jsx-rewrite.js +616 -0
- package/lib/plugin/recma-stringify.js +42 -0
- package/lib/plugin/rehype-recma.js +218 -0
- package/lib/run.js +31 -0
- package/lib/types.d.ts +46 -0
- package/lib/util/estree-util-create.js +27 -0
- package/lib/util/estree-util-declaration-to-expression.js +32 -0
- package/lib/util/estree-util-is-declaration.js +20 -0
- package/lib/util/estree-util-specifiers-to-declarations.js +90 -0
- package/lib/util/estree-util-to-binary-addition.js +23 -0
- package/lib/util/estree-util-to-id-or-member-expression.js +108 -0
- package/lib/util/render-error.js +91 -0
- package/lib/util/resolve-evaluate-options.js +64 -0
- package/lib/util/resolve-file-and-options.js +40 -0
- package/package.json +36 -29
- package/CHANGELOG.md +0 -71
- package/dist/compile.d.ts +0 -6
- package/dist/compile.d.ts.map +0 -1
- package/dist/compile.js +0 -12
- package/dist/compile.js.map +0 -1
- package/dist/estree/create.d.ts +0 -2
- package/dist/estree/create.d.ts.map +0 -1
- package/dist/estree/create.js +0 -14
- package/dist/estree/create.js.map +0 -1
- package/dist/estree/declaration-to-expression.d.ts +0 -3
- package/dist/estree/declaration-to-expression.d.ts.map +0 -1
- package/dist/estree/declaration-to-expression.js +0 -12
- package/dist/estree/declaration-to-expression.js.map +0 -1
- package/dist/estree/error.d.ts +0 -61
- package/dist/estree/error.d.ts.map +0 -1
- package/dist/estree/error.js +0 -87
- package/dist/estree/error.js.map +0 -1
- package/dist/estree/is-declaration.d.ts +0 -3
- package/dist/estree/is-declaration.d.ts.map +0 -1
- package/dist/estree/is-declaration.js +0 -9
- package/dist/estree/is-declaration.js.map +0 -1
- package/dist/estree/position-from-estree.d.ts +0 -13
- package/dist/estree/position-from-estree.d.ts.map +0 -1
- package/dist/estree/position-from-estree.js +0 -34
- package/dist/estree/position-from-estree.js.map +0 -1
- package/dist/estree/specifiers-to-object-pattern.d.ts +0 -5
- package/dist/estree/specifiers-to-object-pattern.d.ts.map +0 -1
- package/dist/estree/specifiers-to-object-pattern.js +0 -33
- package/dist/estree/specifiers-to-object-pattern.js.map +0 -1
- package/dist/evaluate.d.ts +0 -22
- package/dist/evaluate.d.ts.map +0 -1
- package/dist/evaluate.js +0 -27
- package/dist/evaluate.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/plugin/estree-jsx-build.d.ts +0 -6
- package/dist/plugin/estree-jsx-build.d.ts.map +0 -1
- package/dist/plugin/estree-jsx-build.js +0 -38
- package/dist/plugin/estree-jsx-build.js.map +0 -1
- package/dist/plugin/estree-jsx-rewrite.d.ts +0 -6
- package/dist/plugin/estree-jsx-rewrite.d.ts.map +0 -1
- package/dist/plugin/estree-jsx-rewrite.js +0 -214
- package/dist/plugin/estree-jsx-rewrite.js.map +0 -1
- package/dist/plugin/estree-stringify.d.ts +0 -2
- package/dist/plugin/estree-stringify.d.ts.map +0 -1
- package/dist/plugin/estree-stringify.js +0 -127
- package/dist/plugin/estree-stringify.js.map +0 -1
- package/dist/plugin/estree-wrap-in-content.d.ts +0 -18
- package/dist/plugin/estree-wrap-in-content.d.ts.map +0 -1
- package/dist/plugin/estree-wrap-in-content.js +0 -375
- package/dist/plugin/estree-wrap-in-content.js.map +0 -1
- package/dist/plugin/rehype-estree.d.ts +0 -12
- package/dist/plugin/rehype-estree.d.ts.map +0 -1
- package/dist/plugin/rehype-estree.js +0 -122
- package/dist/plugin/rehype-estree.js.map +0 -1
- package/dist/plugin/rehype-set-layout.d.ts +0 -6
- package/dist/plugin/rehype-set-layout.d.ts.map +0 -1
- package/dist/plugin/rehype-set-layout.js +0 -30
- package/dist/plugin/rehype-set-layout.js.map +0 -1
- package/dist/processor.d.ts +0 -14
- package/dist/processor.d.ts.map +0 -1
- package/dist/processor.js +0 -52
- package/dist/processor.js.map +0 -1
- package/dist/utils/remove-quotes.d.ts +0 -3
- package/dist/utils/remove-quotes.d.ts.map +0 -1
- package/dist/utils/remove-quotes.js +0 -6
- package/dist/utils/remove-quotes.js.map +0 -1
package/LICENSE.org
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 gatsbyjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
export { createProcessor } from
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export type
|
|
5
|
-
|
|
1
|
+
export { createProcessor } from "./lib/core.js";
|
|
2
|
+
export type ProcessorOptions = import('./lib/core.js').ProcessorOptions;
|
|
3
|
+
export type CompileOptions = import('./lib/compile.js').CompileOptions;
|
|
4
|
+
export type EvaluateOptions = import('./lib/evaluate.js').EvaluateOptions;
|
|
5
|
+
export type OrgComponents = import('./lib/types.js').OrgComponents;
|
|
6
|
+
export type OrgContent = import('./lib/types.js').OrgContent;
|
|
7
|
+
export type OrgModule = import('./lib/types.js').OrgModule;
|
|
8
|
+
export type OrgProps = import('./lib/types.js').OrgProps;
|
|
9
|
+
export { compile, compileSync } from "./lib/compile.js";
|
|
10
|
+
export { evaluate, evaluateSync } from "./lib/evaluate.js";
|
|
11
|
+
export { run, runSync } from "./lib/run.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile MDX to JS.
|
|
3
|
+
*
|
|
4
|
+
* @param {VFileCompatible} vfileCompatible
|
|
5
|
+
* MDX document to parse (`string`, `Buffer`, `vfile`, anything that can be
|
|
6
|
+
* given to `vfile`).
|
|
7
|
+
* @param {CompileOptions | null | undefined} [compileOptions]
|
|
8
|
+
* Compile configuration.
|
|
9
|
+
* @return {Promise<VFile>}
|
|
10
|
+
* File.
|
|
11
|
+
*/
|
|
12
|
+
export function compile(vfileCompatible: VFileCompatible, compileOptions?: CompileOptions | null | undefined): Promise<VFile>;
|
|
13
|
+
/**
|
|
14
|
+
* Synchronously compile MDX to JS.
|
|
15
|
+
*
|
|
16
|
+
* @param {VFileCompatible} vfileCompatible
|
|
17
|
+
* MDX document to parse (`string`, `Buffer`, `vfile`, anything that can be
|
|
18
|
+
* given to `vfile`).
|
|
19
|
+
* @param {CompileOptions | null | undefined} [compileOptions]
|
|
20
|
+
* Compile configuration.
|
|
21
|
+
* @return {VFile}
|
|
22
|
+
* File.
|
|
23
|
+
*/
|
|
24
|
+
export function compileSync(vfileCompatible: VFileCompatible, compileOptions?: CompileOptions | null | undefined): VFile;
|
|
25
|
+
export type VFile = import('vfile').VFile;
|
|
26
|
+
export type VFileCompatible = import('vfile').VFileCompatible;
|
|
27
|
+
export type PluginOptions = import('./core.js').PluginOptions;
|
|
28
|
+
export type BaseProcessorOptions = import('./core.js').BaseProcessorOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Core configuration.
|
|
31
|
+
*/
|
|
32
|
+
export type CoreProcessorOptions = Omit<BaseProcessorOptions, 'format'>;
|
|
33
|
+
/**
|
|
34
|
+
* Extra configuration.
|
|
35
|
+
*/
|
|
36
|
+
export type ExtraOptions = {
|
|
37
|
+
/**
|
|
38
|
+
* Format of `file`.
|
|
39
|
+
*/
|
|
40
|
+
format?: 'detect' | 'mdx' | 'md' | null | undefined;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Configuration.
|
|
44
|
+
*/
|
|
45
|
+
export type CompileOptions = CoreProcessorOptions & PluginOptions & ExtraOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const development: false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const development: boolean;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline to:
|
|
3
|
+
*
|
|
4
|
+
* 1. Parse org-mode
|
|
5
|
+
* 2. Transform through reorg (oast), rehype (hast), and recma (esast)
|
|
6
|
+
* 3. Serialize as JavaScript
|
|
7
|
+
*
|
|
8
|
+
* @param {ProcessorOptions | null | undefined} [options]
|
|
9
|
+
* Configuration.
|
|
10
|
+
* @return {Processor}
|
|
11
|
+
* Processor.
|
|
12
|
+
*/
|
|
13
|
+
export function createProcessor(options?: ProcessorOptions | null | undefined): Processor;
|
|
14
|
+
export type PluggableList = import('unified').PluggableList;
|
|
15
|
+
export type Processor = import('unified').Processor;
|
|
16
|
+
export type RehypeRecmaOptions = import('./plugin/rehype-recma.js').Options;
|
|
17
|
+
export type RecmaDocumentOptions = import('./plugin/recma-document.js').RecmaDocumentOptions;
|
|
18
|
+
export type RecmaStringifyOptions = import('./plugin/recma-stringify.js').RecmaStringifyOptions;
|
|
19
|
+
export type RecmaJsxRewriteOptions = import('./plugin/recma-jsx-rewrite.js').RecmaJsxRewriteOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Base configuration.
|
|
22
|
+
*/
|
|
23
|
+
export type BaseProcessorOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to keep JSX.
|
|
26
|
+
* Format of the files to be processed.
|
|
27
|
+
*/
|
|
28
|
+
jsx?: boolean | null | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to compile to a whole program or a function body..
|
|
31
|
+
*/
|
|
32
|
+
outputFormat?: 'function-body' | 'program';
|
|
33
|
+
/**
|
|
34
|
+
* List of recma (esast, JavaScript) plugins.
|
|
35
|
+
*/
|
|
36
|
+
recmaPlugins?: import("unified").PluggableList | null | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* List of remark (mdast, markdown) plugins.
|
|
39
|
+
*/
|
|
40
|
+
reorgPlugins?: import("unified").PluggableList | null | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* List of rehype (hast, HTML) plugins.
|
|
43
|
+
*/
|
|
44
|
+
rehypePlugins?: import("unified").PluggableList | null | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Options to pass through to `reorg-rehype`.
|
|
47
|
+
*/
|
|
48
|
+
reorgRehypeOptions?: import('@orgajs/reorg-rehype').Options | null | undefined;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for internal plugins.
|
|
52
|
+
*/
|
|
53
|
+
export type PluginOptions = Omit<RehypeRecmaOptions & RecmaDocumentOptions & RecmaStringifyOptions & RecmaJsxRewriteOptions, 'outputFormat'>;
|
|
54
|
+
/**
|
|
55
|
+
* Configuration for processor.
|
|
56
|
+
*/
|
|
57
|
+
export type ProcessorOptions = BaseProcessorOptions & PluginOptions;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluate MDX.
|
|
3
|
+
*
|
|
4
|
+
* @param {VFileCompatible} vfileCompatible
|
|
5
|
+
* MDX document to parse (`string`, `Buffer`, `vfile`, anything that can be
|
|
6
|
+
* given to `vfile`).
|
|
7
|
+
* @param {EvaluateOptions} evaluateOptions
|
|
8
|
+
* Configuration for evaluation.
|
|
9
|
+
* @return {Promise<ExportMap>}
|
|
10
|
+
* Export map.
|
|
11
|
+
*/
|
|
12
|
+
export function evaluate(vfileCompatible: VFileCompatible, evaluateOptions: EvaluateOptions): Promise<ExportMap>;
|
|
13
|
+
/**
|
|
14
|
+
* Synchronously evaluate MDX.
|
|
15
|
+
*
|
|
16
|
+
* @param {VFileCompatible} vfileCompatible
|
|
17
|
+
* MDX document to parse (`string`, `Buffer`, `vfile`, anything that can be
|
|
18
|
+
* given to `vfile`).
|
|
19
|
+
* @param {EvaluateOptions} evaluateOptions
|
|
20
|
+
* Configuration for evaluation.
|
|
21
|
+
* @return {ExportMap}
|
|
22
|
+
* Export map.
|
|
23
|
+
*/
|
|
24
|
+
export function evaluateSync(vfileCompatible: VFileCompatible, evaluateOptions: EvaluateOptions): ExportMap;
|
|
25
|
+
export type ExportMap = import('./types.js').OrgModule;
|
|
26
|
+
export type VFileCompatible = import('vfile').VFileCompatible;
|
|
27
|
+
export type EvaluateOptions = import('./util/resolve-evaluate-options.js').EvaluateOptions;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export function recmaDocument(this: import("unified").Processor<void, import("estree").Program, void, void>, ...settings: [] | [RecmaDocumentOptions | null | undefined]): void | import("unified").Transformer<import("estree").Program, import("estree").Program>;
|
|
2
|
+
export type Directive = import('estree-jsx').Directive;
|
|
3
|
+
export type ExportAllDeclaration = import('estree-jsx').ExportAllDeclaration;
|
|
4
|
+
export type ExportDefaultDeclaration = import('estree-jsx').ExportDefaultDeclaration;
|
|
5
|
+
export type ExportNamedDeclaration = import('estree-jsx').ExportNamedDeclaration;
|
|
6
|
+
export type ExportSpecifier = import('estree-jsx').ExportSpecifier;
|
|
7
|
+
export type Expression = import('estree-jsx').Expression;
|
|
8
|
+
export type FunctionDeclaration = import('estree-jsx').FunctionDeclaration;
|
|
9
|
+
export type ImportDeclaration = import('estree-jsx').ImportDeclaration;
|
|
10
|
+
export type ImportDefaultSpecifier = import('estree-jsx').ImportDefaultSpecifier;
|
|
11
|
+
export type ImportExpression = import('estree-jsx').ImportExpression;
|
|
12
|
+
export type ImportSpecifier = import('estree-jsx').ImportSpecifier;
|
|
13
|
+
export type Literal = import('estree-jsx').Literal;
|
|
14
|
+
export type JSXElement = import('estree-jsx').JSXElement;
|
|
15
|
+
export type ModuleDeclaration = import('estree-jsx').ModuleDeclaration;
|
|
16
|
+
export type Node = import('estree-jsx').Node;
|
|
17
|
+
export type Program = import('estree-jsx').Program;
|
|
18
|
+
export type Property = import('estree-jsx').Property;
|
|
19
|
+
export type SimpleLiteral = import('estree-jsx').SimpleLiteral;
|
|
20
|
+
export type SpreadElement = import('estree-jsx').SpreadElement;
|
|
21
|
+
export type Statement = import('estree-jsx').Statement;
|
|
22
|
+
export type VariableDeclarator = import('estree-jsx').VariableDeclarator;
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for internal plugin `recma-document`.
|
|
25
|
+
*/
|
|
26
|
+
export type RecmaDocumentOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* Whether to use either `import` and `export` statements to get the runtime
|
|
29
|
+
* (and optionally provider) and export the content, or get values from
|
|
30
|
+
* `arguments` and return things.
|
|
31
|
+
*/
|
|
32
|
+
outputFormat?: 'function-body' | 'program' | null | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to keep `import` (and `export … from`) statements or compile them
|
|
35
|
+
* to dynamic `import()` instead.
|
|
36
|
+
*/
|
|
37
|
+
useDynamicImport?: boolean | null | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve `import`s (and `export … from`, and `import.meta.url`) relative to
|
|
40
|
+
* this URL.
|
|
41
|
+
*/
|
|
42
|
+
baseUrl?: string | null | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Pragma for JSX (used in classic runtime).
|
|
45
|
+
*/
|
|
46
|
+
pragma?: string | null | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Pragma for JSX fragments (used in classic runtime).
|
|
49
|
+
*/
|
|
50
|
+
pragmaFrag?: string | null | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Where to import the identifier of `pragma` from (used in classic runtime).
|
|
53
|
+
*/
|
|
54
|
+
pragmaImportSource?: string | null | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Place to import automatic JSX runtimes from (used in automatic runtime).
|
|
57
|
+
*/
|
|
58
|
+
jsxImportSource?: string | null | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* JSX runtime to use.
|
|
61
|
+
*/
|
|
62
|
+
jsxRuntime?: 'automatic' | 'classic' | null | undefined;
|
|
63
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function recmaJsxBuild(this: import("unified").Processor<void, import("estree").Program, void, void>, ...settings: [RecmaJsxBuildOptions | null | undefined] | []): void | import("unified").Transformer<import("estree").Program, import("estree").Program>;
|
|
2
|
+
export type Program = import('estree-jsx').Program;
|
|
3
|
+
export type BuildJsxOptions = import('estree-util-build-jsx').BuildJsxOptions;
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for internal plugin `recma-jsx-build`.
|
|
6
|
+
*/
|
|
7
|
+
export type ExtraOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Whether to keep the import of the automatic runtime or get it from
|
|
10
|
+
* `arguments[0]` instead.
|
|
11
|
+
*/
|
|
12
|
+
outputFormat?: 'function-body' | 'program' | null | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type RecmaJsxBuildOptions = BuildJsxOptions & ExtraOptions;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function recmaJsxRewrite(this: import("unified").Processor<void, import("estree").Program, void, void>, ...settings: [] | [RecmaJsxRewriteOptions | null | undefined]): void | import("unified").Transformer<import("estree").Program, import("estree").Program>;
|
|
2
|
+
export type Expression = import('estree-jsx').Expression;
|
|
3
|
+
export type EstreeFunction = import('estree-jsx').Function;
|
|
4
|
+
export type Identifier = import('estree-jsx').Identifier;
|
|
5
|
+
export type ImportSpecifier = import('estree-jsx').ImportSpecifier;
|
|
6
|
+
export type JSXElement = import('estree-jsx').JSXElement;
|
|
7
|
+
export type ModuleDeclaration = import('estree-jsx').ModuleDeclaration;
|
|
8
|
+
export type Node = import('estree-jsx').Node;
|
|
9
|
+
export type ObjectPattern = import('estree-jsx').ObjectPattern;
|
|
10
|
+
export type Program = import('estree-jsx').Program;
|
|
11
|
+
export type Property = import('estree-jsx').Property;
|
|
12
|
+
export type Statement = import('estree-jsx').Statement;
|
|
13
|
+
export type VariableDeclarator = import('estree-jsx').VariableDeclarator;
|
|
14
|
+
export type Scope = import('periscopic').Scope & {
|
|
15
|
+
node: Node;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Configuration for internal plugin `recma-jsx-rewrite`.
|
|
19
|
+
*/
|
|
20
|
+
export type RecmaJsxRewriteOptions = {
|
|
21
|
+
/**
|
|
22
|
+
* Whether to use an import statement or `arguments[0]` to get the provider.
|
|
23
|
+
*/
|
|
24
|
+
outputFormat?: 'function-body' | 'program' | null | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Place to import a provider from.
|
|
27
|
+
*/
|
|
28
|
+
providerImportSource?: string | null | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to add extra info to error messages in generated code.
|
|
31
|
+
*
|
|
32
|
+
* This also results in the development automatic JSX runtime
|
|
33
|
+
* (`/jsx-dev-runtime`, `jsxDEV`) being used, which passes positional info to
|
|
34
|
+
* nodes.
|
|
35
|
+
* The default can be set to `true` in Node.js through environment variables:
|
|
36
|
+
* set `NODE_ENV=development`.
|
|
37
|
+
*/
|
|
38
|
+
development?: boolean | null | undefined;
|
|
39
|
+
};
|
|
40
|
+
export type StackEntry = {
|
|
41
|
+
objects: Array<string>;
|
|
42
|
+
components: Array<string>;
|
|
43
|
+
tags: Array<string>;
|
|
44
|
+
references: Record<string, {
|
|
45
|
+
node: JSXElement;
|
|
46
|
+
component: boolean;
|
|
47
|
+
}>;
|
|
48
|
+
idToInvalidComponentName: Map<string | number, string>;
|
|
49
|
+
node: EstreeFunction;
|
|
50
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function recmaStringify(this: import("unified").Processor<void, import("estree").Program, import("estree").Program, string>, ...settings: [] | [RecmaStringifyOptions | null | undefined]): void;
|
|
2
|
+
export type Program = import('estree-jsx').Program;
|
|
3
|
+
export type SourceMapGenerator = typeof import('source-map').SourceMapGenerator;
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for internal plugin `recma-stringify`.
|
|
6
|
+
*/
|
|
7
|
+
export type RecmaStringifyOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Generate a source map by passing a `SourceMapGenerator` from `source-map`
|
|
10
|
+
* in.
|
|
11
|
+
*/
|
|
12
|
+
SourceMapGenerator?: SourceMapGenerator | null | undefined;
|
|
13
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function rehypeRecma(this: import("unified").Processor<void, import("hast").Root, void, void>, ...settings: [] | [Options | undefined]): void | import("unified").Transformer<import("hast").Root, import("estree").Program>;
|
|
2
|
+
export type Program = import('estree-jsx').Program;
|
|
3
|
+
export type Expression = import('estree-jsx').Expression;
|
|
4
|
+
export type ModuleDeclaration = import('estree-jsx').ModuleDeclaration;
|
|
5
|
+
export type Root = import('hast').Root;
|
|
6
|
+
export type Handle = import('hast-util-to-estree').Handle;
|
|
7
|
+
export type HastToEstreeOptions = import('hast-util-to-estree').Options;
|
|
8
|
+
/**
|
|
9
|
+
* Specify casing to use for attribute names.
|
|
10
|
+
*
|
|
11
|
+
* HTML casing is for example `class`, `stroke-linecap`, `xml:lang`.
|
|
12
|
+
* React casing is for example `className`, `strokeLinecap`, `xmlLang`.
|
|
13
|
+
*/
|
|
14
|
+
export type ElementAttributeNameCase = 'html' | 'react';
|
|
15
|
+
/**
|
|
16
|
+
* Casing to use for property names in `style` objects.
|
|
17
|
+
*
|
|
18
|
+
* CSS casing is for example `background-color` and `-webkit-line-clamp`.
|
|
19
|
+
* DOM casing is for example `backgroundColor` and `WebkitLineClamp`.
|
|
20
|
+
*/
|
|
21
|
+
export type StylePropertyNameCase = 'css' | 'dom';
|
|
22
|
+
/**
|
|
23
|
+
* Configuration for internal plugin `rehype-recma`.
|
|
24
|
+
*/
|
|
25
|
+
export type MoreOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* Specify casing to use for attribute names.
|
|
28
|
+
*
|
|
29
|
+
* This casing is used for hast elements, not for embedded Org JSX nodes
|
|
30
|
+
* (components that someone authored manually).
|
|
31
|
+
*/
|
|
32
|
+
elementAttributeNameCase?: ElementAttributeNameCase | undefined | null;
|
|
33
|
+
/**
|
|
34
|
+
* Specify casing to use for property names in `style` objects.
|
|
35
|
+
*
|
|
36
|
+
* This casing is used for hast elements, not for embedded Org JSX nodes
|
|
37
|
+
* (components that someone authored manually).
|
|
38
|
+
*/
|
|
39
|
+
stylePropertyNameCase?: StylePropertyNameCase | undefined | null;
|
|
40
|
+
/**
|
|
41
|
+
* - Whether to skip imports
|
|
42
|
+
*/
|
|
43
|
+
skipImport?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* - Specify which hast properties to parse as JSX.
|
|
46
|
+
*/
|
|
47
|
+
parseJSX?: string[];
|
|
48
|
+
};
|
|
49
|
+
export type Options = HastToEstreeOptions & MoreOptions;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asynchronously run code.
|
|
3
|
+
*
|
|
4
|
+
* @param {{toString(): string}} file
|
|
5
|
+
* JS document to run.
|
|
6
|
+
* @param {unknown} options
|
|
7
|
+
* Parameter.
|
|
8
|
+
* @return {Promise<any>}
|
|
9
|
+
* Anything.
|
|
10
|
+
*/
|
|
11
|
+
export function run(file: {
|
|
12
|
+
toString(): string;
|
|
13
|
+
}, options: unknown): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Synchronously run code.
|
|
16
|
+
*
|
|
17
|
+
* @param {{toString(): string}} file
|
|
18
|
+
* JS document to run.
|
|
19
|
+
* @param {unknown} options
|
|
20
|
+
* Parameter.
|
|
21
|
+
* @return {any}
|
|
22
|
+
* Anything.
|
|
23
|
+
*/
|
|
24
|
+
export function runSync(file: {
|
|
25
|
+
toString(): string;
|
|
26
|
+
}, options: unknown): any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('estree-jsx').Node} Node
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @param {Node} from
|
|
6
|
+
* Node to take from.
|
|
7
|
+
* @param {Node} to
|
|
8
|
+
* Node to add to.
|
|
9
|
+
* @returns {void}
|
|
10
|
+
* Nothing.
|
|
11
|
+
*/
|
|
12
|
+
export function create(from: Node, to: Node): void;
|
|
13
|
+
export type Node = import('estree-jsx').Node;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('estree-jsx').Declaration} Declaration
|
|
3
|
+
* @typedef {import('estree-jsx').Expression} Expression
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Turn a declaration into an expression.
|
|
7
|
+
*
|
|
8
|
+
* Doesn’t work for variable declarations, but that’s fine for our use case
|
|
9
|
+
* because currently we’re using this utility for export default declarations,
|
|
10
|
+
* which can’t contain variable declarations.
|
|
11
|
+
*
|
|
12
|
+
* @param {Declaration} declaration
|
|
13
|
+
* Declaration.
|
|
14
|
+
* @returns {Expression}
|
|
15
|
+
* Expression.
|
|
16
|
+
*/
|
|
17
|
+
export function declarationToExpression(declaration: Declaration): Expression;
|
|
18
|
+
export type Declaration = import('estree-jsx').Declaration;
|
|
19
|
+
export type Expression = import('estree-jsx').Expression;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('estree-jsx').Node} Node
|
|
3
|
+
* @typedef {import('estree-jsx').Declaration} Declaration
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Check if `node` is a declaration.
|
|
7
|
+
*
|
|
8
|
+
* @param {Node} node
|
|
9
|
+
* Node to check.
|
|
10
|
+
* @returns {node is Declaration}
|
|
11
|
+
* Whether `node` is a declaration.
|
|
12
|
+
*/
|
|
13
|
+
export function isDeclaration(node: Node): node is import("estree").Declaration;
|
|
14
|
+
export type Node = import('estree-jsx').Node;
|
|
15
|
+
export type Declaration = import('estree-jsx').Declaration;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier>} specifiers
|
|
3
|
+
* @param {Expression} init
|
|
4
|
+
* @returns {Array<VariableDeclarator>}
|
|
5
|
+
*/
|
|
6
|
+
export function specifiersToDeclarations(specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier>, init: Expression): Array<VariableDeclarator>;
|
|
7
|
+
export type AssignmentProperty = import('estree-jsx').AssignmentProperty;
|
|
8
|
+
export type ExportSpecifier = import('estree-jsx').ExportSpecifier;
|
|
9
|
+
export type Expression = import('estree-jsx').Expression;
|
|
10
|
+
export type Identifier = import('estree-jsx').Identifier;
|
|
11
|
+
export type ImportDefaultSpecifier = import('estree-jsx').ImportDefaultSpecifier;
|
|
12
|
+
export type ImportNamespaceSpecifier = import('estree-jsx').ImportNamespaceSpecifier;
|
|
13
|
+
export type ImportSpecifier = import('estree-jsx').ImportSpecifier;
|
|
14
|
+
export type VariableDeclarator = import('estree-jsx').VariableDeclarator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('estree-jsx').Expression} Expression
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @param {Array<Expression>} expressions
|
|
6
|
+
*/
|
|
7
|
+
export function toBinaryAddition(expressions: Array<Expression>): import("estree").Expression;
|
|
8
|
+
export type Expression = import('estree-jsx').Expression;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Array<string | number>} ids
|
|
3
|
+
* @returns {Identifier | MemberExpression}
|
|
4
|
+
*/
|
|
5
|
+
export function toIdOrMemberExpression(ids: Array<string | number>): Identifier | MemberExpression;
|
|
6
|
+
export function toJsxIdOrMemberExpression(ids: Array<string | number>): JSXIdentifier | JSXMemberExpression;
|
|
7
|
+
export type Identifier = import('estree-jsx').Identifier;
|
|
8
|
+
export type JSXIdentifier = import('estree-jsx').JSXIdentifier;
|
|
9
|
+
export type JSXMemberExpression = import('estree-jsx').JSXMemberExpression;
|
|
10
|
+
export type Literal = import('estree-jsx').Literal;
|
|
11
|
+
export type MemberExpression = import('estree-jsx').MemberExpression;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../core.js').ProcessorOptions} ProcessorOptions
|
|
3
|
+
*
|
|
4
|
+
* @typedef RunnerOptions
|
|
5
|
+
* Configuration with JSX runtime.
|
|
6
|
+
* @property {any} Fragment
|
|
7
|
+
* Symbol to use for fragments.
|
|
8
|
+
* @property {any} [jsx]
|
|
9
|
+
* Function to generate an element with static children in production mode.
|
|
10
|
+
* @property {any} [jsxs]
|
|
11
|
+
* Function to generate an element with dynamic children in production mode.
|
|
12
|
+
* @property {any} [jsxDEV]
|
|
13
|
+
* Function to generate an element in development mode.
|
|
14
|
+
* @property {any} [useOrgComponents]
|
|
15
|
+
* Function to get `MDXComponents` from context.
|
|
16
|
+
*
|
|
17
|
+
* @typedef {Omit<ProcessorOptions, 'jsx' | 'jsxImportSource' | 'jsxRuntime' | 'pragma' | 'pragmaFrag' | 'pragmaImportSource' | 'providerImportSource' | 'outputFormat'> } EvaluateProcessorOptions
|
|
18
|
+
* Compile configuration without JSX options for evaluation.
|
|
19
|
+
*
|
|
20
|
+
* @typedef {EvaluateProcessorOptions & RunnerOptions} EvaluateOptions
|
|
21
|
+
* Configuration for evaluation.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Split compiletime options from runtime options.
|
|
25
|
+
*
|
|
26
|
+
* @param {EvaluateOptions | null | undefined} options
|
|
27
|
+
* @returns {{compiletime: ProcessorOptions, runtime: RunnerOptions}}
|
|
28
|
+
*/
|
|
29
|
+
export function resolveEvaluateOptions(options: EvaluateOptions | null | undefined): {
|
|
30
|
+
compiletime: ProcessorOptions;
|
|
31
|
+
runtime: RunnerOptions;
|
|
32
|
+
};
|
|
33
|
+
export type ProcessorOptions = import('../core.js').ProcessorOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Configuration with JSX runtime.
|
|
36
|
+
*/
|
|
37
|
+
export type RunnerOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* Symbol to use for fragments.
|
|
40
|
+
*/
|
|
41
|
+
Fragment: any;
|
|
42
|
+
/**
|
|
43
|
+
* Function to generate an element with static children in production mode.
|
|
44
|
+
*/
|
|
45
|
+
jsx?: any;
|
|
46
|
+
/**
|
|
47
|
+
* Function to generate an element with dynamic children in production mode.
|
|
48
|
+
*/
|
|
49
|
+
jsxs?: any;
|
|
50
|
+
/**
|
|
51
|
+
* Function to generate an element in development mode.
|
|
52
|
+
*/
|
|
53
|
+
jsxDEV?: any;
|
|
54
|
+
/**
|
|
55
|
+
* Function to get `MDXComponents` from context.
|
|
56
|
+
*/
|
|
57
|
+
useOrgComponents?: any;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Compile configuration without JSX options for evaluation.
|
|
61
|
+
*/
|
|
62
|
+
export type EvaluateProcessorOptions = Omit<ProcessorOptions, 'jsx' | 'jsxImportSource' | 'jsxRuntime' | 'pragma' | 'pragmaFrag' | 'pragmaImportSource' | 'providerImportSource' | 'outputFormat'>;
|
|
63
|
+
/**
|
|
64
|
+
* Configuration for evaluation.
|
|
65
|
+
*/
|
|
66
|
+
export type EvaluateOptions = EvaluateProcessorOptions & RunnerOptions;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a file and options from a given `vfileCompatible` and options that
|
|
3
|
+
* might contain `format: 'detect'`.
|
|
4
|
+
*
|
|
5
|
+
* @param {VFileCompatible} vfileCompatible
|
|
6
|
+
* @param {CompileOptions | null | undefined} [options]
|
|
7
|
+
* @returns {{file: VFile, options: ProcessorOptions}}
|
|
8
|
+
*/
|
|
9
|
+
export function resolveFileAndOptions(vfileCompatible: VFileCompatible, options?: CompileOptions | null | undefined): {
|
|
10
|
+
file: VFile;
|
|
11
|
+
options: ProcessorOptions;
|
|
12
|
+
};
|
|
13
|
+
export type VFileCompatible = import('vfile').VFileCompatible;
|
|
14
|
+
export type ProcessorOptions = import('../core.js').ProcessorOptions;
|
|
15
|
+
export type CompileOptions = import('../compile.js').CompileOptions;
|
|
16
|
+
import { VFile } from 'vfile';
|
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./lib/core.js').ProcessorOptions} ProcessorOptions
|
|
3
|
+
* @typedef {import('./lib/compile.js').CompileOptions} CompileOptions
|
|
4
|
+
* @typedef {import('./lib/evaluate.js').EvaluateOptions} EvaluateOptions
|
|
5
|
+
* @typedef {import('./lib/types.js').OrgComponents} OrgComponents
|
|
6
|
+
* @typedef {import('./lib/types.js').OrgContent} OrgContent
|
|
7
|
+
* @typedef {import('./lib/types.js').OrgModule} OrgModule
|
|
8
|
+
* @typedef {import('./lib/types.js').OrgProps} OrgProps
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export { createProcessor } from './lib/core.js'
|
|
12
|
+
export { compile, compileSync } from './lib/compile.js'
|
|
13
|
+
export { evaluate, evaluateSync } from './lib/evaluate.js'
|
|
14
|
+
export { run, runSync } from './lib/run.js'
|
package/lib/compile.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('vfile').VFile} VFile
|
|
3
|
+
* @typedef {import('vfile').VFileCompatible} VFileCompatible
|
|
4
|
+
* @typedef {import('./core.js').PluginOptions} PluginOptions
|
|
5
|
+
* @typedef {import('./core.js').BaseProcessorOptions} BaseProcessorOptions
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Omit<BaseProcessorOptions, 'format'>} CoreProcessorOptions
|
|
10
|
+
* Core configuration.
|
|
11
|
+
*
|
|
12
|
+
* @typedef ExtraOptions
|
|
13
|
+
* Extra configuration.
|
|
14
|
+
* @property {'detect' | 'mdx' | 'md' | null | undefined} [format='detect']
|
|
15
|
+
* Format of `file`.
|
|
16
|
+
*
|
|
17
|
+
* @typedef {CoreProcessorOptions & PluginOptions & ExtraOptions} CompileOptions
|
|
18
|
+
* Configuration.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import {createProcessor} from './core.js'
|
|
22
|
+
import {resolveFileAndOptions} from './util/resolve-file-and-options.js'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Compile MDX to JS.
|
|
26
|
+
*
|
|
27
|
+
* @param {VFileCompatible} vfileCompatible
|
|
28
|
+
* MDX document to parse (`string`, `Buffer`, `vfile`, anything that can be
|
|
29
|
+
* given to `vfile`).
|
|
30
|
+
* @param {CompileOptions | null | undefined} [compileOptions]
|
|
31
|
+
* Compile configuration.
|
|
32
|
+
* @return {Promise<VFile>}
|
|
33
|
+
* File.
|
|
34
|
+
*/
|
|
35
|
+
export function compile(vfileCompatible, compileOptions) {
|
|
36
|
+
const {file, options} = resolveFileAndOptions(vfileCompatible, compileOptions)
|
|
37
|
+
return createProcessor(options).process(file)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Synchronously compile MDX to JS.
|
|
42
|
+
*
|
|
43
|
+
* @param {VFileCompatible} vfileCompatible
|
|
44
|
+
* MDX document to parse (`string`, `Buffer`, `vfile`, anything that can be
|
|
45
|
+
* given to `vfile`).
|
|
46
|
+
* @param {CompileOptions | null | undefined} [compileOptions]
|
|
47
|
+
* Compile configuration.
|
|
48
|
+
* @return {VFile}
|
|
49
|
+
* File.
|
|
50
|
+
*/
|
|
51
|
+
export function compileSync(vfileCompatible, compileOptions) {
|
|
52
|
+
const {file, options} = resolveFileAndOptions(vfileCompatible, compileOptions)
|
|
53
|
+
return createProcessor(options).processSync(file)
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const development = false
|
package/lib/condition.js
ADDED