I have written google app script code for a spreadsheet. I want to publish part of it as an add-on,
the other part (which stays as script bound to the spreadsheet) should b
There is no way to call functions from inside an Add-On.
However, the documentation for Libraries mentions how to make methods and properties private, under the Best practices section, number 3.
You can use these methods to create a structure similar to private
encapsulation on languages like Java and others, where you have private methods and properties and then public methods that allow users to manipulate those.
If you debug a project with libraries, you will be able to browse the code on the libraries as read-only.
While that is an expected result, since other languages also have it (if you are debugging a java code, even if there is no source provided, you can still see the JVM method headers and the stack-trace.), there is not much to be done.
However, you can use a clever method to obfuscate your code:
Consider publishing a web app that receives the data you plan on manipulating and interact with that instead with Apps Script's UrlFetchApp
.
You can also make a library to "hide" the fact that you are calling an web app from your non-debugging users (after all, they would be able to see your code). But your "hidden" code would be safe.