@orgajs/orgx 2.5.2 → 2.6.1
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/index.js +1 -1
- package/lib/compile.d.ts.map +1 -1
- package/lib/compile.js +12 -6
- package/lib/core.js +5 -5
- package/lib/evaluate.js +4 -4
- package/lib/plugin/recma-build-jsx-transform.d.ts.map +1 -1
- package/lib/plugin/recma-build-jsx-transform.js +52 -52
- package/lib/plugin/recma-document.d.ts +1 -1
- package/lib/plugin/recma-document.js +546 -546
- package/lib/plugin/recma-jsx-rewrite.js +527 -527
- package/lib/plugin/rehype-recma.d.ts.map +1 -1
- package/lib/plugin/rehype-recma.js +102 -103
- package/lib/run.js +3 -3
- package/lib/util/estree-util-create.js +11 -11
- package/lib/util/estree-util-declaration-to-expression.js +11 -11
- package/lib/util/estree-util-is-declaration.js +5 -5
- package/lib/util/estree-util-specifiers-to-declarations.js +68 -68
- package/lib/util/estree-util-to-binary-addition.d.ts.map +1 -1
- package/lib/util/estree-util-to-binary-addition.js +13 -11
- package/lib/util/estree-util-to-id-or-member-expression.d.ts.map +1 -1
- package/lib/util/estree-util-to-id-or-member-expression.js +66 -64
- package/lib/util/render-error.js +83 -83
- package/lib/util/resolve-evaluate-options.js +31 -31
- package/lib/util/resolve-file-and-options.js +15 -15
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* @typedef {import('./lib/types.js').OrgProps} OrgProps
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export { createProcessor } from './lib/core.js'
|
|
12
11
|
export { compile, compileSync } from './lib/compile.js'
|
|
12
|
+
export { createProcessor } from './lib/core.js'
|
|
13
13
|
export { evaluate, evaluateSync } from './lib/evaluate.js'
|
|
14
14
|
export { run, runSync } from './lib/run.js'
|
|
15
15
|
export { isOrgContent } from './lib/util/is-org-content.js'
|
package/lib/compile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["compile.js"],"names":[],"mappings":"AAuBA;;;;;;;;;;GAUG;AACH,yCARW,eAAe,mBAGf,cAAc,GAAG,IAAI,GAAG,SAAS,GAEhC,OAAO,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["compile.js"],"names":[],"mappings":"AAuBA;;;;;;;;;;GAUG;AACH,yCARW,eAAe,mBAGf,cAAc,GAAG,IAAI,GAAG,SAAS,GAEhC,OAAO,CAAC,KAAK,CAAC,CASzB;AAED;;;;;;;;;;GAUG;AACH,6CARW,eAAe,mBAGf,cAAc,GAAG,IAAI,GAAG,SAAS,GAEhC,KAAK,CAShB;oBA1DY,OAAO,OAAO,EAAE,KAAK;8BACrB,OAAO,OAAO,EAAE,eAAe;4BAC/B,OAAO,WAAW,EAAE,aAAa;mCACjC,OAAO,WAAW,EAAE,oBAAoB;;;;mCAIxC,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC;;;;;;;;aAKnC,QAAQ,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS;;;;;6BAG3C,oBAAoB,GAAG,aAAa,GAAG,YAAY"}
|
package/lib/compile.js
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
* Configuration.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import {createProcessor} from './core.js'
|
|
22
|
-
import {resolveFileAndOptions} from './util/resolve-file-and-options.js'
|
|
21
|
+
import { createProcessor } from './core.js'
|
|
22
|
+
import { resolveFileAndOptions } from './util/resolve-file-and-options.js'
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Compile MDX to JS.
|
|
@@ -33,8 +33,11 @@ import {resolveFileAndOptions} from './util/resolve-file-and-options.js'
|
|
|
33
33
|
* File.
|
|
34
34
|
*/
|
|
35
35
|
export function compile(vfileCompatible, compileOptions) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const { file, options } = resolveFileAndOptions(
|
|
37
|
+
vfileCompatible,
|
|
38
|
+
compileOptions
|
|
39
|
+
)
|
|
40
|
+
return createProcessor(options).process(file)
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
/**
|
|
@@ -49,6 +52,9 @@ export function compile(vfileCompatible, compileOptions) {
|
|
|
49
52
|
* File.
|
|
50
53
|
*/
|
|
51
54
|
export function compileSync(vfileCompatible, compileOptions) {
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
const { file, options } = resolveFileAndOptions(
|
|
56
|
+
vfileCompatible,
|
|
57
|
+
compileOptions
|
|
58
|
+
)
|
|
59
|
+
return createProcessor(options).processSync(file)
|
|
54
60
|
}
|
package/lib/core.js
CHANGED
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
* Configuration for processor.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
|
-
import { unified } from 'unified'
|
|
35
34
|
import reorgParse from '@orgajs/reorg-parse'
|
|
35
|
+
import reorgRehype from '@orgajs/reorg-rehype'
|
|
36
36
|
import recmaBuildJsx from 'recma-build-jsx'
|
|
37
37
|
import recmaJsx from 'recma-jsx'
|
|
38
38
|
import recmaStringify from 'recma-stringify'
|
|
39
|
-
import
|
|
39
|
+
import { unified } from 'unified'
|
|
40
|
+
import { recmaBuildJsxTransform } from './plugin/recma-build-jsx-transform.js'
|
|
40
41
|
import { recmaDocument } from './plugin/recma-document.js'
|
|
41
42
|
import { recmaJsxRewrite } from './plugin/recma-jsx-rewrite.js'
|
|
42
43
|
import rehypeRecma from './plugin/rehype-recma.js'
|
|
43
|
-
import { recmaBuildJsxTransform } from './plugin/recma-build-jsx-transform.js'
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Pipeline to:
|
|
@@ -77,7 +77,7 @@ export function createProcessor(options) {
|
|
|
77
77
|
.use(reorgPlugins || [])
|
|
78
78
|
.use(reorgRehype, {
|
|
79
79
|
...reorgRehypeOptions,
|
|
80
|
-
allowDangerousHtml: true
|
|
80
|
+
allowDangerousHtml: true
|
|
81
81
|
})
|
|
82
82
|
.use(rehypePlugins || [])
|
|
83
83
|
.use(rehypeRecma, { elementAttributeNameCase, stylePropertyNameCase })
|
|
@@ -85,7 +85,7 @@ export function createProcessor(options) {
|
|
|
85
85
|
.use(recmaJsxRewrite, {
|
|
86
86
|
development: dev,
|
|
87
87
|
providerImportSource,
|
|
88
|
-
outputFormat
|
|
88
|
+
outputFormat
|
|
89
89
|
})
|
|
90
90
|
|
|
91
91
|
if (!jsx) {
|
package/lib/evaluate.js
CHANGED
|
@@ -20,8 +20,8 @@ import { resolveEvaluateOptions } from './util/resolve-evaluate-options.js'
|
|
|
20
20
|
* Export map.
|
|
21
21
|
*/
|
|
22
22
|
export async function evaluate(vfileCompatible, evaluateOptions) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const { compiletime, runtime } = resolveEvaluateOptions(evaluateOptions)
|
|
24
|
+
return run(await compile(vfileCompatible, compiletime), runtime)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -36,6 +36,6 @@ export async function evaluate(vfileCompatible, evaluateOptions) {
|
|
|
36
36
|
* Export map.
|
|
37
37
|
*/
|
|
38
38
|
export function evaluateSync(vfileCompatible, evaluateOptions) {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const { compiletime, runtime } = resolveEvaluateOptions(evaluateOptions)
|
|
40
|
+
return runSync(compileSync(vfileCompatible, compiletime), runtime)
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recma-build-jsx-transform.d.ts","sourceRoot":"","sources":["recma-build-jsx-transform.js"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,iDALW,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"recma-build-jsx-transform.d.ts","sourceRoot":"","sources":["recma-build-jsx-transform.js"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,iDALW,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,IAe7B,MALN,OAKU,KAHR,SAAS,CAiDtB;;;;;;;;;mBAxEa,eAAe,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS;;6BANlC,YAAY"}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* `arguments[0]` instead (default: `'program'`).
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {specifiersToDeclarations} from '../util/estree-util-specifiers-to-declarations.js'
|
|
14
|
-
import {toIdOrMemberExpression} from '../util/estree-util-to-id-or-member-expression.js'
|
|
13
|
+
import { specifiersToDeclarations } from '../util/estree-util-specifiers-to-declarations.js'
|
|
14
|
+
import { toIdOrMemberExpression } from '../util/estree-util-to-id-or-member-expression.js'
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Plugin to change the tree after compiling JSX away.
|
|
@@ -22,59 +22,59 @@ import {toIdOrMemberExpression} from '../util/estree-util-to-id-or-member-expres
|
|
|
22
22
|
* Transform.
|
|
23
23
|
*/
|
|
24
24
|
export function recmaBuildJsxTransform(options) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/* c8 ignore next -- always given in `@mdx-js/mdx` */
|
|
26
|
+
const { outputFormat } = options || {}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @param {Program} tree
|
|
30
|
+
* Tree.
|
|
31
|
+
* @returns {undefined}
|
|
32
|
+
* Nothing.
|
|
33
|
+
*/
|
|
34
|
+
return function (tree) {
|
|
35
|
+
// Remove the pragma comment that we injected ourselves as it is no longer
|
|
36
|
+
// needed.
|
|
37
|
+
// if (tree.comments) {
|
|
38
|
+
// tree.comments = tree.comments.filter(function (d) {
|
|
39
|
+
// return !d.data?._mdxIsPragmaComment
|
|
40
|
+
// })
|
|
41
|
+
// }
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
// When compiling to a function body, replace the import that was just
|
|
44
|
+
// generated, and get `jsx`, `jsxs`, and `Fragment` from `arguments[0]`
|
|
45
|
+
// instead.
|
|
46
|
+
if (outputFormat === 'function-body') {
|
|
47
|
+
let index = 0
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
// Skip directives: JS currently only has `use strict`, but Acorn allows
|
|
50
|
+
// arbitrary ones.
|
|
51
|
+
// Practically things like `use client` could be used?
|
|
52
|
+
while (index < tree.body.length) {
|
|
53
|
+
const child = tree.body[index]
|
|
54
|
+
if ('directive' in child && child.directive) {
|
|
55
|
+
index++
|
|
56
|
+
} else {
|
|
57
|
+
break
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const declaration = tree.body[index]
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
if (
|
|
64
|
+
declaration &&
|
|
65
|
+
declaration.type === 'ImportDeclaration' &&
|
|
66
|
+
typeof declaration.source.value === 'string' &&
|
|
67
|
+
/\/jsx-(dev-)?runtime$/.test(declaration.source.value)
|
|
68
|
+
) {
|
|
69
|
+
tree.body[index] = {
|
|
70
|
+
type: 'VariableDeclaration',
|
|
71
|
+
kind: 'const',
|
|
72
|
+
declarations: specifiersToDeclarations(
|
|
73
|
+
declaration.specifiers,
|
|
74
|
+
toIdOrMemberExpression(['arguments', 0])
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
80
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function recmaDocument(this: import("unified").Processor, ...parameters: [RecmaDocumentOptions | null | undefined]
|
|
1
|
+
export function recmaDocument(this: import("unified").Processor, ...parameters: [] | [RecmaDocumentOptions | null | undefined]): void | import("unified").Transformer<import("estree").Program, import("estree").Program> | undefined;
|
|
2
2
|
export type Directive = import("estree-jsx").Directive;
|
|
3
3
|
export type ExportAllDeclaration = import("estree-jsx").ExportAllDeclaration;
|
|
4
4
|
export type ExportDefaultDeclaration = import("estree-jsx").ExportDefaultDeclaration;
|