@portel/photon-core 2.3.0 → 2.4.0

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.
Files changed (54) hide show
  1. package/dist/asset-discovery.d.ts +25 -0
  2. package/dist/asset-discovery.d.ts.map +1 -0
  3. package/dist/asset-discovery.js +144 -0
  4. package/dist/asset-discovery.js.map +1 -0
  5. package/dist/class-detection.d.ts +32 -0
  6. package/dist/class-detection.d.ts.map +1 -0
  7. package/dist/class-detection.js +86 -0
  8. package/dist/class-detection.js.map +1 -0
  9. package/dist/compiler.d.ts +22 -0
  10. package/dist/compiler.d.ts.map +1 -0
  11. package/dist/compiler.js +48 -0
  12. package/dist/compiler.js.map +1 -0
  13. package/dist/env-utils.d.ts +61 -0
  14. package/dist/env-utils.d.ts.map +1 -0
  15. package/dist/env-utils.js +171 -0
  16. package/dist/env-utils.js.map +1 -0
  17. package/dist/index.d.ts +7 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +21 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/mime-types.d.ts +13 -0
  22. package/dist/mime-types.d.ts.map +1 -0
  23. package/dist/mime-types.js +47 -0
  24. package/dist/mime-types.js.map +1 -0
  25. package/dist/rendering/index.d.ts +49 -0
  26. package/dist/rendering/index.d.ts.map +1 -1
  27. package/dist/rendering/index.js +153 -0
  28. package/dist/rendering/index.js.map +1 -1
  29. package/dist/schema-extractor.d.ts.map +1 -1
  30. package/dist/schema-extractor.js +3 -0
  31. package/dist/schema-extractor.js.map +1 -1
  32. package/dist/types.d.ts +2 -0
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js.map +1 -1
  35. package/dist/validation.d.ts +51 -0
  36. package/dist/validation.d.ts.map +1 -0
  37. package/dist/validation.js +249 -0
  38. package/dist/validation.js.map +1 -0
  39. package/dist/version-check.d.ts +22 -0
  40. package/dist/version-check.d.ts.map +1 -0
  41. package/dist/version-check.js +91 -0
  42. package/dist/version-check.js.map +1 -0
  43. package/package.json +2 -2
  44. package/src/asset-discovery.ts +160 -0
  45. package/src/class-detection.ts +94 -0
  46. package/src/compiler.ts +57 -0
  47. package/src/env-utils.ts +216 -0
  48. package/src/index.ts +80 -0
  49. package/src/mime-types.ts +49 -0
  50. package/src/rendering/index.ts +197 -0
  51. package/src/schema-extractor.ts +4 -0
  52. package/src/types.ts +2 -0
  53. package/src/validation.ts +363 -0
  54. package/src/version-check.ts +92 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Asset Discovery Utilities
