@xyd-js/context 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,43 @@
1
+ // src/meta.ts
2
+ var registry = /* @__PURE__ */ new Map();
3
+ function registerMetaComponent(name, componentName, transform) {
4
+ registry.set(name, {
5
+ name,
6
+ componentName,
7
+ transform
8
+ });
9
+ }
10
+ function getMetaComponent(name) {
11
+ return registry.get(name);
12
+ }
13
+
14
+ // src/index.ts
15
+ var settings = null;
16
+ var basePath = null;
17
+ function contextSettings() {
18
+ if (!settings) {
19
+ throw new Error("Context settings not found");
20
+ }
21
+ return settings;
22
+ }
23
+ function setContextSettings(s) {
24
+ settings = s;
25
+ }
26
+ function contextBasePath() {
27
+ if (!basePath) {
28
+ throw new Error("Context base path not found");
29
+ }
30
+ return basePath;
31
+ }
32
+ function setContextBasePath(p) {
33
+ basePath = p;
34
+ }
35
+ export {
36
+ contextBasePath,
37
+ contextSettings,
38
+ getMetaComponent,
39
+ registerMetaComponent,
40
+ setContextBasePath,
41
+ setContextSettings
42
+ };
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/meta.ts","../src/index.ts"],"sourcesContent":["import type { RootContent } from 'mdast'\n\nimport type { Metadata, Theme } from '@xyd-js/core'\n\ntype TransformFn = (\n themeSettings: Theme,\n metaProps: any, \n outputVars: any,\n treeChilds: readonly RootContent[],\n meta: Metadata<any>\n) => any // TODO: fix any\n\ninterface MetaComponent {\n name: string\n \n componentName: string\n\n transform: TransformFn\n}\n\nconst registry = new Map<string, MetaComponent>()\n\nexport function registerMetaComponent(\n name: string,\n componentName: string,\n transform: TransformFn\n) {\n registry.set(name, {\n name,\n componentName,\n transform\n })\n}\n\nexport function getMetaComponent(name: string) {\n return registry.get(name)\n}\n","import { Settings } from \"@xyd-js/core\";\n\nexport * from \"./meta\"\n\nlet settings: Settings | null = null\nlet basePath: string | null = null\n\nexport function contextSettings(): Settings {\n if (!settings) {\n throw new Error(\"Context settings not found\")\n }\n\n return settings\n}\n\nexport function setContextSettings(s: Settings) {\n settings = s\n}\n\nexport function contextBasePath(): string {\n if (!basePath) {\n throw new Error(\"Context base path not found\")\n }\n\n return basePath\n}\n\nexport function setContextBasePath(p: string) {\n basePath = p\n}"],"mappings":";AAoBA,IAAM,WAAW,oBAAI,IAA2B;AAEzC,SAAS,sBACZ,MACA,eACA,WACF;AACE,WAAS,IAAI,MAAM;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACJ,CAAC;AACL;AAEO,SAAS,iBAAiB,MAAc;AAC3C,SAAO,SAAS,IAAI,IAAI;AAC5B;;;AChCA,IAAI,WAA4B;AAChC,IAAI,WAA0B;AAEvB,SAAS,kBAA4B;AACxC,MAAI,CAAC,UAAU;AACX,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAChD;AAEA,SAAO;AACX;AAEO,SAAS,mBAAmB,GAAa;AAC5C,aAAW;AACf;AAEO,SAAS,kBAA0B;AACtC,MAAI,CAAC,UAAU;AACX,UAAM,IAAI,MAAM,6BAA6B;AAAA,EACjD;AAEA,SAAO;AACX;AAEO,SAAS,mBAAmB,GAAW;AAC1C,aAAW;AACf;","names":[]}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@xyd-js/context",
3
+ "version": "0.1.0-build.157",
4
+ "description": "shared xyd context",
5
+ "main": "./dist/index.js",
6
+ "type": "module",
7
+ "exports": {
8
+ "./package.json": "./package.json",
9
+ ".": "./dist/index.js"
10
+ },
11
+ "dependencies": {
12
+ "@xyd-js/core": "0.1.0-build.170"
13
+ },
14
+ "devDependencies": {
15
+ "@types/mdast": "^4.0.3",
16
+ "@types/node": "^22.14.1",
17
+ "@vitest/coverage-v8": "^1.3.1",
18
+ "rimraf": "^3.0.2",
19
+ "tsup": "^8.3.0",
20
+ "typescript": "^4.5.5",
21
+ "vitest": "^1.3.1"
22
+ },
23
+ "scripts": {
24
+ "clean": "rimraf build",
25
+ "prebuild": "pnpm clean",
26
+ "build": "tsup",
27
+ "watch": "tsup --watch",
28
+ "test": "vitest",
29
+ "test:watch": "vitest watch"
30
+ }
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { Settings } from "@xyd-js/core";
2
+
3
+ export * from "./meta"
4
+
5
+ let settings: Settings | null = null
6
+ let basePath: string | null = null
7
+
8
+ export function contextSettings(): Settings {
9
+ if (!settings) {
10
+ throw new Error("Context settings not found")
11
+ }
12
+
13
+ return settings
14
+ }
15
+
16
+ export function setContextSettings(s: Settings) {
17
+ settings = s
18
+ }
19
+
20
+ export function contextBasePath(): string {
21
+ if (!basePath) {
22
+ throw new Error("Context base path not found")
23
+ }
24
+
25
+ return basePath
26
+ }
27
+
28
+ export function setContextBasePath(p: string) {
29
+ basePath = p
30
+ }
package/src/meta.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { RootContent } from 'mdast'
2
+
3
+ import type { Metadata, Theme } from '@xyd-js/core'
4
+
5
+ type TransformFn = (
6
+ themeSettings: Theme,
7
+ metaProps: any,
8
+ outputVars: any,
9
+ treeChilds: readonly RootContent[],
10
+ meta: Metadata<any>
11
+ ) => any // TODO: fix any
12
+
13
+ interface MetaComponent {
14
+ name: string
15
+
16
+ componentName: string
17
+
18
+ transform: TransformFn
19
+ }
20
+
21
+ const registry = new Map<string, MetaComponent>()
22
+
23
+ export function registerMetaComponent(
24
+ name: string,
25
+ componentName: string,
26
+ transform: TransformFn
27
+ ) {
28
+ registry.set(name, {
29
+ name,
30
+ componentName,
31
+ transform
32
+ })
33
+ }
34
+
35
+ export function getMetaComponent(name: string) {
36
+ return registry.get(name)
37
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "esnext",
4
+ "esModuleInterop": true,
5
+ "moduleResolution": "node",
6
+ "target": "ES6",
7
+ "lib": [
8
+ "dom",
9
+ "dom.iterable",
10
+ "esnext"
11
+ ],
12
+ "allowJs": true,
13
+ "skipLibCheck": true,
14
+ "strict": false,
15
+ "noEmit": false,
16
+ "incremental": false,
17
+ "resolveJsonModule": true,
18
+ "isolatedModules": true,
19
+ "jsx": "react",
20
+ "plugins": [
21
+ {
22
+ "name": "next"
23
+ }
24
+ ],
25
+ "strictNullChecks": true,
26
+ "baseUrl": ".",
27
+ "paths": {
28
+ "@xyd-js/core": ["../xyd-core/src"]
29
+ },
30
+ "typeRoots": [
31
+ "./types.d.ts"
32
+ ]
33
+ },
34
+ "include": [
35
+ "next-env.d.ts",
36
+ "**/*.ts",
37
+ "**/*.tsx",
38
+ ".next/types/**/*.ts",
39
+ "types.d.ts"
40
+ ],
41
+ "exclude": [
42
+ "node_modules"
43
+ ]
44
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,23 @@
1
+ import {defineConfig, Options} from 'tsup';
2
+
3
+ const config: Options = {
4
+ entry: ['src/index.ts'],
5
+ format: ['esm'], // Output both ESM and CJS formats
6
+ target: 'node16', // Ensure compatibility with Node.js 16
7
+ dts: {
8
+ entry: 'src/index.ts', // Specify the entry for DTS
9
+ resolve: true, // Resolve external types
10
+ },
11
+ splitting: false, // Disable code splitting
12
+ sourcemap: true, // Generate source maps
13
+ clean: true, // Clean the output directory before each build
14
+ esbuildOptions: (options) => {
15
+ options.platform = 'node'; // Ensure the platform is set to Node.js
16
+ options.external = ['node:fs/promises']; // Mark 'node:fs/promises' as external
17
+ options.loader = {'.js': 'jsx'}; // Ensure proper handling of .js files
18
+ },
19
+ tsconfig: 'tsconfig.json',
20
+ ignoreWatch: ['node_modules', 'dist', '.git', 'build'] // Exclude unnecessary directories
21
+ }
22
+
23
+ export default defineConfig(config);