GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — :zap: :construction: unstable hot server · nullstack/nullstack@9f6abc4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • client
    • index.js
    • instanceProxyHandler.js
    • worker.js
  • loaders
    • add-source-to-node.js
    • ignore-import.js
    • inject-hmr.js
    • register-static-from-server.js
    • string-replace.js
  • package.json
  • scripts
    • index.js
    • socket.js
  • server
    • dotenv.js
    • index.js
    • manifest.js
    • printError.js
    • server.js
    • template.js
    • worker.js
  • tests
    • .env.test
    • package.json
    • src
      • Application.css
      • Application.njs
      • ContextWorker.njs
      • FullStackLifecycle.njs
      • FullStackLifecycle.test.js
    • webpack.config.js
  • webpack.config.js
  • workers
    • dynamicInstall.js
    • staticInstall.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎client/index.js‎

Copy file name to clipboardExpand all lines: client/index.js
+20-27Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import element from '../shared/element'
22
import fragment from '../shared/fragment'
33
import generateTree from '../shared/generateTree'
44
import { loadPlugins, useClientPlugins } from '../shared/plugins'
5+
import dangerouslySilenceHmr from '../shared/silenceHmr'
56
import client from './client'
67
import context, { generateContext } from './context'
78
import environment from './environment'
@@ -106,46 +107,38 @@ export default class Nullstack {
106107
}
107108

