ebt-vue3 2.49.2 → 2.50.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ebt-vue3",
3
- "version": "2.49.2",
3
+ "version": "2.50.2",
4
4
  "description": "Vue3 Library for SuttaCentral Voice EBT-Sites",
5
5
  "author": "Karl Lew",
6
6
  "scripts": {
@@ -46,7 +46,7 @@
46
46
  "merkle-json": "^2.13.0",
47
47
  "pinia": "^2.0.16",
48
48
  "roboto-fontface": "*",
49
- "scv-esm": "^1.132.25",
49
+ "scv-esm": "^1.132.27",
50
50
  "serve-favicon": "^2.5.0",
51
51
  "uuid": "^9.0.0",
52
52
  "vite-plugin-vuetify": "^2.0.3",
@@ -119,6 +119,46 @@
119
119
 
120
120
  card.onAfterMounted({settings, volatile});
121
121
  },
122
+ watch: {
123
+ 'card.location': {
124
+ async handler(newLoc, oldLoc) {
125
+ const msg = 'SuttaView.watch.card.location()';
126
+ const dbg = DBG.MOUNTED;
127
+
128
+ // Skip if no previous location (initial mount handles this)
129
+ if (!oldLoc || !newLoc) return;
130
+
131
+ // Skip if same sutta_uid (just segment change)
132
+ if (newLoc[0] === oldLoc[0]) return;
133
+
134
+ dbg && console.log(msg, '[1]location changed', {newLoc, oldLoc});
135
+
136
+ // Reload sutta data for new location
137
+ let { suttas, settings, volatile, card, config } = this;
138
+ let ref = {
139
+ sutta_uid: newLoc[0],
140
+ lang: newLoc[1],
141
+ author: newLoc[2],
142
+ };
143
+ let suttaRef = SuttaRef.create(ref);
144
+ if (suttaRef == null) {
145
+ let eMsg = `Invalid SuttaRef ${JSON.stringify(ref)}`;
146
+ console.log(msg, eMsg);
147
+ volatile.alert(eMsg);
148
+ return;
149
+ }
150
+ let { sutta_uid, lang, author } = suttaRef;
151
+ dbg && console.log(msg, `[2]reloading suttaRef:${suttaRef}`);
152
+ let idbSuttaRef = await suttas.getIdbSuttaRef({
153
+ sutta_uid, lang, author
154
+ });
155
+ this.idbSuttaRef = idbSuttaRef?.value;
156
+
157
+ card.onAfterMounted({settings, volatile});
158
+ },
159
+ deep: true,
160
+ },
161
+ },
122
162
  methods: {
123
163
  segKey(card, seg) {
124
164
  let rawId = `${seg.scid}_CARD${card.id.substring(0,8)}`;
@@ -164,6 +164,84 @@ class MockSettings {
164
164
 
165
165
  should(nAdd).equal(1);
166
166
  });
167
+ it("pathToCard() creates new card for different sutta", () => {
168
+ // Bug test: navigating from mn1 to mn3 should create separate cards
169
+ let cf = new CardFactory();
170
+ let cards = [];
171
+ let langTrans = "en";
172
+ let defaultLang = langTrans;
173
+ let addCard = (opts) => {
174
+ let card = new EbtCard(Object.assign({langTrans}, opts));
175
+ cards.push(card);
176
+ return card;
177
+ };
178
+
179
+ // Create card for mn1
180
+ let cardMN1 = cf.pathToCard({
181
+ path: '/sutta/mn1/en/sujato',
182
+ cards,
183
+ addCard,
184
+ defaultLang
185
+ });
186
+ should(cards.length).equal(1);
187
+ should(cardMN1.location[0]).match(/mn1/);
188
+
189
+ // Navigate to mn3 - should create NEW card (different sutta_uid)
190
+ let cardMN3 = cf.pathToCard({
191
+ path: '/sutta/mn3/en/sujato',
192
+ cards,
193
+ addCard,
194
+ defaultLang
195
+ });
196
+
197
+ // Bug check: If mn3 card !== mn1 card, new card was created (correct)
198
+ // If mn3 card === mn1 card with location still mn1, bug exists
199
+ should(cards.length).equal(2); // Two separate cards
200
+ should(cardMN3.location[0]).match(/mn3/);
201
+ should(cardMN3).not.equal(cardMN1);
202
+ });
203
+ it("pathToCard() handles path with query params before hash", () => {
204
+ // Test: URL like ?src=sc#/sutta/mn3/en/sujato
205
+ let cf = new CardFactory();
206
+ let cards = [];
207
+ let langTrans = "en";
208
+ let defaultLang = langTrans;
209
+ let addCard = (opts) => {
210
+ let card = new EbtCard(Object.assign({langTrans}, opts));
211
+ cards.push(card);
212
+ return card;
213
+ };
214
+
215
+ // Test various path formats that might come from Vue Router
216
+ let card1 = cf.pathToCard({
217
+ path: '/sutta/mn3/en/sujato', // Normal path
218
+ cards,
219
+ addCard,
220
+ defaultLang
221
+ });
222
+ should(cards.length).equal(1);
223
+ should(card1.location[0]).match(/mn3/);
224
+
225
+ // Test with hash prefix (shouldn't happen from Vue Router, but test anyway)
226
+ let card2 = cf.pathToCard({
227
+ path: '#/sutta/mn4/en/sujato',
228
+ cards,
229
+ addCard,
230
+ defaultLang
231
+ });
232
+ should(cards.length).equal(2);
233
+ should(card2.location[0]).match(/mn4/);
234
+
235
+ // Test with full URL format including query string (edge case)
236
+ let card3 = cf.pathToCard({
237
+ path: '?src=sc#/sutta/mn5/en/sujato',
238
+ cards,
239
+ addCard,
240
+ defaultLang
241
+ });
242
+ should(cards.length).equal(3);
243
+ should(card3.location[0]).match(/mn5/);
244
+ });
167
245
  it("pathToCard() /#", ()=>{
168
246
  let cf = new CardFactory();
169
247
  let cards = [];