Skip to content

Commit

Permalink
fix(editor): fix "when switch to element assemble from ap assemble->r…
Browse files Browse the repository at this point in the history
…un quickly, will error" bug

reason
meta3d-ui-control-codeedit -> getMonaco() return empty because deferLoad not finish

solution
handle the empty case
  • Loading branch information
yyc-git committed Mar 12, 2024
1 parent 16ca0a9 commit 48e8901
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 22 deletions.
2 changes: 1 addition & 1 deletion contributes/meta3d-action-addcomponent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-action-addcomponent",
"version": "1.3.1",
"version": "1.3.2",
"publisher": "meta3d",
"repoLink": "",
"protocol": {
Expand Down
2 changes: 1 addition & 1 deletion contributes/meta3d-ui-control-codeedit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-ui-control-codeedit",
"version": "1.3.1",
"version": "1.3.2",
"displayName": "代码编辑",
"publisher": "meta3d",
"protocol": {
Expand Down
8 changes: 8 additions & 0 deletions contributes/meta3d-ui-control-codeedit/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ export let getContribute: getContributeMeta3D<uiControlContribute<inputFunc, spe
if (api.nullable.isNullable(editor)) {
let monaco = getMonaco()

console.log("empty monaco")

if (api.nullable.isNullable(monaco)) {
return [meta3dState, null]
}

monaco = api.nullable.getExn(monaco)

editor = monaco.editor.create(container, {
model: monaco.editor.createModel(code, "typescript"),
})
Expand Down
26 changes: 19 additions & 7 deletions doc/jiehuo.org
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ start position error



* TODO publish and update
* DONE publish and update
addcomponent
sceneview c
gameview c
Expand All @@ -372,7 +372,9 @@ component-script

* DONE fix: clone gameObject with script component error

# * TODO fix: sometimes "can't find editor" error
* DONE fix: sometimes "can't find editor" error

monaco.editor?

# * TODO perf: switch to element assemble too slow

Expand All @@ -388,12 +390,7 @@ fix gamma pass
* DONE default scene remove Arcball_Camera2


* TODO fix: active arcball_forsceneview->publish error


* TODO fix: camera group can set near, far

* TODO feat: add arcball component



Expand Down Expand Up @@ -571,3 +568,18 @@ can add util functions!

maintain visible







* TODO small improvement

** TODO fix: camera group can set near, far

** TODO feat: add arcball component; can set distance, phi, theta, target,

** TODO fix: active arcball_forsceneview->publish error

TODO hidden Arcball Camera For Scene View in sceneTree?
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-webgl1-three-gameviewrender",
"version": "1.3.7",
"version": "1.3.9",
"publisher": "meta3d",
"protocol": {
"name": "meta3d-pipeline-webgl1-three-gameviewrender-protocol"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-webgl1-three-sceneviewrender",
"version": "1.3.1",
"version": "1.3.2",
"publisher": "meta3d",
"protocol": {
"name": "meta3d-pipeline-webgl1-three-sceneviewrender-protocol"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-imgui-webgl1-renderer",
"version": "1.3.1",
"version": "1.3.2",
"publisher": "meta3d",
"displayName": "imgui-webgl1-renderer",
"protocol": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-component-script",
"version": "1.3.1",
"version": "1.3.2",
"publisher": "meta3d",
"protocol": {
"name": "meta3d-component-script-protocol"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-webgl1-three-webrender",
"version": "1.3.6",
"version": "1.3.7",
"publisher": "meta3d",
"protocol": {
"name": "meta3d-pipeline-webgl1-three-webrender-protocol"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ module Method = {

()->Js.Promise.resolve
}, _)
->Js.Promise.catch(e => {
service.console.errorWithExn(. e->Error.promiseErrorToExn, None)->Obj.magic

->Js.Promise.catch(
e => {
service.console.errorWithExn(. e->Error.promiseErrorToExn, None)->Obj.magic
},
// (e->Obj.magic)["errorType"] === "script"
// ? {
// loopFrameID.current =
Expand All @@ -62,8 +63,9 @@ module Method = {

// ()->Js.Promise.resolve
// }
// : e->Js.Exn.anyToExnInternal->Js.Promise.reject
}, _)
// : e->Js.Exn.anyToExnInternal->Js.Promise.reject
_,
)
->ignore
}

Expand Down Expand Up @@ -136,7 +138,7 @@ let make = (~service: AssembleSpaceType.service) => {

service.react.useEffect1(. () => {
MessageUtils.showCatchedErrorMessage(() => {
switch Meta3dMonacoUtils.Main.getMonaco() {
switch Meta3dMonacoUtils.Main.getMonaco()->Meta3dCommonlib.OptionSt.fromNullable {
| None =>
Meta3dMonacoUtils.Main.deferLoad()
->Js.Promise.catch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let make = (~service: FrontendType.service) => {

React.useEffect1(() => {
MessageUtils.showCatchedErrorMessage(() => {
switch Meta3dMonacoUtils.Main.getMonaco() {
switch Meta3dMonacoUtils.Main.getMonaco()->Meta3dCommonlib.OptionSt.fromNullable {
| None =>
Meta3dMonacoUtils.Main.deferLoad()
->Js.Promise.catch(
Expand Down
4 changes: 3 additions & 1 deletion utils/meta3d-monaco-utils/src/Main.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { nullable } from "meta3d-commonlib-ts/src/nullable"

export type monaco = any

export function getMonaco(): monaco
export function getMonaco(): nullable<monaco>

0 comments on commit 48e8901

Please sign in to comment.