ceifa / wasmoon

A real lua 5.4 VM with JS bindings made with webassembly
MIT License
496 stars 32 forks source link

[Feature Request] Filter properties on Proxy objects? #102

Closed volundmush closed 11 months ago

volundmush commented 11 months ago

When you expose a JavaScript object such as a class instance as a Lua object, it gets Proxied. This is good, I like it!

The only problem is that the resulting Lua Proxy does not respect private/protected/readonly sorts of TypeScript access types. Which, of course, it cannot, since JavaScript is unaware of those things.

That being the case, another approach is needed in order to protect methods and traits. Possibly a prefix mask like _ or h or something which Proxy could filter out when creating __index?

tims-bsquare commented 11 months ago

I think you'll be able to do this by prefixing fields with a #. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties