diff --git a/builder/src/Generate.hs b/builder/src/Generate.hs index aff6a71f..713b4029 100644 --- a/builder/src/Generate.hs +++ b/builder/src/Generate.hs @@ -101,9 +101,10 @@ repl root details ansi (Build.ReplArtifacts home modules localizer annotations) checkForDebugUses :: Objects -> Task () checkForDebugUses (Objects _ locals) = - case Map.keys (Map.filter Nitpick.hasDebugUses locals) of - [] -> return () - m:ms -> Task.throw (Exit.GenerateCannotOptimizeDebugValues m ms) + return () + -- case Map.keys (Map.filter Nitpick.hasDebugUses locals) of + -- [] -> return () + -- m:ms -> Task.throw (Exit.GenerateCannotOptimizeDebugValues m ms) diff --git a/extra/Lamdera/Injection.hs b/extra/Lamdera/Injection.hs index dfeb9751..a88f6b16 100644 --- a/extra/Lamdera/Injection.hs +++ b/extra/Lamdera/Injection.hs @@ -79,7 +79,7 @@ behaviors and limitations. See extra/Lamdera/ReverseProxy.hs for the proxy itself -} modifiedHttp_toTask isProd = - onlyIf (not isProd) + -- onlyIf (not isProd) -- Identical to original except for alterIfProxyRequired addition [text| @@ -314,6 +314,19 @@ injections isBackend isLocalDev = fns: fns } : {}; } + + // Restore Debug.* from dev mode to see what happens + // $$elm$$core$$Debug$$log = _Debug_log_UNUSED; + $$elm$$core$$Debug$$log = F2(function(tag, value) + { + console.log(tag + ': ', value); + return value; + }); + // $$elm$$core$$Debug$$toString = _Debug_toString_UNUSED; + + // debugger + 0; + |] -- // https://github.com/elm/bytes/issues/20 diff --git a/extra/Lamdera/Live.hs b/extra/Lamdera/Live.hs index a45c5630..708b6a9a 100644 --- a/extra/Lamdera/Live.hs +++ b/extra/Lamdera/Live.hs @@ -25,20 +25,19 @@ lamderaLiveSrc = if Ext.Common.isDebug_ then do Lamdera.debug $ "🗿 Using debug mode lamderaLive" - userHome <- Dir.getHomeDirectory - let overrideRoot = userHome "dev/projects/lamdera-compiler/extra" + let overrideRoot = withCompilerRoot "extra" overridePath = overrideRoot "live.js" - overridePathBuilt = overrideRoot "dist/live.js" + overridePathBuild = overrideRoot "dist/live.js" exists <- doesFileExist overridePath if exists then do - Lamdera.debug $ "🗿 Using " ++ overridePathBuilt ++ " for lamderaLive" + Lamdera.debug $ "🗿 Using overridePathBuild " ++ overridePathBuild ++ " for lamderaLive" Ext.Common.requireBinary "npm" Ext.Common.requireBinary "esbuild" - Ext.Common.bash $ "cd " <> overrideRoot <> " && npm i && esbuild " <> overridePath <> " --bundle --minify --target=chrome58,firefox57,safari11,edge16 > " <> overridePathBuilt - -- Ext.Common.bash $ "cd " <> overrideRoot <> " && npm i && esbuild " <> overridePath <> " --bundle --target=chrome58,firefox57,safari11,edge16 > " <> overridePathBuilt - overrideM <- readUtf8Text overridePathBuilt + -- Ext.Common.bash $ "cd " <> overrideRoot <> " && npm i && esbuild " <> overridePath <> " --bundle --minify --target=chrome58,firefox57,safari11,edge16 > " <> overridePathBuild + Ext.Common.bash $ "cd " <> overrideRoot <> " && npm i && esbuild " <> overridePath <> " --bundle --target=chrome58,firefox57,safari11,edge16 > " <> overridePathBuild + overrideM <- readUtf8Text overridePathBuild case overrideM of Just override -> do pure (T.encodeUtf8Builder override) diff --git a/extra/LocalDev/LocalDev.elm b/extra/LocalDev/LocalDev.elm index 86ad44c1..94449111 100644 --- a/extra/LocalDev/LocalDev.elm +++ b/extra/LocalDev/LocalDev.elm @@ -388,6 +388,136 @@ type LiveStatus | Offline +msgToString : Msg -> String +msgToString m = + case m of + FEMsg x -> + "FEMsg " ++ Debug.toString x + + BEMsg backendMsg -> + "BEMsg " ++ Debug.toString backendMsg + + BEtoFE clientId toFrontend -> + "BEtoFE " ++ clientId ++ " " ++ Debug.toString toFrontend + + BEtoFEDelayed clientId toFrontend -> + "BEtoFEDelayed " ++ clientId ++ " " ++ Debug.toString toFrontend + + FEtoBE toBackend -> + "FEtoBE " ++ Debug.toString toBackend + + FEtoBEDelayed toBackend -> + "FEtoBEDelayed " ++ Debug.toString toBackend + + FENewUrl url -> + "FENewUrl " ++ Debug.toString url + + OnConnection d -> + "OnConnection " ++ Debug.toString d + + OnDisconnection d -> + "OnDisconnection " ++ Debug.toString d + + ReceivedToBackend ( s, c, bytes ) -> + "ReceivedToBackend " ++ s ++ " " ++ c ++ " " ++ Debug.toString bytes + + ReceivedToFrontend args -> + "ReceivedToFrontend " ++ Debug.toString args + + ReceivedBackendModel bytes -> + "ReceivedBackendModel " ++ Debug.toString bytes + + RPCIn rpcArgsJson -> + "RPCIn " ++ Debug.toString rpcArgsJson + + SetNodeTypeLeader bool -> + "SetNodeTypeLeader " ++ Debug.toString bool + + SetLiveStatus bool -> + "SetLiveStatus " ++ Debug.toString bool + + ReceivedClientId clientId -> + "ReceivedClientId " ++ clientId + + ExpandedDevbar -> + "ExpandedDevbar" + + CollapsedDevbar -> + "CollapsedDevbar" + + ResetDebugStoreBoth -> + "ResetDebugStoreBoth" + + ResetDebugStoreFE -> + "ResetDebugStoreFE" + + ResetDebugStoreBE -> + "ResetDebugStoreBE" + + ToggledFreezeMode -> + "ToggledFreezeMode" + + ToggledNetworkDelay -> + "ToggledNetworkDelay" + + ToggledLogging -> + "ToggledLogging" + + QRCodeShow -> + "QRCodeShow" + + QRCodeHide -> + "QRCodeHide" + + ClickedLocation -> + "ClickedLocation" + + PersistBackend reload -> + "PersistBackend" + + Reload -> + "Reload" + + EnvClicked -> + "EnvClicked" + + EnvModeSelected _ -> + "EnvModeSelected" + + EnvCleared -> + "EnvCleared" + + ModelResetCleared -> + "ModelResetCleared" + + VersionCheck _ -> + "VersionCheck" + + VersionCheckResult _ -> + "VersionCheckResult" + + LoadLatestSnapshotFilename -> + "LoadLatestSnapshotFilename" + + LoadLatestSnapshotFilenamesResult _ -> + "LoadLatestSnapshotFilenamesResult" + + LoadSnapshot _ -> + "LoadSnapshot" + + LoadSnapshotLegacy _ -> + "LoadSnapshotLegacy" + + LoadedSnapshot _ -> + "LoadedSnapshot" + + LoadedSnapshotLegacy _ -> + "LoadedSnapshotLegacy" + + Noop -> + "Noop" + + update : Msg -> Model -> ( Model, Cmd Msg ) update msg m = let @@ -397,9 +527,12 @@ update msg m = else v + + _ = + Debug.log "msg" (msgToString msg) in - -- case Debug.log "msg" msg of - case msg of + case Debug.log "msg" msg of + -- case msg of FEMsg frontendMsg -> let x = diff --git a/extra/live.js b/extra/live.js index 53f22954..ec8aeb46 100644 --- a/extra/live.js +++ b/extra/live.js @@ -78,6 +78,7 @@ const flushOutbound = function() { } const msgEmitter = function(payload) { + debugger if (connected) { ws.json(payload) } else { @@ -96,6 +97,7 @@ const flushInbound = function() { const msgInbound = function(portname, arg) { if (app !== null) { + debugger app.ports[portname].send(arg) } else { bufferInbound.unshift({ n: portname, a: arg }) @@ -126,6 +128,7 @@ window.setupApp = function(name, elid) { } // window.app = app app.ports.send_ToFrontend.subscribe(function (payload) { + debugger if (payload.b !== null) { payload.b = bytesToBase64(payload.b) } @@ -134,6 +137,7 @@ window.setupApp = function(name, elid) { }) app.ports.save_BackendModel.subscribe(function (payload) { + debugger payload.b = bytesToBase64(payload.b) payload.f = (payload.f) ? "force" : "" msgEmitter(payload) @@ -144,6 +148,7 @@ window.setupApp = function(name, elid) { }) app.ports.send_ToBackend.subscribe(function (bytes) { + debugger var b64 = bytesToBase64(bytes) // console.log(`[S] ToBackend`, { t:"ToBackend", s: sessionId, c: clientId, b: b64 }) msgEmitter({ t:"ToBackend", s: sessionId, c: clientId, b: b64 }) @@ -200,11 +205,13 @@ window.setupApp = function(name, elid) { break; case "ToBackend": + debugger // console.log(`[R] ToBackend`, d) app.ports.receive_ToBackend.send([d.s, d.c, base64ToBytes(d.b)]) break; case "ToFrontend": + debugger // Only process messages for our clientId, or a broadcast if (d.c == clientId || d.c == sessionId || d.c == "b") { // console.log(`[R] ToFrontend`, d) @@ -219,6 +226,7 @@ window.setupApp = function(name, elid) { break; case "p": + debugger if (app === null) { // We're being given a backend state to boot up with initBackendModel = base64ToBytes(d.b) @@ -239,6 +247,7 @@ window.setupApp = function(name, elid) { var response = null const returnHandler = function(payload) { + debugger if (payload.r === d.r) { // console.log("got rpc resp:", payload) response = payload @@ -251,6 +260,7 @@ window.setupApp = function(name, elid) { if (d.i) { d.i = JSON.parse(d.i); } if (d.j) { d.j = JSON.parse(d.j); } + debugger app.ports.rpcIn.send(d) // Is there a nicer way to do this? diff --git a/terminal/src/Develop.hs b/terminal/src/Develop.hs index d4f2217b..34268952 100644 --- a/terminal/src/Develop.hs +++ b/terminal/src/Develop.hs @@ -250,6 +250,7 @@ serveElm sentryCache path = compileToBuilder :: FilePath -> IO BS.ByteString compileToBuilder path = do + _ <- Lamdera.enableLongNames result <- compile path pure $ @@ -311,7 +312,7 @@ compile path = Lamdera.PostCompile.check details artifacts Exit.ReactorBadBuild Lamdera.TypeHash.buildCheckHashes artifacts - javascript <- Task.mapError Exit.ReactorBadGenerate $ Generate.dev root details artifacts + javascript <- Task.mapError Exit.ReactorBadGenerate $ Generate.prod root details artifacts let (NE.List name _) = Build.getRootNames artifacts return $ Html.sandwich root name javascript diff --git a/test/Test.hs b/test/Test.hs index c20a2d2f..44272907 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -106,8 +106,8 @@ For more information on how to use the GHCi debugger, see the GHC User's Guide. -- target = buildTestHarnessToProductionJs -- target = checkProjectCompiles -- target = previewProject --- target = liveReloadLive -target = Test.all +target = liveReloadLive +-- target = Test.all -- target = rerunJust "Lamdera.Evergreen.TestMigrationHarness -> .full first - (WithMigrations 2)" -- target = checkUserConfig -- target = Test.Wire.buildAllPackages @@ -205,8 +205,12 @@ liveReloadLive = do setEnv "LDEBUG" "1" setEnv "EXPERIMENTAL" "1" - let p = "/Users/mario/lamdera/test/v1" + -- let p = "/Users/mario/lamdera/test/v1" -- let p = "/Users/mario/dev/test/lamdera-init" + -- let p = "/Users/mario/dev/projects/refinable" + + let p = withRuntimeRoot "test/scenario-migrations1" + -- let p = "/Users/mario/lamdera/overrides/packages/elm/bytes/1.0.8/benchmarks" -- rmdir "/Users/mario/.elm"