@layla-network/sdk 0.1.3 → 0.1.4
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/dist/index.cjs +15 -9
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +15 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -538,13 +538,15 @@ function oneShot(command, responseEvent, extract, signal) {
|
|
|
538
538
|
|
|
539
539
|
// src/resources/characters.ts
|
|
540
540
|
var Characters = class {
|
|
541
|
-
|
|
542
|
-
* Ask the native host for the available character cards. Resolves once with
|
|
543
|
-
* the host's `on_get_characters_response` payload, or rejects on error/abort.
|
|
544
|
-
*/
|
|
545
|
-
list(options = {}) {
|
|
541
|
+
list(offset = 0, range = 10, options = {}) {
|
|
546
542
|
return oneShot(
|
|
547
|
-
{
|
|
543
|
+
{
|
|
544
|
+
cmd: "get_characters",
|
|
545
|
+
data: {
|
|
546
|
+
offset,
|
|
547
|
+
limit: range
|
|
548
|
+
}
|
|
549
|
+
},
|
|
548
550
|
"on_get_characters_response",
|
|
549
551
|
(event) => {
|
|
550
552
|
const data = event.data;
|
|
@@ -684,13 +686,17 @@ function installLaylaMock(options = {}) {
|
|
|
684
686
|
queueMicrotask(() => emit({ event: "on_message_end" }));
|
|
685
687
|
}
|
|
686
688
|
}
|
|
687
|
-
async function handleGetCharacters() {
|
|
689
|
+
async function handleGetCharacters(data) {
|
|
688
690
|
await delay(latencyMs);
|
|
689
691
|
if (shouldError()) {
|
|
690
692
|
emitError("Simulated characters error");
|
|
691
693
|
return;
|
|
692
694
|
}
|
|
693
|
-
|
|
695
|
+
const { offset, limit } = data;
|
|
696
|
+
emit({
|
|
697
|
+
event: "on_get_characters_response",
|
|
698
|
+
data: characters.slice(offset, offset + limit)
|
|
699
|
+
});
|
|
694
700
|
}
|
|
695
701
|
async function handleGetCharacterImage(data) {
|
|
696
702
|
await delay(latencyMs);
|
|
@@ -750,7 +756,7 @@ function installLaylaMock(options = {}) {
|
|
|
750
756
|
handleCancel();
|
|
751
757
|
break;
|
|
752
758
|
case "get_characters":
|
|
753
|
-
void handleGetCharacters();
|
|
759
|
+
void handleGetCharacters(msg.data);
|
|
754
760
|
break;
|
|
755
761
|
case "get_character_image":
|
|
756
762
|
void handleGetCharacterImage(msg.data);
|
package/dist/index.d.cts
CHANGED
|
@@ -86,6 +86,10 @@ interface LaylaApiSendMessage {
|
|
|
86
86
|
/** Ask the host for the list of available character cards (a one-shot request). */
|
|
87
87
|
interface LaylaApiGetCharacters {
|
|
88
88
|
cmd: 'get_characters';
|
|
89
|
+
data: {
|
|
90
|
+
offset: number;
|
|
91
|
+
limit: number;
|
|
92
|
+
};
|
|
89
93
|
}
|
|
90
94
|
/** Ask the host for a character image identified by <characterId>. */
|
|
91
95
|
interface LaylaApiGetCharacterImage {
|
|
@@ -409,7 +413,7 @@ declare class Characters {
|
|
|
409
413
|
* Ask the native host for the available character cards. Resolves once with
|
|
410
414
|
* the host's `on_get_characters_response` payload, or rejects on error/abort.
|
|
411
415
|
*/
|
|
412
|
-
list(options?: RequestOptions): Promise<LaylaCharacter[]>;
|
|
416
|
+
list(offset?: number, range?: number, options?: RequestOptions): Promise<LaylaCharacter[]>;
|
|
413
417
|
/**
|
|
414
418
|
* Ask the native host for a character portrait. Resolves to a ready-to-use
|
|
415
419
|
* image src string, or null when the character has no image.
|
package/dist/index.d.ts
CHANGED
|
@@ -86,6 +86,10 @@ interface LaylaApiSendMessage {
|
|
|
86
86
|
/** Ask the host for the list of available character cards (a one-shot request). */
|
|
87
87
|
interface LaylaApiGetCharacters {
|
|
88
88
|
cmd: 'get_characters';
|
|
89
|
+
data: {
|
|
90
|
+
offset: number;
|
|
91
|
+
limit: number;
|
|
92
|
+
};
|
|
89
93
|
}
|
|
90
94
|
/** Ask the host for a character image identified by <characterId>. */
|
|
91
95
|
interface LaylaApiGetCharacterImage {
|
|
@@ -409,7 +413,7 @@ declare class Characters {
|
|
|
409
413
|
* Ask the native host for the available character cards. Resolves once with
|
|
410
414
|
* the host's `on_get_characters_response` payload, or rejects on error/abort.
|
|
411
415
|
*/
|
|
412
|
-
list(options?: RequestOptions): Promise<LaylaCharacter[]>;
|
|
416
|
+
list(offset?: number, range?: number, options?: RequestOptions): Promise<LaylaCharacter[]>;
|
|
413
417
|
/**
|
|
414
418
|
* Ask the native host for a character portrait. Resolves to a ready-to-use
|
|
415
419
|
* image src string, or null when the character has no image.
|
package/dist/index.js
CHANGED
|
@@ -503,13 +503,15 @@ function oneShot(command, responseEvent, extract, signal) {
|
|
|
503
503
|
|
|
504
504
|
// src/resources/characters.ts
|
|
505
505
|
var Characters = class {
|
|
506
|
-
|
|
507
|
-
* Ask the native host for the available character cards. Resolves once with
|
|
508
|
-
* the host's `on_get_characters_response` payload, or rejects on error/abort.
|
|
509
|
-
*/
|
|
510
|
-
list(options = {}) {
|
|
506
|
+
list(offset = 0, range = 10, options = {}) {
|
|
511
507
|
return oneShot(
|
|
512
|
-
{
|
|
508
|
+
{
|
|
509
|
+
cmd: "get_characters",
|
|
510
|
+
data: {
|
|
511
|
+
offset,
|
|
512
|
+
limit: range
|
|
513
|
+
}
|
|
514
|
+
},
|
|
513
515
|
"on_get_characters_response",
|
|
514
516
|
(event) => {
|
|
515
517
|
const data = event.data;
|
|
@@ -649,13 +651,17 @@ function installLaylaMock(options = {}) {
|
|
|
649
651
|
queueMicrotask(() => emit({ event: "on_message_end" }));
|
|
650
652
|
}
|
|
651
653
|
}
|
|
652
|
-
async function handleGetCharacters() {
|
|
654
|
+
async function handleGetCharacters(data) {
|
|
653
655
|
await delay(latencyMs);
|
|
654
656
|
if (shouldError()) {
|
|
655
657
|
emitError("Simulated characters error");
|
|
656
658
|
return;
|
|
657
659
|
}
|
|
658
|
-
|
|
660
|
+
const { offset, limit } = data;
|
|
661
|
+
emit({
|
|
662
|
+
event: "on_get_characters_response",
|
|
663
|
+
data: characters.slice(offset, offset + limit)
|
|
664
|
+
});
|
|
659
665
|
}
|
|
660
666
|
async function handleGetCharacterImage(data) {
|
|
661
667
|
await delay(latencyMs);
|
|
@@ -715,7 +721,7 @@ function installLaylaMock(options = {}) {
|
|
|
715
721
|
handleCancel();
|
|
716
722
|
break;
|
|
717
723
|
case "get_characters":
|
|
718
|
-
void handleGetCharacters();
|
|
724
|
+
void handleGetCharacters(msg.data);
|
|
719
725
|
break;
|
|
720
726
|
case "get_character_image":
|
|
721
727
|
void handleGetCharacterImage(msg.data);
|