@xyd-js/plugins 0.0.0-build-2acf05c-20251207022018 → 0.0.0-build-83b15db-20251213220910

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": "@xyd-js/plugins",
3
- "version": "0.0.0-build-2acf05c-20251207022018",
3
+ "version": "0.0.0-build-83b15db-20251213220910",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -11,10 +11,10 @@
11
11
  }
12
12
  },
13
13
  "dependencies": {
14
- "@xyd-js/uniform": "0.0.0-build-2acf05c-20251207022018"
14
+ "@xyd-js/uniform": "0.0.0-build-83b15db-20251213220910"
15
15
  },
16
16
  "peerDependencies": {
17
- "@xyd-js/framework": "0.0.0-build-2acf05c-20251207022018"
17
+ "@xyd-js/framework": "0.0.0-build-83b15db-20251213220910"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@vitest/coverage-v8": "^1.3.1",
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type {Plugin as Vite} from "vite"
2
2
  import React from "react"
3
+ import { Plugin as MarkdownPlugin } from 'unified';
3
4
 
4
5
  import {type UniformPlugin as Uniform} from "@xyd-js/uniform"
5
- import {HeadConfig, Settings} from "@xyd-js/core"
6
+ import {HeadConfig, Settings, Metadata} from "@xyd-js/core"
6
7
  import type {SurfaceTarget} from "@xyd-js/framework"
7
8
 
8
9
  // // TODO: share with theme-api ?
@@ -15,28 +16,50 @@ export type PluginComponents = {
15
16
  component: React.ComponentType<any>,
16
17
  name?: string,
17
18
  dist?: string // TODO: fix in the future
19
+ isInline?: boolean // true if component should be inlined instead of imported
18
20
  }[] | {
19
21
  [component: string]: React.ComponentType<any>
20
22
  }
21
23
 
24
+ export interface HookCallbackArgs {
25
+ metadata: Metadata<any>
26
+ }
27
+
22
28
  /**
23
29
  * Plugin interface
24
30
  *
25
31
  * @example
26
32
  * ```ts
27
33
  * function myPlugin(): Plugin {
28
- * return {
29
- * name: "my-plugin",
30
- * vite: [
31
- * {
32
- * name: "my-vite-plugin",
33
- * }
34
- * ],
35
- * uniform: [
36
- * pluginOpenAIMeta,
37
- * ],
38
- * atlas: {
39
- * components: {
34
+ * return (settings) => {
35
+ * return {
36
+ * name: "my-plugin",
37
+ * vite: [
38
+ * {
39
+ * name: "my-vite-plugin",
40
+ * }
41
+ * ],
42
+ * uniform: [
43
+ * pluginOpenAIMeta,
44
+ * ],
45
+ * components: [
46
+ * {
47
+ * component: MyComponent,
48
+ * name: "MyComponent",
49
+ * dist: "./dist/MyComponent.js"
50
+ * }
51
+ * ],
52
+ * head: [
53
+ * ["style", {}, "body { margin: 0; }"]
54
+ * ],
55
+ * markdown: {
56
+ * remark: [remarkPlugin],
57
+ * rehype: [rehypePlugin],
58
+ * },
59
+ * hooks: {
60
+ * applyComponents(cfg) {
61
+ * return cfg?.metadata?.component === "my-plugin";
62
+ * }
40
63
  * }
41
64
  * }
42
65
  * }
@@ -51,8 +74,16 @@ export interface PluginConfig {
51
74
  components?: PluginComponents
52
75
  head?: HeadConfig[]
53
76
  markdown?: {
54
- remark: any[],
55
- rehype: any[],
77
+ remark?: MarkdownPlugin[],
78
+ rehype?: MarkdownPlugin[],
79
+ remarkRehypeHandlers?: any // TODO: fix any
80
+ },
81
+ hooks?: {
82
+ // TODO: types
83
+ applyComponents?: (cfg: HookCallbackArgs) => boolean
84
+
85
+ // TODO: finish
86
+ // applyHeads?: (cfg: any) => boolean
56
87
  }
57
88
  }
58
89
 
@@ -63,4 +94,4 @@ export type Plugin = (settings: Readonly<Settings>) => PluginConfig
63
94
  // }
64
95
  // customComponents?: {
65
96
  // [name: string]: PluginCustomComponents
66
- // },
97
+ // },