{"id":19560020,"url":"https://github.com/plotdb/sandbox","last_synced_at":"2026-06-09T01:04:04.022Z","repository":{"id":40425974,"uuid":"186848261","full_name":"plotdb/sandbox","owner":"plotdb","description":"Handy Sandbox for executing / rendering arbitrary JavaScript.","archived":false,"fork":false,"pushed_at":"2022-12-15T16:02:59.000Z","size":2106,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T02:06:24.939Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plotdb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-15T14:53:40.000Z","updated_at":"2022-01-22T03:14:18.000Z","dependencies_parsed_at":"2023-01-29T03:45:22.744Z","dependency_job_id":null,"html_url":"https://github.com/plotdb/sandbox","commit_stats":null,"previous_names":["plotdb/sandbox.js"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Fsandbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Fsandbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Fsandbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Fsandbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plotdb","download_url":"https://codeload.github.com/plotdb/sandbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239942786,"owners_count":19722335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T05:05:38.599Z","updated_at":"2025-11-20T01:03:41.170Z","avatar_url":"https://github.com/plotdb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sandbox.js\n\nSandboxing javascript in embedded iframe.\n\n\n## Usage\n\nvar sb = new sandbox(config);\n\n## Configurations\n\n * root - root element. sandbox.js will create one if this is omitted.\n * container - if root is not specified or root doesn't have a parent, attach root to container.\n   default to document.body if both root and container are omitted.\n * sandbox - iframe sandbox attributes. default to \"allow-scripts allow-pointer-lock\".\n   Note: blob iframe in Firefox exploits host cookie with empty sandbox.\n * className: space separated class list to add over the root element.\n * window - works in standalone popup window. root and container won't be necessary when window provided.\n   window, if provided, should be an object containing following members:\n   - name - window name. randomly generated if omitted.\n   - width - window width. decided by sandbox.js if omitted.\n   - height - window height. decided by sandbox.js if omitted.\n\n\n## Methods\n\n * setProxy(({obj: obj}) - set an object as proxy interface. Proxy object must passed in an object like:\n\n   ```\n   sb.setProxy({ Interface: Interface });\n   ```\n\n   once set, you can invoke corresponding object in sandbox with following:\n\n   ```\n   sb.proxy.someFunc(args);\n   ```\n\n   you must have the object ( e.g., Interface ) with the exact same name as a global object in sandbox context.\n\n * send(msg) - send message to sandbox. msg will be wrapped in an object as:\n\n   ```\n   { type: \\msg, payload: your-msg-data }\n   ```\n\n * reload() - reload sandbox.\n * load(payload) - initialize sandbox content. payload can be a plain string or has following structure:\n\n   ```\n   {\n      \"html\": (string or {url: HTML-URL} ),\n      \"css\":  (string or {url: CSS-URL} ),\n      \"js\":   (string or {url: JS-URL} )\n   }\n   ```\n * openWindow(cfg) - open sandbox in a standalone window.\n   - cfg.name - window name.\n\n\n## Sample Usage\n\niframe mode:\n```\n    /* create a sandbox instance */ \n    var sb = new sandbox({\n      container: 'selector-for-certain-node',\n      className: 'space separated class names'\n    });\n\n    /* load and render code */\n    sb.load({js: '...', html: '...', css: '...'});\n\n    /* you can still render it again in a standalone window */\n    sb.openWindow({name: \"window-name\"})\n      .then(function() { ... });\n```\n\nwindow mode:\n```\n    /* create a sandbox instance */ \n    var sb = new sandbox({\n      window: 'window-name'\n    });\n\n    /* load and render code */\n    sb.load({js: '...', html: '...', css: '...'});\n```\n\nyou can also init with both modes:\n```\n    /* create a sandbox instance */ \n    var sb = new sandbox({\n      window: 'window-name',\n      container: 'selector-for-certain-node'\n    });\n```\n\n## Resources\n\n - how figma support plugins: https://www.figma.com/blog/how-we-built-the-figma-plugin-system/\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotdb%2Fsandbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplotdb%2Fsandbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotdb%2Fsandbox/lists"}