-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ftd.main-package
(variable) and ftd.is_app_mounted
(function)
#2061
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
amitu
reviewed
Jan 31, 2025
siddhantk232
changed the title
Feat/ftd app path ex
Jan 31, 2025
ftd.main-package
(variable) and ftd.is_app_mounted
(function)
WARN: the `ftd.main-package` does not work yet. It's stored in the `global` map in js output and it's not getting resolved when used in an ftd file. This should be key on `ftd` object itself. - `ftd.main-package`: A string variable that stores the name of the packaeg. This is useful to determine if a package is mounted in another package or if it's running standalone. - Refactor: Create `HostBuiltins` type and use it instead of Array of fixed sized type everywhere. This makes it easy to add new builtins
This allows to use the following in ftd code: ```ftd -- ftd.text: $ftd.main-package ```
This variable is used to support the optional second parameter (app) in `ftd.app-path` function. The `ftd.app-path` function now takes a second optional arg. This arg is used to construct app paths for any app that is mounted using `fastn.app` in FASTN.ftd.
We don't need this definition here. This function is only invoked internally through `ftd.app-path` function.
If a package has `lets-auth` app mounted. Then the following code will show "Hello" as output: ```ftd -- string app: lets-auth -- ftd.text: Hello if: { ftd.is_app_mounted(app) } ;; or ftd.is_app_mounted("lets-auth") ```
- Update the docs of `ftd.app-path` to mention the second `app` parameter. - Document `ftd.main-package` string variable - Document `ftd.is_app_mounted(app: string)` ftd function. This can be used to conditionally render things based on the mounting status of specific apps (using app package's system name)
`fastn` touches both the file system (through its fs routing) and the urls (since it's a webserver, duh). This might create a situation where people think `ftd.app-path` is something related to fs but it's really constructing the path relative to your website url. For this reason, this has been renamed to `ftd.app-url` instead.
siddhantk232
force-pushed
the
feat/ftd-app-path-ex
branch
from
February 1, 2025 09:23
8af6134
to
0e5667c
Compare
amitu
approved these changes
Feb 1, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Demo video: https://youtu.be/IrfsVCy7Y0Y
TODO
ftd.main-package
variableapp
param toftd.app-path
ftd.is_app_mounted
functionftd.app-path
ftd.main-package
ftd.is_app_mounted
ftd.app-path
->ftd.app-url