108109
if (module.hot) {
109-
Nullstack.serverHashes ??= {}
110-
Nullstack.serverPings = 0
111-
Nullstack.clientPings = 0
112-
const socket = new WebSocket(`ws${router.base.slice(4)}/ws`)
113-
socket.onmessage = async function (e) {
114-
const data = JSON.parse(e.data)
115-
if (data.type === 'NULLSTACK_SERVER_STARTED') {
116-
Nullstack.serverPings++
117-
if (Nullstack.needsReload || !environment.hot) {
110+
dangerouslySilenceHmr()
111+
112+
const source = new window.EventSource('/nullstack/hmr')
113+
const pingAndReload = async () => {
114+
let serverBackOnline = false
115+
try {
116+
const response = await fetch('/nullstack/hmr')
117+
serverBackOnline = response.ok
118+
} catch (e) {
119+
// setTimeout(pingAndReload, 100)
120+
} finally {
121+
if (serverBackOnline) {
118122
window.location.reload()
123+
} else {
124+
setTimeout(pingAndReload, 500)
119125
}
120126
}
121127
}
128+
source.onerror = pingAndReload
129+
122130
Nullstack.updateInstancesPrototypes = function updateInstancesPrototypes(klass, hash, serverHash) {
123131
for (const key in context.instances) {
124132
const instance = context.instances[key]
125133
if (instance.constructor.hash === hash) {
126134
Object.setPrototypeOf(instance, klass.prototype)
127135
}
128136
}
129-
if (Nullstack.serverHashes[hash]) {
130-
if (Nullstack.serverHashes[hash] !== serverHash) {
131-
if (Nullstack.clientPings < Nullstack.serverPings) {
132-
window.location.reload()
133-
} else {
134-
Nullstack.needsReload = true
135-
}
136-
}
137-
Nullstack.clientPings++
138-
}
139-
Nullstack.serverHashes[hash] = serverHash
137+
windowEvent('environment')
140138
client.update()
141139
}
142-
Nullstack.hotReload = function hotReload(klass) {
143-
if (client.skipHotReplacement) {
144-
window.location.reload()
145-
} else {
146-
Nullstack.start(klass)
147-
windowEvent('environment')
148-
}
140+
Nullstack.hotReload = function hotReload() {
141+
window.location.reload()
149142
}
150143
module.hot.decline()
151144
}
Collapse file

‎client/instanceProxyHandler.js‎

Copy file name to clipboardExpand all lines: client/instanceProxyHandler.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ const instanceProxyHandler = {
2020
try {
2121
result = target[name].call(proxy, scopedContext)
2222
} catch (error) {
23-
context.catch && context.catch(error)
23+
if (context.catch) {
24+
context.catch(error)
25+
} else {
26+
throw error
27+
}
2428
return null
2529
}
2630
if (result instanceof Promise) {
Collapse file

‎client/worker.js‎

Copy file name to clipboardExpand all lines: client/worker.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ async function register() {
3838
const request = `/service-worker.js`
3939
try {
4040
proxy.registration = await navigator.serviceWorker.register(request, { scope: '/' })
41+
if (environment.development) {
42+
proxy.registration.unregister()
43+
}
4144
} catch (error) {
4245
console.error(error)
4346
}
Collapse file

‎loaders/add-source-to-node.js‎

Copy file name to clipboardExpand all lines: loaders/add-source-to-node.js
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const parse = require('@babel/parser').parse
22
const traverse = require('@babel/traverse').default
33

44
module.exports = function (source) {
5-
this.cacheable && this.cacheable()
65
const uniquePositions = new Set()
76
const ast = parse(source, {
87
sourceType: 'module',
Collapse file

‎loaders/ignore-import.js‎

Copy file name to clipboardExpand all lines: loaders/ignore-import.js
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ MIT Licensed
55
https://npmjs.com/package/ignore-loader
66
*/
77
module.exports = function () {
8-
this.cacheable && this.cacheable()
98
return ''
109
}
Collapse file

‎loaders/inject-hmr.js‎

Copy file name to clipboardExpand all lines: loaders/inject-hmr.js
-39Lines changed: 0 additions & 39 deletions
This file was deleted.
Collapse file

‎loaders/register-static-from-server.js‎

Copy file name to clipboardExpand all lines: loaders/register-static-from-server.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,16 @@ module.exports = function (source) {
3737
output += `\nNullstack.registry["${legacyHash}"] = ${klassName};`
3838
output += `\n${klassName}.hash = "${hash}";`
3939
output += `\n${klassName}.bindStaticFunctions(${klassName});`
40+
output += 'if (module.hot) {'
41+
for (const methodName of methodNames) {
42+
output += `\n${klassName}.${methodName}.hash = "${hash}.${methodName}";`
43+
output += `\nNullstack.registry["${hash}.${methodName}"] = ${klassName}.${methodName};`
44+
output += `\nNullstack.registry["${legacyHash}.${methodName}"] = ${klassName}.${methodName};`
45+
}
46+
output += `\nNullstack.registry["${hash}"] = ${klassName};`
47+
output += `\nNullstack.registry["${legacyHash}"] = ${klassName};`
48+
output += `\n${klassName}.hash = "${hash}";`
49+
output += `\n${klassName}.bindStaticFunctions(${klassName});`
50+
output += '}'
4051
return output
4152
}
Collapse file

‎loaders/string-replace.js‎

Copy file name to clipboardExpand all lines: loaders/string-replace.js
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ MIT Licensed
44
Original: https://npmjs.com/package/string-replace-loader
55
*/
66
module.exports = function (source, map) {
7-
this.cacheable()
8-
97
const optionsArray = this.getOptions().multiple
108
let newSource = source
119

Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+21-19Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,36 @@
1616
},
1717
"dependencies": {
1818
"@babel/core": "^7.18.13",
19-
"@babel/parser": "7.17.12",
19+
"@babel/parser": "7.20.15",
2020
"@babel/plugin-proposal-class-properties": "^7.18.6",
2121
"@babel/plugin-proposal-export-default-from": "^7.18.10",
2222
"@babel/plugin-transform-react-jsx": "^7.18.10",
2323
"@babel/plugin-transform-typescript": "^7.18.12",
2424
"@babel/preset-env": "^7.18.10",
2525
"@babel/preset-react": "^7.18.6",
26-
"@babel/traverse": "7.17.12",
27-
"@swc/core": "1.2.179",
28-
"babel-loader": "^8.2.5",
29-
"body-parser": "1.20.0",
30-
"commander": "8.3.0",
26+
"@babel/traverse": "7.20.13",
27+
"@swc/core": "1.3.32",
28+
"babel-loader": "9.1.2",
29+
"body-parser": "1.20.1",
30+
"commander": "10.0.0",
3131
"copy-webpack-plugin": "^11.0.0",
32-
"css-loader": "6.7.1",
33-
"dotenv": "8.6.0",
32+
"css-loader": "6.7.3",
33+
"dotenv": "16.0.3",
3434
"eslint-plugin-jest": "^27.1.6",
35-
"eslint-plugin-nullstack": "^0.0.11",
36-
"express": "4.18.1",
37-
"fs-extra": "10.1.0",
38-
"mini-css-extract-plugin": "2.6.0",
35+
"eslint-plugin-nullstack": "0.0.12",
36+
"express": "4.18.2",
37+
"fs-extra": "11.1.0",
38+
"mini-css-extract-plugin": "2.7.2",
3939
"node-fetch": "2.6.7",
4040
"nodemon-webpack-plugin": "^4.8.1",
41-
"sass": "1.51.0",
42-
"sass-loader": "8.0.2",
43-
"swc-loader": "0.2.1",
44-
"terser-webpack-plugin": "5.3.1",
45-
"webpack": "5.72.1",
46-
"webpack-dev-server": "4.9.0",
47-
"ws": "7.5.7"
41+
"sass": "1.58.0",
42+
"sass-loader": "13.2.0",
43+
"style-loader": "^3.3.1",
44+
"swc-loader": "0.2.3",
45+
"terser-webpack-plugin": "5.3.6",
46+
"webpack": "5.75.0",
47+
"webpack-dev-server": "4.11.1",
48+
"webpack-hot-middleware": "^2.25.3",
49+
"ws": "8.12.0"
4850
}
4951
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.