{"id":18410226,"url":"https://github.com/slainless/prodeskel-ws","last_synced_at":"2025-08-10T00:15:09.916Z","repository":{"id":247320587,"uuid":"821654056","full_name":"slainless/prodeskel-ws","owner":"slainless","description":"Basic WebSocket client implementations for DIGIDES Prodeskel Service.","archived":false,"fork":false,"pushed_at":"2024-07-16T11:04:18.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T16:49:47.604Z","etag":null,"topics":["esm","jsr","typia","websocket"],"latest_commit_sha":null,"homepage":"https://jsr.io/@slainless/prodeskel-ws","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/slainless.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-29T04:19:35.000Z","updated_at":"2024-07-16T11:04:21.000Z","dependencies_parsed_at":"2024-11-06T03:31:57.830Z","dependency_job_id":"9cabf29e-38d8-4e3b-a080-4e60c76c96d4","html_url":"https://github.com/slainless/prodeskel-ws","commit_stats":null,"previous_names":["slainless/prodeskel-ws"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/slainless/prodeskel-ws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fprodeskel-ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fprodeskel-ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fprodeskel-ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fprodeskel-ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slainless","download_url":"https://codeload.github.com/slainless/prodeskel-ws/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slainless%2Fprodeskel-ws/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269656018,"owners_count":24454571,"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","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["esm","jsr","typia","websocket"],"created_at":"2024-11-06T03:29:49.805Z","updated_at":"2025-08-10T00:15:09.890Z","avatar_url":"https://github.com/slainless.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prodeskel-ws\n\n[![JSR Scope](https://jsr.io/badges/@slainless)](https://jsr.io/@slainless/prodeskel-ws) [![JSR Scope](https://jsr.io/badges/@slainless/prodeskel-ws)](https://jsr.io/@slainless/prodeskel-ws)\n\nBasic WebSocket client implementations for DIGIDES Prodeskel Service.\n\nThis package should provide browser-compliant client (extending browser's WebSocket)\nand to-be-added later, advanced client for server-side usage.\n\nThis package is ESM-only. IIFE version for browser is also available, check out usage below.\n\n## Features\n\nThis package is basically just an extension to base `WebSocket` class, with\nsome added methods to allow easier integration:\n\n- **`ready()`**: Throws error in case of invalid prodeskel server, closed, or error on initialization.\n- **`login()`**: Provides easy in-connection authentication.\n- **`on()`, `once()`, `off()`**: Provides event listener handling shortcut for the underneath websocket.\n- **`start()`**: Start synchronization process.\n- **`stop()`**: Stop synchronization process.\n- Many events which can be tapped/listened into, such as `state_change`, `auth`, `sync_task`, etc. It's also possible to listen to derivative/specific event such `sync_task:sync` or `sync_task:sync:started`. [Full event list](./src/schema/response.ts).\n\n## Note\n\nSince the connections are synchronized with each other based on their schema, `start` and `stop` command are shared across\nall the other connections with same schema. To put it simply, all connections with same schema are working on the same space and task.\nOne user can stop a running task and the other user will receive broadcast that the task has been stopped. Progress of the\ntask are also synchronized so each user with same schema should receive same progress broadcast packets.\n\nThe only commands that are locally scoped to connection are `identify_yourself` and (obviously) `auth`.\n\nAlso, it's possible that the task is not immediately ran and will be put in queue, based on server task pool.\n\n## Usage\n\nFor package installation, please refer to [JSR native imports](https://jsr.io/docs/native-imports) or [JSR npm compat](https://jsr.io/docs/npm-compatibility).\n\nIf you prefer to use it directly in browser (or Deno without using native imports), you can also import the project from `esm.sh`:\n\n```ts\nimport {\n  ProdeskelWebSocket,\n  State,\n} from 'https://esm.sh/jsr/@slainless/prodeskel-ws/browser'\n```\n\nFor now, this package only provides core implementation and implementation for browser usage,\nwhich can be imported from `@slainless/prodeskel-ws/browser`.\n\nThere is also IIFE version available, which should be loadable directly with:\n\n```html\n\u003cscript src=\"https://raw.esm.sh/jsr/@slainless/prodeskel-ws/dist/browser.min.js\"\u003e\u003c/script\u003e\n```\n\nAfter loading, `prodeskelws` global object should be available to use, which should expose `ProdeskelWebSocket`, `State`, and `getEventName`.\n\n### Examples\n\nA fully working demo, built on top of Carbon and Alpine is available at [slainless/digides-prodeskel-ws-client-demo](https://github.com/slainless/digides-prodeskel-ws-client-demo).\n\n#### Client generation\n\n```ts\nimport { ProdeskelWebSocket } from '@slainless/prodeskel-ws'\n\nasync function createClient() {\n  const ws = new ProdeskelWebSocket('wss://service.id/ws')\n  await ws.ready()\n  return ws\n}\n```\n\n#### Full usage\n\n```ts\nimport { ProdeskelWebSocket } from '@slainless/prodeskel-ws'\n\n...\n\nasync function createClient(server, credential) {\n  const ws = new ProdeskelWebSocket(server)\n  await ws.login(credential.username, credential.password, credential.schema)\n\n  ws.on('sync_task', (packet) =\u003e {\n    updateProgress(packet)\n  })\n\n  ws.on('sync_status', (packet) =\u003e {\n    updateStatus(packet)\n  })\n\n  return ws\n}\n\n...\n\nlet [ws, setWs] = useState()\n\nreturn \u003cdiv\u003e\n  \u003cinput onChange={(e) =\u003e {\n    createClient(e.target.value, credential)\n      .then(setWs)\n  }}/\u003e\n  \u003cbutton onClick={() =\u003e ws?.start()}\u003eStart\u003cbutton\u003e\n  \u003cbutton onClick={() =\u003e ws?.stop()}\u003eStop\u003cbutton\u003e\n  \u003cdiv id=\"output\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n\n## Underlying connection\n\nUnderlying connection is intentionally exposed, to allow manual control over it in case more advanced\nusage is needed, for example, manual event handling. The connection should be accessible from\n`ProdeskelWebSocket.connection`.\n\nAlso, correct event code can be acquired from `getEventName`, exported by `./core` or by each platform specific\nmodule.\n\n```ts\nimport { getEventName, ProdeskelWebSocket } from '@slainless/prodeskel-ws'\n\nasync function createClient(credential) {\n  const ws = new ProdeskelWebSocket('wss://service.id/ws')\n  await ws.login(credential.username, credential.password, credential.schema)\n\n  // Connection at the very least should be returning WebSocketLike.\n  ws.connection.on(getEventName('message'), (packet) =\u003e {\n    console.log(packet)\n  })\n}\n```\n\n## Development\n\n- Developed in Bun environment\n- Data validation with `typia`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslainless%2Fprodeskel-ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslainless%2Fprodeskel-ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslainless%2Fprodeskel-ws/lists"}