@vxrn/mdx 1.2.29 → 1.2.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxrn/mdx",
3
- "version": "1.2.29",
3
+ "version": "1.2.31",
4
4
  "type": "commonjs",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -9,7 +9,7 @@
9
9
  "// 👋 note - import === require here, mdx-bundler is cjs only must await import() this package": "./",
10
10
  "import": "./dist/index.js",
11
11
  "require": "./dist/index.js",
12
- "default": "./dist/index.native.js"
12
+ "default": "./dist/index.js"
13
13
  }
14
14
  },
15
15
  "main": "dist/index.js",
@@ -27,6 +27,12 @@
27
27
  "lint:fix": "biome check --write src",
28
28
  "watch": "yarn build --watch"
29
29
  },
30
+ "tamagui-build": {
31
+ "bundleExternal": [
32
+ "mdx-bundler",
33
+ "@mdx-js/mdx"
34
+ ]
35
+ },
30
36
  "dependencies": {
31
37
  "compare-versions": "^4.1.3",
32
38
  "esbuild-wasm": "^0.25.11",
@@ -47,7 +53,7 @@
47
53
  "unist-util-visit": "^2.0.3"
48
54
  },
49
55
  "devDependencies": {
50
- "@tamagui/build": "^1.139.2"
56
+ "@tamagui/build": "^1.140.2"
51
57
  },
52
58
  "publishConfig": {
53
59
  "access": "public"
package/src/index.ts CHANGED
@@ -2,4 +2,6 @@ export { getAllFrontmatter } from './getAllFrontmatter'
2
2
  export { getMDX } from './getMDX'
3
3
  export { getAllVersionsFromPath, getMDXBySlug } from './getMDXBySlug'
4
4
  export { createCodeHighlighter } from './highlightCode'
5
+ export { rehypeHeroTemplate } from './rehypeHeroTemplate'
5
6
  export type { Frontmatter } from './types'
7
+ export type { RehypeHeroTemplateOptions } from './rehypeHeroTemplate'
@@ -0,0 +1,39 @@
1
+ import { createRequire } from 'node:module'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import visit from 'unist-util-visit'
5
+
6
+ export type RehypeHeroTemplateOptions = {
7
+ demosPackage?: string // package name to resolve (e.g. '@tamagui/demos')
8
+ demosPath?: string // or direct path to demos directory
9
+ }
10
+
11
+ export const rehypeHeroTemplate = (options: RehypeHeroTemplateOptions = {}) => {
12
+ let demosRoot: string
13
+
14
+ if (options.demosPath) {
15
+ demosRoot = options.demosPath
16
+ } else if (options.demosPackage) {
17
+ // @ts-ignore
18
+ const requireFn = typeof require === 'undefined' ? createRequire(import.meta.url) : require
19
+ const resolved = requireFn.resolve(options.demosPackage)
20
+ demosRoot = path.join(resolved, '..', '..', '..')
21
+ } else {
22
+ throw new Error('rehypeHeroTemplate requires either demosPackage or demosPath option')
23
+ }
24
+
25
+ return (tree: any) => {
26
+ visit(tree, 'element', (node: any) => {
27
+ if (node.tagName !== 'code' || !node.properties.template) return
28
+ const templateName = node.properties.template
29
+ if (!templateName) return
30
+ const templatePath = path.join(demosRoot, 'src', `${templateName}Demo.tsx`)
31
+ try {
32
+ const source = fs.readFileSync(templatePath, 'utf8')
33
+ node.children[0].value = source
34
+ } catch (err: any) {
35
+ console.warn(`Error setting template`, err.message)
36
+ }
37
+ })
38
+ }
39
+ }
package/types/index.d.ts CHANGED
@@ -2,5 +2,7 @@ export { getAllFrontmatter } from './getAllFrontmatter';
2
2
  export { getMDX } from './getMDX';
3
3
  export { getAllVersionsFromPath, getMDXBySlug } from './getMDXBySlug';
4
4
  export { createCodeHighlighter } from './highlightCode';
5
+ export { rehypeHeroTemplate } from './rehypeHeroTemplate';
5
6
  export type { Frontmatter } from './types';
7
+ export type { RehypeHeroTemplateOptions } from './rehypeHeroTemplate';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,6 @@
1
+ export type RehypeHeroTemplateOptions = {
2
+ demosPackage?: string;
3
+ demosPath?: string;
4
+ };
5
+ export declare const rehypeHeroTemplate: (options?: RehypeHeroTemplateOptions) => (tree: any) => void;
6
+ //# sourceMappingURL=rehypeHeroTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rehypeHeroTemplate.d.ts","sourceRoot":"","sources":["../src/rehypeHeroTemplate.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAS,yBAA8B,MAchE,MAAM,GAAG,SAclB,CAAA"}