@viostream/viostream-player-svelte 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -93,13 +93,11 @@
93
93
 
94
94
  // Internal state
95
95
  let containerEl: HTMLDivElement | undefined = $state();
96
+ let embedTargetEl: HTMLDivElement | undefined = $state();
96
97
  let player: ViostreamPlayer | undefined = $state();
97
98
  let errorMsg: string | undefined = $state();
98
99
  let isLoading = $state(true);
99
100
 
100
- // Unique ID for the container
101
- const containerId = `viostream-player-${Math.random().toString(36).slice(2, 10)}`;
102
-
103
101
  // Build the embed options object from props
104
102
  function buildEmbedOptions(): ViostreamEmbedOptions {
105
103
  const opts: ViostreamEmbedOptions = {};
@@ -137,7 +135,17 @@
137
135
  ];
138
136
 
139
137
  onMount(() => {
140
- debug('onMount publicKey=%s accountKey=%s containerId=%s', publicKey, accountKey, containerId);
138
+ // Generate unique IDs on the client only and assign them imperatively
139
+ // to the DOM elements. This avoids SSR/hydration mismatches caused by
140
+ // Math.random() producing different values on server vs client.
141
+ const containerId = `viostream-player-${Math.random().toString(36).slice(2, 10)}`;
142
+ const embedTargetId = `viostream-embed-${Math.random().toString(36).slice(2, 10)}`;
143
+
144
+ containerEl!.id = containerId;
145
+ containerEl!.setAttribute('data-viostream-sdk', `${SDK_NAME}@${SDK_VERSION}`);
146
+ embedTargetEl!.id = embedTargetId;
147
+
148
+ debug('onMount publicKey=%s accountKey=%s containerId=%s embedTargetId=%s', publicKey, accountKey, containerId, embedTargetId);
141
149
 
142
150
  let destroyed = false;
143
151
 
@@ -152,12 +160,12 @@
152
160
  }
153
161
 
154
162
  const embedOpts = buildEmbedOptions();
155
- debug('init: calling api.embed publicKey=%s containerId=%s options=%o', publicKey, containerId, embedOpts);
156
- const raw: RawViostreamPlayerInstance = api.embed(publicKey, containerId, embedOpts, normalizeForceAspectRatio(forceAspectRatio));
163
+ debug('init: calling api.embed publicKey=%s embedTargetId=%s options=%o', publicKey, embedTargetId, embedOpts);
164
+ const raw: RawViostreamPlayerInstance = api.embed(publicKey, embedTargetId, embedOpts, normalizeForceAspectRatio(forceAspectRatio));
157
165
  debug('init: api.embed returned raw player');
158
166
 
159
- const wrappedPlayer = wrapRawPlayer(raw, containerId);
160
- debug('init: wrapRawPlayer completed containerId=%s', containerId);
167
+ const wrappedPlayer = wrapRawPlayer(raw, embedTargetId);
168
+ debug('init: wrapRawPlayer completed embedTargetId=%s', embedTargetId);
161
169
 
162
170
  if (destroyed) {
163
171
  debug('init: stale closure detected after wrapRawPlayer — destroying and aborting publicKey=%s', publicKey);
@@ -230,13 +238,13 @@
230
238
  </script>
231
239
 
232
240
  <div
233
- id={containerId}
234
241
  class={className}
235
242
  bind:this={containerEl}
236
243
  data-viostream-player
237
244
  data-viostream-public-key={publicKey}
238
- data-viostream-sdk={`${SDK_NAME}@${SDK_VERSION}`}
239
245
  >
246
+ <div bind:this={embedTargetEl} data-viostream-embed-target></div>
247
+
240
248
  {#if isLoading}
241
249
  {#if loadingSnippet}
242
250
  {@render loadingSnippet()}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const SDK_NAME = "viostream-player-svelte";
2
- export declare const SDK_VERSION = "0.2.8";
2
+ export declare const SDK_VERSION = "0.2.10";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by scripts/sync-version.mjs — do not edit
2
2
  export const SDK_NAME = 'viostream-player-svelte';
3
- export const SDK_VERSION = '0.2.8';
3
+ export const SDK_VERSION = '0.2.10';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viostream/viostream-player-svelte",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Svelte 5 SDK for the Viostream video player — embed, control, and listen to player events",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -31,7 +31,7 @@
31
31
  "!dist/**/*.spec.*"
32
32
  ],
33
33
  "dependencies": {
34
- "@viostream/viostream-player-core": "^0.2.8",
34
+ "@viostream/viostream-player-core": "^0.2.10",
35
35
  "debug": "^4.4.3"
36
36
  },
37
37
  "peerDependencies": {