Apart from the options listed under 'Publish' menu in the script editor window, the below 3 options may also keep code private to the developer.
Option1:
3 files are to be created:
1.1 A spreadsheet to receive the user input, this serves as a user interface, and is to be shared with the user.
1.2 A standalone library script file to receive the input from the UI spreadsheet.
1.3 A standalone private script file to process the data which the library file receives.
Option 1 Spreadsheet
As a reference for this option is a spreadsheet at the above link.
When 'Submit' is clicked, the spreadsheet ID is sent to the library script file and the developer is given editor permission. The private script file then opens the file and processes the input.
Option 2:
5 files are to be created
2.1 A spreadsheet which serves as a login screen. This is shared with the user.
2.2 A spreadsheet which serves as the actual application that contains the data. A user interface. This spreadsheet is made available to the user after successful login. The user logs-out of the application from this sheet.
2.3 A spreadsheet which maintains the login status of the user. This is private to the developer.
2.4 A library script file which updates the login status of the user in the spreadsheet created in the step above and changes the access permission to the private script file. This script file is included as a library resource in both the login spreadsheet and user interface spreadsheet.
2.5 A library script file which processes the data entered in the user interface sheet. This script file contains code that the developer wants to keep private. This file is included as a library resource in the user interface spreadsheet only.
Option 2 Spreadsheet
As a reference for this option is a spreadsheet at the above link.
When the user clicks the 'Get Started' button the user is logged into the application after updating the cell value in spreadsheet 2.3.The library script file which contains private code is set to shareable after successful Login by using addViewer method. A link to the application is presented to the user and the user interacts with the application while 'Logged in'. When the user logs-out from the application removeViewer method is called to make the script file private again.
In this option, the private code file is accessible to the users while they use the application. The file may be kept private by using timers, script triggers, prompts, alerts, etc.
In both of my spreadsheets I use time based triggers set to run every minute to process the applications. This may cause the output to be delayed. The triggers are created on the server side and not at the client side.
Option 3: Private shared folder
2 files are to be created:
3.1 A spreadsheet to receive the user input, this serves as a user interface, and is to be shared with the user.
3.2 A standalone private script file to process the spreadsheet.
Please refer this link on how to create a private shared folder.
In this option, no script is visible to the user. Even the shared spreadsheet may not contain code.