@xyd-js/plugins 0.1.0-build.157

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/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@xyd-js/plugins",
3
+ "version": "0.1.0-build.157",
4
+ "description": "",
5
+ "main": "./dist/index.js",
6
+ "type": "module",
7
+ "exports": {
8
+ "./package.json": "./package.json",
9
+ ".": {
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "dependencies": {
14
+ "@xyd-js/uniform": "0.1.0-build.172"
15
+ },
16
+ "peerDependencies": {
17
+ "@xyd-js/framework": "0.1.0-build.189"
18
+ },
19
+ "devDependencies": {
20
+ "@vitest/coverage-v8": "^1.3.1",
21
+ "vite": "^7.0.0",
22
+ "vitest": "^1.3.1",
23
+ "rimraf": "^3.0.2",
24
+ "tsup": "^8.3.0"
25
+ },
26
+ "scripts": {
27
+ "clean": "rimraf build",
28
+ "prebuild": "pnpm clean",
29
+ "build": "tsup",
30
+ "test": "vitest",
31
+ "test:coverage": "vitest run --coverage"
32
+ }
33
+ }
package/src/index.ts ADDED
@@ -0,0 +1,62 @@
1
+ import type {Plugin as Vite} from "vite"
2
+ import React from "react"
3
+
4
+ import {type UniformPlugin as Uniform} from "@xyd-js/uniform"
5
+ import {HeadConfig, Settings} from "@xyd-js/core"
6
+ import type {SurfaceTarget} from "@xyd-js/framework"
7
+
8
+ // // TODO: share with theme-api ?
9
+ // export interface PluginCustomComponents {
10
+ // component: React.ComponentType<any>
11
+ // surface: SurfaceTarget
12
+ // }
13
+
14
+ export type PluginComponents = {
15
+ component: React.ComponentType<any>,
16
+ name?: string,
17
+ dist?: string // TODO: fix in the future
18
+ }[] | {
19
+ [component: string]: React.ComponentType<any>
20
+ }
21
+
22
+ /**
23
+ * Plugin interface
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * 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: {
40
+ * }
41
+ * }
42
+ * }
43
+ * }
44
+ * ```
45
+ */
46
+ export interface PluginConfig {
47
+ name: string
48
+
49
+ vite?: Vite[]
50
+ uniform?: Uniform<any>[] // TODO: fix any
51
+ components?: PluginComponents
52
+ head?: HeadConfig[]
53
+ }
54
+
55
+ export type Plugin = (settings: Readonly<Settings>) => PluginConfig
56
+
57
+ // atlas?: { // TODO: in the future
58
+ // components?: any
59
+ // }
60
+ // customComponents?: {
61
+ // [name: string]: PluginCustomComponents
62
+ // },
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "esnext",
4
+ "esModuleInterop": true,
5
+ "moduleResolution": "bundler",
6
+ "target": "esnext",
7
+ "baseUrl": ".",
8
+ "lib": ["dom", "dom.iterable", "esnext"],
9
+ "allowJs": true,
10
+ "skipLibCheck": true,
11
+ "strict": false,
12
+ "noEmit": true,
13
+ "incremental": false,
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "jsx": "preserve",
17
+ "plugins": [],
18
+ "strictNullChecks": true
19
+ },
20
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
21
+ "exclude": ["node_modules"]
22
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,33 @@
1
+ import {copyFile} from 'node:fs/promises';
2
+ import {join} from 'node:path';
3
+
4
+ import {defineConfig, Options} from 'tsup';
5
+
6
+ import pkg from './package.json';
7
+
8
+ const deps = [
9
+ // ...Object.keys(pkg.dependencies || {}),
10
+ ...Object.keys(pkg.devDependencies || {}),
11
+ ]
12
+ const config: Options = {
13
+ entry: {
14
+ index: 'src/index.ts',
15
+ },
16
+ dts: {
17
+ entry: {
18
+ index: 'src/index.ts',
19
+ },
20
+ resolve: true, // Resolve external types
21
+ },
22
+ format: ['esm'],
23
+ platform: 'node',
24
+ shims: false,
25
+ splitting: false,
26
+ sourcemap: true,
27
+ clean: true,
28
+ external: [
29
+ ...deps,
30
+ ]
31
+ }
32
+
33
+ export default defineConfig(config);