@litert-lm/core 0.16.0 → 0.17.0

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.
Files changed (106) hide show
  1. package/README.md +164 -0
  2. package/dist/cleanup.d.ts +25 -0
  3. package/dist/cleanup.d.ts.map +1 -0
  4. package/dist/cleanup.js +36 -0
  5. package/dist/cleanup.js.map +1 -0
  6. package/dist/conversation.d.ts +51 -0
  7. package/dist/conversation.d.ts.map +1 -0
  8. package/dist/conversation.js +171 -0
  9. package/dist/conversation.js.map +1 -0
  10. package/dist/conversation_config.d.ts +153 -0
  11. package/dist/conversation_config.d.ts.map +1 -0
  12. package/dist/conversation_config.js +17 -0
  13. package/dist/conversation_config.js.map +1 -0
  14. package/dist/engine.d.ts +37 -0
  15. package/dist/engine.d.ts.map +1 -0
  16. package/dist/engine.js +203 -0
  17. package/dist/engine.js.map +1 -0
  18. package/dist/engine_settings.d.ts +57 -0
  19. package/dist/engine_settings.d.ts.map +1 -0
  20. package/dist/engine_settings.js +114 -0
  21. package/dist/engine_settings.js.map +1 -0
  22. package/dist/global_litertlm.d.ts +66 -0
  23. package/dist/global_litertlm.d.ts.map +1 -0
  24. package/dist/global_litertlm.js +85 -0
  25. package/dist/global_litertlm.js.map +1 -0
  26. package/dist/index.d.ts +31 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +31 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/litertlm_web.d.ts +32 -0
  31. package/dist/litertlm_web.d.ts.map +1 -0
  32. package/dist/litertlm_web.js +75 -0
  33. package/dist/litertlm_web.js.map +1 -0
  34. package/dist/load.d.ts +28 -0
  35. package/dist/load.d.ts.map +1 -0
  36. package/dist/load.js +50 -0
  37. package/dist/load.js.map +1 -0
  38. package/dist/load_litertlm.d.ts +58 -0
  39. package/dist/load_litertlm.d.ts.map +1 -0
  40. package/dist/load_litertlm.js +87 -0
  41. package/dist/load_litertlm.js.map +1 -0
  42. package/dist/mutex.d.ts +45 -0
  43. package/dist/mutex.d.ts.map +1 -0
  44. package/dist/mutex.js +62 -0
  45. package/dist/mutex.js.map +1 -0
  46. package/dist/orchestration/auto_tool_chat.d.ts +82 -0
  47. package/dist/orchestration/auto_tool_chat.d.ts.map +1 -0
  48. package/dist/orchestration/auto_tool_chat.js +304 -0
  49. package/dist/orchestration/auto_tool_chat.js.map +1 -0
  50. package/dist/orchestration/chat_interface.d.ts +30 -0
  51. package/dist/orchestration/chat_interface.d.ts.map +1 -0
  52. package/dist/orchestration/chat_interface.js +17 -0
  53. package/dist/orchestration/chat_interface.js.map +1 -0
  54. package/dist/orchestration/webmcp_tool.d.ts +41 -0
  55. package/dist/orchestration/webmcp_tool.d.ts.map +1 -0
  56. package/dist/orchestration/webmcp_tool.js +32 -0
  57. package/dist/orchestration/webmcp_tool.js.map +1 -0
  58. package/dist/readable_stream_data_stream_wrapper.d.ts +44 -0
  59. package/dist/readable_stream_data_stream_wrapper.d.ts.map +1 -0
  60. package/dist/readable_stream_data_stream_wrapper.js +315 -0
  61. package/dist/readable_stream_data_stream_wrapper.js.map +1 -0
  62. package/dist/session.d.ts +51 -0
  63. package/dist/session.d.ts.map +1 -0
  64. package/dist/session.js +107 -0
  65. package/dist/session.js.map +1 -0
  66. package/dist/session_config.d.ts +60 -0
  67. package/dist/session_config.d.ts.map +1 -0
  68. package/dist/session_config.js +109 -0
  69. package/dist/session_config.js.map +1 -0
  70. package/dist/testing/fakes.d.ts +67 -0
  71. package/dist/testing/fakes.d.ts.map +1 -0
  72. package/dist/testing/fakes.js +125 -0
  73. package/dist/testing/fakes.js.map +1 -0
  74. package/dist/testing/index.d.ts +17 -0
  75. package/dist/testing/index.d.ts.map +1 -0
  76. package/dist/testing/index.js +17 -0
  77. package/dist/testing/index.js.map +1 -0
  78. package/dist/types.d.ts +42 -0
  79. package/dist/types.d.ts.map +1 -0
  80. package/dist/types.js +17 -0
  81. package/dist/types.js.map +1 -0
  82. package/dist/url_path_utils.d.ts +28 -0
  83. package/dist/url_path_utils.d.ts.map +1 -0
  84. package/dist/url_path_utils.js +34 -0
  85. package/dist/url_path_utils.js.map +1 -0
  86. package/dist/wasm_binding_types.d.ts +379 -0
  87. package/dist/wasm_binding_types.d.ts.map +1 -0
  88. package/dist/wasm_binding_types.js +39 -0
  89. package/dist/wasm_binding_types.js.map +1 -0
  90. package/dist/wasm_feature_detect.d.ts +45 -0
  91. package/dist/wasm_feature_detect.d.ts.map +1 -0
  92. package/dist/wasm_feature_detect.js +139 -0
  93. package/dist/wasm_feature_detect.js.map +1 -0
  94. package/dist/wasm_utils.d.ts +30 -0
  95. package/dist/wasm_utils.d.ts.map +1 -0
  96. package/dist/wasm_utils.js +41 -0
  97. package/dist/wasm_utils.js.map +1 -0
  98. package/package.json +1 -1
  99. package/wasm/litertlm_wasm_asyncify_internal.js +8724 -0
  100. package/wasm/litertlm_wasm_asyncify_internal.wasm +0 -0
  101. package/wasm/litertlm_wasm_compat_asyncify_internal.js +8733 -0
  102. package/wasm/litertlm_wasm_compat_asyncify_internal.wasm +0 -0
  103. package/wasm/litertlm_wasm_compat_internal.js +8521 -0
  104. package/wasm/litertlm_wasm_compat_internal.wasm +0 -0
  105. package/wasm/litertlm_wasm_internal.js +8510 -0
  106. package/wasm/litertlm_wasm_internal.wasm +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session_config.js","sourceRoot":"","sources":["../src/session_config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAU,WAAW,EAAqC,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAC,8BAA8B,EAAE,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AAErF,4DAA4D;AAC5D,OAAO,EAAC,WAAW,EAAC,CAAC;AAkCrB;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC5C,aAA4B,EAC5B,IAAI,GAAG,iBAAiB,EAAE,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CAAC;QACD,iBAAiB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC5C,QAAQ,CAAC,MAAM,EAAE,CAAC;IACpB,CAAC;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC5C,iBAAoC;IACtC,MAAM,aAAa,GAAG,iBAAiB,CAAC,uBAAuB,EAAE,CAAC;IAElE,OAAO;QACL,oBAAoB,EAAE,iBAAiB,CAAC,uBAAuB,EAAE;QACjE,qBAAqB,EAAE,iBAAiB,CAAC,wBAAwB,EAAE;QACnE,aAAa,EAAE;YACb,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,KAAK;YAChC,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE;YACpB,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE;YACpB,WAAW,EAAE,aAAa,CAAC,WAAW,EAAE;YACxC,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE;SAC3B;QACD,YAAY,EACR,8BAA8B,CAAC,iBAAiB,CAAC,eAAe,EAAE,CAAC;aAC9D,GAAG,CAAC,8BAA8B,CAAC;QAC5C,YAAY,EAAE,iBAAiB,CAAC,eAAe,EAAE;QACjD,mBAAmB,EAAE,iBAAiB,CAAC,sBAAsB,EAAE;QAC/D,cAAc,EAAE,iBAAiB,CAAC,iBAAiB,EAAE,CAAC,KAAK;QAC3D,4BAA4B,EACxB,iBAAiB,CAAC,+BAA+B,EAAE;QACvD,kBAAkB,EAAE,iBAAiB,CAAC,qBAAqB,EAAE;QAC7D,eAAe,EAAE,iBAAiB,CAAC,kBAAkB,EAAE;KACxD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { ChatInterface } from '../orchestration/chat_interface.js';
