@vistagenic/vista 0.1.0-alpha.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.
Files changed (100) hide show
  1. package/bin/vista.js +98 -0
  2. package/dist/auth/index.d.ts +8 -0
  3. package/dist/auth/index.js +16 -0
  4. package/dist/bin/build-rsc.d.ts +17 -0
  5. package/dist/bin/build-rsc.js +320 -0
  6. package/dist/bin/build.d.ts +4 -0
  7. package/dist/bin/build.js +336 -0
  8. package/dist/bin/file-scanner.d.ts +66 -0
  9. package/dist/bin/file-scanner.js +399 -0
  10. package/dist/bin/server-component-plugin.d.ts +17 -0
  11. package/dist/bin/server-component-plugin.js +133 -0
  12. package/dist/bin/webpack.config.d.ts +6 -0
  13. package/dist/bin/webpack.config.js +138 -0
  14. package/dist/build/manifest.d.ts +95 -0
  15. package/dist/build/manifest.js +168 -0
  16. package/dist/build/rsc/client-manifest.d.ts +48 -0
  17. package/dist/build/rsc/client-manifest.js +191 -0
  18. package/dist/build/rsc/client-reference-plugin.d.ts +37 -0
  19. package/dist/build/rsc/client-reference-plugin.js +185 -0
  20. package/dist/build/rsc/compiler.d.ts +36 -0
  21. package/dist/build/rsc/compiler.js +311 -0
  22. package/dist/build/rsc/index.d.ts +16 -0
  23. package/dist/build/rsc/index.js +32 -0
  24. package/dist/build/rsc/native-scanner.d.ts +123 -0
  25. package/dist/build/rsc/native-scanner.js +165 -0
  26. package/dist/build/rsc/rsc-renderer.d.ts +99 -0
  27. package/dist/build/rsc/rsc-renderer.js +269 -0
  28. package/dist/build/rsc/server-component-loader.d.ts +19 -0
  29. package/dist/build/rsc/server-component-loader.js +147 -0
  30. package/dist/build/rsc/server-manifest.d.ts +63 -0
  31. package/dist/build/rsc/server-manifest.js +268 -0
  32. package/dist/build/webpack/loaders/vista-flight-loader.d.ts +17 -0
  33. package/dist/build/webpack/loaders/vista-flight-loader.js +93 -0
  34. package/dist/build/webpack/plugins/vista-flight-plugin.d.ts +36 -0
  35. package/dist/build/webpack/plugins/vista-flight-plugin.js +133 -0
  36. package/dist/client/dynamic.d.ts +25 -0
  37. package/dist/client/dynamic.js +68 -0
  38. package/dist/client/font.d.ts +98 -0
  39. package/dist/client/font.js +109 -0
  40. package/dist/client/head.d.ts +79 -0
  41. package/dist/client/head.js +261 -0
  42. package/dist/client/hydration.d.ts +45 -0
  43. package/dist/client/hydration.js +291 -0
  44. package/dist/client/link.d.ts +30 -0
  45. package/dist/client/link.js +188 -0
  46. package/dist/client/navigation.d.ts +28 -0
  47. package/dist/client/navigation.js +116 -0
  48. package/dist/client/router.d.ts +41 -0
  49. package/dist/client/router.js +190 -0
  50. package/dist/client/script.d.ts +51 -0
  51. package/dist/client/script.js +118 -0
  52. package/dist/components/client-island.d.ts +34 -0
  53. package/dist/components/client-island.js +75 -0
  54. package/dist/components/client.d.ts +29 -0
  55. package/dist/components/client.js +102 -0
  56. package/dist/components/index.d.ts +1 -0
  57. package/dist/components/index.js +8 -0
  58. package/dist/components/link.d.ts +6 -0
  59. package/dist/components/link.js +13 -0
  60. package/dist/config.d.ts +10 -0
  61. package/dist/config.js +31 -0
  62. package/dist/dev-error.d.ts +35 -0
  63. package/dist/dev-error.js +310 -0
  64. package/dist/image/get-img-props.d.ts +28 -0
  65. package/dist/image/get-img-props.js +49 -0
  66. package/dist/image/image-config.d.ts +20 -0
  67. package/dist/image/image-config.js +20 -0
  68. package/dist/image/image-loader.d.ts +7 -0
  69. package/dist/image/image-loader.js +14 -0
  70. package/dist/image/index.d.ts +6 -0
  71. package/dist/image/index.js +110 -0
  72. package/dist/image.d.ts +10 -0
  73. package/dist/image.js +7 -0
  74. package/dist/index.d.ts +20 -0
  75. package/dist/index.js +53 -0
  76. package/dist/metadata/generate.d.ts +22 -0
  77. package/dist/metadata/generate.js +324 -0
  78. package/dist/metadata/index.d.ts +7 -0
  79. package/dist/metadata/index.js +26 -0
  80. package/dist/metadata/types.d.ts +325 -0
  81. package/dist/metadata/types.js +15 -0
  82. package/dist/router/context.d.ts +8 -0
  83. package/dist/router/context.js +13 -0
  84. package/dist/router/index.d.ts +2 -0
  85. package/dist/router/index.js +18 -0
  86. package/dist/router/provider.d.ts +5 -0
  87. package/dist/router/provider.js +31 -0
  88. package/dist/server/client-boundary.d.ts +48 -0
  89. package/dist/server/client-boundary.js +133 -0
  90. package/dist/server/engine.d.ts +4 -0
  91. package/dist/server/engine.js +651 -0
  92. package/dist/server/index.d.ts +95 -0
  93. package/dist/server/index.js +177 -0
  94. package/dist/server/rsc-engine.d.ts +20 -0
  95. package/dist/server/rsc-engine.js +588 -0
  96. package/dist/server/rsc-module-system.d.ts +33 -0
  97. package/dist/server/rsc-module-system.js +119 -0
  98. package/dist/types/index.d.ts +4 -0
  99. package/dist/types/index.js +2 -0
  100. package/package.json +103 -0
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ /**
3
+ * Vista RSC Module System
4
+ *
5
+ * Intercepts require() calls for client components during SSR.
6
+ * Client components are replaced with placeholder divs that will be
7
+ * hydrated on the client side.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.initializeRSCModuleSystem = initializeRSCModuleSystem;
14
+ exports._getMountId = _getMountId;
15
+ exports._addReference = _addReference;
16
+ exports.resetRSCState = resetRSCState;
17
+ exports.getClientReferences = getClientReferences;
18
+ exports.shutdownRSCModuleSystem = shutdownRSCModuleSystem;
19
+ const path_1 = __importDefault(require("path"));
20
+ const module_1 = __importDefault(require("module"));
21
+ // Global state for RSC rendering
22
+ let clientManifest = null;
23
+ let clientReferences = [];
24
+ let mountIdCounter = 0;
25
+ let isInitialized = false;
26
+ let originalCompile = null;
27
+ /**
28
+ * Check if file content has 'client load' directive
29
+ */
30
+ function hasClientDirective(content) {
31
+ const trimmed = content.trim();
32
+ return trimmed.startsWith("'client load'") || trimmed.startsWith('"client load"');
33
+ }
34
+ /**
35
+ * Initialize the RSC module system
36
+ * Must be called BEFORE any app modules are loaded
37
+ */
38
+ function initializeRSCModuleSystem(manifest, cwd) {
39
+ if (isInitialized)
40
+ return;
41
+ clientManifest = manifest;
42
+ isInitialized = true;
43
+ // Hook into Module._compile which is called for every loaded module
44
+ originalCompile = module_1.default.prototype._compile;
45
+ module_1.default.prototype._compile = function (content, filename) {
46
+ // Check if this is a TypeScript/JavaScript file with client directive
47
+ if (/\.[jt]sx?$/.test(filename) && hasClientDirective(content)) {
48
+ const basename = path_1.default.basename(filename, path_1.default.extname(filename));
49
+ const componentId = `client:${basename}`;
50
+ // This is a client component - return a proxy module that renders a placeholder
51
+ const proxyCode = `
52
+ const React = require('react');
53
+ const clientRefs = require('${__filename.replace(/\\/g, '/')}');
54
+
55
+ function ClientComponentProxy(props) {
56
+ const mountId = '__vista_cc_' + clientRefs._getMountId();
57
+ const entry = ${JSON.stringify({ id: componentId, chunkName: basename })};
58
+
59
+ clientRefs._addReference({
60
+ id: entry.id,
61
+ mountId: mountId,
62
+ props: Object.fromEntries(
63
+ Object.entries(props).filter(([k, v]) =>
64
+ k !== 'children' && typeof v !== 'function' && !React.isValidElement(v)
65
+ )
66
+ ),
67
+ chunkUrl: '/_vista/static/chunks/' + entry.chunkName + '.js',
68
+ exportName: 'default'
69
+ });
70
+
71
+ // Return a placeholder div that will be hydrated on the client
72
+ return React.createElement('div', {
73
+ id: mountId,
74
+ 'data-vista-cc': entry.id,
75
+ 'data-vista-mount': mountId,
76
+ style: { display: 'contents' }
77
+ }, 'Loading...');
78
+ }
79
+
80
+ module.exports = ClientComponentProxy;
81
+ module.exports.default = ClientComponentProxy;
82
+ module.exports.__esModule = true;
83
+ `;
84
+ return originalCompile.call(this, proxyCode, filename);
85
+ }
86
+ return originalCompile.call(this, content, filename);
87
+ };
88
+ console.log('[Vista RSC] Module interception initialized');
89
+ }
90
+ // Helper functions exposed for the proxy code
91
+ function _getMountId() {
92
+ return mountIdCounter++;
93
+ }
94
+ function _addReference(ref) {
95
+ clientReferences.push(ref);
96
+ }
97
+ /**
98
+ * Reset state for new render
99
+ */
100
+ function resetRSCState() {
101
+ clientReferences = [];
102
+ mountIdCounter = 0;
103
+ }
104
+ /**
105
+ * Get collected client references
106
+ */
107
+ function getClientReferences() {
108
+ return [...clientReferences];
109
+ }
110
+ /**
111
+ * Shutdown the RSC module system
112
+ */
113
+ function shutdownRSCModuleSystem() {
114
+ if (originalCompile) {
115
+ module_1.default.prototype._compile = originalCompile;
116
+ }
117
+ clientManifest = null;
118
+ isInitialized = false;
119
+ }
@@ -0,0 +1,4 @@
1
+ export interface Metadata {
2
+ title?: string;
3
+ description?: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@vistagenic/vista",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "The React Framework for Visionaries - Rust-powered SSR with Server Components",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/vistagen/Vista-Js.git",
10
+ "directory": "packages/vista"
11
+ },
12
+ "author": "Vista Team",
13
+ "license": "MIT",
14
+ "keywords": [
15
+ "react",
16
+ "framework",
17
+ "ssr",
18
+ "server-components",
19
+ "rsc",
20
+ "rust",
21
+ "swc",
22
+ "vista"
23
+ ],
24
+ "files": [
25
+ "dist",
26
+ "bin"
27
+ ],
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
+ },
33
+ "./link": {
34
+ "types": "./dist/client/link.d.ts",
35
+ "default": "./dist/client/link.js"
36
+ },
37
+ "./image": {
38
+ "types": "./dist/image/index.d.ts",
39
+ "default": "./dist/image/index.js"
40
+ },
41
+ "./router": {
42
+ "types": "./dist/client/router.d.ts",
43
+ "default": "./dist/client/router.js"
44
+ },
45
+ "./navigation": {
46
+ "types": "./dist/client/navigation.d.ts",
47
+ "default": "./dist/client/navigation.js"
48
+ },
49
+ "./dynamic": {
50
+ "types": "./dist/client/dynamic.d.ts",
51
+ "default": "./dist/client/dynamic.js"
52
+ },
53
+ "./script": {
54
+ "types": "./dist/client/script.d.ts",
55
+ "default": "./dist/client/script.js"
56
+ },
57
+ "./font": {
58
+ "types": "./dist/client/font.d.ts",
59
+ "default": "./dist/client/font.js"
60
+ },
61
+ "./head": {
62
+ "types": "./dist/client/head.d.ts",
63
+ "default": "./dist/client/head.js"
64
+ },
65
+ "./config": {
66
+ "types": "./dist/config.d.ts",
67
+ "default": "./dist/config.js"
68
+ },
69
+ "./package.json": "./package.json"
70
+ },
71
+ "bin": {
72
+ "vista": "./bin/vista.js"
73
+ },
74
+ "scripts": {
75
+ "build": "tsc"
76
+ },
77
+ "dependencies": {
78
+ "esbuild": "^0.24.2",
79
+ "express": "^4.21.2",
80
+ "react": "^19.0.0",
81
+ "react-dom": "^19.0.0",
82
+ "ts-node": "^10.9.2",
83
+ "webpack": "^5.90.0",
84
+ "webpack-dev-middleware": "^7.0.0",
85
+ "webpack-hot-middleware": "^2.26.0",
86
+ "swc-loader": "^0.2.6",
87
+ "@swc/core": "^1.4.0",
88
+ "@swc-node/register": "^1.9.0",
89
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
90
+ "react-refresh": "^0.14.0",
91
+ "null-loader": "^4.0.1",
92
+ "chokidar": "^3.6.0"
93
+ },
94
+ "devDependencies": {
95
+ "@types/express": "^5.0.0",
96
+ "@types/node": "^22.10.2",
97
+ "@types/react": "^19.0.1",
98
+ "@types/react-dom": "^19.0.2",
99
+ "@types/webpack": "^5.28.5",
100
+ "@types/webpack-hot-middleware": "^2.25.9",
101
+ "typescript": "^5.7.2"
102
+ }
103
+ }