@jxrstudios/jxr 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JXR Studios
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # JXR.js — Edge OS Runtime Framework
2
+
3
+ A JavaScript runtime framework for elite developers. Execute JavaScript at the edge with zero-build JSX transformation, virtual file system, worker pools, and secure module resolution.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @jxrstudios/jxr
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { JXRRuntime, jxrRuntime } from '@jxrstudios/jxr';
15
+
16
+ // Use the global singleton
17
+ await jxrRuntime.init();
18
+
19
+ // Or create your own instance
20
+ const runtime = new JXRRuntime({
21
+ maxWorkers: 8,
22
+ moqEndpoint: 'wss://edge.jxr.dev',
23
+ enableCrypto: true,
24
+ });
25
+ await runtime.init();
26
+
27
+ // Transform and execute JSX modules
28
+ const module = await runtime.resolveModule('/src/App.tsx');
29
+
30
+ // Build preview HTML
31
+ const html = runtime.buildPreviewDocument();
32
+
33
+ // Listen to metrics
34
+ runtime.onMetrics((metrics) => {
35
+ console.log('Worker pool:', metrics.workerPool);
36
+ console.log('Cache size:', metrics.moduleCache.size);
37
+ });
38
+ ```
39
+
40
+ ## Features
41
+
42
+ - **VirtualFS** — In-memory file system with project templates
43
+ - **JSXTransformer** — Zero-build JSX/TSX transformation
44
+ - **WorkerPool** — Parallel task execution with metrics
45
+ - **MoQTransport** — Edge data streaming (Media over QUIC)
46
+ - **JXRCrypto** — Module integrity verification & signing
47
+ - **ModuleCache** — LRU cache for resolved modules
48
+ - **ImportMapBuilder** — Browser import map generation
49
+
50
+ ## Usage
51
+
52
+ ### Virtual File System
53
+
54
+ ```typescript
55
+ import { VirtualFS, DEFAULT_PROJECT_FILES } from '@jxrstudios/jxr';
56
+
57
+ const vfs = new VirtualFS(DEFAULT_PROJECT_FILES);
58
+ vfs.write('/src/components/Button.tsx', `export const Button = () => <button>Click</button>`);
59
+ const file = vfs.read('/src/components/Button.tsx');
60
+ ```
61
+
62
+ ### JSX Transformation
63
+
64
+ ```typescript
65
+ import { JSXTransformer } from '@jxrstudios/jxr';
66
+
67
+ const transformer = new JSXTransformer();
68
+ const transformed = transformer.transform(
69
+ `export const App = () => <h1>Hello JXR</h1>`,
70
+ '/src/App.tsx'
71
+ );
72
+ const objectUrl = transformer.createObjectUrl(transformed);
73
+ ```
74
+
75
+ ### Worker Pool
76
+
77
+ ```typescript
78
+ import { WorkerPool } from '@jxrstudios/jxr';
79
+
80
+ const pool = new WorkerPool('/jxr-worker.js', { maxWorkers: 4 });
81
+ const result = await pool.executeTask({
82
+ id: 'task-1',
83
+ type: 'transform',
84
+ payload: { code: '...' },
85
+ priority: 'high',
86
+ });
87
+ const metrics = pool.getMetrics();
88
+ ```
89
+
90
+ ### Web Crypto
91
+
92
+ ```typescript
93
+ import { jxrCrypto } from '@jxrstudios/jxr';
94
+
95
+ const hash = await jxrCrypto.hashModule('import React from "react"');
96
+ const manifest = await jxrCrypto.signManifest({
97
+ modules: [{ path: '/src/App.tsx', hash }],
98
+ }, 'your-private-key');
99
+ ```
100
+
101
+ ## API Reference
102
+
103
+ See the TypeScript definitions for full API documentation.
104
+
105
+ ## License
106
+
107
+ MIT
@@ -0,0 +1,20 @@
1
+ /**
2
+ * JXR.js — Edge OS Runtime Framework
3
+ * A runtime for executing JavaScript at the edge with:
4
+ * - Virtual File System
5
+ * - JSX Transformation (zero-build)
6
+ * - Worker Pool orchestration
7
+ * - MoQ Transport streaming
8
+ * - Web Crypto module integrity
9
+ */
10
+ export { WorkerPool } from './worker-pool.js';
11
+ export type { WorkerMetrics, PoolMetrics, WorkerStatus, TaskPriority, } from './worker-pool.js';
12
+ export { MoQTransport } from './moq-transport.js';
13
+ export type { MoQStreamMetrics, MoQConnectionState, MoQObject, MoQTrackNamespace, } from './moq-transport.js';
14
+ export { JXRCrypto, jxrCrypto } from './web-crypto.js';
15
+ export type { ModuleHash, SignedManifest } from './web-crypto.js';
16
+ export { VirtualFS, JSXTransformer, ImportMapBuilder, ModuleCache, DEFAULT_PROJECT_FILES, } from './module-resolver.js';
17
+ export type { VirtualFile, VirtualDirectory, ResolvedModule, ImportMap, } from './module-resolver.js';
18
+ export { JXRRuntime, jxrRuntime } from './runtime.js';
19
+ export type { JXRRuntimeConfig, JXRRuntimeMetrics } from './runtime.js';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EACL,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * JXR.js — Edge OS Runtime Framework
3
+ * A runtime for executing JavaScript at the edge with:
4
+ * - Virtual File System
5
+ * - JSX Transformation (zero-build)
6
+ * - Worker Pool orchestration
7
+ * - MoQ Transport streaming
8
+ * - Web Crypto module integrity
9
+ */
10
+ export { WorkerPool } from './worker-pool.js';
11
+ export { MoQTransport } from './moq-transport.js';
12
+ export { JXRCrypto, jxrCrypto } from './web-crypto.js';
13
+ export { VirtualFS, JSXTransformer, ImportMapBuilder, ModuleCache, DEFAULT_PROJECT_FILES, } from './module-resolver.js';
14
+ export { JXRRuntime, jxrRuntime } from './runtime.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQ9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGvD,OAAO,EACL,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * JXR.js — Module Resolver & Virtual File System
3
+ * ─────────────────────────────────────────────────────────────────────────────
4
+ * Design: LavaFlow OS — Thermal Precision + Edge Command
5
+ * Layer: Core Runtime / Module System
6
+ *
7
+ * Architecture:
8
+ * Zero-build-step module resolution pipeline:
9
+ * 1. VirtualFS: In-memory file system with change notification
10
+ * 2. ModuleResolver: Resolves imports to VirtualFS entries
11
+ * 3. JSXTransformer: Browser-native JSX → JS transform (no Babel/esbuild)
12
+ * 4. ImportMapBuilder: Generates browser-native import maps for esm.sh CDN
13
+ * 5. ModuleCache: LRU cache with crypto integrity verification
14
+ *
15
+ * The resolver produces browser-executable ES modules from JSX/TSX source
16
+ * without any build step, using the esm.sh CDN for npm package resolution.
17
+ * ─────────────────────────────────────────────────────────────────────────────
18
+ */
19
+ export interface VirtualFile {
20
+ path: string;
21
+ content: string;
22
+ language: 'tsx' | 'ts' | 'jsx' | 'js' | 'css' | 'json' | 'md' | 'html';
23
+ lastModified: number;
24
+ size: number;
25
+ dirty: boolean;
26
+ }
27
+ export interface VirtualDirectory {
28
+ path: string;
29
+ name: string;
30
+ children: (VirtualFile | VirtualDirectory)[];
31
+ expanded: boolean;
32
+ }
33
+ export interface ResolvedModule {
34
+ path: string;
35
+ source: string;
36
+ transformed: string;
37
+ objectUrl: string | null;
38
+ dependencies: string[];
39
+ resolvedAt: number;
40
+ transformMs: number;
41
+ }
42
+ export interface ImportMap {
43
+ imports: Record<string, string>;
44
+ scopes?: Record<string, Record<string, string>>;
45
+ }
46
+ type FileChangeHandler = (file: VirtualFile, event: 'create' | 'update' | 'delete') => void;
47
+ /**
48
+ * VirtualFS — In-memory file system with reactive change notifications
49
+ */
50
+ export declare class VirtualFS {
51
+ private files;
52
+ private changeHandlers;
53
+ constructor(initialFiles?: VirtualFile[]);
54
+ write(path: string, content: string): VirtualFile;
55
+ read(path: string): VirtualFile | null;
56
+ delete(path: string): boolean;
57
+ list(prefix?: string): VirtualFile[];
58
+ exists(path: string): boolean;
59
+ onChange(handler: FileChangeHandler): () => void;
60
+ private emit;
61
+ buildTree(rootPath?: string): VirtualDirectory;
62
+ toJSON(): Record<string, string>;
63
+ private detectLanguage;
64
+ }
65
+ /**
66
+ * JSXTransformer — Zero-dependency JSX → JS transform
67
+ *
68
+ * Uses a lightweight regex-based transform for simple JSX,
69
+ * with Sucrase-style transforms for production accuracy.
70
+ * Falls back to esm.sh/sucrase for complex transforms.
71
+ */
72
+ export declare class JSXTransformer {
73
+ private objectUrls;
74
+ /**
75
+ * Transform JSX/TSX source to browser-executable ES module
76
+ * Uses the automatic JSX runtime (React 17+)
77
+ */
78
+ transform(source: string, filePath: string): string;
79
+ private stripTypeScript;
80
+ private transformJSX;
81
+ private parseProps;
82
+ private rewriteImports;
83
+ createObjectUrl(source: string, type?: string): string;
84
+ revokeObjectUrl(url: string): void;
85
+ cleanup(): void;
86
+ }
87
+ /**
88
+ * ImportMapBuilder — Generates browser-native import maps
89
+ */
90
+ export declare class ImportMapBuilder {
91
+ private imports;
92
+ /** Add a package mapping to the import map */
93
+ add(specifier: string, url: string): this;
94
+ /** Add React and common packages */
95
+ addReactDefaults(reactVersion?: string): this;
96
+ build(): ImportMap;
97
+ toScriptTag(): string;
98
+ }
99
+ /**
100
+ * ModuleCache — LRU cache with integrity verification
101
+ */
102
+ export declare class ModuleCache {
103
+ private cache;
104
+ private readonly maxSize;
105
+ constructor(maxSize?: number);
106
+ set(path: string, module: ResolvedModule): void;
107
+ get(path: string): ResolvedModule | null;
108
+ invalidate(path: string): void;
109
+ clear(): void;
110
+ get size(): number;
111
+ }
112
+ /** Default project template files */
113
+ export declare const DEFAULT_PROJECT_FILES: VirtualFile[];
114
+ export {};
115
+ //# sourceMappingURL=module-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-resolver.d.ts","sourceRoot":"","sources":["../src/module-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;IACvE,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,WAAW,GAAG,gBAAgB,CAAC,EAAE,CAAC;IAC7C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED,KAAK,iBAAiB,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE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