{"id":19972598,"url":"https://github.com/jpb06/sdk-test","last_synced_at":"2025-08-07T14:47:44.786Z","repository":{"id":248888173,"uuid":"830026668","full_name":"jpb06/sdk-test","owner":"jpb06","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-19T14:01:22.000Z","size":388,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T09:28:19.052Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sdk-test.vercel.app","language":"TypeScript","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/jpb06.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-17T13:05:13.000Z","updated_at":"2024-07-19T14:01:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"dec50ffd-f1c5-44ed-8c23-eac6597ba00f","html_url":"https://github.com/jpb06/sdk-test","commit_stats":null,"previous_names":["jpb06/sdk-test"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fsdk-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fsdk-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fsdk-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fsdk-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpb06","download_url":"https://codeload.github.com/jpb06/sdk-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241405411,"owners_count":19957812,"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-13T03:08:38.732Z","updated_at":"2025-03-01T18:22:49.416Z","avatar_url":"https://github.com/jpb06.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sdk-test\n\nThis is a POC for the integration of a web app into a heavy client. The heavy client part can be found [here](https://github.com/jpb06/sdk-test-java-app).\n\n# Next app\n\nOur next app will expose several pages. Each page can be seen as an independent feature block (called widget) that can be loaded in an oustide context (like a heavy client app, for example).\n\n# Communication\n\n![Workflow](./assets/workflow.png)\n\nTo communicate with the outside context, [fseglard](https://github.com/fseglard) has written a sdk based on [post message api](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage).\n\n## Sdk API\n\n### `init`\n\nThe `init` function replaces an element in the DOM with an iframe that will target one of our next app widget pages.\n\n```tsx\n\u003cdiv id=\"my-widget\" /\u003e\n\u003cscript src=\"/libs/sdk.min.js\" /\u003e\n\u003cscript\u003e\n  const widget = new window.WidgetSdk({\n    baseUrl: 'http://localhost:3000',\n    frameHeight: 600,\n    frameWidth: 900,\n    theme: 'neutral',\n    token: 'my-token',\n    type: 'user',\n  });\n\n  widget.init('my-widget');\n\u003c/script\u003e\n```\n\n### `emit`\n\nThe `emit` function sends an event:\n\n```typescript\nconst framebus = useFramebusContext();\n\nconst handleClick = () =\u003e {\n  framebus.emit('user.actions.doStuff', {\n    payload: {\n      id: 126\n      name: 'Yolo bro',\n    },\n  });\n};\n```\n\n### `on`\n\nThe `on` function creates a listener for an event type:\n\n```typescript\nconst framebus = useFramebusContext();\n\nuseEffect(() =\u003e {\n  framebus.on('user.get', ({ id }) =\u003e {\n    console.info(`user.get event fired with id ${id}`);\n    // ...\n  });\n}, [framebus]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpb06%2Fsdk-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpb06%2Fsdk-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpb06%2Fsdk-test/lists"}