3
+ *
4
+ * Discover and extract UI, prompt, and resource assets from Photon files.
5
+ * Extracted from photon's loader.ts.
6
+ *
7
+ * Depends on: getMimeType (from ./mime-types), SchemaExtractor (from ./schema-extractor)
8
+ */
9
+ import type { PhotonAssets } from './types.js';
10
+ /**
11
+ * Discover and extract assets from a Photon file
12
+ *
13
+ * Convention:
14
+ * - Asset folder: {photon-name}/ next to {photon-name}.photon.ts
15
+ * - Subfolder: ui/, prompts/, resources/
16
+ *
17
+ * @param photonPath - Absolute path to the .photon.ts file
18
+ * @param source - Source code content of the Photon file
19
+ */
20
+ export declare function discoverAssets(photonPath: string, source: string): Promise<PhotonAssets | undefined>;
21
+ /**
22
+ * Auto-discover assets from the ui/, prompts/, resources/ subdirectories
23
+ */
24
+ export declare function autoDiscoverAssets(assetFolder: string, assets: PhotonAssets): Promise<void>;
25
+ //# sourceMappingURL=asset-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-discovery.d.ts","sourceRoot":"","sources":["../src/asset-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAc/C;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CA+CnC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,IAAI,CAAC,CAgEf"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Asset Discovery Utilities
3
+ *
4
+ * Discover and extract UI, prompt, and resource assets from Photon files.
5
+ * Extracted from photon's loader.ts.
6
+ *
7
+ * Depends on: getMimeType (from ./mime-types), SchemaExtractor (from ./schema-extractor)
8
+ */
9
+ import * as fs from 'fs/promises';
10
+ import * as path from 'path';
11
+ import { getMimeType } from './mime-types.js';
12
+ import { SchemaExtractor } from './schema-extractor.js';
13
+ /**
14
+ * Check if a file or directory exists
15
+ */
16
+ async function fileExists(filePath) {
17
+ try {
18
+ await fs.access(filePath);
19
+ return true;
20
+ }
21
+ catch {
22
+ return false;
23
+ }
24
+ }
25
+ /**
26
+ * Discover and extract assets from a Photon file
27
+ *
28
+ * Convention:
29
+ * - Asset folder: {photon-name}/ next to {photon-name}.photon.ts
30
+ * - Subfolder: ui/, prompts/, resources/
31
+ *
32
+ * @param photonPath - Absolute path to the .photon.ts file
33
+ * @param source - Source code content of the Photon file
34
+ */
35
+ export async function discoverAssets(photonPath, source) {
36
+ const extractor = new SchemaExtractor();
37
+ const dir = path.dirname(photonPath);
38
+ const basename = path.basename(photonPath, '.photon.ts');
39
+ // Convention: asset folder has same name as photon (without .photon.ts)
40
+ const assetFolder = path.join(dir, basename);
41
+ // Check if asset folder exists
42
+ let folderExists = false;
43
+ try {
44
+ const stat = await fs.stat(assetFolder);
45
+ folderExists = stat.isDirectory();
46
+ }
47
+ catch {
48
+ // Folder doesn't exist
49
+ }
50
+ // Extract explicit asset declarations from source annotations
51
+ const assets = extractor.extractAssets(source, folderExists ? assetFolder : undefined);
52
+ // If no folder exists and no explicit declarations, skip
53
+ if (!folderExists &&
54
+ assets.ui.length === 0 &&
55
+ assets.prompts.length === 0 &&
56
+ assets.resources.length === 0) {
57
+ return undefined;
58
+ }
59
+ if (folderExists) {
60
+ // Resolve paths for explicitly declared assets
61
+ for (const ui of assets.ui) {
62
+ ui.resolvedPath = path.resolve(assetFolder, ui.path.replace(/^\.\//, ''));
63
+ }
64
+ for (const prompt of assets.prompts) {
65
+ prompt.resolvedPath = path.resolve(assetFolder, prompt.path.replace(/^\.\//, ''));
66
+ }
67
+ for (const resource of assets.resources) {
68
+ resource.resolvedPath = path.resolve(assetFolder, resource.path.replace(/^\.\//, ''));
69
+ }
70
+ // Auto-discover assets from folder structure
71
+ await autoDiscoverAssets(assetFolder, assets);
72
+ }
73
+ return assets;
74
+ }
75
+ /**
76
+ * Auto-discover assets from the ui/, prompts/, resources/ subdirectories
77
+ */
78
+ export async function autoDiscoverAssets(assetFolder, assets) {
79
+ // Auto-discover UI files
80
+ const uiDir = path.join(assetFolder, 'ui');
81
+ if (await fileExists(uiDir)) {
82
+ try {
83
+ const files = await fs.readdir(uiDir);
84
+ for (const file of files) {
85
+ const id = path.basename(file, path.extname(file));
86
+ if (!assets.ui.find((u) => u.id === id)) {
87
+ assets.ui.push({
88
+ id,
89
+ path: `./ui/${file}`,
90
+ resolvedPath: path.join(uiDir, file),
91
+ mimeType: getMimeType(file),
92
+ });
93
+ }
94
+ }
95
+ }
96
+ catch {
97
+ // Ignore errors
98
+ }
99
+ }
100
+ // Auto-discover prompt files
101
+ const promptsDir = path.join(assetFolder, 'prompts');
102
+ if (await fileExists(promptsDir)) {
103
+ try {
104
+ const files = await fs.readdir(promptsDir);
105
+ for (const file of files) {
106
+ if (file.endsWith('.md') || file.endsWith('.txt')) {
107
+ const id = path.basename(file, path.extname(file));
108
+ if (!assets.prompts.find((p) => p.id === id)) {
109
+ assets.prompts.push({
110
+ id,
111
+ path: `./prompts/${file}`,
112
+ resolvedPath: path.join(promptsDir, file),
113
+ });
114
+ }
115
+ }
116
+ }
117
+ }
118
+ catch {
119
+ // Ignore errors
120
+ }
121
+ }
122
+ // Auto-discover resource files
123
+ const resourcesDir = path.join(assetFolder, 'resources');
124
+ if (await fileExists(resourcesDir)) {
125
+ try {
126
+ const files = await fs.readdir(resourcesDir);
127
+ for (const file of files) {
128
+ const id = path.basename(file, path.extname(file));
129
+ if (!assets.resources.find((r) => r.id === id)) {
130
+ assets.resources.push({
131
+ id,
132
+ path: `./resources/${file}`,
133
+ resolvedPath: path.join(resourcesDir, file),
134
+ mimeType: getMimeType(file),
135
+ });
136
+ }
137
+ }
138
+ }
139
+ catch {
140
+ // Ignore errors
141
+ }
142
+ }
143
+ }
144
+ //# sourceMappingURL=asset-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-discovery.js","sourceRoot":"","sources":["../src/asset-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;GAEG;AACH,KAAK,UAAU,UAAU,CAAC,QAAgB;IACxC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAkB,EAClB,MAAc;IAEd,MAAM,SAAS,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAEzD,wEAAwE;IACxE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAE7C,+BAA+B;IAC/B,IAAI,YAAY,GA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CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;oBAC/C,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;wBACpB,EAAE;wBACF,IAAI,EAAE,eAAe,IAAI,EAAE;wBAC3B,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;wBAC3C,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC;qBAC5B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,gBAAgB;QAClB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Class Detection Utilities
3
+ *
4
+ * Shared logic for detecting Photon classes in ES modules.
5
+ * Extracted from photon, ncp, and lumina loaders.
6
+ */
7
+ /**
8
+ * Check if a value is a class constructor
9
+ */
10
+ export declare function isClass(fn: unknown): fn is new (...args: unknown[]) => unknown;
11
+ /**
12
+ * Check if a class has async methods (instance or static)
13
+ *
14
+ * Checks for AsyncFunction, AsyncGeneratorFunction, and GeneratorFunction
15
+ * on both prototype (instance methods) and the class itself (static methods).
16
+ */
17
+ export declare function hasAsyncMethods(ClassConstructor: new (...args: unknown[]) => unknown): boolean;
18
+ /**
19
+ * Find a single Photon class in a module
20
+ *
21
+ * Priority: default export first, then named exports.
22
+ * Returns the first class with async methods, or null.
23
+ */
24
+ export declare function findPhotonClass(module: Record<string, unknown>): (new (...args: unknown[]) => unknown) | null;
25
+ /**
26
+ * Find all Photon classes in a module
27
+ *
28
+ * Returns every exported class that has async methods.
29
+ * Used by NCP which may load multiple classes from one file.
30
+ */
31
+ export declare function findPhotonClasses(module: Record<string, unknown>): Array<new (...args: unknown[]) => unknown>;
32
+ //# sourceMappingURL=class-detection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-detection.d.ts","sourceRoot":"","sources":["../src/class-detection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,OAAO,CA+B9F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,IAAI,CAgB7G;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAU7G"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Class Detection Utilities
3
+ *
4
+ * Shared logic for detecting Photon classes in ES modules.
5
+ * Extracted from photon, ncp, and lumina loaders.
6
+ */
7
+ /**
8
+ * Check if a value is a class constructor
9
+ */
10
+ export function isClass(fn) {
11
+ return typeof fn === 'function' && /^\s*class\s+/.test(fn.toString());
12
+ }
13
+ /**
14
+ * Check if a class has async methods (instance or static)
15
+ *
16
+ * Checks for AsyncFunction, AsyncGeneratorFunction, and GeneratorFunction
17
+ * on both prototype (instance methods) and the class itself (static methods).
18
+ */
19
+ export function hasAsyncMethods(ClassConstructor) {
20
+ const asyncCtorNames = new Set([
21
+ 'AsyncFunction',
22
+ 'AsyncGeneratorFunction',
23
+ 'GeneratorFunction',
24
+ ]);
25
+ // Check instance methods on prototype
26
+ const prototype = ClassConstructor.prototype;
27
+ for (const key of Object.getOwnPropertyNames(prototype)) {
28
+ if (key === 'constructor')
29
+ continue;
30
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, key);
31
+ if (descriptor && typeof descriptor.value === 'function') {
32
+ if (asyncCtorNames.has(descriptor.value.constructor.name)) {
33
+ return true;
34
+ }
35
+ }
36
+ }
37
+ // Check static methods on the class itself
38
+ for (const key of Object.getOwnPropertyNames(ClassConstructor)) {
39
+ if (['length', 'name', 'prototype'].includes(key))
40
+ continue;
41
+ const descriptor = Object.getOwnPropertyDescriptor(ClassConstructor, key);
42
+ if (descriptor && typeof descriptor.value === 'function') {
43
+ if (asyncCtorNames.has(descriptor.value.constructor.name)) {
44
+ return true;
45
+ }
46
+ }
47
+ }
48
+ return false;
49
+ }
50
+ /**
51
+ * Find a single Photon class in a module
52
+ *
53
+ * Priority: default export first, then named exports.
54
+ * Returns the first class with async methods, or null.
55
+ */
56
+ export function findPhotonClass(module) {
57
+ // Try default export first
58
+ if (module.default && isClass(module.default)) {
59
+ if (hasAsyncMethods(module.default)) {
60
+ return module.default;
61
+ }
62
+ }
63
+ // Try named exports
64
+ for (const exportedItem of Object.values(module)) {
65
+ if (isClass(exportedItem) && hasAsyncMethods(exportedItem)) {
66
+ return exportedItem;
67
+ }
68
+ }
69
+ return null;
70
+ }
71
+ /**
72
+ * Find all Photon classes in a module
73
+ *
74
+ * Returns every exported class that has async methods.
75
+ * Used by NCP which may load multiple classes from one file.
76
+ */
77
+ export function findPhotonClasses(module) {
78
+ const classes = [];
79
+ for (const exportedItem of Object.values(module)) {
80
+ if (isClass(exportedItem) && hasAsyncMethods(exportedItem)) {
81
+ classes.push(exportedItem);
82
+ }
83
+ }
84
+ return classes;
85
+ }
86
+ //# sourceMappingURL=class-detection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-detection.js","sourceRoot":"","sources":["../src/class-detection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,EAAW;IACjC,OAAO,OAAO,EAAE,KAAK,UAAU,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AACxE,CA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AAe,CAAC,MAA+B;IAC7D,2BAA2B;IAC3B,IAAI,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9C,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB,CAAC;IACH,CAAC;IAED,oBAAoB;IACpB,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,OAAO,CAAC,YAAY,CAAC,IAAI,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;YAC3D,OAAO,YAAY,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA+B;IAC/D,MAAM,OAAO,GAA+C,EAAE,CAAC;IAE/D,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,OAAO,CAAC,YAAY,CAAC,IAAI,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * TypeScript Compiler Utilities
3
+ *
4
+ * Shared esbuild-based TypeScript compilation with caching.
5
+ * Extracted from photon and ncp loaders.
6
+ *
7
+ * NOTE: No esbuild dependency in package.json — the consumer must provide it.
8
+ * Uses `await import('esbuild')` for dynamic resolution.
9
+ */
10
+ /**
11
+ * Compile a .photon.ts file to JavaScript and cache the result
12
+ *
13
+ * @param tsFilePath - Absolute path to the TypeScript source file
14
+ * @param options.cacheDir - Directory to store compiled output
15
+ * @param options.content - Optional pre-read file content (avoids extra read)
16
+ * @returns Absolute path to the compiled .mjs file
17
+ */
18
+ export declare function compilePhotonTS(tsFilePath: string, options: {
19
+ cacheDir: string;
20
+ content?: string;
21
+ }): Promise<string>;
22
+ //# sourceMappingURL=compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9C,OAAO,CAAC,MAAM,CAAC,CA+BjB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * TypeScript Compiler Utilities
3
+ *
4
+ * Shared esbuild-based TypeScript compilation with caching.
5
+ * Extracted from photon and ncp loaders.
6
+ *
7
+ * NOTE: No esbuild dependency in package.json — the consumer must provide it.
8
+ * Uses `await import('esbuild')` for dynamic resolution.
9
+ */
10
+ import * as fs from 'fs/promises';
11
+ import * as path from 'path';
12
+ import * as crypto from 'crypto';
13
+ /**
14
+ * Compile a .photon.ts file to JavaScript and cache the result
15
+ *
16
+ * @param tsFilePath - Absolute path to the TypeScript source file
17
+ * @param options.cacheDir - Directory to store compiled output
18
+ * @param options.content - Optional pre-read file content (avoids extra read)
19
+ * @returns Absolute path to the compiled .mjs file
20
+ */
21
+ export async function compilePhotonTS(tsFilePath, options) {
22
+ const source = options.content ?? (await fs.readFile(tsFilePath, 'utf-8'));
23
+ const hash = crypto.createHash('sha256').update(source).digest('hex').slice(0, 16);
24
+ const fileName = path.basename(tsFilePath, '.ts');
25
+ const cachedJsPath = path.join(options.cacheDir, `${fileName}.${hash}.mjs`);
26
+ // Check if cached version exists
27
+ try {
28
+ await fs.access(cachedJsPath);
29
+ return cachedJsPath;
30
+ }
31
+ catch {
32
+ // Cache miss — compile
33
+ }
34
+ // Dynamic import — consumer must have esbuild installed
35
+ const esbuild = await import('esbuild');
36
+ const result = await esbuild.transform(source, {
37
+ loader: 'ts',
38
+ format: 'esm',
39
+ target: 'es2022',
40
+ sourcemap: 'inline',
41
+ });
42
+ // Ensure cache directory exists
43
+ await fs.mkdir(options.cacheDir, { recursive: true });
44
+ // Write compiled JavaScript
45
+ await fs.writeFile(cachedJsPath, result.code, 'utf-8');
46
+ return cachedJsPath;
47
+ }
48
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAAkB,EAClB,OAA+C;IAE/C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEnF,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,QAAQ,IAAI,IAAI,MAAM,CAAC,CAAC;IAE5E,iCAAiC;IACjC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC9B,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,uBAAuB;IACzB,CAAC;IAED,wDAAwD;IACxD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE;QAC7C,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,QAAQ;KACpB,CAAC,CAAC;IAEH,gCAAgC;IAChC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtD,4BAA4B;IAC5B,MAAM,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEvD,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Environment Variable Utilities
3
+ *
4
+ * Shared logic for resolving constructor parameters from environment variables.
5
+ * Extracted from photon's config-docs.ts and lumina's photon-loader.ts.
6
+ */
7
+ /**
8
+ * Minimal constructor parameter info needed for env resolution.
9
+ * Compatible with both photon-core's full ConstructorParam and
10
+ * lumina's simplified version (which omits isPrimitive).
11
+ */
12
+ export interface EnvConstructorParam {
13
+ name: string;
14
+ type: string;
15
+ isOptional: boolean;
16
+ hasDefault: boolean;
17
+ defaultValue?: any;
18
+ }
19
+ /**
20
+ * Info about a missing required parameter
21
+ */
22
+ export interface MissingParamInfo {
23
+ paramName: string;
24
+ envVarName: string;
25
+ type: string;
26
+ }
27
+ /**
28
+ * Convert a photon name and parameter name to an environment variable name
29
+ *
30
+ * @example toEnvVarName('my-mcp', 'apiKey') → 'MY_MCP_API_KEY'
31
+ */
32
+ export declare function toEnvVarName(photonName: string, paramName: string): string;
33
+ /**
34
+ * Parse an environment variable string value to the appropriate type
35
+ */
36
+ export declare function parseEnvValue(value: string, type: string): any;
37
+ /**
38
+ * Generate a sensible example value for a parameter based on its name and type
39
+ */
40
+ export declare function generateExampleValue(paramName: string, paramType: string): string | null;
41
+ /**
42
+ * Generate documentation and example env vars for constructor parameters
43
+ */
44
+ export declare function summarizeConstructorParams(params: EnvConstructorParam[], photonName: string): {
45
+ docs: string;
46
+ exampleEnv: Record<string, string>;
47
+ };
48
+ /**
49
+ * Generate a user-friendly error message for missing configuration
50
+ */
51
+ export declare function generateConfigErrorMessage(photonName: string, missing: MissingParamInfo[]): string;
52
+ /**
53
+ * Resolve constructor arguments from environment variables
54
+ *
55
+ * @returns values array (aligned with params) and configError string if any required params are missing
56
+ */
57
+ export declare function resolveEnvArgs(params: EnvConstructorParam[], photonName: string): {
58
+ values: any[];
59
+ missing: MissingParamInfo[];
60
+ };
61
+ //# sourceMappingURL=env-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-utils.d.ts","sourceRoot":"","sources":["../src/env-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAO1E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAU9D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4CxF;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,mBAAmB,EAAE,EAC7B,UAAU,EAAE,MAAM,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA8BtD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,MAAM,CAmCR;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,mBAAmB,EAAE,EAC7B,UAAU,EAAE,MAAM,GACjB;IAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAAC,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAAE,CAmBhD"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Environment Variable Utilities
3
+ *
4
+ * Shared logic for resolving constructor parameters from environment variables.
5
+ * Extracted from photon's config-docs.ts and lumina's photon-loader.ts.
6
+ */
7
+ /**
8
+ * Convert a photon name and parameter name to an environment variable name
9
+ *
10
+ * @example toEnvVarName('my-mcp', 'apiKey') → 'MY_MCP_API_KEY'
11
+ */
12
+ export function toEnvVarName(photonName, paramName) {
13
+ const prefix = photonName.toUpperCase().replace(/-/g, '_');
14
+ const suffix = paramName
15
+ .replace(/([A-Z])/g, '_$1')
16
+ .toUpperCase()
17
+ .replace(/^_/, '');
18
+ return `${prefix}_${suffix}`;
19
+ }
20
+ /**
21
+ * Parse an environment variable string value to the appropriate type
22
+ */
23
+ export function parseEnvValue(value, type) {
24
+ switch (type) {
25
+ case 'number':
26
+ return parseFloat(value);
27
+ case 'boolean':
28
+ return value.toLowerCase() === 'true';
29
+ case 'string':
30
+ default:
31
+ return value;
32
+ }
33
+ }
34
+ /**
35
+ * Generate a sensible example value for a parameter based on its name and type
36
+ */
37
+ export function generateExampleValue(paramName, paramType) {
38
+ const lowerName = paramName.toLowerCase();
39
+ if (lowerName.includes('apikey') || lowerName.includes('api_key')) {
40
+ return 'sk_your_api_key_here';
41
+ }
42
+ if (lowerName.includes('token') || lowerName.includes('secret')) {
43
+ return 'your_secret_token';
44
+ }
45
+ if (lowerName.includes('url') || lowerName.includes('endpoint')) {
46
+ return 'https://api.example.com';
47
+ }
48
+ if (lowerName.includes('host') || lowerName.includes('server')) {
49
+ return 'localhost';
50
+ }
51
+ if (lowerName.includes('port')) {
52
+ return '5432';
53
+ }
54
+ if (lowerName.includes('database') || lowerName.includes('db')) {
55
+ return 'my_database';
56
+ }
57
+ if (lowerName.includes('user') || lowerName.includes('username')) {
58
+ return 'admin';
59
+ }
60
+ if (lowerName.includes('password')) {
61
+ return 'your_secure_password';
62
+ }
63
+ if (lowerName.includes('path') || lowerName.includes('dir')) {
64
+ return '/path/to/directory';
65
+ }
66
+ if (lowerName.includes('name')) {
67
+ return 'my-service';
68
+ }
69
+ if (lowerName.includes('region')) {
70
+ return 'us-east-1';
71
+ }
72
+ if (paramType === 'boolean') {
73
+ return 'true';
74
+ }
75
+ if (paramType === 'number') {
76
+ return '3000';
77
+ }
78
+ return null;
79
+ }
80
+ /**
81
+ * Generate documentation and example env vars for constructor parameters
82
+ */
83
+ export function summarizeConstructorParams(params, photonName) {
84
+ const docs = params
85
+ .map((param) => {
86
+ const envVarName = toEnvVarName(photonName, param.name);
87
+ const required = !param.isOptional && !param.hasDefault;
88
+ const status = required ? '[REQUIRED]' : '[OPTIONAL]';
89
+ const defaultInfo = param.hasDefault
90
+ ? ` (default: ${JSON.stringify(param.defaultValue)})`
91
+ : '';
92
+ const exampleValue = generateExampleValue(param.name, param.type);
93
+ let line = ` • ${envVarName} ${status}`;
94
+ line += `\n Type: ${param.type}${defaultInfo}`;
95
+ if (exampleValue) {
96
+ line += `\n Example: ${envVarName}="${exampleValue}"`;
97
+ }
98
+ return line;
99
+ })
100
+ .join('\n\n');
101
+ const exampleEnv = {};
102
+ params.forEach((param) => {
103
+ const envVarName = toEnvVarName(photonName, param.name);
104
+ if (!param.isOptional && !param.hasDefault) {
105
+ exampleEnv[envVarName] =
106
+ generateExampleValue(param.name, param.type) || `your-${param.name}`;
107
+ }
108
+ });
109
+ return { docs, exampleEnv };
110
+ }
111
+ /**
112
+ * Generate a user-friendly error message for missing configuration
113
+ */
114
+ export function generateConfigErrorMessage(photonName, missing) {
115
+ const envVarList = missing
116
+ .map((m) => ` • ${m.envVarName} (${m.paramName}: ${m.type})`)
117
+ .join('\n');
118
+ const exampleEnv = Object.fromEntries(missing.map((m) => [m.envVarName, `<your-${m.paramName}>`]));
119
+ return `
120
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
121
+ ⚠️ Configuration Warning: ${photonName} MCP
122
+
123
+ Missing required environment variables:
124
+ ${envVarList}
125
+
126
+ Tools will fail until configuration is fixed.
127
+
128
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
129
+
130
+ To fix, add environment variables to your MCP client config:
131
+
132
+ {
133
+ "mcpServers": {
134
+ "${photonName}": {
135
+ "command": "npx",
136
+ "args": ["@portel/photon", "${photonName}"],
137
+ "env": ${JSON.stringify(exampleEnv, null, 8).replace(/\n/g, '\n ')}
138
+ }
139
+ }
140
+ }
141
+
142
+ Or run: photon ${photonName} --config
143
+
144
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
145
+ `.trim();
146
+ }
147
+ /**
148
+ * Resolve constructor arguments from environment variables
149
+ *
150
+ * @returns values array (aligned with params) and configError string if any required params are missing
151
+ */
152
+ export function resolveEnvArgs(params, photonName) {
153
+ const values = [];
154
+ const missing = [];
155
+ for (const param of params) {
156
+ const envVarName = toEnvVarName(photonName, param.name);
157
+ const envValue = process.env[envVarName];
158
+ if (envValue !== undefined) {
159
+ values.push(parseEnvValue(envValue, param.type));
160
+ }
161
+ else if (param.hasDefault || param.isOptional) {
162
+ values.push(undefined);
163
+ }
164
+ else {
165
+ missing.push({ paramName: param.name, envVarName, type: param.type });
166
+ values.push(undefined);
167
+ }
168
+ }
169
+ return { values, missing };
170
+ }
171
+ //# sourceMappingURL=env-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-utils.js","sourceRoot":"","sources":["../src/env-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwBH;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB,EAAE,SAAiB;IAChE,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,SAAS;SACrB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,WAAW,EAAE;SACb,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACrB,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,IAAY;IACvD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3B,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;QACxC,KAAK,QAAQ,CAAC;QACd;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAiB,EAAE,SAAiB;IACvE,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IAE1C,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAClE,OAAO,sBAAsB,CAAC;IAChC,CAAC;IACD,IAAI,SAAS,CAAC,QAAQ,CAAC,OAA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,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAEzC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YAChD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YACtE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -51,4 +51,11 @@ export * from './channels/index.js';
51
51
  export { withLock, setLockManager, getLockManager, type LockManager, } from './decorators.js';
52
52
  export { type McpAppsInitialize, type McpAppsToolInput, type McpAppsToolResult, type McpAppsHostContextChanged, type McpAppsResourceTeardown, type McpAppsModelContextUpdate, type PlatformContext, createMcpAppsInitialize, createThemeChangeMessages, } from './mcp-apps.js';
53
53
  export { getPhotonConfigDir, getPhotonConfigPath, loadPhotonConfig, savePhotonConfig, hasPhotonConfig, deletePhotonConfig, listConfiguredPhotons, } from './config.js';
54
+ export { isClass, hasAsyncMethods, findPhotonClass, findPhotonClasses, } from './class-detection.js';
55
+ export { toEnvVarName, parseEnvValue, generateExampleValue, summarizeConstructorParams, generateConfigErrorMessage, resolveEnvArgs, type MissingParamInfo, type EnvConstructorParam, } from './env-utils.js';
56
+ export { compilePhotonTS } from './compiler.js';
57
+ export { getMimeType } from './mime-types.js';
58
+ export { parseRuntimeRequirement, checkRuntimeCompatibility, } from './version-check.js';
59
+ export { PhotonError, ValidationError, type ValidationResult, type Validator, combineResults, isString, isNumber, isBoolean, isObject, isArray, notEmpty, hasLength, matchesPattern, isEmail, isUrl, inRange, isPositive, isInteger, hasArrayLength, arrayOf, hasFields, oneOf, validate, validateOrThrow, pathExists, hasExtension, assertDefined, assertString, assertNumber, assertObject, assertArray, } from './validation.js';
60
+ export { discoverAssets, autoDiscoverAssets, } from './asset-discovery.js';
54
61
  //# sourceMappingURL=index.d.ts.map