Skip to content

Commit b893913

Browse files
dmjioclaude
andcommitted
Incorporate dual-thread architecture to enable instant first-frame render (IFR)
- Drop jsaddle/jsaddle-warp from GHC and native nix package sets - Switch miso source from pinned fetchFromGitHub rev to fetchFromFlake (master) - Bump cabal.project miso tag to master - Update flake.lock for new miso revision - Fix withJS comment: jsaddle -> WASM Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 52ba2fe commit b893913

14 files changed

Lines changed: 87 additions & 88 deletions

File tree

bun.lock

Lines changed: 16 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ allow-newer:
1010
source-repository-package
1111
type: git
1212
location: https://github.com/dmjio/miso.git
13-
tag: 1.12.0
13+
tag: master

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/miso-lynx.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/haskell/packages/ghc/default.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ self: super:
1111

1212
/* examples */
1313
miso-lynx-examples = self.callCabal2nix "miso-lynx-examples" source.examples {};
14-
jsaddle = self.callCabal2nix "jsaddle" "${source.jsaddle}/jsaddle" {};
15-
jsaddle-warp =
16-
dontCheck (self.callCabal2nix "jsaddle-warp" "${source.jsaddle}/jsaddle-warp" {});
1714

1815
/* cruft */
1916
crypton = dontCheck super.crypton;

nix/haskell/packages/native/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ self: super:
1010
miso-lynx = self.callCabal2nix "miso-lynx" source.miso-lynx {};
1111

1212
/* deps */
13-
jsaddle = self.callCabal2nix "jsaddle" "${source.jsaddle}/jsaddle" {};
1413
ghcjs-base = self.callCabal2nix "ghcjs-base" source.ghcjs-base {};
1514

1615
/* examples */

nix/source.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ let
1414
(hasSuffix ".html" baseName) ||
1515
(hasSuffix ".png" baseName) ||
1616
(hasSuffix ".js" baseName) ||
17+
(hasSuffix ".c" baseName) ||
1718
(hasSuffix ".ts" baseName) ||
1819
(hasSuffix ".json" baseName) ||
1920
(baseName == "README.md") ||
@@ -32,7 +33,6 @@ in
3233
miso-lynx = make-src-filter ../.;
3334
examples = make-src-filter ../examples;
3435
miso = fetchFromFlake (nodes.miso);
35-
jsaddle = fetchFromFlake (nodes.jsaddle);
3636
ghcjs-base = fetchFromGitHub {
3737
owner = "dmjio";
3838
repo = "ghcjs-base";

src/Miso/Lynx.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import Control.Monad (void)
5353
lynx :: Eq model => Events -> App model action -> IO ()
5454
lynx events vcomp = withJS (renderApp events "native" vcomp)
5555
-----------------------------------------------------------------------------
56-
-- | Used when compiling with jsaddle to make miso's JavaScript present in
56+
-- | Used when compiling with WASM to make miso's JavaScript present in
5757
-- the execution context.
5858
withJS :: IO a -> IO ()
5959
withJS action = void $ do

ts/globals.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare var __BACKGROUND__: boolean;
2+
declare var __MAIN_THREAD__: boolean;

ts/miso-lynx.ts

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import { mts } from './miso/mts';
2-
import { bts } from './miso/bts';
3-
import * as btsContext from './miso/bts/context';
4-
import * as mtsContext from './miso/mts/context';
5-
61
import {
72
TextDecoder,
83
TextEncoder,
@@ -19,32 +14,25 @@ globalThis['TextEncoder'] = TextEncoder;
1914
globalThis['BigInt'] = JSBI.BigInt;
2015
globalThis['JSBI'] = JSBI;
2116

22-
if ('__BACKGROUND__' in globalThis) {
23-
globalThis['native'] = {
24-
drawingContext : btsContext.drawingContext,
25-
eventContext : btsContext.eventContext,
26-
componentContext : btsContext.componentContext
27-
}
17+
import { bts } from './miso/bts';
18+
import { mts } from './miso/mts';
19+
import { drawingContext as btsDC, eventContext as btsEC, componentContext as btsCX } from './miso/bts/context';
20+
import { drawingContext as mtsDC, eventContext as mtsEC, componentContext as mtsCX } from './miso/mts/context';
21+
22+
// both use nodeId
23+
globalThis['nodeId'] = 1;
24+
globalThis['initialDraw'] = true;
25+
26+
if (__BACKGROUND__) {
27+
globalThis['native'] = { drawingContext: btsDC, eventContext: btsEC, componentContext: btsCX };
2828
globalThis['patches'] = [];
29-
globalThis['nodeId'] = 1;
3029
bts();
3130
} else {
32-
globalThis['native'] = {
33-
drawingContext : mtsContext.drawingContext,
34-
eventContext : mtsContext.eventContext,
35-
componentContext : mtsContext.componentContext
36-
};
37-
}
38-
39-
/* init mts() */
40-
globalThis['renderPage'] = function () {
41-
mts();
31+
globalThis['native'] = { drawingContext: mtsDC, eventContext: mtsEC, componentContext: mtsCX };
32+
globalThis['renderPage'] = () => mts();
33+
globalThis['runWorklet'] = (worklet, params) => worklet(params);
4234
}
4335

4436
/* etc. */
4537
globalThis['processData'] = () => {};
4638

47-
/* runWorklet boilerplate */
48-
globalThis['runWorklet'] = (worklet, params) => {
49-
return worklet(params);
50-
}

0 commit comments

Comments
 (0)