1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-29 08:56:58 +02:00

added jsvm binding

This commit is contained in:
Gani Georgiev
2023-07-23 16:43:38 +03:00
parent 132a8c0aab
commit 085fb1601e
3 changed files with 5582 additions and 5458 deletions

View File

@@ -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