mithril-lynx 0.0.3 → 0.0.4
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.
- package/package.json +2 -2
- package/plugin.js +50 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mithril-lynx",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Mithril.js rendered through Lynx's Element PAPI
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "Mithril.js rendered through Lynx's Element PAPI \u2014 a contract-complete port of mithril/render/render.js@2.3.8 to the Lynx main thread, packaged as a reusable framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
package/plugin.js
CHANGED
|
@@ -35,6 +35,28 @@ function findSibling(dir, candidates) {
|
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Walks up from a resolved file to the root of the package that owns it,
|
|
40
|
+
* verified by name rather than assumed from the layout — this package's
|
|
41
|
+
* exports map deliberately doesn't expose ./package.json, so the usual
|
|
42
|
+
* require.resolve("<pkg>/package.json") trick isn't available here.
|
|
43
|
+
*/
|
|
44
|
+
function packageRootOf(resolvedFile) {
|
|
45
|
+
let dir = path.dirname(resolvedFile);
|
|
46
|
+
for (let i = 0; i < 10; i++) {
|
|
47
|
+
try {
|
|
48
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
|
|
49
|
+
if (pkg.name === "mithril-lynx") return dir;
|
|
50
|
+
} catch {
|
|
51
|
+
// keep walking
|
|
52
|
+
}
|
|
53
|
+
const parent = path.dirname(dir);
|
|
54
|
+
if (parent === dir) break;
|
|
55
|
+
dir = parent;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
38
60
|
export function pluginMithrilLynx(options = {}) {
|
|
39
61
|
const targetSdkVersion = options.targetSdkVersion ?? "3.5";
|
|
40
62
|
|
|
@@ -69,6 +91,34 @@ export function pluginMithrilLynx(options = {}) {
|
|
|
69
91
|
// leave resolution as-is rather than guessing.
|
|
70
92
|
}
|
|
71
93
|
|
|
94
|
+
// Same class of problem, worse symptom: mithril-lynx itself keeps
|
|
95
|
+
// per-app state in module-level variables — the shim's rootWrapper/
|
|
96
|
+
// redraw/runRender, main-thread.js's latestData and its cross-thread
|
|
97
|
+
// handler maps, background.js's mirror of those. Two physical copies
|
|
98
|
+
// means two disconnected renderers: the app renders through one, and
|
|
99
|
+
// any LIBRARY that depends on mithril-lynx (a component library, say,
|
|
100
|
+
// resolving its own nested copy once linked) calls shim.redraw() on
|
|
101
|
+
// the other — whose `redraw` is still null. That's a silent no-op:
|
|
102
|
+
// no error, nothing logged, components simply never update. Confirmed
|
|
103
|
+
// on real hardware 2026-09-11 while building mithril-lynx-ui, where
|
|
104
|
+
// it read as "the animation just doesn't run".
|
|
105
|
+
try {
|
|
106
|
+
const appRequire = createRequire(path.join(process.cwd(), "package.json"));
|
|
107
|
+
const selfDir = packageRootOf(appRequire.resolve("mithril-lynx"));
|
|
108
|
+
if (selfDir != null) {
|
|
109
|
+
// The bare specifier has to point at the entry FILE: aliasing it
|
|
110
|
+
// to the directory would bypass this package's own exports map
|
|
111
|
+
// (which has no "main" to fall back on) and fail to resolve.
|
|
112
|
+
// The prefix alias then keeps subpaths — "mithril-lynx/main-thread"
|
|
113
|
+
// and friends, which hold state of their own — on that same copy.
|
|
114
|
+
chain.resolve.alias.set("mithril-lynx$", path.join(selfDir, "src", "lynx-mithril-shim.js"));
|
|
115
|
+
chain.resolve.alias.set("mithril-lynx", selfDir);
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
// App doesn't resolve mithril-lynx from its own root (it's being
|
|
119
|
+
// consumed some other way) — leave resolution alone.
|
|
120
|
+
}
|
|
121
|
+
|
|
72
122
|
const rawEntries = Object.entries(chain.entryPoints.entries() ?? {});
|
|
73
123
|
chain.entryPoints.clear();
|
|
74
124
|
|