mirror of
https://github.com/pocketbase/pocketbase.git
synced 2024-12-01 11:01:04 +02:00
added jsvm binding
This commit is contained in:
parent
132a8c0aab
commit
085fb1601e
10992
plugins/jsvm/internal/types/generated/types.d.ts
vendored
10992
plugins/jsvm/internal/types/generated/types.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -153,6 +153,32 @@ type appWithoutHooks = Omit<pocketbase.PocketBase, ` + "`on${string}`" + `>
|
||||
*/
|
||||
declare var $app: appWithoutHooks
|
||||
|
||||
/**
|
||||
* ` + "`$template`" + ` is a global helper to load and cache HTML templates on the fly.
|
||||
*
|
||||
* The templates uses the standard Go [html/template](https://pkg.go.dev/html/template)
|
||||
* and [text/template](https://pkg.go.dev/text/template) package syntax.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ` + "```" + `js
|
||||
* routerAdd("get", "/hello", (c) => {
|
||||
* const html = $template.loadFiles(
|
||||
* "views/layout.html",
|
||||
* "views/content.html",
|
||||
* ).render({"name": "John"})
|
||||
*
|
||||
* return c.html(200, html)
|
||||
* })
|
||||
* ` + "```" + `
|
||||
*
|
||||
* _Note that this method is available only in pb_hooks context._
|
||||
*
|
||||
* @namespace
|
||||
* @group PocketBase
|
||||
*/
|
||||
declare var $template: template.Registry
|
||||
|
||||
/**
|
||||
* arrayOf creates a placeholder array of the specified models.
|
||||
* Usually used to populate DB result into an array of models.
|
||||
@ -811,6 +837,7 @@ func main() {
|
||||
"github.com/pocketbase/dbx": {"*"},
|
||||
"github.com/pocketbase/pocketbase/tools/security": {"*"},
|
||||
"github.com/pocketbase/pocketbase/tools/filesystem": {"*"},
|
||||
"github.com/pocketbase/pocketbase/tools/template": {"*"},
|
||||
"github.com/pocketbase/pocketbase/tokens": {"*"},
|
||||
"github.com/pocketbase/pocketbase/apis": {"*"},
|
||||
"github.com/pocketbase/pocketbase/forms": {"*"},
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/plugins/jsvm/internal/types/generated"
|
||||
"github.com/pocketbase/pocketbase/tools/template"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -199,11 +200,12 @@ func (p *plugin) registerHooks() error {
|
||||
return nil
|
||||
})
|
||||
|
||||
// this is safe to be shared across multiple vms
|
||||
registry := new(require.Registry)
|
||||
// safe to be shared across multiple vms
|
||||
requireRegistry := new(require.Registry)
|
||||
templateRegistry := template.NewRegistry()
|
||||
|
||||
sharedBinds := func(vm *goja.Runtime) {
|
||||
registry.Enable(vm)
|
||||
requireRegistry.Enable(vm)
|
||||
console.Enable(vm)
|
||||
process.Enable(vm)
|
||||
baseBinds(vm)
|
||||
@ -214,6 +216,7 @@ func (p *plugin) registerHooks() error {
|
||||
apisBinds(vm)
|
||||
httpClientBinds(vm)
|
||||
vm.Set("$app", p.app)
|
||||
vm.Set("$template", templateRegistry)
|
||||
}
|
||||
|
||||
// initiliaze the executor vms
|
||||
|
Loading…
Reference in New Issue
Block a user