@absolutejs/absolute 0.14.0 → 0.15.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 (96) hide show
  1. package/.claude/settings.local.json +11 -0
  2. package/CLAUDE.md +11 -2
  3. package/LICENSE +74 -18
  4. package/README.md +4 -4
  5. package/THIRD_PARTY_NOTICES.md +61 -0
  6. package/dist/cli/index.js +24 -8
  7. package/dist/dev/client/cssUtils.ts +288 -0
  8. package/dist/dev/client/domDiff.ts +261 -0
  9. package/dist/dev/client/domState.ts +271 -0
  10. package/dist/dev/client/errorOverlay.ts +145 -0
  11. package/dist/dev/client/frameworkDetect.ts +63 -0
  12. package/dist/dev/client/handlers/html.ts +415 -0
  13. package/dist/dev/client/handlers/htmx.ts +248 -0
  14. package/dist/dev/client/handlers/react.ts +80 -0
  15. package/dist/dev/client/handlers/rebuild.ts +147 -0
  16. package/dist/dev/client/handlers/svelte.ts +129 -0
  17. package/dist/dev/client/handlers/vue.ts +254 -0
  18. package/dist/dev/client/headPatch.ts +213 -0
  19. package/dist/dev/client/hmrClient.ts +204 -0
  20. package/dist/dev/client/moduleVersions.ts +57 -0
  21. package/dist/dev/client/reactRefreshSetup.ts +21 -0
  22. package/dist/index.js +3028 -478
  23. package/dist/index.js.map +49 -19
  24. package/dist/{build → src/build}/compileSvelte.d.ts +2 -1
  25. package/dist/src/build/compileVue.d.ts +33 -0
  26. package/dist/src/build/generateReactIndexes.d.ts +1 -0
  27. package/dist/src/build/htmlScriptHMRPlugin.d.ts +13 -0
  28. package/dist/src/build/wrapHTMLScript.d.ts +24 -0
  29. package/dist/{core → src/core}/build.d.ts +2 -2
  30. package/dist/src/core/devBuild.d.ts +6 -0
  31. package/dist/{core → src/core}/index.d.ts +2 -1
  32. package/dist/src/core/lookup.d.ts +3 -0
  33. package/dist/{core → src/core}/pageHandlers.d.ts +4 -4
  34. package/dist/src/dev/assetStore.d.ts +12 -0
  35. package/dist/src/dev/buildHMRClient.d.ts +1 -0
  36. package/dist/src/dev/clientManager.d.ts +26 -0
  37. package/dist/src/dev/configResolver.d.ts +13 -0
  38. package/dist/src/dev/dependencyGraph.d.ts +13 -0
  39. package/dist/src/dev/fileHashTracker.d.ts +2 -0
  40. package/dist/src/dev/fileWatcher.d.ts +3 -0
  41. package/dist/src/dev/moduleMapper.d.ts +21 -0
  42. package/dist/src/dev/moduleVersionTracker.d.ts +7 -0
  43. package/dist/src/dev/pathUtils.d.ts +5 -0
  44. package/dist/src/dev/reactComponentClassifier.d.ts +2 -0
  45. package/dist/src/dev/rebuildTrigger.d.ts +10 -0
  46. package/dist/src/dev/simpleHTMLHMR.d.ts +4 -0
  47. package/dist/src/dev/simpleHTMXHMR.d.ts +4 -0
  48. package/dist/src/dev/simpleSvelteHMR.d.ts +1 -0
  49. package/dist/src/dev/simpleVueHMR.d.ts +1 -0
  50. package/dist/src/dev/webSocket.d.ts +9 -0
  51. package/dist/{index.d.ts → src/index.d.ts} +1 -0
  52. package/dist/src/plugins/hmr.d.ts +62 -0
  53. package/dist/{plugins → src/plugins}/index.d.ts +2 -1
  54. package/dist/{svelte → src/svelte}/renderToReadableStream.d.ts +3 -1
  55. package/dist/src/utils/getRegisterClientScript.d.ts +10 -0
  56. package/dist/{utils → src/utils}/index.d.ts +2 -0
  57. package/dist/src/utils/logger.d.ts +45 -0
  58. package/dist/src/utils/networking.d.ts +2 -0
  59. package/dist/src/utils/normalizePath.d.ts +9 -0
  60. package/dist/src/utils/registerClientScript.d.ts +51 -0
  61. package/dist/{types.d.ts → types/build.d.ts} +6 -0
  62. package/dist/types/client.d.ts +104 -0
  63. package/dist/types/index.d.ts +4 -0
  64. package/dist/types/messages.d.ts +138 -0
  65. package/dist/types/websocket.d.ts +6 -0
  66. package/eslint.config.mjs +5 -1
  67. package/package.json +19 -14
  68. package/tsconfig.build.json +1 -1
  69. package/types/build.ts +46 -0
  70. package/types/client.ts +109 -0
  71. package/types/index.ts +4 -0
  72. package/types/messages.ts +205 -0
  73. package/types/websocket.ts +12 -0
  74. package/types/window-globals.ts +53 -0
  75. package/dist/build/compileVue.d.ts +0 -5
  76. package/dist/build/generateReactIndexes.d.ts +0 -1
  77. package/dist/core/lookup.d.ts +0 -1
  78. package/dist/utils/networking.d.ts +0 -1
  79. /package/dist/{build → src/build}/generateManifest.d.ts +0 -0
  80. /package/dist/{build → src/build}/outputLogs.d.ts +0 -0
  81. /package/dist/{build → src/build}/scanEntryPoints.d.ts +0 -0
  82. /package/dist/{build → src/build}/updateAssetPaths.d.ts +0 -0
  83. /package/dist/{cli → src/cli}/index.d.ts +0 -0
  84. /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
  85. /package/dist/{plugins → src/plugins}/networking.d.ts +0 -0
  86. /package/dist/{plugins → src/plugins}/pageRouter.d.ts +0 -0
  87. /package/dist/{svelte → src/svelte}/renderToPipeableStream.d.ts +0 -0
  88. /package/dist/{svelte → src/svelte}/renderToString.d.ts +0 -0
  89. /package/dist/{utils → src/utils}/cleanup.d.ts +0 -0
  90. /package/dist/{utils → src/utils}/commonAncestor.d.ts +0 -0
  91. /package/dist/{utils → src/utils}/escapeScriptContent.d.ts +0 -0
  92. /package/dist/{utils → src/utils}/generateHeadElement.d.ts +0 -0
  93. /package/dist/{utils → src/utils}/getDurationString.d.ts +0 -0
  94. /package/dist/{utils → src/utils}/getEnv.d.ts +0 -0
  95. /package/dist/{utils → src/utils}/stringModifiers.d.ts +0 -0
  96. /package/dist/{utils → src/utils}/validateSafePath.d.ts +0 -0
