browser-runtime-octane 0.0.7 → 0.0.8
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/src/index.js +15 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-runtime-octane",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"browser-module-runtime": "0.0.
|
|
25
|
+
"browser-module-runtime": "0.0.8",
|
|
26
26
|
"octane": "*"
|
|
27
27
|
},
|
|
28
28
|
"description": "Octane JSX, TSX, and TSRX compiler and renderer adapter for browser-module-runtime.",
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function snapshotProps(next){
|
|
2
|
+
if(next===null||typeof next!=="object"||Array.isArray(next)||
|
|
3
|
+
(Object.getPrototypeOf(next)!==Object.prototype&&Object.getPrototypeOf(next)!==null))
|
|
4
|
+
throw new TypeError('updateProps expects a plain object of next props');
|
|
5
|
+
return {...next};
|
|
6
|
+
}
|
|
1
7
|
/** Official Octane browser compiler uses compile(source, filename, options).
|
|
2
8
|
* Compiled TSRX/TSX/JSX is owned by Octane, not by the generic runtime. */
|
|
3
9
|
export function octane({compiler,renderer,version='unverified',provider='esm.sh',compilerOptions={}}={}) {
|
|
@@ -26,8 +32,15 @@ export function octane({compiler,renderer,version='unverified',provider='esm.sh'
|
|
|
26
32
|
async mount({component,target,props}) {
|
|
27
33
|
octaneRenderer ||= await (ownerRuntime ? ownerRuntime.import('octane') : import('octane'));
|
|
28
34
|
const root=octaneRenderer.createRoot(target);
|
|
29
|
-
root.render(component,props);
|
|
30
|
-
|
|
35
|
+
root.render(component,snapshotProps(props));
|
|
36
|
+
let closed=false;
|
|
37
|
+
return {
|
|
38
|
+
updateProps(next){
|
|
39
|
+
if(closed)throw new Error('Octane mount has been disposed');
|
|
40
|
+
return root.render(component,snapshotProps(next));
|
|
41
|
+
},
|
|
42
|
+
dispose(){if(!closed){closed=true;return root.unmount();}}
|
|
43
|
+
};
|
|
31
44
|
}
|
|
32
45
|
}]
|
|
33
46
|
};
|