@orgajs/orgx 2.1.0 → 2.2.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Evaluate MDX.
2
+ * Evaluate Org Content.
3
3
  *
4
4
  * @param {VFileCompatible} vfileCompatible
5
5
  * MDX document to parse (`string`, `Buffer`, `vfile`, anything that can be
@@ -0,0 +1,38 @@
1
+ /// <reference types="react" />
2
+ type FunctionComponent<Props> = (props: Props) => JSX.Element | null;
3
+ type ClassComponent<Props> = new (props: Props) => JSX.ElementClass;
4
+ type Component<Props> = FunctionComponent<Props> | ClassComponent<Props> | keyof JSX.IntrinsicElements;
5
+ interface NestedOrgComponents {
6
+ [key: string]: NestedOrgComponents | Component<any>;
7
+ }
8
+ export type OrgComponents = NestedOrgComponents & {
9
+ [Key in keyof JSX.IntrinsicElements]?: Component<JSX.IntrinsicElements[Key]>;
10
+ } & {
11
+ /**
12
+ * If a wrapper component is defined, the org content will be wrapped inside of it.
13
+ */
14
+ wrapper?: Component<any>;
15
+ };
16
+ export interface OrgProps {
17
+ /**
18
+ * Which props exactly may be passed into the component depends on the contents of the org
19
+ * file.
20
+ */
21
+ [key: string]: unknown;
22
+ /**
23
+ * This prop may be used to customize how certain components are rendered.
24
+ */
25
+ components?: OrgComponents;
26
+ }
27
+ export type OrgContent = (props: OrgProps) => JSX.Element;
28
+ export interface OrgModule {
29
+ /**
30
+ * This could be any value that is exported from the org file.
31
+ */
32
+ [key: string]: unknown;
33
+ /**
34
+ * A functional JSX component which renders the content of the org file.
35
+ */
36
+ default: OrgContent;
37
+ }
38
+ export {};
package/lib/evaluate.js CHANGED
@@ -9,7 +9,7 @@ import { run, runSync } from './run.js'
9
9
  import { resolveEvaluateOptions } from './util/resolve-evaluate-options.js'
10
10
 
11
11
  /**
12
- * Evaluate MDX.
12
+ * Evaluate Org Content.
13
13
  *
14
14
  * @param {VFileCompatible} vfileCompatible
15
15
  * MDX document to parse (`string`, `Buffer`, `vfile`, anything that can be
@@ -564,7 +564,7 @@ function createImportProvider(providerImportSource, outputFormat) {
564
564
  const specifiers = [
565
565
  {
566
566
  type: 'ImportSpecifier',
567
- imported: { type: 'Identifier', name: 'useMDXComponents' },
567
+ imported: { type: 'Identifier', name: 'useOrgComponents' },
568
568
  local: { type: 'Identifier', name: '_provideComponents' },
569
569
  },
570
570
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orgajs/orgx",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "description": "orga compiler with jsx support",
5
5
  "author": "Xiaoxing Hu <hi@xiaoxing.dev>",
6
6
  "license": "MIT",
@@ -19,7 +19,8 @@
19
19
  "files": [
20
20
  "lib",
21
21
  "dist",
22
- "index.js"
22
+ "index.js",
23
+ "types.d.ts"
23
24
  ],
24
25
  "devDependencies": {
25
26
  "@types/estree": "^1.0.1",
@@ -45,8 +46,8 @@
45
46
  "unist-util-position-from-estree": "^1.1.2",
46
47
  "unist-util-stringify-position": "^3.0.3",
47
48
  "vfile": "^5.3.7",
48
- "@orgajs/reorg-parse": "^4.1.0",
49
- "@orgajs/reorg-rehype": "^4.1.0"
49
+ "@orgajs/reorg-parse": "^4.1.2",
50
+ "@orgajs/reorg-rehype": "^4.1.2"
50
51
  },
51
52
  "scripts": {
52
53
  "clean": "tsc --build --clean",
package/types.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ // TODO: move this to DefinitlyTyped
2
+ declare module '*.org' {
3
+ import { OrgaProps } from '@orgajs/orgx'
4
+ export default function OrgaContent(props: OrgaProps): JSX.Element
5
+ }
File without changes