@@ -0,0 +1,4 @@
1
+ export * from './build';
2
+ export * from './client';
3
+ export * from './messages';
4
+ export * from './websocket';
@@ -0,0 +1,138 @@
1
+ export type PingMessage = {
2
+ type: 'ping';
3
+ };
4
+ export type ReadyMessage = {
5
+ type: 'ready';
6
+ framework?: string | null;
7
+ };
8
+ export type RequestRebuildMessage = {
9
+ type: 'request-rebuild';
10
+ };
11
+ export type HydrationErrorMessage = {
12
+ type: 'hydration-error';
13
+ data?: {
14
+ componentName?: string;
15
+ componentPath?: string;
16
+ error?: string;
17
+ };
18
+ };
19
+ export type HMRClientMessage = PingMessage | ReadyMessage | RequestRebuildMessage | HydrationErrorMessage;
20
+ export type ManifestMessage = {
21
+ type: 'manifest';
22
+ data: {
23
+ manifest: Record<string, string>;
24
+ serverVersions?: Record<string, number>;
25
+ };
26
+ timestamp: number;
27
+ };
28
+ export type RebuildStartMessage = {
29
+ type: 'rebuild-start';
30
+ data: {
31
+ affectedFrameworks: string[];
32
+ };
33
+ timestamp: number;
34
+ };
35
+ export type RebuildCompleteMessage = {
36
+ type: 'rebuild-complete';
37
+ data: {
38
+ affectedFrameworks: string[];
39
+ manifest: Record<string, string>;
40
+ };
41
+ timestamp: number;
42
+ };
43
+ export type FrameworkUpdateMessage = {
44
+ type: 'framework-update';
45
+ data: {
46
+ framework: string;
47
+ manifest?: Record<string, string>;
48
+ };
49
+ timestamp: number;
50
+ };
51
+ export type ModuleUpdateMessage = {
52
+ type: 'module-update';
53
+ data: {
54
+ framework: string;
55
+ manifest?: Record<string, string>;
56
+ modules?: Array<{
57
+ sourceFile: string;
58
+ moduleKeys: string[];
59
+ modulePaths: Record<string, string>;
60
+ componentType?: 'client' | 'server';
61
+ version?: number;
62
+ }>;
63
+ moduleVersions?: Record<string, number>;
64
+ serverVersions?: Record<string, number>;
65
+ };
66
+ timestamp: number;
67
+ };
68
+ export type ReactUpdateMessage = {
69
+ type: 'react-update';
70
+ data: {
71
+ sourceFile: string;
72
+ html?: string;
73
+ manifest?: Record<string, string>;
74
+ };
75
+ timestamp: number;
76
+ };
77
+ export type HTMLUpdateMessage = {
78
+ type: 'html-update';
79
+ data: {
80
+ sourceFile: string;
81
+ html?: string;
82
+ };
83
+ timestamp: number;
84
+ };
85
+ export type HTMXUpdateMessage = {
86
+ type: 'htmx-update';
87
+ data: {
88
+ sourceFile: string;
89
+ html?: string;
90
+ };
91
+ timestamp: number;
92
+ };
93
+ export type SvelteUpdateMessage = {
94
+ type: 'svelte-update';
95
+ data: {
96
+ sourceFile: string;
97
+ html?: string;
98
+ manifest?: Record<string, string>;
99
+ cssUrl?: string;
100
+ cssBaseName?: string;
101
+ updateType?: string;
102
+ };
103
+ timestamp: number;
104
+ };
105
+ export type VueUpdateMessage = {
106
+ type: 'vue-update';
107
+ data: {
108
+ sourceFile: string;
109
+ html?: string;
110
+ manifest?: Record<string, string>;
111
+ hmrId?: string;
112
+ changeType?: 'style-only' | 'template-only' | 'script' | 'full';
113
+ componentPath?: string;
114
+ cssUrl?: string;
115
+ cssBaseName?: string;
116
+ updateType?: 'css-only' | 'full';
117
+ };
118
+ timestamp: number;
119
+ };
120
+ export type RebuildErrorMessage = {
121
+ type: 'rebuild-error';
122
+ data: {
123
+ affectedFrameworks: string[];
124
+ error: string;
125
+ };
126
+ timestamp: number;
127
+ };
128
+ export type PongMessage = {
129
+ type: 'pong';
130
+ timestamp: number;
131
+ };
132
+ export type ConnectedMessage = {
133
+ type: 'connected';
134
+ message?: string;
135
+ timestamp: number;
136
+ };
137
+ export type HMRServerMessage = ManifestMessage | RebuildStartMessage | RebuildCompleteMessage | FrameworkUpdateMessage | ModuleUpdateMessage | ReactUpdateMessage | HTMLUpdateMessage | HTMXUpdateMessage | SvelteUpdateMessage | VueUpdateMessage | RebuildErrorMessage | PongMessage | ConnectedMessage;
138
+ export declare const isValidHMRClientMessage: (data: unknown) => data is HMRClientMessage;
@@ -0,0 +1,6 @@
1
+ export declare const WS_READY_STATE_OPEN = 1;
2
+ export interface HMRWebSocket {
3
+ send(data: string): void;
4
+ close(code?: number, reason?: string): void;
5
+ readyState: number;
6
+ }
package/eslint.config.mjs CHANGED
@@ -35,9 +35,13 @@ export default defineConfig([
35
35
  files: ['**/*.{ts,tsx}'],
36
36
  languageOptions: {
37
37
  globals: {
38
+ ...globals.node,
38
39
  // TODO: These should only be applied to the src/core/build.ts file.
39
40
  BuildMessage: 'readonly',
40
- ResolveMessage: 'readonly'
41
+ ResolveMessage: 'readonly',
42
+ NodeJS: 'readonly',
43
+ Bun: 'readonly',
44
+ Buffer: 'readonly'
41
45
  },
42
46
  parser: tsParser,
43
47
  parserOptions: {
package/package.json CHANGED
@@ -4,15 +4,18 @@
4
4
  "absolutejs": "./dist/cli/index.js"
5
5
  },
6
6
  "description": "A fullstack meta-framework for building web applications with TypeScript",
7
+ "engines": {
8
+ "bun": ">=1.3.6"
9
+ },
7
10
  "devDependencies": {
8
- "@elysiajs/static": "1.3.0",
11
+ "@elysiajs/static": "1.4.0",
9
12
  "@stylistic/eslint-plugin-ts": "4.2.0",
10
13
  "@tailwindcss/cli": "4.1.7",
11
- "@types/bun": "latest",
12
- "@types/react": "19.1.5",
13
- "@types/react-dom": "19.1.5",
14
+ "@types/bun": "^1.2.18",
15
+ "@types/react": "19.2.0",
16
+ "@types/react-dom": "19.2.0",
14
17
  "autoprefixer": "10.4.21",
15
- "elysia": "1.3.1",
18
+ "elysia": "1.4.18",
16
19
  "elysia-scoped-state": "0.1.1",
17
20
  "eslint": "9.26.0",
18
21
  "eslint-plugin-absolute": "0.1.4",
@@ -22,20 +25,21 @@
22
25
  "postcss": "8.5.3",
23
26
  "prettier": "3.5.3",
24
27
  "prettier-plugin-svelte": "3.4.0",
25
- "react": "19.1.0",
28
+ "react": "19.2.1",
29
+ "react-dom": "19.2.1",
30
+ "react-refresh": "^0.18.0",
26
31
  "svelte": "5.35.2",
27
32
  "tailwindcss": "4.1.7",
28
33
  "typescript": "5.8.3",
29
34
  "typescript-eslint": "8.32.0",
30
35
  "vue": "3.5.27"
31
36
  },
32
- "license": "CC BY-NC 4.0",
37
+ "license": "BSL-1.1",
33
38
  "main": "./dist/index.js",
34
39
  "name": "@absolutejs/absolute",
35
40
  "peerDependencies": {
36
- "elysia": "^1.3.0",
41
+ "elysia": "^1.4.0",
37
42
  "react": "^19.1.0",
38
- "react-dom": "^19.1.0",
39
43
  "svelte": "^5.35.2",
40
44
  "vue": "^3.5.27"
41
45
  },
@@ -44,16 +48,17 @@
44
48
  "url": "https://github.com/absolutejs/absolutejs.git"
45
49
  },
46
50
  "scripts": {
47
- "build": "rm -rf dist && bun build src/index.ts --outdir dist --sourcemap --target=bun --external react --external react-dom --external vue --external @vue/compiler-sfc --external svelte --external elysia && bun build src/cli/index.ts --outfile dist/cli/index.js --target=bun && tsc --emitDeclarationOnly --project tsconfig.build.json",
51
+ "build": "rm -rf dist && bun build src/index.ts --outdir dist --sourcemap --target=bun --external react --external react-dom --external vue --external @vue/compiler-sfc --external svelte --external elysia && bun build src/cli/index.ts --outfile dist/cli/index.js --target=bun && tsc --emitDeclarationOnly --project tsconfig.build.json && mkdir -p dist/dev && cp -r src/dev/client dist/dev/client",
48
52
  "db:push": "drizzle-kit push",
49
53
  "db:studio": "drizzle-kit studio",
50
- "dev": "bun src/cli/index.ts dev example/server.ts",
54
+ "dev": "bun run src/cli/index.ts dev example/server.ts",
55
+ "start": "NODE_ENV=production bun run example/server.ts",
51
56
  "format": "prettier --write \"./**/*.{js,jsx,ts,tsx,css,json,mjs,md,svelte,html,vue}\"",
52
57
  "lint": "eslint ./",
53
58
  "release": "bun run format && bun run build && bun publish",
54
- "test": "echo \"Error: no test specified\" && exit 1",
59
+ "test": "bun test",
55
60
  "typecheck": "bun run tsc --noEmit"
56
61
  },
57
- "types": "./dist/index.d.ts",
58
- "version": "0.14.0"
62
+ "types": "./dist/src/index.d.ts",
63
+ "version": "0.15.1"
59
64
  }
@@ -15,6 +15,6 @@
15
15
  "strict": true,
16
16
  "target": "ESNext"
17
17
  },