17
+ import type { Conversation } from '../conversation.js';
18
+ import type { ConversationConfig, Message, MessageLike } from '../conversation_config.js';
19
+ import type { Engine } from '../engine.js';
20
+ import type { EngineSettings } from '../engine_settings.js';
21
+ import type { Session } from '../session.js';
22
+ import type { SessionConfig } from '../session_config.js';
23
+ import type { RecursiveRequired } from '../types.js';
24
+ import type { BenchmarkInfo } from '../wasm_binding_types.js';
25
+ /** Fake implementation of Conversation for testing. */
26
+ export declare class ConversationFake implements ChatInterface {
27
+ initialHistory: Message[];
28
+ history: Message[];
29
+ nextResponses: Message[];
30
+ constructor(initialHistory?: Message[]);
31
+ /**
32
+ * Enqueues a message that the fake will return on the next call to
33
+ * sendMessage or sendMessageStreaming. Can be called multiple times.
34
+ */
35
+ queueResponse(message: Message): void;
36
+ private popNextResponse;
37
+ private appendInput;
38
+ sendMessage(message: MessageLike | MessageLike[]): Promise<Message>;
39
+ sendMessageStreaming(message: MessageLike | MessageLike[]): ReadableStream<Message>;
40
+ getHistory(): Message[];
41
+ cancel(): void;
42
+ delete(): Promise<void>;
43
+ getTokenCount(): Promise<number>;
44
+ getBenchmarkInfo(): Promise<BenchmarkInfo>;
45
+ clone(): Conversation;
46
+ }
47
+ /** Fake implementation of Session for testing. */
48
+ export declare class SessionFake {
49
+ inputsPrefilled: string[];
50
+ runPrefill(inputs: string[]): Promise<void>;
51
+ runDecode(): ReturnType<Session['runDecode']>;
52
+ cancel(): void;
53
+ clone(): Session;
54
+ delete(): Promise<void>;
55
+ }
56
+ /** Fake implementation of Engine for testing. */
57
+ export declare class EngineFake {
58
+ readonly settings: RecursiveRequired<EngineSettings>;
59
+ cachedSession: SessionFake;
60
+ cachedConversation: ConversationFake;
61
+ constructor(settings: EngineSettings);
62
+ static create(engineSettings: EngineSettings, inputPromptAsHint?: string): Promise<Engine>;
63
+ createSession(sessionConfig?: SessionConfig): Promise<Session>;
64
+ createConversation(config?: ConversationConfig): Promise<Conversation>;
65
+ delete(): Promise<void>;
66
+ }
67
+ //# sourceMappingURL=fakes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fakes.d.ts","sourceRoot":"","sources":["../../src/testing/fakes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAC,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,2BAA2B,CAAC;AACxF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE5D,uDAAuD;AACvD,qBAAa,gBAAiB,YAAW,aAAa;IAIjC,cAAc,EAAE,OAAO,EAAE;IAH5C,OAAO,EAAE,OAAO,EAAE,CAAM;IACxB,aAAa,EAAE,OAAO,EAAE,CAAM;gBAEX,cAAc,GAAE,OAAO,EAAO;IAIjD;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO;IAI9B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,WAAW;IAab,WAAW,CAAC,OAAO,EAAE,WAAW,GAAC,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAOvE,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAC,WAAW,EAAE,GACnD,cAAc,CAAC,OAAO,CAAC;IAY3B,UAAU,IAAI,OAAO,EAAE;IAIvB,MAAM;IAEA,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;IAUhD,KAAK,IAAI,YAAY;CAKtB;AAED,kDAAkD;AAClD,qBAAa,WAAW;IACtB,eAAe,EAAE,MAAM,EAAE,CAAM;IAEzB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C,SAAS,IAAI,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAKnD,MAAM;IAEN,KAAK,IAAI,OAAO;IAMV,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAC9B;AAED,iDAAiD;AACjD,qBAAa,UAAU;IACrB,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACrD,aAAa,cAAqB;IAClC,kBAAkB,mBAA0B;gBAEhC,QAAQ,EAAE,cAAc;WAIvB,MAAM,CAAC,cAAc,EAAE,cAAc,EAAE,iBAAiB,SAAK,GACtE,OAAO,CAAC,MAAM,CAAC;IAIb,aAAa,CAAC,aAAa,GAAE,aAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlE,kBAAkB,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAItE,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAC9B"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /** Fake implementation of Conversation for testing. */
17
+ export class ConversationFake {
18
+ initialHistory;
19
+ history = [];
20
+ nextResponses = [];
21
+ constructor(initialHistory = []) {
22
+ this.initialHistory = initialHistory;
23
+ this.history = [...initialHistory];
24
+ }
25
+ /**
26
+ * Enqueues a message that the fake will return on the next call to
27
+ * sendMessage or sendMessageStreaming. Can be called multiple times.
28
+ */
29
+ queueResponse(message) {
30
+ this.nextResponses.push(message);
31
+ }
32
+ popNextResponse() {
33
+ if (this.nextResponses.length > 0) {
34
+ return this.nextResponses.shift();
35
+ }
36
+ return { role: 'model', content: 'hello from fake' };
37
+ }
38
+ appendInput(message) {
39
+ if (Array.isArray(message)) {
40
+ this.history.push(...message.map(m => typeof m === 'string' ? { role: 'user', content: m } :
41
+ m));
42
+ }
43
+ else {
44
+ this.history.push(typeof message === 'string' ?
45
+ { role: 'user', content: message } :
46
+ message);
47
+ }
48
+ }
49
+ async sendMessage(message) {
50
+ this.appendInput(message);
51
+ const newMessage = this.popNextResponse();
52
+ this.history.push(newMessage);
53
+ return newMessage;
54
+ }
55
+ sendMessageStreaming(message) {
56
+ this.appendInput(message);
57
+ return new ReadableStream({
58
+ start: (controller) => {
59
+ const newMessage = this.popNextResponse();
60
+ this.history.push(newMessage);
61
+ controller.enqueue(newMessage);
62
+ controller.close();
63
+ }
64
+ });
65
+ }
66
+ getHistory() {
67
+ return [...this.history];
68
+ }
69
+ cancel() { }
70
+ async delete() { }
71
+ async getTokenCount() {
72
+ return this.history.length * 10;
73
+ }
74
+ async getBenchmarkInfo() {
75
+ return {
76
+ lastPrefillTokensPerSecond: 0,
77
+ lastPrefillTokenCount: 0,
78
+ lastDecodeTokensPerSecond: 0,
79
+ lastDecodeTokenCount: 0,
80
+ timeToFirstTokenInSecond: 0,
81
+ };
82
+ }
83
+ clone() {
84
+ const cloned = new ConversationFake([...this.history]);
85
+ cloned.nextResponses = [...this.nextResponses];
86
+ return cloned;
87
+ }
88
+ }
89
+ /** Fake implementation of Session for testing. */
90
+ export class SessionFake {
91
+ inputsPrefilled = [];
92
+ async runPrefill(inputs) {
93
+ this.inputsPrefilled.push(...inputs);
94
+ }
95
+ async runDecode() {
96
+ return { getTexts: () => ['decoded response'], delete: () => { } };
97
+ }
98
+ cancel() { }
99
+ clone() {
100
+ const cloned = new SessionFake();
101
+ cloned.inputsPrefilled = [...this.inputsPrefilled];
102
+ return cloned;
103
+ }
104
+ async delete() { }
105
+ }
106
+ /** Fake implementation of Engine for testing. */
107
+ export class EngineFake {
108
+ settings;
109
+ cachedSession = new SessionFake();
110
+ cachedConversation = new ConversationFake();
111
+ constructor(settings) {
112
+ this.settings = settings;
113
+ }
114
+ static async create(engineSettings, inputPromptAsHint = '') {
115
+ return new EngineFake(engineSettings);
116
+ }
117
+ async createSession(sessionConfig = {}) {
118
+ return this.cachedSession;
119
+ }
120
+ async createConversation(config) {
121
+ return this.cachedConversation;
122
+ }
123
+ async delete() { }
124
+ }
125
+ //# sourceMappingURL=fakes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fakes.js","sourceRoot":"","sources":["../../src/testing/fakes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,uDAAuD;AACvD,MAAM,OAAO,gBAAgB;IAIR;IAHnB,OAAO,GAAc,EAAE,CAAC;IACxB,aAAa,GAAc,EAAE,CAAC;IAE9B,YAAmB,iBAA4B,EAAE;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAC/C,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,OAAgB;QAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CA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,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,MAAM,CAAC,eAAe,GAAG,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,OAAO,MAA4B,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,MAAM,KAAmB,CAAC;CACjC;AAED,iDAAiD;AACjD,MAAM,OAAO,UAAU;IACZ,QAAQ,CAAoC;IACrD,aAAa,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,kBAAkB,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAE5C,YAAY,QAAwB;QAClC,IAAI,CAAC,QAAQ,GAAG,QAA6C,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,cAA8B,EAAE,iBAAiB,GAAG,EAAE;QAExE,OAAO,IAAI,UAAU,CAAC,cAAc,CAAsB,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,gBAA+B,EAAE;QACnD,OAAO,IAAI,CAAC,aAAmC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,MAA2B;QAClD,OAAO,IAAI,CAAC,kBAA6C,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,MAAM,KAAmB,CAAC;CACjC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './fakes.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,YAAY,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './fakes.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,YAAY,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Recursively makes all properties of T required.
18
+ */
19
+ export type RecursiveRequired<T> = T extends Set<infer U> ? Set<RecursiveRequired<U>> : T extends object ? {
20
+ [K in keyof T]-?: RecursiveRequired<T[K]>;
21
+ } : T;
22
+ /**
23
+ * Primitive JSON value.
24
+ *
25
+ * This includes 'null' in order to match the JSON spec.
26
+ */
27
+ export type JsonPrimitive = string | number | boolean | null;
28
+ /**
29
+ * Array of JSON values.
30
+ */
31
+ export type JsonArray = JsonValue[];
32
+ /**
33
+ * Object of JSON values.
34
+ */
35
+ export interface JsonObject {
36
+ [key: string]: JsonValue | undefined;
37
+ }
38
+ /**
39
+ * Any valid JSON value.
40
+ */
41
+ export type JsonValue = JsonPrimitive | JsonArray | JsonObject;
42
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAC7B,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAClD,CAAC,SAAS,MAAM,GAAG;KAClB,CAAC,IAAI,MAAM,CAAC,CAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3C,GAAG,CAAC,CAAC;AAEN;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,IAAI,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAC,SAAS,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAC,SAAS,GAAC,UAAU,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Type for a path to a resource.
18
+ */
19
+ export type UrlPath = string;
20
+ /**
21
+ * Returns the string representation of the given url path.
22
+ */
23
+ export declare function pathToString(path: UrlPath): string;
24
+ /**
25
+ * Appends a path segment to the given url path.
26
+ */
27
+ export declare function appendPathSegment(path: UrlPath, segment: string): string;
28
+ //# sourceMappingURL=url_path_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url_path_utils.d.ts","sourceRoot":"","sources":["../src/url_path_utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQxE"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Returns the string representation of the given url path.
18
+ */
19
+ export function pathToString(path) {
20
+ return path;
21
+ }
22
+ /**
23
+ * Appends a path segment to the given url path.
24
+ */
25
+ export function appendPathSegment(path, segment) {
26
+ if (!path)
27
+ return segment;
28
+ if (!segment)
29
+ return path;
30
+ const pathWithSlash = path.endsWith('/') ? path : path + '/';
31
+ const segmentWithoutSlash = segment.startsWith('/') ? segment.substring(1) : segment;
32
+ return pathWithSlash + segmentWithoutSlash;
33
+ }
34
+ //# sourceMappingURL=url_path_utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url_path_utils.js","sourceRoot":"","sources":["../src/url_path_utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAa;IACxC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa,EAAE,OAAe;IAC9D,IAAI,CAAC,IAAI;QAAE,OAAO,OAAO,CAAC;IAC1B,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC;IAC7D,MAAM,mBAAmB,GACrB,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7D,OAAO,aAAa,GAAG,mBAAmB,CAAC;AAC7C,CAAC"}