18
- "exclude": ["node_modules"],
18
+ "exclude": ["node_modules", "src/dev/client"],
19
19
  "include": ["src/**/*"]
20
20
  }
package/types/build.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { ComponentType as ReactComponent } from 'react';
2
+ import { Component as SvelteComponent } from 'svelte';
3
+ import { Component as VueComponent } from 'vue';
4
+
5
+ export type BuildOptions = {
6
+ preserveIntermediateFiles?: boolean;
7
+ /** When true, build() throws on error instead of exit(1) - used by HMR rebuilds */
8
+ throwOnError?: boolean;
9
+ hmr?: {
10
+ debounceMs?: number;
11
+ };
12
+ };
13
+
14
+ export type BuildConfig = {
15
+ buildDirectory?: string;
16
+ assetsDirectory?: string;
17
+ publicDirectory?: string;
18
+ reactDirectory?: string;
19
+ vueDirectory?: string;
20
+ angularDirectory?: string;
21
+ astroDirectory?: string;
22
+ svelteDirectory?: string;
23
+ htmlDirectory?: string;
24
+ htmxDirectory?: string;
25
+ tailwind?: {
26
+ input: string;
27
+ output: string;
28
+ };
29
+ options?: BuildOptions;
30
+ // Optional: List of files to rebuild incrementally (absolute paths)
31
+ // When provided, only these files and their dependencies will be rebuilt
32
+ incrementalFiles?: string[];
33
+ };
34
+
35
+ export type PropsOf<Component> =
36
+ Component extends ReactComponent<infer Props>
37
+ ? Props
38
+ : Component extends SvelteComponent<infer Props>
39
+ ? Props
40
+ : Component extends VueComponent<infer Props>
41
+ ? Props
42
+ : Record<string, never>;
43
+
44
+ export type PropsArgs<C> = keyof PropsOf<C> extends never ? [] : [PropsOf<C>];
45
+
46
+ export type Prettify<T> = { [K in keyof T]: T[K] } & {};
@@ -0,0 +1,109 @@
1
+ /* Client-side HMR type definitions */
2
+
3
+ export interface ErrorOverlayOptions {
4
+ column?: number;
5
+ file?: string;
6
+ framework?: string;
7
+ line?: number;
8
+ lineText?: string;
9
+ message?: string;
10
+ }
11
+
12
+ export interface DOMStateEntry {
13
+ checked?: boolean;
14
+ id?: string;
15
+ idx: number;
16
+ name?: string;
17
+ open?: boolean;
18
+ selEnd?: number;
19
+ selStart?: number;
20
+ selected?: boolean;
21
+ tag: string;
22
+ text?: string;
23
+ type?: string;
24
+ value?: string;
25
+ values?: string[];
26
+ }
27
+
28
+ export interface DOMStateSnapshot {
29
+ activeKey: string | null;
30
+ items: DOMStateEntry[];
31
+ }
32
+
33
+ export interface SavedComponentState {
34
+ count: number;
35
+ }
36
+
37
+ export interface SavedState {
38
+ componentState: SavedComponentState;
39
+ forms: Record<string, Record<string, boolean | string>>;
40
+ scroll: { window: { x: number; y: number } };
41
+ }
42
+
43
+ export interface ScriptInfo {
44
+ src: string;
45
+ type: string;
46
+ }
47
+
48
+ export interface CSSUpdateResult {
49
+ linksToActivate: HTMLLinkElement[];
50
+ linksToRemove: HTMLLinkElement[];
51
+ linksToWaitFor: Promise<void>[];
52
+ }
53
+
54
+ /* Shared mutable state for the HMR client */
55
+ export const hmrState = {
56
+ isConnected: false,
57
+ isFirstHMRUpdate: true,
58
+ isHMRUpdating: false,
59
+ pingInterval: null as ReturnType<typeof setInterval> | null,
60
+ reconnectTimeout: null as ReturnType<typeof setTimeout> | null
61
+ };
62
+
63
+ /* Window interface extensions for HMR globals */
64
+ declare global {
65
+ interface Window {
66
+ $RefreshReg$?: (type: unknown, id: string) => void;
67
+ $RefreshRuntime$?: {
68
+ createSignatureFunctionForTransform: () => (
69
+ type: unknown
70
+ ) => unknown;
71
+ injectIntoGlobalHook: (win: Window) => void;
72
+ performReactRefresh: () => void;
73
+ register: (type: unknown, id: string) => void;
74
+ };
75
+ $RefreshSig$?: () => (type: unknown) => unknown;
76
+ __HMR_DOM_STATE__?: { count?: number; [key: string]: unknown };
77
+ __HMR_FRAMEWORK__?: string;
78
+ __HMR_MANIFEST__?: Record<string, string>;
79
+ __HMR_MODULE_UPDATES__?: Array<unknown>;
80
+ __HMR_MODULE_VERSIONS__?: Record<string, number>;
81
+ __HMR_PRESERVED_STATE__?: Record<string, unknown>;
82
+ __HMR_SERVER_VERSIONS__?: Record<string, number>;
83
+ __HMR_UPDATE_COUNT__?: number;
84
+ __HMR_WS__?: WebSocket;
85
+ __INITIAL_PROPS__?: Record<string, unknown>;
86
+ __REACT_ROOT__?: { render: (element: unknown) => void };
87
+ __SVELTE_COMPONENT__?: Record<string, unknown>;
88
+ __SVELTE_UNMOUNT__?: () => void;
89
+ __VUE_APP__?:
90
+ | ({
91
+ unmount: () => void;
92
+ _instance?: {
93
+ setupState?: Record<string, unknown>;
94
+ subTree?: {
95
+ children?: unknown[];
96
+ component?: {
97
+ setupState?: Record<string, unknown>;
98
+ subTree?: unknown;
99
+ };
100
+ };
101
+ };
102
+ } & Record<string, unknown>)
103
+ | null;
104
+ __VUE_HMR_COMPONENTS__?: Record<string, unknown>;
105
+ htmx?: { process: (element: HTMLElement | Document) => void };
106
+ }
107
+ }
108
+
109
+ export {};
package/types/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './build';
2
+ export * from './client';
3
+ export * from './messages';
4
+ export * from './websocket';
@@ -0,0 +1,205 @@
1
+ /* HMR message types for client-server communication */
2
+
3
+ /* Client-to-server message types */
4
+ export type PingMessage = {
5
+ type: 'ping';
6
+ };
7
+
8
+ export type ReadyMessage = {
9
+ type: 'ready';
10
+ framework?: string | null;
11
+ };
12
+
13
+ export type RequestRebuildMessage = {
14
+ type: 'request-rebuild';
15
+ };
16
+
17
+ export type HydrationErrorMessage = {
18
+ type: 'hydration-error';
19
+ data?: {
20
+ componentName?: string;
21
+ componentPath?: string;
22
+ error?: string;
23
+ };
24
+ };
25
+
26
+ export type HMRClientMessage =
27
+ | PingMessage
28
+ | ReadyMessage
29
+ | RequestRebuildMessage
30
+ | HydrationErrorMessage;
31
+
32
+ /* Server-to-client message types */
33
+ export type ManifestMessage = {
34
+ type: 'manifest';
35
+ data: {
36
+ manifest: Record<string, string>;
37
+ serverVersions?: Record<string, number>;
38
+ };
39
+ timestamp: number;
40
+ };
41
+
42
+ export type RebuildStartMessage = {
43
+ type: 'rebuild-start';
44
+ data: {
45
+ affectedFrameworks: string[];
46
+ };
47
+ timestamp: number;
48
+ };
49
+
50
+ export type RebuildCompleteMessage = {
51
+ type: 'rebuild-complete';
52
+ data: {
53
+ affectedFrameworks: string[];
54
+ manifest: Record<string, string>;
55
+ };
56
+ timestamp: number;
57
+ };
58
+
59
+ export type FrameworkUpdateMessage = {
60
+ type: 'framework-update';
61
+ data: {
62
+ framework: string;
63
+ manifest?: Record<string, string>;
64
+ };
65
+ timestamp: number;
66
+ };
67
+
68
+ export type ModuleUpdateMessage = {
69
+ type: 'module-update';
70
+ data: {
71
+ framework: string;
72
+ manifest?: Record<string, string>;
73
+ modules?: Array<{
74
+ sourceFile: string;
75
+ moduleKeys: string[];
76
+ modulePaths: Record<string, string>;
77
+ componentType?: 'client' | 'server';
78
+ version?: number;
79
+ }>;
80
+ moduleVersions?: Record<string, number>;
81
+ serverVersions?: Record<string, number>;
82
+ };
83
+ timestamp: number;
84
+ };
85
+
86
+ export type ReactUpdateMessage = {
87
+ type: 'react-update';
88
+ data: {
89
+ sourceFile: string;
90
+ html?: string;
91
+ manifest?: Record<string, string>;
92
+ };
93
+ timestamp: number;
94
+ };
95
+
96
+ export type HTMLUpdateMessage = {
97
+ type: 'html-update';
98
+ data: {
99
+ sourceFile: string;
100
+ html?: string;
101
+ };
102
+ timestamp: number;
103
+ };
104
+
105
+ export type HTMXUpdateMessage = {
106
+ type: 'htmx-update';
107
+ data: {
108
+ sourceFile: string;
109
+ html?: string;
110
+ };
111
+ timestamp: number;
112
+ };
113
+
114
+ export type SvelteUpdateMessage = {
115
+ type: 'svelte-update';
116
+ data: {
117
+ sourceFile: string;
118
+ html?: string;
119
+ manifest?: Record<string, string>;
120
+ cssUrl?: string;
121
+ cssBaseName?: string;
122
+ updateType?: string;
123
+ };
124
+ timestamp: number;
125
+ };
126
+
127
+ export type VueUpdateMessage = {
128
+ type: 'vue-update';
129
+ data: {
130
+ sourceFile: string;
131
+ html?: string;
132
+ manifest?: Record<string, string>;
133
+ // Native Vue HMR fields
134
+ hmrId?: string;
135
+ changeType?: 'style-only' | 'template-only' | 'script' | 'full';
136
+ componentPath?: string;
137
+ cssUrl?: string;
138
+ cssBaseName?: string;
139
+ updateType?: 'css-only' | 'full';
140
+ };
141
+ timestamp: number;
142
+ };
143
+
144
+ export type RebuildErrorMessage = {
145
+ type: 'rebuild-error';
146
+ data: {
147
+ affectedFrameworks: string[];
148
+ error: string;
149
+ };
150
+ timestamp: number;
151
+ };
152
+
153
+ export type PongMessage = {
154
+ type: 'pong';
155
+ timestamp: number;
156
+ };
157
+
158
+ export type ConnectedMessage = {
159
+ type: 'connected';
160
+ message?: string;
161
+ timestamp: number;
162
+ };
163
+
164
+ export type HMRServerMessage =
165
+ | ManifestMessage
166
+ | RebuildStartMessage
167
+ | RebuildCompleteMessage
168
+ | FrameworkUpdateMessage
169
+ | ModuleUpdateMessage
170
+ | ReactUpdateMessage
171
+ | HTMLUpdateMessage
172
+ | HTMXUpdateMessage
173
+ | SvelteUpdateMessage
174
+ | VueUpdateMessage
175
+ | RebuildErrorMessage
176
+ | PongMessage
177
+ | ConnectedMessage;
178
+
179
+ /* Type guard for client messages */
180
+ export const isValidHMRClientMessage = (
181
+ data: unknown
182
+ ): data is HMRClientMessage => {
183
+ if (!data || typeof data !== 'object') {
184
+ return false;
185
+ }
186
+
187
+ const message = data as Record<string, unknown>;
188
+
189
+ if (!('type' in message) || typeof message.type !== 'string') {
190
+ return false;
191
+ }
192
+
193
+ switch (message.type) {
194
+ case 'ping':
195
+ return true;
196
+ case 'ready':
197
+ return true;
198
+ case 'request-rebuild':
199
+ return true;
200
+ case 'hydration-error':
201
+ return true;
202
+ default:
203
+ return false;
204
+ }
205
+ };
@@ -0,0 +1,12 @@
1
+ /* WebSocket types for HMR */
2
+
3
+ /* WebSocket ready state constant */
4
+ export const WS_READY_STATE_OPEN = 1;
5
+
6
+ /* Minimal WebSocket interface for HMR clients
7
+ Compatible with Elysia's WebSocket implementation */
8
+ export interface HMRWebSocket {
9
+ send(data: string): void;
10
+ close(code?: number, reason?: string): void;
11
+ readyState: number;
12
+ }
@@ -0,0 +1,53 @@
1
+ /* Extend Window interface with HMR-specific globals */
2
+ declare global {
3
+ interface Window {
4
+ /* Framework for current page, set at build time in index files */
5
+ __HMR_FRAMEWORK__?: string;
6
+
7
+ /* HMR manifest - maps component names to built file paths */
8
+ __HMR_MANIFEST__?: Record<string, string>;
9
+
10
+ /* Array of pending HMR module updates */
11
+ __HMR_MODULE_UPDATES__?: Array<unknown>;
12
+
13
+ /* Client-side module versions - tracks what version the client has loaded */
14
+ __HMR_MODULE_VERSIONS__?: Record<string, number>;
15
+
16
+ /* Server-side module versions - tracks what version the server has */
17
+ __HMR_SERVER_VERSIONS__?: Record<string, number>;
18
+
19
+ /* React root instance for HMR re-rendering */
20
+ __REACT_ROOT__?: {
21
+ render: (element: unknown) => void;
22
+ };
23
+
24
+ /* Initial props passed to React component */
25
+ __INITIAL_PROPS__?: Record<string, unknown>;
26
+
27
+ /* Preserved state across HMR updates */
28
+ __HMR_PRESERVED_STATE__?: Record<string, unknown>;
29
+
30
+ /* Update counter for debugging */
31
+ __HMR_UPDATE_COUNT__?: number;
32
+
33
+ /* Svelte component instance */
34
+ __SVELTE_COMPONENT__?: Record<string, unknown>;
35
+
36
+ /* Svelte unmount function (closure over current runtime + component) */
37
+ __SVELTE_UNMOUNT__?: () => void;
38
+
39
+ /* WebSocket instance for HMR */
40
+ __HMR_WS__?: WebSocket;
41
+
42
+ /* HTMX global (if HTMX is loaded) */
43
+ htmx?: {
44
+ process: (element: HTMLElement | Document) => void;
45
+ };
46
+
47
+ /* DOM state preserved during HTML/HTMX HMR updates */
48
+ __HMR_DOM_STATE__?: { count?: number; [key: string]: unknown };
49
+ }
50
+ }
51
+
52
+ /* Export empty object to make this a module */
53
+ export {};
@@ -1,5 +0,0 @@
1
- export declare const compileVue: (entryPoints: string[], vueRootDir: string) => Promise<{
2
- vueCssPaths: string[];
3
- vueIndexPaths: string[];
4
- vueServerPaths: string[];
5
- }>;
@@ -1 +0,0 @@
1
- export declare const generateReactIndexFiles: (reactPagesDirectory: string, reactIndexesDirectory: string) => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const asset: (manifest: Record<string, string>, name: string) => string;
@@ -1 +0,0 @@
1
- export declare const getLocalIPAddress: () => string;