@xpert-ai/chatkit-types 0.0.5 → 0.0.7
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.d.ts +22 -18
- package/dist/index.js +2 -2118
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2124 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
throw TypeError(msg);
|
|
4
|
-
};
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
11
|
-
var _a, _collection, _storages, _SignalArray_instances, readStorageFor_fn, dirtyStorageFor_fn;
|
|
12
|
-
var __defProp$1 = Object.defineProperty;
|
|
13
|
-
var __export = (target, all) => {
|
|
14
|
-
for (var name in all) __defProp$1(target, name, {
|
|
15
|
-
get: all[name],
|
|
16
|
-
enumerable: true
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
function getDefaultExportFromCjs(x) {
|
|
20
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
21
|
-
}
|
|
22
|
-
var decamelize = function(str, sep) {
|
|
23
|
-
if (typeof str !== "string") {
|
|
24
|
-
throw new TypeError("Expected a string");
|
|
25
|
-
}
|
|
26
|
-
sep = typeof sep === "undefined" ? "_" : sep;
|
|
27
|
-
return str.replace(/([a-z\d])([A-Z])/g, "$1" + sep + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + sep + "$2").toLowerCase();
|
|
28
|
-
};
|
|
29
|
-
const snakeCase = /* @__PURE__ */ getDefaultExportFromCjs(decamelize);
|
|
30
|
-
var camelcase = { exports: {} };
|
|
31
|
-
const UPPERCASE = /[\p{Lu}]/u;
|
|
32
|
-
const LOWERCASE = /[\p{Ll}]/u;
|
|
33
|
-
const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
|
|
34
|
-
const IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
|
|
35
|
-
const SEPARATORS = /[_.\- ]+/;
|
|
36
|
-
const LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
|
|
37
|
-
const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
|
|
38
|
-
const NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
|
|
39
|
-
const preserveCamelCase = (string, toLowerCase, toUpperCase) => {
|
|
40
|
-
let isLastCharLower = false;
|
|
41
|
-
let isLastCharUpper = false;
|
|
42
|
-
let isLastLastCharUpper = false;
|
|
43
|
-
for (let i = 0; i < string.length; i++) {
|
|
44
|
-
const character = string[i];
|
|
45
|
-
if (isLastCharLower && UPPERCASE.test(character)) {
|
|
46
|
-
string = string.slice(0, i) + "-" + string.slice(i);
|
|
47
|
-
isLastCharLower = false;
|
|
48
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
49
|
-
isLastCharUpper = true;
|
|
50
|
-
i++;
|
|
51
|
-
} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character)) {
|
|
52
|
-
string = string.slice(0, i - 1) + "-" + string.slice(i - 1);
|
|
53
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
54
|
-
isLastCharUpper = false;
|
|
55
|
-
isLastCharLower = true;
|
|
56
|
-
} else {
|
|
57
|
-
isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
|
|
58
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
59
|
-
isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return string;
|
|
63
|
-
};
|
|
64
|
-
const preserveConsecutiveUppercase = (input, toLowerCase) => {
|
|
65
|
-
LEADING_CAPITAL.lastIndex = 0;
|
|
66
|
-
return input.replace(LEADING_CAPITAL, (m1) => toLowerCase(m1));
|
|
67
|
-
};
|
|
68
|
-
const postProcess = (input, toUpperCase) => {
|
|
69
|
-
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
|
|
70
|
-
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
|
71
|
-
return input.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier)).replace(NUMBERS_AND_IDENTIFIER, (m) => toUpperCase(m));
|
|
72
|
-
};
|
|
73
|
-
const camelCase = (input, options) => {
|
|
74
|
-
if (!(typeof input === "string" || Array.isArray(input))) {
|
|
75
|
-
throw new TypeError("Expected the input to be `string | string[]`");
|
|
76
|
-
}
|
|
77
|
-
options = {
|
|
78
|
-
pascalCase: false,
|
|
79
|
-
preserveConsecutiveUppercase: false,
|
|
80
|
-
...options
|
|
81
|
-
};
|
|
82
|
-
if (Array.isArray(input)) {
|
|
83
|
-
input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
|
|
84
|
-
} else {
|
|
85
|
-
input = input.trim();
|
|
86
|
-
}
|
|
87
|
-
if (input.length === 0) {
|
|
88
|
-
return "";
|
|
89
|
-
}
|
|
90
|
-
const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
|
|
91
|
-
const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
|
|
92
|
-
if (input.length === 1) {
|
|
93
|
-
return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
|
|
94
|
-
}
|
|
95
|
-
const hasUpperCase = input !== toLowerCase(input);
|
|
96
|
-
if (hasUpperCase) {
|
|
97
|
-
input = preserveCamelCase(input, toLowerCase, toUpperCase);
|
|
98
|
-
}
|
|
99
|
-
input = input.replace(LEADING_SEPARATORS, "");
|
|
100
|
-
if (options.preserveConsecutiveUppercase) {
|
|
101
|
-
input = preserveConsecutiveUppercase(input, toLowerCase);
|
|
102
|
-
} else {
|
|
103
|
-
input = toLowerCase(input);
|
|
104
|
-
}
|
|
105
|
-
if (options.pascalCase) {
|
|
106
|
-
input = toUpperCase(input.charAt(0)) + input.slice(1);
|
|
107
|
-
}
|
|
108
|
-
return postProcess(input, toUpperCase);
|
|
109
|
-
};
|
|
110
|
-
camelcase.exports = camelCase;
|
|
111
|
-
camelcase.exports.default = camelCase;
|
|
112
|
-
function keyToJson(key, map) {
|
|
113
|
-
return (map == null ? void 0 : map[key]) || snakeCase(key);
|
|
114
|
-
}
|
|
115
|
-
function mapKeys(fields, mapper, map) {
|
|
116
|
-
const mapped = {};
|
|
117
|
-
for (const key in fields) if (Object.hasOwn(fields, key)) mapped[mapper(key, map)] = fields[key];
|
|
118
|
-
return mapped;
|
|
119
|
-
}
|
|
120
|
-
var serializable_exports = {};
|
|
121
|
-
__export(serializable_exports, {
|
|
122
|
-
Serializable: () => Serializable,
|
|
123
|
-
get_lc_unique_name: () => get_lc_unique_name
|
|
124
|
-
});
|
|
125
|
-
function shallowCopy(obj) {
|
|
126
|
-
return Array.isArray(obj) ? [...obj] : { ...obj };
|
|
127
|
-
}
|
|
128
|
-
function replaceSecrets(root, secretsMap) {
|
|
129
|
-
const result = shallowCopy(root);
|
|
130
|
-
for (const [path, secretId] of Object.entries(secretsMap)) {
|
|
131
|
-
const [last, ...partsReverse] = path.split(".").reverse();
|
|
132
|
-
let current = result;
|
|
133
|
-
for (const part of partsReverse.reverse()) {
|
|
134
|
-
if (current[part] === void 0) break;
|
|
135
|
-
current[part] = shallowCopy(current[part]);
|
|
136
|
-
current = current[part];
|
|
137
|
-
}
|
|
138
|
-
if (current[last] !== void 0) current[last] = {
|
|
139
|
-
lc: 1,
|
|
140
|
-
type: "secret",
|
|
141
|
-
id: [secretId]
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
function get_lc_unique_name(serializableClass) {
|
|
147
|
-
const parentClass = Object.getPrototypeOf(serializableClass);
|
|
148
|
-
const lcNameIsSubclassed = typeof serializableClass.lc_name === "function" && (typeof parentClass.lc_name !== "function" || serializableClass.lc_name() !== parentClass.lc_name());
|
|
149
|
-
if (lcNameIsSubclassed) return serializableClass.lc_name();
|
|
150
|
-
else return serializableClass.name;
|
|
151
|
-
}
|
|
152
|
-
var Serializable = class Serializable2 {
|
|
153
|
-
constructor(kwargs, ..._args) {
|
|
154
|
-
__publicField(this, "lc_serializable", false);
|
|
155
|
-
__publicField(this, "lc_kwargs");
|
|
156
|
-
if (this.lc_serializable_keys !== void 0) this.lc_kwargs = Object.fromEntries(Object.entries(kwargs || {}).filter(([key]) => {
|
|
157
|
-
var _a2;
|
|
158
|
-
return (_a2 = this.lc_serializable_keys) == null ? void 0 : _a2.includes(key);
|
|
159
|
-
}));
|
|
160
|
-
else this.lc_kwargs = kwargs ?? {};
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* The name of the serializable. Override to provide an alias or
|
|
164
|
-
* to preserve the serialized module name in minified environments.
|
|
165
|
-
*
|
|
166
|
-
* Implemented as a static method to support loading logic.
|
|
167
|
-
*/
|
|
168
|
-
static lc_name() {
|
|
169
|
-
return this.name;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The final serialized identifier for the module.
|
|
173
|
-
*/
|
|
174
|
-
get lc_id() {
|
|
175
|
-
return [...this.lc_namespace, get_lc_unique_name(this.constructor)];
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* A map of secrets, which will be omitted from serialization.
|
|
179
|
-
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
180
|
-
* Values are the secret ids, which will be used when deserializing.
|
|
181
|
-
*/
|
|
182
|
-
get lc_secrets() {
|
|
183
|
-
return void 0;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* A map of additional attributes to merge with constructor args.
|
|
187
|
-
* Keys are the attribute names, e.g. "foo".
|
|
188
|
-
* Values are the attribute values, which will be serialized.
|
|
189
|
-
* These attributes need to be accepted by the constructor as arguments.
|
|
190
|
-
*/
|
|
191
|
-
get lc_attributes() {
|
|
192
|
-
return void 0;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* A map of aliases for constructor args.
|
|
196
|
-
* Keys are the attribute names, e.g. "foo".
|
|
197
|
-
* Values are the alias that will replace the key in serialization.
|
|
198
|
-
* This is used to eg. make argument names match Python.
|
|
199
|
-
*/
|
|
200
|
-
get lc_aliases() {
|
|
201
|
-
return void 0;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* A manual list of keys that should be serialized.
|
|
205
|
-
* If not overridden, all fields passed into the constructor will be serialized.
|
|
206
|
-
*/
|
|
207
|
-
get lc_serializable_keys() {
|
|
208
|
-
return void 0;
|
|
209
|
-
}
|
|
210
|
-
toJSON() {
|
|
211
|
-
if (!this.lc_serializable) return this.toJSONNotImplemented();
|
|
212
|
-
if (this.lc_kwargs instanceof Serializable2 || typeof this.lc_kwargs !== "object" || Array.isArray(this.lc_kwargs)) return this.toJSONNotImplemented();
|
|
213
|
-
const aliases = {};
|
|
214
|
-
const secrets = {};
|
|
215
|
-
const kwargs = Object.keys(this.lc_kwargs).reduce((acc, key) => {
|
|
216
|
-
acc[key] = key in this ? this[key] : this.lc_kwargs[key];
|
|
217
|
-
return acc;
|
|
218
|
-
}, {});
|
|
219
|
-
for (let current = Object.getPrototypeOf(this); current; current = Object.getPrototypeOf(current)) {
|
|
220
|
-
Object.assign(aliases, Reflect.get(current, "lc_aliases", this));
|
|
221
|
-
Object.assign(secrets, Reflect.get(current, "lc_secrets", this));
|
|
222
|
-
Object.assign(kwargs, Reflect.get(current, "lc_attributes", this));
|
|
223
|
-
}
|
|
224
|
-
Object.keys(secrets).forEach((keyPath) => {
|
|
225
|
-
let read = this;
|
|
226
|
-
let write = kwargs;
|
|
227
|
-
const [last, ...partsReverse] = keyPath.split(".").reverse();
|
|
228
|
-
for (const key of partsReverse.reverse()) {
|
|
229
|
-
if (!(key in read) || read[key] === void 0) return;
|
|
230
|
-
if (!(key in write) || write[key] === void 0) {
|
|
231
|
-
if (typeof read[key] === "object" && read[key] != null) write[key] = {};
|
|
232
|
-
else if (Array.isArray(read[key])) write[key] = [];
|
|
233
|
-
}
|
|
234
|
-
read = read[key];
|
|
235
|
-
write = write[key];
|
|
236
|
-
}
|
|
237
|
-
if (last in read && read[last] !== void 0) write[last] = write[last] || read[last];
|
|
238
|
-
});
|
|
239
|
-
return {
|
|
240
|
-
lc: 1,
|
|
241
|
-
type: "constructor",
|
|
242
|
-
id: this.lc_id,
|
|
243
|
-
kwargs: mapKeys(Object.keys(secrets).length ? replaceSecrets(kwargs, secrets) : kwargs, keyToJson, aliases)
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
toJSONNotImplemented() {
|
|
247
|
-
return {
|
|
248
|
-
lc: 1,
|
|
249
|
-
type: "not_implemented",
|
|
250
|
-
id: this.lc_id
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
function isDataContentBlock(content_block) {
|
|
255
|
-
return typeof content_block === "object" && content_block !== null && "type" in content_block && typeof content_block.type === "string" && "source_type" in content_block && (content_block.source_type === "url" || content_block.source_type === "base64" || content_block.source_type === "text" || content_block.source_type === "id");
|
|
256
|
-
}
|
|
257
|
-
function isURLContentBlock(content_block) {
|
|
258
|
-
return isDataContentBlock(content_block) && content_block.source_type === "url" && "url" in content_block && typeof content_block.url === "string";
|
|
259
|
-
}
|
|
260
|
-
function isBase64ContentBlock(content_block) {
|
|
261
|
-
return isDataContentBlock(content_block) && content_block.source_type === "base64" && "data" in content_block && typeof content_block.data === "string";
|
|
262
|
-
}
|
|
263
|
-
function isIDContentBlock(content_block) {
|
|
264
|
-
return isDataContentBlock(content_block) && content_block.source_type === "id" && "id" in content_block && typeof content_block.id === "string";
|
|
265
|
-
}
|
|
266
|
-
function parseBase64DataUrl({ dataUrl: data_url, asTypedArray = false }) {
|
|
267
|
-
const formatMatch = data_url.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/);
|
|
268
|
-
let mime_type;
|
|
269
|
-
if (formatMatch) {
|
|
270
|
-
mime_type = formatMatch[1].toLowerCase();
|
|
271
|
-
const data = asTypedArray ? Uint8Array.from(atob(formatMatch[2]), (c) => c.charCodeAt(0)) : formatMatch[2];
|
|
272
|
-
return {
|
|
273
|
-
mime_type,
|
|
274
|
-
data
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
return void 0;
|
|
278
|
-
}
|
|
279
|
-
function _isContentBlock(block, type) {
|
|
280
|
-
return _isObject(block) && block.type === type;
|
|
281
|
-
}
|
|
282
|
-
function _isObject(value) {
|
|
283
|
-
return typeof value === "object" && value !== null;
|
|
284
|
-
}
|
|
285
|
-
function _isString(value) {
|
|
286
|
-
return typeof value === "string";
|
|
287
|
-
}
|
|
288
|
-
function convertToV1FromAnthropicContentBlock(block) {
|
|
289
|
-
if (_isContentBlock(block, "document") && _isObject(block.source) && "type" in block.source) {
|
|
290
|
-
if (block.source.type === "base64" && _isString(block.source.media_type) && _isString(block.source.data)) return {
|
|
291
|
-
type: "file",
|
|
292
|
-
mimeType: block.source.media_type,
|
|
293
|
-
data: block.source.data
|
|
294
|
-
};
|
|
295
|
-
else if (block.source.type === "url" && _isString(block.source.url)) return {
|
|
296
|
-
type: "file",
|
|
297
|
-
url: block.source.url
|
|
298
|
-
};
|
|
299
|
-
else if (block.source.type === "file" && _isString(block.source.file_id)) return {
|
|
300
|
-
type: "file",
|
|
301
|
-
fileId: block.source.file_id
|
|
302
|
-
};
|
|
303
|
-
else if (block.source.type === "text" && _isString(block.source.data)) return {
|
|
304
|
-
type: "file",
|
|
305
|
-
mimeType: String(block.source.media_type ?? "text/plain"),
|
|
306
|
-
data: block.source.data
|
|
307
|
-
};
|
|
308
|
-
} else if (_isContentBlock(block, "image") && _isObject(block.source) && "type" in block.source) {
|
|
309
|
-
if (block.source.type === "base64" && _isString(block.source.media_type) && _isString(block.source.data)) return {
|
|
310
|
-
type: "image",
|
|
311
|
-
mimeType: block.source.media_type,
|
|
312
|
-
data: block.source.data
|
|
313
|
-
};
|
|
314
|
-
else if (block.source.type === "url" && _isString(block.source.url)) return {
|
|
315
|
-
type: "image",
|
|
316
|
-
url: block.source.url
|
|
317
|
-
};
|
|
318
|
-
else if (block.source.type === "file" && _isString(block.source.file_id)) return {
|
|
319
|
-
type: "image",
|
|
320
|
-
fileId: block.source.file_id
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
return void 0;
|
|
324
|
-
}
|
|
325
|
-
function convertToV1FromAnthropicInput(content) {
|
|
326
|
-
function* iterateContent() {
|
|
327
|
-
for (const block of content) {
|
|
328
|
-
const stdBlock = convertToV1FromAnthropicContentBlock(block);
|
|
329
|
-
if (stdBlock) yield stdBlock;
|
|
330
|
-
else yield block;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return Array.from(iterateContent());
|
|
334
|
-
}
|
|
335
|
-
function convertToV1FromDataContentBlock(block) {
|
|
336
|
-
if (isURLContentBlock(block)) return {
|
|
337
|
-
type: block.type,
|
|
338
|
-
mimeType: block.mime_type,
|
|
339
|
-
url: block.url,
|
|
340
|
-
metadata: block.metadata
|
|
341
|
-
};
|
|
342
|
-
if (isBase64ContentBlock(block)) return {
|
|
343
|
-
type: block.type,
|
|
344
|
-
mimeType: block.mime_type ?? "application/octet-stream",
|
|
345
|
-
data: block.data,
|
|
346
|
-
metadata: block.metadata
|
|
347
|
-
};
|
|
348
|
-
if (isIDContentBlock(block)) return {
|
|
349
|
-
type: block.type,
|
|
350
|
-
mimeType: block.mime_type,
|
|
351
|
-
fileId: block.id,
|
|
352
|
-
metadata: block.metadata
|
|
353
|
-
};
|
|
354
|
-
return block;
|
|
355
|
-
}
|
|
356
|
-
function convertToV1FromDataContent(content) {
|
|
357
|
-
return content.map(convertToV1FromDataContentBlock);
|
|
358
|
-
}
|
|
359
|
-
function isOpenAIDataBlock(block) {
|
|
360
|
-
if (_isContentBlock(block, "image_url") && _isObject(block.image_url)) return true;
|
|
361
|
-
if (_isContentBlock(block, "input_audio") && _isObject(block.input_audio)) return true;
|
|
362
|
-
if (_isContentBlock(block, "file") && _isObject(block.file)) return true;
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
function convertToV1FromOpenAIDataBlock(block) {
|
|
366
|
-
if (_isContentBlock(block, "image_url") && _isObject(block.image_url) && _isString(block.image_url.url)) {
|
|
367
|
-
const parsed = parseBase64DataUrl({ dataUrl: block.image_url.url });
|
|
368
|
-
if (parsed) return {
|
|
369
|
-
type: "image",
|
|
370
|
-
mimeType: parsed.mime_type,
|
|
371
|
-
data: parsed.data
|
|
372
|
-
};
|
|
373
|
-
else return {
|
|
374
|
-
type: "image",
|
|
375
|
-
url: block.image_url.url
|
|
376
|
-
};
|
|
377
|
-
} else if (_isContentBlock(block, "input_audio") && _isObject(block.input_audio) && _isString(block.input_audio.data) && _isString(block.input_audio.format)) return {
|
|
378
|
-
type: "audio",
|
|
379
|
-
data: block.input_audio.data,
|
|
380
|
-
mimeType: `audio/${block.input_audio.format}`
|
|
381
|
-
};
|
|
382
|
-
else if (_isContentBlock(block, "file") && _isObject(block.file) && _isString(block.file.data)) {
|
|
383
|
-
const parsed = parseBase64DataUrl({ dataUrl: block.file.data });
|
|
384
|
-
if (parsed) return {
|
|
385
|
-
type: "file",
|
|
386
|
-
data: parsed.data,
|
|
387
|
-
mimeType: parsed.mime_type
|
|
388
|
-
};
|
|
389
|
-
else if (_isString(block.file.file_id)) return {
|
|
390
|
-
type: "file",
|
|
391
|
-
fileId: block.file.file_id
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
return block;
|
|
395
|
-
}
|
|
396
|
-
function convertToV1FromChatCompletionsInput(blocks) {
|
|
397
|
-
const convertedBlocks = [];
|
|
398
|
-
for (const block of blocks) if (isOpenAIDataBlock(block)) convertedBlocks.push(convertToV1FromOpenAIDataBlock(block));
|
|
399
|
-
else convertedBlocks.push(block);
|
|
400
|
-
return convertedBlocks;
|
|
401
|
-
}
|
|
402
|
-
function isMessage(message) {
|
|
403
|
-
return typeof message === "object" && message !== null && "type" in message && "content" in message && (typeof message.content === "string" || Array.isArray(message.content));
|
|
404
|
-
}
|
|
405
|
-
function convertToFormattedString(message, format = "pretty") {
|
|
406
|
-
if (format === "pretty") return convertToPrettyString(message);
|
|
407
|
-
return JSON.stringify(message);
|
|
408
|
-
}
|
|
409
|
-
function convertToPrettyString(message) {
|
|
410
|
-
const lines = [];
|
|
411
|
-
const title = ` ${message.type.charAt(0).toUpperCase() + message.type.slice(1)} Message `;
|
|
412
|
-
const sepLen = Math.floor((80 - title.length) / 2);
|
|
413
|
-
const sep = "=".repeat(sepLen);
|
|
414
|
-
const secondSep = title.length % 2 === 0 ? sep : `${sep}=`;
|
|
415
|
-
lines.push(`${sep}${title}${secondSep}`);
|
|
416
|
-
if (message.type === "ai") {
|
|
417
|
-
const aiMessage = message;
|
|
418
|
-
if (aiMessage.tool_calls && aiMessage.tool_calls.length > 0) {
|
|
419
|
-
lines.push("Tool Calls:");
|
|
420
|
-
for (const tc of aiMessage.tool_calls) {
|
|
421
|
-
lines.push(` ${tc.name} (${tc.id})`);
|
|
422
|
-
lines.push(` Call ID: ${tc.id}`);
|
|
423
|
-
lines.push(" Args:");
|
|
424
|
-
for (const [key, value] of Object.entries(tc.args)) lines.push(` ${key}: ${typeof value === "object" ? JSON.stringify(value) : value}`);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
if (message.type === "tool") {
|
|
429
|
-
const toolMessage = message;
|
|
430
|
-
if (toolMessage.name) lines.push(`Name: ${toolMessage.name}`);
|
|
431
|
-
}
|
|
432
|
-
if (typeof message.content === "string" && message.content.trim()) {
|
|
433
|
-
if (lines.length > 1) lines.push("");
|
|
434
|
-
lines.push(message.content);
|
|
435
|
-
}
|
|
436
|
-
return lines.join("\n");
|
|
437
|
-
}
|
|
438
|
-
const MESSAGE_SYMBOL = Symbol.for("langchain.message");
|
|
439
|
-
function mergeContent(firstContent, secondContent) {
|
|
440
|
-
if (typeof firstContent === "string") {
|
|
441
|
-
if (firstContent === "") return secondContent;
|
|
442
|
-
if (typeof secondContent === "string") return firstContent + secondContent;
|
|
443
|
-
else if (Array.isArray(secondContent) && secondContent.length === 0) return firstContent;
|
|
444
|
-
else if (Array.isArray(secondContent) && secondContent.some((c) => isDataContentBlock(c))) return [{
|
|
445
|
-
type: "text",
|
|
446
|
-
source_type: "text",
|
|
447
|
-
text: firstContent
|
|
448
|
-
}, ...secondContent];
|
|
449
|
-
else return [{
|
|
450
|
-
type: "text",
|
|
451
|
-
text: firstContent
|
|
452
|
-
}, ...secondContent];
|
|
453
|
-
} else if (Array.isArray(secondContent)) return _mergeLists(firstContent, secondContent) ?? [...firstContent, ...secondContent];
|
|
454
|
-
else if (secondContent === "") return firstContent;
|
|
455
|
-
else if (Array.isArray(firstContent) && firstContent.some((c) => isDataContentBlock(c))) return [...firstContent, {
|
|
456
|
-
type: "file",
|
|
457
|
-
source_type: "text",
|
|
458
|
-
text: secondContent
|
|
459
|
-
}];
|
|
460
|
-
else return [...firstContent, {
|
|
461
|
-
type: "text",
|
|
462
|
-
text: secondContent
|
|
463
|
-
}];
|
|
464
|
-
}
|
|
465
|
-
function _mergeStatus(left, right) {
|
|
466
|
-
if (left === "error" || right === "error") return "error";
|
|
467
|
-
return "success";
|
|
468
|
-
}
|
|
469
|
-
function stringifyWithDepthLimit(obj, depthLimit) {
|
|
470
|
-
function helper(obj$1, currentDepth) {
|
|
471
|
-
if (typeof obj$1 !== "object" || obj$1 === null || obj$1 === void 0) return obj$1;
|
|
472
|
-
if (currentDepth >= depthLimit) {
|
|
473
|
-
if (Array.isArray(obj$1)) return "[Array]";
|
|
474
|
-
return "[Object]";
|
|
475
|
-
}
|
|
476
|
-
if (Array.isArray(obj$1)) return obj$1.map((item) => helper(item, currentDepth + 1));
|
|
477
|
-
const result = {};
|
|
478
|
-
for (const key of Object.keys(obj$1)) result[key] = helper(obj$1[key], currentDepth + 1);
|
|
479
|
-
return result;
|
|
480
|
-
}
|
|
481
|
-
return JSON.stringify(helper(obj, 0), null, 2);
|
|
482
|
-
}
|
|
483
|
-
var BaseMessage = class extends Serializable {
|
|
484
|
-
constructor(arg) {
|
|
485
|
-
const fields = typeof arg === "string" || Array.isArray(arg) ? { content: arg } : arg;
|
|
486
|
-
if (!fields.additional_kwargs) fields.additional_kwargs = {};
|
|
487
|
-
if (!fields.response_metadata) fields.response_metadata = {};
|
|
488
|
-
super(fields);
|
|
489
|
-
__publicField(this, "lc_namespace", ["langchain_core", "messages"]);
|
|
490
|
-
__publicField(this, "lc_serializable", true);
|
|
491
|
-
__publicField(this, _a, true);
|
|
492
|
-
__publicField(this, "id");
|
|
493
|
-
__publicField(this, "name");
|
|
494
|
-
__publicField(this, "content");
|
|
495
|
-
__publicField(this, "additional_kwargs");
|
|
496
|
-
__publicField(this, "response_metadata");
|
|
497
|
-
this.name = fields.name;
|
|
498
|
-
if (fields.content === void 0 && fields.contentBlocks !== void 0) {
|
|
499
|
-
this.content = fields.contentBlocks;
|
|
500
|
-
this.response_metadata = {
|
|
501
|
-
output_version: "v1",
|
|
502
|
-
...fields.response_metadata
|
|
503
|
-
};
|
|
504
|
-
} else if (fields.content !== void 0) {
|
|
505
|
-
this.content = fields.content ?? [];
|
|
506
|
-
this.response_metadata = fields.response_metadata;
|
|
507
|
-
} else {
|
|
508
|
-
this.content = [];
|
|
509
|
-
this.response_metadata = fields.response_metadata;
|
|
510
|
-
}
|
|
511
|
-
this.additional_kwargs = fields.additional_kwargs;
|
|
512
|
-
this.id = fields.id;
|
|
513
|
-
}
|
|
514
|
-
get lc_aliases() {
|
|
515
|
-
return {
|
|
516
|
-
additional_kwargs: "additional_kwargs",
|
|
517
|
-
response_metadata: "response_metadata"
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* @deprecated Use .getType() instead or import the proper typeguard.
|
|
522
|
-
* For example:
|
|
523
|
-
*
|
|
524
|
-
* ```ts
|
|
525
|
-
* import { isAIMessage } from "@langchain/core/messages";
|
|
526
|
-
*
|
|
527
|
-
* const message = new AIMessage("Hello!");
|
|
528
|
-
* isAIMessage(message); // true
|
|
529
|
-
* ```
|
|
530
|
-
*/
|
|
531
|
-
_getType() {
|
|
532
|
-
return this.type;
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* @deprecated Use .type instead
|
|
536
|
-
* The type of the message.
|
|
537
|
-
*/
|
|
538
|
-
getType() {
|
|
539
|
-
return this._getType();
|
|
540
|
-
}
|
|
541
|
-
/** Get text content of the message. */
|
|
542
|
-
get text() {
|
|
543
|
-
if (typeof this.content === "string") return this.content;
|
|
544
|
-
if (!Array.isArray(this.content)) return "";
|
|
545
|
-
return this.content.map((c) => {
|
|
546
|
-
if (typeof c === "string") return c;
|
|
547
|
-
if (c.type === "text") return c.text;
|
|
548
|
-
return "";
|
|
549
|
-
}).join("");
|
|
550
|
-
}
|
|
551
|
-
get contentBlocks() {
|
|
552
|
-
const blocks = typeof this.content === "string" ? [{
|
|
553
|
-
type: "text",
|
|
554
|
-
text: this.content
|
|
555
|
-
}] : this.content;
|
|
556
|
-
const parsingSteps = [
|
|
557
|
-
convertToV1FromDataContent,
|
|
558
|
-
convertToV1FromChatCompletionsInput,
|
|
559
|
-
convertToV1FromAnthropicInput
|
|
560
|
-
];
|
|
561
|
-
const parsedBlocks = parsingSteps.reduce((blocks$1, step) => step(blocks$1), blocks);
|
|
562
|
-
return parsedBlocks;
|
|
563
|
-
}
|
|
564
|
-
toDict() {
|
|
565
|
-
return {
|
|
566
|
-
type: this.getType(),
|
|
567
|
-
data: this.toJSON().kwargs
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
static lc_name() {
|
|
571
|
-
return "BaseMessage";
|
|
572
|
-
}
|
|
573
|
-
get _printableFields() {
|
|
574
|
-
return {
|
|
575
|
-
id: this.id,
|
|
576
|
-
content: this.content,
|
|
577
|
-
name: this.name,
|
|
578
|
-
additional_kwargs: this.additional_kwargs,
|
|
579
|
-
response_metadata: this.response_metadata
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
static isInstance(obj) {
|
|
583
|
-
return typeof obj === "object" && obj !== null && MESSAGE_SYMBOL in obj && obj[MESSAGE_SYMBOL] === true && isMessage(obj);
|
|
584
|
-
}
|
|
585
|
-
_updateId(value) {
|
|
586
|
-
this.id = value;
|
|
587
|
-
this.lc_kwargs.id = value;
|
|
588
|
-
}
|
|
589
|
-
get [(_a = MESSAGE_SYMBOL, Symbol.toStringTag)]() {
|
|
590
|
-
return this.constructor.lc_name();
|
|
591
|
-
}
|
|
592
|
-
[Symbol.for("nodejs.util.inspect.custom")](depth) {
|
|
593
|
-
if (depth === null) return this;
|
|
594
|
-
const printable = stringifyWithDepthLimit(this._printableFields, Math.max(4, depth));
|
|
595
|
-
return `${this.constructor.lc_name()} ${printable}`;
|
|
596
|
-
}
|
|
597
|
-
toFormattedString(format = "pretty") {
|
|
598
|
-
return convertToFormattedString(this, format);
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
function _mergeDicts(left = {}, right = {}) {
|
|
602
|
-
const merged = { ...left };
|
|
603
|
-
for (const [key, value] of Object.entries(right)) if (merged[key] == null) merged[key] = value;
|
|
604
|
-
else if (value == null) continue;
|
|
605
|
-
else if (typeof merged[key] !== typeof value || Array.isArray(merged[key]) !== Array.isArray(value)) throw new Error(`field[${key}] already exists in the message chunk, but with a different type.`);
|
|
606
|
-
else if (typeof merged[key] === "string") if (key === "type") continue;
|
|
607
|
-
else if ([
|
|
608
|
-
"id",
|
|
609
|
-
"name",
|
|
610
|
-
"output_version",
|
|
611
|
-
"model_provider"
|
|
612
|
-
].includes(key)) {
|
|
613
|
-
if (value) merged[key] = value;
|
|
614
|
-
} else merged[key] += value;
|
|
615
|
-
else if (typeof merged[key] === "object" && !Array.isArray(merged[key])) merged[key] = _mergeDicts(merged[key], value);
|
|
616
|
-
else if (Array.isArray(merged[key])) merged[key] = _mergeLists(merged[key], value);
|
|
617
|
-
else if (merged[key] === value) continue;
|
|
618
|
-
else console.warn(`field[${key}] already exists in this message chunk and value has unsupported type.`);
|
|
619
|
-
return merged;
|
|
620
|
-
}
|
|
621
|
-
function _mergeLists(left, right) {
|
|
622
|
-
if (left === void 0 && right === void 0) return void 0;
|
|
623
|
-
else if (left === void 0 || right === void 0) return left || right;
|
|
624
|
-
else {
|
|
625
|
-
const merged = [...left];
|
|
626
|
-
for (const item of right) if (typeof item === "object" && item !== null && "index" in item && typeof item.index === "number") {
|
|
627
|
-
const toMerge = merged.findIndex((leftItem) => {
|
|
628
|
-
const isObject = typeof leftItem === "object";
|
|
629
|
-
const indiciesMatch = "index" in leftItem && leftItem.index === item.index;
|
|
630
|
-
const idsMatch = "id" in leftItem && "id" in item && (leftItem == null ? void 0 : leftItem.id) === (item == null ? void 0 : item.id);
|
|
631
|
-
const eitherItemMissingID = !("id" in leftItem) || !(leftItem == null ? void 0 : leftItem.id) || !("id" in item) || !(item == null ? void 0 : item.id);
|
|
632
|
-
return isObject && indiciesMatch && (idsMatch || eitherItemMissingID);
|
|
633
|
-
});
|
|
634
|
-
if (toMerge !== -1 && typeof merged[toMerge] === "object" && merged[toMerge] !== null) merged[toMerge] = _mergeDicts(merged[toMerge], item);
|
|
635
|
-
else merged.push(item);
|
|
636
|
-
} else if (typeof item === "object" && item !== null && "text" in item && item.text === "") continue;
|
|
637
|
-
else merged.push(item);
|
|
638
|
-
return merged;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
function _mergeObj(left, right) {
|
|
642
|
-
if (left === void 0 && right === void 0) return void 0;
|
|
643
|
-
if (left === void 0 || right === void 0) return left ?? right;
|
|
644
|
-
else if (typeof left !== typeof right) throw new Error(`Cannot merge objects of different types.
|
|
645
|
-
Left ${typeof left}
|
|
646
|
-
Right ${typeof right}`);
|
|
647
|
-
else if (typeof left === "string" && typeof right === "string") return left + right;
|
|
648
|
-
else if (Array.isArray(left) && Array.isArray(right)) return _mergeLists(left, right);
|
|
649
|
-
else if (typeof left === "object" && typeof right === "object") return _mergeDicts(left, right);
|
|
650
|
-
else if (left === right) return left;
|
|
651
|
-
else throw new Error(`Can not merge objects of different types.
|
|
652
|
-
Left ${left}
|
|
653
|
-
Right ${right}`);
|
|
654
|
-
}
|
|
655
|
-
var BaseMessageChunk = class BaseMessageChunk2 extends BaseMessage {
|
|
656
|
-
static isInstance(obj) {
|
|
657
|
-
if (!super.isInstance(obj)) return false;
|
|
658
|
-
let proto = Object.getPrototypeOf(obj);
|
|
659
|
-
while (proto !== null) {
|
|
660
|
-
if (proto === BaseMessageChunk2.prototype) return true;
|
|
661
|
-
proto = Object.getPrototypeOf(proto);
|
|
662
|
-
}
|
|
663
|
-
return false;
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
var tool_exports = {};
|
|
667
|
-
__export(tool_exports, {
|
|
668
|
-
ToolMessage: () => ToolMessage,
|
|
669
|
-
ToolMessageChunk: () => ToolMessageChunk,
|
|
670
|
-
defaultToolCallParser: () => defaultToolCallParser,
|
|
671
|
-
isDirectToolOutput: () => isDirectToolOutput,
|
|
672
|
-
isToolMessage: () => isToolMessage,
|
|
673
|
-
isToolMessageChunk: () => isToolMessageChunk
|
|
674
|
-
});
|
|
675
|
-
function isDirectToolOutput(x) {
|
|
676
|
-
return x != null && typeof x === "object" && "lc_direct_tool_output" in x && x.lc_direct_tool_output === true;
|
|
677
|
-
}
|
|
678
|
-
var ToolMessage = class extends BaseMessage {
|
|
679
|
-
constructor(fields, tool_call_id, name) {
|
|
680
|
-
const toolMessageFields = typeof fields === "string" || Array.isArray(fields) ? {
|
|
681
|
-
content: fields,
|
|
682
|
-
name,
|
|
683
|
-
tool_call_id
|
|
684
|
-
} : fields;
|
|
685
|
-
super(toolMessageFields);
|
|
686
|
-
__publicField(this, "lc_direct_tool_output", true);
|
|
687
|
-
__publicField(this, "type", "tool");
|
|
688
|
-
/**
|
|
689
|
-
* Status of the tool invocation.
|
|
690
|
-
* @version 0.2.19
|
|
691
|
-
*/
|
|
692
|
-
__publicField(this, "status");
|
|
693
|
-
__publicField(this, "tool_call_id");
|
|
694
|
-
__publicField(this, "metadata");
|
|
695
|
-
/**
|
|
696
|
-
* Artifact of the Tool execution which is not meant to be sent to the model.
|
|
697
|
-
*
|
|
698
|
-
* Should only be specified if it is different from the message content, e.g. if only
|
|
699
|
-
* a subset of the full tool output is being passed as message content but the full
|
|
700
|
-
* output is needed in other parts of the code.
|
|
701
|
-
*/
|
|
702
|
-
__publicField(this, "artifact");
|
|
703
|
-
this.tool_call_id = toolMessageFields.tool_call_id;
|
|
704
|
-
this.artifact = toolMessageFields.artifact;
|
|
705
|
-
this.status = toolMessageFields.status;
|
|
706
|
-
this.metadata = toolMessageFields.metadata;
|
|
707
|
-
}
|
|
708
|
-
static lc_name() {
|
|
709
|
-
return "ToolMessage";
|
|
710
|
-
}
|
|
711
|
-
get lc_aliases() {
|
|
712
|
-
return { tool_call_id: "tool_call_id" };
|
|
713
|
-
}
|
|
714
|
-
static isInstance(message) {
|
|
715
|
-
return super.isInstance(message) && message.type === "tool";
|
|
716
|
-
}
|
|
717
|
-
get _printableFields() {
|
|
718
|
-
return {
|
|
719
|
-
...super._printableFields,
|
|
720
|
-
tool_call_id: this.tool_call_id,
|
|
721
|
-
artifact: this.artifact
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
var ToolMessageChunk = class extends BaseMessageChunk {
|
|
726
|
-
constructor(fields) {
|
|
727
|
-
super(fields);
|
|
728
|
-
__publicField(this, "type", "tool");
|
|
729
|
-
__publicField(this, "tool_call_id");
|
|
730
|
-
/**
|
|
731
|
-
* Status of the tool invocation.
|
|
732
|
-
* @version 0.2.19
|
|
733
|
-
*/
|
|
734
|
-
__publicField(this, "status");
|
|
735
|
-
/**
|
|
736
|
-
* Artifact of the Tool execution which is not meant to be sent to the model.
|
|
737
|
-
*
|
|
738
|
-
* Should only be specified if it is different from the message content, e.g. if only
|
|
739
|
-
* a subset of the full tool output is being passed as message content but the full
|
|
740
|
-
* output is needed in other parts of the code.
|
|
741
|
-
*/
|
|
742
|
-
__publicField(this, "artifact");
|
|
743
|
-
this.tool_call_id = fields.tool_call_id;
|
|
744
|
-
this.artifact = fields.artifact;
|
|
745
|
-
this.status = fields.status;
|
|
746
|
-
}
|
|
747
|
-
static lc_name() {
|
|
748
|
-
return "ToolMessageChunk";
|
|
749
|
-
}
|
|
750
|
-
concat(chunk) {
|
|
751
|
-
const Cls = this.constructor;
|
|
752
|
-
return new Cls({
|
|
753
|
-
content: mergeContent(this.content, chunk.content),
|
|
754
|
-
additional_kwargs: _mergeDicts(this.additional_kwargs, chunk.additional_kwargs),
|
|
755
|
-
response_metadata: _mergeDicts(this.response_metadata, chunk.response_metadata),
|
|
756
|
-
artifact: _mergeObj(this.artifact, chunk.artifact),
|
|
757
|
-
tool_call_id: this.tool_call_id,
|
|
758
|
-
id: this.id ?? chunk.id,
|
|
759
|
-
status: _mergeStatus(this.status, chunk.status)
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
get _printableFields() {
|
|
763
|
-
return {
|
|
764
|
-
...super._printableFields,
|
|
765
|
-
tool_call_id: this.tool_call_id,
|
|
766
|
-
artifact: this.artifact
|
|
767
|
-
};
|
|
768
|
-
}
|
|
769
|
-
};
|
|
770
|
-
function defaultToolCallParser(rawToolCalls) {
|
|
771
|
-
const toolCalls = [];
|
|
772
|
-
const invalidToolCalls = [];
|
|
773
|
-
for (const toolCall of rawToolCalls) if (!toolCall.function) continue;
|
|
774
|
-
else {
|
|
775
|
-
const functionName = toolCall.function.name;
|
|
776
|
-
try {
|
|
777
|
-
const functionArgs = JSON.parse(toolCall.function.arguments);
|
|
778
|
-
toolCalls.push({
|
|
779
|
-
name: functionName || "",
|
|
780
|
-
args: functionArgs || {},
|
|
781
|
-
id: toolCall.id
|
|
782
|
-
});
|
|
783
|
-
} catch {
|
|
784
|
-
invalidToolCalls.push({
|
|
785
|
-
name: functionName,
|
|
786
|
-
args: toolCall.function.arguments,
|
|
787
|
-
id: toolCall.id,
|
|
788
|
-
error: "Malformed args."
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
return [toolCalls, invalidToolCalls];
|
|
793
|
-
}
|
|
794
|
-
function isToolMessage(x) {
|
|
795
|
-
return typeof x === "object" && x !== null && "getType" in x && typeof x.getType === "function" && x.getType() === "tool";
|
|
796
|
-
}
|
|
797
|
-
function isToolMessageChunk(x) {
|
|
798
|
-
return x._getType() === "tool";
|
|
799
|
-
}
|
|
1
|
+
import "@langchain/core/messages/tool";
|
|
2
|
+
import "@a2ui/lit/0.8";
|
|
800
3
|
function isClientToolRequest(value) {
|
|
801
4
|
return value && Array.isArray(value.clientToolCalls);
|
|
802
5
|
}
|
|
803
|
-
const eventInit = {
|
|
804
|
-
bubbles: true,
|
|
805
|
-
cancelable: true,
|
|
806
|
-
composed: true
|
|
807
|
-
};
|
|
808
|
-
const _StateEvent = class _StateEvent extends CustomEvent {
|
|
809
|
-
constructor(payload) {
|
|
810
|
-
super(_StateEvent.eventName, { detail: payload, ...eventInit });
|
|
811
|
-
this.payload = payload;
|
|
812
|
-
}
|
|
813
|
-
};
|
|
814
|
-
_StateEvent.eventName = "a2uiaction";
|
|
815
|
-
let StateEvent = _StateEvent;
|
|
816
|
-
const opacityBehavior = `
|
|
817
|
-
&:not([disabled]) {
|
|
818
|
-
cursor: pointer;
|
|
819
|
-
opacity: var(--opacity, 0);
|
|
820
|
-
transition: opacity var(--speed, 0.2s) cubic-bezier(0, 0, 0.3, 1);
|
|
821
|
-
|
|
822
|
-
&:hover,
|
|
823
|
-
&:focus {
|
|
824
|
-
opacity: 1;
|
|
825
|
-
}
|
|
826
|
-
}`;
|
|
827
|
-
`
|
|
828
|
-
${new Array(21).fill(0).map((_, idx) => {
|
|
829
|
-
return `.behavior-ho-${idx * 5} {
|
|
830
|
-
--opacity: ${idx / 20};
|
|
831
|
-
${opacityBehavior}
|
|
832
|
-
}`;
|
|
833
|
-
}).join("\n")}
|
|
834
|
-
|
|
835
|
-
.behavior-o-s {
|
|
836
|
-
overflow: scroll;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
.behavior-o-a {
|
|
840
|
-
overflow: auto;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
.behavior-o-h {
|
|
844
|
-
overflow: hidden;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
.behavior-sw-n {
|
|
848
|
-
scrollbar-width: none;
|
|
849
|
-
}
|
|
850
|
-
`;
|
|
851
|
-
const grid = 4;
|
|
852
|
-
`
|
|
853
|
-
${new Array(25).fill(0).map((_, idx) => {
|
|
854
|
-
return `
|
|
855
|
-
.border-bw-${idx} { border-width: ${idx}px; }
|
|
856
|
-
.border-btw-${idx} { border-top-width: ${idx}px; }
|
|
857
|
-
.border-bbw-${idx} { border-bottom-width: ${idx}px; }
|
|
858
|
-
.border-blw-${idx} { border-left-width: ${idx}px; }
|
|
859
|
-
.border-brw-${idx} { border-right-width: ${idx}px; }
|
|
860
|
-
|
|
861
|
-
.border-ow-${idx} { outline-width: ${idx}px; }
|
|
862
|
-
.border-br-${idx} { border-radius: ${idx * grid}px; overflow: hidden;}`;
|
|
863
|
-
}).join("\n")}
|
|
864
|
-
|
|
865
|
-
.border-br-50pc {
|
|
866
|
-
border-radius: 50%;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
.border-bs-s {
|
|
870
|
-
border-style: solid;
|
|
871
|
-
}
|
|
872
|
-
`;
|
|
873
|
-
const shades = [
|
|
874
|
-
0,
|
|
875
|
-
5,
|
|
876
|
-
10,
|
|
877
|
-
15,
|
|
878
|
-
20,
|
|
879
|
-
25,
|
|
880
|
-
30,
|
|
881
|
-
35,
|
|
882
|
-
40,
|
|
883
|
-
50,
|
|
884
|
-
60,
|
|
885
|
-
70,
|
|
886
|
-
80,
|
|
887
|
-
90,
|
|
888
|
-
95,
|
|
889
|
-
98,
|
|
890
|
-
99,
|
|
891
|
-
100
|
|
892
|
-
];
|
|
893
|
-
function toProp(key) {
|
|
894
|
-
if (key.startsWith("nv")) {
|
|
895
|
-
return `--nv-${key.slice(2)}`;
|
|
896
|
-
}
|
|
897
|
-
return `--${key[0]}-${key.slice(1)}`;
|
|
898
|
-
}
|
|
899
|
-
const color = (src) => `
|
|
900
|
-
${src.map((key) => {
|
|
901
|
-
const inverseKey = getInverseKey(key);
|
|
902
|
-
return `.color-bc-${key} { border-color: light-dark(var(${toProp(key)}), var(${toProp(inverseKey)})); }`;
|
|
903
|
-
}).join("\n")}
|
|
904
|
-
|
|
905
|
-
${src.map((key) => {
|
|
906
|
-
const inverseKey = getInverseKey(key);
|
|
907
|
-
const vals = [
|
|
908
|
-
`.color-bgc-${key} { background-color: light-dark(var(${toProp(key)}), var(${toProp(inverseKey)})); }`,
|
|
909
|
-
`.color-bbgc-${key}::backdrop { background-color: light-dark(var(${toProp(key)}), var(${toProp(inverseKey)})); }`
|
|
910
|
-
];
|
|
911
|
-
for (let o = 0.1; o < 1; o += 0.1) {
|
|
912
|
-
vals.push(`.color-bbgc-${key}_${(o * 100).toFixed(0)}::backdrop {
|
|
913
|
-
background-color: light-dark(oklch(from var(${toProp(key)}) l c h / calc(alpha * ${o.toFixed(1)})), oklch(from var(${toProp(inverseKey)}) l c h / calc(alpha * ${o.toFixed(1)})) );
|
|
914
|
-
}
|
|
915
|
-
`);
|
|
916
|
-
}
|
|
917
|
-
return vals.join("\n");
|
|
918
|
-
}).join("\n")}
|
|
919
|
-
|
|
920
|
-
${src.map((key) => {
|
|
921
|
-
const inverseKey = getInverseKey(key);
|
|
922
|
-
return `.color-c-${key} { color: light-dark(var(${toProp(key)}), var(${toProp(inverseKey)})); }`;
|
|
923
|
-
}).join("\n")}
|
|
924
|
-
`;
|
|
925
|
-
const getInverseKey = (key) => {
|
|
926
|
-
const match = key.match(/^([a-z]+)(\d+)$/);
|
|
927
|
-
if (!match)
|
|
928
|
-
return key;
|
|
929
|
-
const [, prefix, shadeStr] = match;
|
|
930
|
-
const shade = parseInt(shadeStr, 10);
|
|
931
|
-
const target = 100 - shade;
|
|
932
|
-
const inverseShade = shades.reduce((prev, curr) => Math.abs(curr - target) < Math.abs(prev - target) ? curr : prev);
|
|
933
|
-
return `${prefix}${inverseShade}`;
|
|
934
|
-
};
|
|
935
|
-
const keyFactory = (prefix) => {
|
|
936
|
-
return shades.map((v) => `${prefix}${v}`);
|
|
937
|
-
};
|
|
938
|
-
[
|
|
939
|
-
color(keyFactory("p")),
|
|
940
|
-
color(keyFactory("s")),
|
|
941
|
-
color(keyFactory("t")),
|
|
942
|
-
color(keyFactory("n")),
|
|
943
|
-
color(keyFactory("nv")),
|
|
944
|
-
color(keyFactory("e")),
|
|
945
|
-
`
|
|
946
|
-
.color-bgc-transparent {
|
|
947
|
-
background-color: transparent;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
:host {
|
|
951
|
-
color-scheme: var(--color-scheme);
|
|
952
|
-
}
|
|
953
|
-
`
|
|
954
|
-
];
|
|
955
|
-
`
|
|
956
|
-
:host {
|
|
957
|
-
${new Array(16).fill(0).map((_, idx) => {
|
|
958
|
-
return `--g-${idx + 1}: ${(idx + 1) * grid}px;`;
|
|
959
|
-
}).join("\n")}
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
${new Array(49).fill(0).map((_, index) => {
|
|
963
|
-
const idx = index - 24;
|
|
964
|
-
const lbl = idx < 0 ? `n${Math.abs(idx)}` : idx.toString();
|
|
965
|
-
return `
|
|
966
|
-
.layout-p-${lbl} { --padding: ${idx * grid}px; padding: var(--padding); }
|
|
967
|
-
.layout-pt-${lbl} { padding-top: ${idx * grid}px; }
|
|
968
|
-
.layout-pr-${lbl} { padding-right: ${idx * grid}px; }
|
|
969
|
-
.layout-pb-${lbl} { padding-bottom: ${idx * grid}px; }
|
|
970
|
-
.layout-pl-${lbl} { padding-left: ${idx * grid}px; }
|
|
971
|
-
|
|
972
|
-
.layout-m-${lbl} { --margin: ${idx * grid}px; margin: var(--margin); }
|
|
973
|
-
.layout-mt-${lbl} { margin-top: ${idx * grid}px; }
|
|
974
|
-
.layout-mr-${lbl} { margin-right: ${idx * grid}px; }
|
|
975
|
-
.layout-mb-${lbl} { margin-bottom: ${idx * grid}px; }
|
|
976
|
-
.layout-ml-${lbl} { margin-left: ${idx * grid}px; }
|
|
977
|
-
|
|
978
|
-
.layout-t-${lbl} { top: ${idx * grid}px; }
|
|
979
|
-
.layout-r-${lbl} { right: ${idx * grid}px; }
|
|
980
|
-
.layout-b-${lbl} { bottom: ${idx * grid}px; }
|
|
981
|
-
.layout-l-${lbl} { left: ${idx * grid}px; }`;
|
|
982
|
-
}).join("\n")}
|
|
983
|
-
|
|
984
|
-
${new Array(25).fill(0).map((_, idx) => {
|
|
985
|
-
return `
|
|
986
|
-
.layout-g-${idx} { gap: ${idx * grid}px; }`;
|
|
987
|
-
}).join("\n")}
|
|
988
|
-
|
|
989
|
-
${new Array(8).fill(0).map((_, idx) => {
|
|
990
|
-
return `
|
|
991
|
-
.layout-grd-col${idx + 1} { grid-template-columns: ${"1fr ".repeat(idx + 1).trim()}; }`;
|
|
992
|
-
}).join("\n")}
|
|
993
|
-
|
|
994
|
-
.layout-pos-a {
|
|
995
|
-
position: absolute;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
.layout-pos-rel {
|
|
999
|
-
position: relative;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
.layout-dsp-none {
|
|
1003
|
-
display: none;
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
.layout-dsp-block {
|
|
1007
|
-
display: block;
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
.layout-dsp-grid {
|
|
1011
|
-
display: grid;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
.layout-dsp-iflex {
|
|
1015
|
-
display: inline-flex;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
.layout-dsp-flexvert {
|
|
1019
|
-
display: flex;
|
|
1020
|
-
flex-direction: column;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
.layout-dsp-flexhor {
|
|
1024
|
-
display: flex;
|
|
1025
|
-
flex-direction: row;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
.layout-fw-w {
|
|
1029
|
-
flex-wrap: wrap;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
.layout-al-fs {
|
|
1033
|
-
align-items: start;
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
.layout-al-fe {
|
|
1037
|
-
align-items: end;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
.layout-al-c {
|
|
1041
|
-
align-items: center;
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
.layout-as-n {
|
|
1045
|
-
align-self: normal;
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
.layout-js-c {
|
|
1049
|
-
justify-self: center;
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
.layout-sp-c {
|
|
1053
|
-
justify-content: center;
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
.layout-sp-ev {
|
|
1057
|
-
justify-content: space-evenly;
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
.layout-sp-bt {
|
|
1061
|
-
justify-content: space-between;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
.layout-sp-s {
|
|
1065
|
-
justify-content: start;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
.layout-sp-e {
|
|
1069
|
-
justify-content: end;
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
.layout-ji-e {
|
|
1073
|
-
justify-items: end;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
.layout-r-none {
|
|
1077
|
-
resize: none;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
.layout-fs-c {
|
|
1081
|
-
field-sizing: content;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
.layout-fs-n {
|
|
1085
|
-
field-sizing: none;
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
.layout-flx-0 {
|
|
1089
|
-
flex: 0 0 auto;
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
.layout-flx-1 {
|
|
1093
|
-
flex: 1 0 auto;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
.layout-c-s {
|
|
1097
|
-
contain: strict;
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
/** Widths **/
|
|
1101
|
-
|
|
1102
|
-
${new Array(10).fill(0).map((_, idx) => {
|
|
1103
|
-
const weight = (idx + 1) * 10;
|
|
1104
|
-
return `.layout-w-${weight} { width: ${weight}%; max-width: ${weight}%; }`;
|
|
1105
|
-
}).join("\n")}
|
|
1106
|
-
|
|
1107
|
-
${new Array(16).fill(0).map((_, idx) => {
|
|
1108
|
-
const weight = idx * grid;
|
|
1109
|
-
return `.layout-wp-${idx} { width: ${weight}px; }`;
|
|
1110
|
-
}).join("\n")}
|
|
1111
|
-
|
|
1112
|
-
/** Heights **/
|
|
1113
|
-
|
|
1114
|
-
${new Array(10).fill(0).map((_, idx) => {
|
|
1115
|
-
const height = (idx + 1) * 10;
|
|
1116
|
-
return `.layout-h-${height} { height: ${height}%; }`;
|
|
1117
|
-
}).join("\n")}
|
|
1118
|
-
|
|
1119
|
-
${new Array(16).fill(0).map((_, idx) => {
|
|
1120
|
-
const height = idx * grid;
|
|
1121
|
-
return `.layout-hp-${idx} { height: ${height}px; }`;
|
|
1122
|
-
}).join("\n")}
|
|
1123
|
-
|
|
1124
|
-
.layout-el-cv {
|
|
1125
|
-
& img,
|
|
1126
|
-
& video {
|
|
1127
|
-
width: 100%;
|
|
1128
|
-
height: 100%;
|
|
1129
|
-
object-fit: cover;
|
|
1130
|
-
margin: 0;
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
.layout-ar-sq {
|
|
1135
|
-
aspect-ratio: 1 / 1;
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
.layout-ex-fb {
|
|
1139
|
-
margin: calc(var(--padding) * -1) 0 0 calc(var(--padding) * -1);
|
|
1140
|
-
width: calc(100% + var(--padding) * 2);
|
|
1141
|
-
height: calc(100% + var(--padding) * 2);
|
|
1142
|
-
}
|
|
1143
|
-
`;
|
|
1144
|
-
`
|
|
1145
|
-
${new Array(21).fill(0).map((_, idx) => {
|
|
1146
|
-
return `.opacity-el-${idx * 5} { opacity: ${idx / 20}; }`;
|
|
1147
|
-
}).join("\n")}
|
|
1148
|
-
`;
|
|
1149
|
-
`
|
|
1150
|
-
:host {
|
|
1151
|
-
--default-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
1152
|
-
--default-font-family-mono: "Courier New", Courier, monospace;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
.typography-f-s {
|
|
1156
|
-
font-family: var(--font-family, var(--default-font-family));
|
|
1157
|
-
font-optical-sizing: auto;
|
|
1158
|
-
font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
.typography-f-sf {
|
|
1162
|
-
font-family: var(--font-family-flex, var(--default-font-family));
|
|
1163
|
-
font-optical-sizing: auto;
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
.typography-f-c {
|
|
1167
|
-
font-family: var(--font-family-mono, var(--default-font-family));
|
|
1168
|
-
font-optical-sizing: auto;
|
|
1169
|
-
font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
.typography-v-r {
|
|
1173
|
-
font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 100;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
.typography-ta-s {
|
|
1177
|
-
text-align: start;
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
.typography-ta-c {
|
|
1181
|
-
text-align: center;
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
.typography-fs-n {
|
|
1185
|
-
font-style: normal;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
.typography-fs-i {
|
|
1189
|
-
font-style: italic;
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
.typography-sz-ls {
|
|
1193
|
-
font-size: 11px;
|
|
1194
|
-
line-height: 16px;
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
.typography-sz-lm {
|
|
1198
|
-
font-size: 12px;
|
|
1199
|
-
line-height: 16px;
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
.typography-sz-ll {
|
|
1203
|
-
font-size: 14px;
|
|
1204
|
-
line-height: 20px;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
.typography-sz-bs {
|
|
1208
|
-
font-size: 12px;
|
|
1209
|
-
line-height: 16px;
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
.typography-sz-bm {
|
|
1213
|
-
font-size: 14px;
|
|
1214
|
-
line-height: 20px;
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
.typography-sz-bl {
|
|
1218
|
-
font-size: 16px;
|
|
1219
|
-
line-height: 24px;
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
.typography-sz-ts {
|
|
1223
|
-
font-size: 14px;
|
|
1224
|
-
line-height: 20px;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
.typography-sz-tm {
|
|
1228
|
-
font-size: 16px;
|
|
1229
|
-
line-height: 24px;
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
.typography-sz-tl {
|
|
1233
|
-
font-size: 22px;
|
|
1234
|
-
line-height: 28px;
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
.typography-sz-hs {
|
|
1238
|
-
font-size: 24px;
|
|
1239
|
-
line-height: 32px;
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
.typography-sz-hm {
|
|
1243
|
-
font-size: 28px;
|
|
1244
|
-
line-height: 36px;
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
.typography-sz-hl {
|
|
1248
|
-
font-size: 32px;
|
|
1249
|
-
line-height: 40px;
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
.typography-sz-ds {
|
|
1253
|
-
font-size: 36px;
|
|
1254
|
-
line-height: 44px;
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
.typography-sz-dm {
|
|
1258
|
-
font-size: 45px;
|
|
1259
|
-
line-height: 52px;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
.typography-sz-dl {
|
|
1263
|
-
font-size: 57px;
|
|
1264
|
-
line-height: 64px;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
.typography-ws-p {
|
|
1268
|
-
white-space: pre-line;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
.typography-ws-nw {
|
|
1272
|
-
white-space: nowrap;
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
.typography-td-none {
|
|
1276
|
-
text-decoration: none;
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
/** Weights **/
|
|
1280
|
-
|
|
1281
|
-
${new Array(9).fill(0).map((_, idx) => {
|
|
1282
|
-
const weight = (idx + 1) * 100;
|
|
1283
|
-
return `.typography-w-${weight} { font-weight: ${weight}; }`;
|
|
1284
|
-
}).join("\n")}
|
|
1285
|
-
`;
|
|
1286
|
-
var __defProp2 = Object.defineProperty;
|
|
1287
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1288
|
-
var __publicField2 = (obj, key, value) => {
|
|
1289
|
-
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1290
|
-
return value;
|
|
1291
|
-
};
|
|
1292
|
-
var __accessCheck2 = (obj, member, msg) => {
|
|
1293
|
-
if (!member.has(obj))
|
|
1294
|
-
throw TypeError("Cannot " + msg);
|
|
1295
|
-
};
|
|
1296
|
-
var __privateIn = (member, obj) => {
|
|
1297
|
-
if (Object(obj) !== obj)
|
|
1298
|
-
throw TypeError('Cannot use the "in" operator on this value');
|
|
1299
|
-
return member.has(obj);
|
|
1300
|
-
};
|
|
1301
|
-
var __privateAdd2 = (obj, member, value) => {
|
|
1302
|
-
if (member.has(obj))
|
|
1303
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1304
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1305
|
-
};
|
|
1306
|
-
var __privateMethod2 = (obj, member, method) => {
|
|
1307
|
-
__accessCheck2(obj, member, "access private method");
|
|
1308
|
-
return method;
|
|
1309
|
-
};
|
|
1310
|
-
/**
|
|
1311
|
-
* @license
|
|
1312
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1313
|
-
*
|
|
1314
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1315
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1316
|
-
*/
|
|
1317
|
-
function defaultEquals(a, b) {
|
|
1318
|
-
return Object.is(a, b);
|
|
1319
|
-
}
|
|
1320
|
-
/**
|
|
1321
|
-
* @license
|
|
1322
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1323
|
-
*
|
|
1324
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1325
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1326
|
-
*/
|
|
1327
|
-
let activeConsumer = null;
|
|
1328
|
-
let inNotificationPhase = false;
|
|
1329
|
-
let epoch = 1;
|
|
1330
|
-
const SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
|
|
1331
|
-
function setActiveConsumer(consumer) {
|
|
1332
|
-
const prev = activeConsumer;
|
|
1333
|
-
activeConsumer = consumer;
|
|
1334
|
-
return prev;
|
|
1335
|
-
}
|
|
1336
|
-
function getActiveConsumer() {
|
|
1337
|
-
return activeConsumer;
|
|
1338
|
-
}
|
|
1339
|
-
function isInNotificationPhase() {
|
|
1340
|
-
return inNotificationPhase;
|
|
1341
|
-
}
|
|
1342
|
-
const REACTIVE_NODE = {
|
|
1343
|
-
version: 0,
|
|
1344
|
-
lastCleanEpoch: 0,
|
|
1345
|
-
dirty: false,
|
|
1346
|
-
producerNode: void 0,
|
|
1347
|
-
producerLastReadVersion: void 0,
|
|
1348
|
-
producerIndexOfThis: void 0,
|
|
1349
|
-
nextProducerIndex: 0,
|
|
1350
|
-
liveConsumerNode: void 0,
|
|
1351
|
-
liveConsumerIndexOfThis: void 0,
|
|
1352
|
-
consumerAllowSignalWrites: false,
|
|
1353
|
-
consumerIsAlwaysLive: false,
|
|
1354
|
-
producerMustRecompute: () => false,
|
|
1355
|
-
producerRecomputeValue: () => {
|
|
1356
|
-
},
|
|
1357
|
-
consumerMarkedDirty: () => {
|
|
1358
|
-
},
|
|
1359
|
-
consumerOnSignalRead: () => {
|
|
1360
|
-
}
|
|
1361
|
-
};
|
|
1362
|
-
function producerAccessed(node) {
|
|
1363
|
-
if (inNotificationPhase) {
|
|
1364
|
-
throw new Error(
|
|
1365
|
-
typeof ngDevMode !== "undefined" && ngDevMode ? `Assertion error: signal read during notification phase` : ""
|
|
1366
|
-
);
|
|
1367
|
-
}
|
|
1368
|
-
if (activeConsumer === null) {
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1371
|
-
activeConsumer.consumerOnSignalRead(node);
|
|
1372
|
-
const idx = activeConsumer.nextProducerIndex++;
|
|
1373
|
-
assertConsumerNode(activeConsumer);
|
|
1374
|
-
if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node) {
|
|
1375
|
-
if (consumerIsLive(activeConsumer)) {
|
|
1376
|
-
const staleProducer = activeConsumer.producerNode[idx];
|
|
1377
|
-
producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
if (activeConsumer.producerNode[idx] !== node) {
|
|
1381
|
-
activeConsumer.producerNode[idx] = node;
|
|
1382
|
-
activeConsumer.producerIndexOfThis[idx] = consumerIsLive(activeConsumer) ? producerAddLiveConsumer(node, activeConsumer, idx) : 0;
|
|
1383
|
-
}
|
|
1384
|
-
activeConsumer.producerLastReadVersion[idx] = node.version;
|
|
1385
|
-
}
|
|
1386
|
-
function producerIncrementEpoch() {
|
|
1387
|
-
epoch++;
|
|
1388
|
-
}
|
|
1389
|
-
function producerUpdateValueVersion(node) {
|
|
1390
|
-
if (!node.dirty && node.lastCleanEpoch === epoch) {
|
|
1391
|
-
return;
|
|
1392
|
-
}
|
|
1393
|
-
if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
|
|
1394
|
-
node.dirty = false;
|
|
1395
|
-
node.lastCleanEpoch = epoch;
|
|
1396
|
-
return;
|
|
1397
|
-
}
|
|
1398
|
-
node.producerRecomputeValue(node);
|
|
1399
|
-
node.dirty = false;
|
|
1400
|
-
node.lastCleanEpoch = epoch;
|
|
1401
|
-
}
|
|
1402
|
-
function producerNotifyConsumers(node) {
|
|
1403
|
-
if (node.liveConsumerNode === void 0) {
|
|
1404
|
-
return;
|
|
1405
|
-
}
|
|
1406
|
-
const prev = inNotificationPhase;
|
|
1407
|
-
inNotificationPhase = true;
|
|
1408
|
-
try {
|
|
1409
|
-
for (const consumer of node.liveConsumerNode) {
|
|
1410
|
-
if (!consumer.dirty) {
|
|
1411
|
-
consumerMarkDirty(consumer);
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
} finally {
|
|
1415
|
-
inNotificationPhase = prev;
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
function producerUpdatesAllowed() {
|
|
1419
|
-
return (activeConsumer == null ? void 0 : activeConsumer.consumerAllowSignalWrites) !== false;
|
|
1420
|
-
}
|
|
1421
|
-
function consumerMarkDirty(node) {
|
|
1422
|
-
var _a2;
|
|
1423
|
-
node.dirty = true;
|
|
1424
|
-
producerNotifyConsumers(node);
|
|
1425
|
-
(_a2 = node.consumerMarkedDirty) == null ? void 0 : _a2.call(node.wrapper ?? node);
|
|
1426
|
-
}
|
|
1427
|
-
function consumerBeforeComputation(node) {
|
|
1428
|
-
node && (node.nextProducerIndex = 0);
|
|
1429
|
-
return setActiveConsumer(node);
|
|
1430
|
-
}
|
|
1431
|
-
function consumerAfterComputation(node, prevConsumer) {
|
|
1432
|
-
setActiveConsumer(prevConsumer);
|
|
1433
|
-
if (!node || node.producerNode === void 0 || node.producerIndexOfThis === void 0 || node.producerLastReadVersion === void 0) {
|
|
1434
|
-
return;
|
|
1435
|
-
}
|
|
1436
|
-
if (consumerIsLive(node)) {
|
|
1437
|
-
for (let i = node.nextProducerIndex; i < node.producerNode.length; i++) {
|
|
1438
|
-
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
while (node.producerNode.length > node.nextProducerIndex) {
|
|
1442
|
-
node.producerNode.pop();
|
|
1443
|
-
node.producerLastReadVersion.pop();
|
|
1444
|
-
node.producerIndexOfThis.pop();
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
function consumerPollProducersForChange(node) {
|
|
1448
|
-
assertConsumerNode(node);
|
|
1449
|
-
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1450
|
-
const producer = node.producerNode[i];
|
|
1451
|
-
const seenVersion = node.producerLastReadVersion[i];
|
|
1452
|
-
if (seenVersion !== producer.version) {
|
|
1453
|
-
return true;
|
|
1454
|
-
}
|
|
1455
|
-
producerUpdateValueVersion(producer);
|
|
1456
|
-
if (seenVersion !== producer.version) {
|
|
1457
|
-
return true;
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
return false;
|
|
1461
|
-
}
|
|
1462
|
-
function producerAddLiveConsumer(node, consumer, indexOfThis) {
|
|
1463
|
-
var _a2;
|
|
1464
|
-
assertProducerNode(node);
|
|
1465
|
-
assertConsumerNode(node);
|
|
1466
|
-
if (node.liveConsumerNode.length === 0) {
|
|
1467
|
-
(_a2 = node.watched) == null ? void 0 : _a2.call(node.wrapper);
|
|
1468
|
-
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1469
|
-
node.producerIndexOfThis[i] = producerAddLiveConsumer(node.producerNode[i], node, i);
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
node.liveConsumerIndexOfThis.push(indexOfThis);
|
|
1473
|
-
return node.liveConsumerNode.push(consumer) - 1;
|
|
1474
|
-
}
|
|
1475
|
-
function producerRemoveLiveConsumerAtIndex(node, idx) {
|
|
1476
|
-
var _a2;
|
|
1477
|
-
assertProducerNode(node);
|
|
1478
|
-
assertConsumerNode(node);
|
|
1479
|
-
if (typeof ngDevMode !== "undefined" && ngDevMode && idx >= node.liveConsumerNode.length) {
|
|
1480
|
-
throw new Error(
|
|
1481
|
-
`Assertion error: active consumer index ${idx} is out of bounds of ${node.liveConsumerNode.length} consumers)`
|
|
1482
|
-
);
|
|
1483
|
-
}
|
|
1484
|
-
if (node.liveConsumerNode.length === 1) {
|
|
1485
|
-
(_a2 = node.unwatched) == null ? void 0 : _a2.call(node.wrapper);
|
|
1486
|
-
for (let i = 0; i < node.producerNode.length; i++) {
|
|
1487
|
-
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
const lastIdx = node.liveConsumerNode.length - 1;
|
|
1491
|
-
node.liveConsumerNode[idx] = node.liveConsumerNode[lastIdx];
|
|
1492
|
-
node.liveConsumerIndexOfThis[idx] = node.liveConsumerIndexOfThis[lastIdx];
|
|
1493
|
-
node.liveConsumerNode.length--;
|
|
1494
|
-
node.liveConsumerIndexOfThis.length--;
|
|
1495
|
-
if (idx < node.liveConsumerNode.length) {
|
|
1496
|
-
const idxProducer = node.liveConsumerIndexOfThis[idx];
|
|
1497
|
-
const consumer = node.liveConsumerNode[idx];
|
|
1498
|
-
assertConsumerNode(consumer);
|
|
1499
|
-
consumer.producerIndexOfThis[idxProducer] = idx;
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
function consumerIsLive(node) {
|
|
1503
|
-
var _a2;
|
|
1504
|
-
return node.consumerIsAlwaysLive || (((_a2 = node == null ? void 0 : node.liveConsumerNode) == null ? void 0 : _a2.length) ?? 0) > 0;
|
|
1505
|
-
}
|
|
1506
|
-
function assertConsumerNode(node) {
|
|
1507
|
-
node.producerNode ?? (node.producerNode = []);
|
|
1508
|
-
node.producerIndexOfThis ?? (node.producerIndexOfThis = []);
|
|
1509
|
-
node.producerLastReadVersion ?? (node.producerLastReadVersion = []);
|
|
1510
|
-
}
|
|
1511
|
-
function assertProducerNode(node) {
|
|
1512
|
-
node.liveConsumerNode ?? (node.liveConsumerNode = []);
|
|
1513
|
-
node.liveConsumerIndexOfThis ?? (node.liveConsumerIndexOfThis = []);
|
|
1514
|
-
}
|
|
1515
|
-
/**
|
|
1516
|
-
* @license
|
|
1517
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1518
|
-
*
|
|
1519
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1520
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1521
|
-
*/
|
|
1522
|
-
function computedGet(node) {
|
|
1523
|
-
producerUpdateValueVersion(node);
|
|
1524
|
-
producerAccessed(node);
|
|
1525
|
-
if (node.value === ERRORED) {
|
|
1526
|
-
throw node.error;
|
|
1527
|
-
}
|
|
1528
|
-
return node.value;
|
|
1529
|
-
}
|
|
1530
|
-
function createComputed(computation) {
|
|
1531
|
-
const node = Object.create(COMPUTED_NODE);
|
|
1532
|
-
node.computation = computation;
|
|
1533
|
-
const computed = () => computedGet(node);
|
|
1534
|
-
computed[SIGNAL] = node;
|
|
1535
|
-
return computed;
|
|
1536
|
-
}
|
|
1537
|
-
const UNSET = /* @__PURE__ */ Symbol("UNSET");
|
|
1538
|
-
const COMPUTING = /* @__PURE__ */ Symbol("COMPUTING");
|
|
1539
|
-
const ERRORED = /* @__PURE__ */ Symbol("ERRORED");
|
|
1540
|
-
const COMPUTED_NODE = /* @__PURE__ */ (() => {
|
|
1541
|
-
return {
|
|
1542
|
-
...REACTIVE_NODE,
|
|
1543
|
-
value: UNSET,
|
|
1544
|
-
dirty: true,
|
|
1545
|
-
error: null,
|
|
1546
|
-
equal: defaultEquals,
|
|
1547
|
-
producerMustRecompute(node) {
|
|
1548
|
-
return node.value === UNSET || node.value === COMPUTING;
|
|
1549
|
-
},
|
|
1550
|
-
producerRecomputeValue(node) {
|
|
1551
|
-
if (node.value === COMPUTING) {
|
|
1552
|
-
throw new Error("Detected cycle in computations.");
|
|
1553
|
-
}
|
|
1554
|
-
const oldValue = node.value;
|
|
1555
|
-
node.value = COMPUTING;
|
|
1556
|
-
const prevConsumer = consumerBeforeComputation(node);
|
|
1557
|
-
let newValue;
|
|
1558
|
-
let wasEqual = false;
|
|
1559
|
-
try {
|
|
1560
|
-
newValue = node.computation.call(node.wrapper);
|
|
1561
|
-
const oldOk = oldValue !== UNSET && oldValue !== ERRORED;
|
|
1562
|
-
wasEqual = oldOk && node.equal.call(node.wrapper, oldValue, newValue);
|
|
1563
|
-
} catch (err) {
|
|
1564
|
-
newValue = ERRORED;
|
|
1565
|
-
node.error = err;
|
|
1566
|
-
} finally {
|
|
1567
|
-
consumerAfterComputation(node, prevConsumer);
|
|
1568
|
-
}
|
|
1569
|
-
if (wasEqual) {
|
|
1570
|
-
node.value = oldValue;
|
|
1571
|
-
return;
|
|
1572
|
-
}
|
|
1573
|
-
node.value = newValue;
|
|
1574
|
-
node.version++;
|
|
1575
|
-
}
|
|
1576
|
-
};
|
|
1577
|
-
})();
|
|
1578
|
-
/**
|
|
1579
|
-
* @license
|
|
1580
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1581
|
-
*
|
|
1582
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1583
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1584
|
-
*/
|
|
1585
|
-
function defaultThrowError() {
|
|
1586
|
-
throw new Error();
|
|
1587
|
-
}
|
|
1588
|
-
let throwInvalidWriteToSignalErrorFn = defaultThrowError;
|
|
1589
|
-
function throwInvalidWriteToSignalError() {
|
|
1590
|
-
throwInvalidWriteToSignalErrorFn();
|
|
1591
|
-
}
|
|
1592
|
-
/**
|
|
1593
|
-
* @license
|
|
1594
|
-
* Copyright Google LLC All Rights Reserved.
|
|
1595
|
-
*
|
|
1596
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
1597
|
-
* found in the LICENSE file at https://angular.io/license
|
|
1598
|
-
*/
|
|
1599
|
-
function createSignal(initialValue) {
|
|
1600
|
-
const node = Object.create(SIGNAL_NODE);
|
|
1601
|
-
node.value = initialValue;
|
|
1602
|
-
const getter = () => {
|
|
1603
|
-
producerAccessed(node);
|
|
1604
|
-
return node.value;
|
|
1605
|
-
};
|
|
1606
|
-
getter[SIGNAL] = node;
|
|
1607
|
-
return getter;
|
|
1608
|
-
}
|
|
1609
|
-
function signalGetFn() {
|
|
1610
|
-
producerAccessed(this);
|
|
1611
|
-
return this.value;
|
|
1612
|
-
}
|
|
1613
|
-
function signalSetFn(node, newValue) {
|
|
1614
|
-
if (!producerUpdatesAllowed()) {
|
|
1615
|
-
throwInvalidWriteToSignalError();
|
|
1616
|
-
}
|
|
1617
|
-
if (!node.equal.call(node.wrapper, node.value, newValue)) {
|
|
1618
|
-
node.value = newValue;
|
|
1619
|
-
signalValueChanged(node);
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
const SIGNAL_NODE = /* @__PURE__ */ (() => {
|
|
1623
|
-
return {
|
|
1624
|
-
...REACTIVE_NODE,
|
|
1625
|
-
equal: defaultEquals,
|
|
1626
|
-
value: void 0
|
|
1627
|
-
};
|
|
1628
|
-
})();
|
|
1629
|
-
function signalValueChanged(node) {
|
|
1630
|
-
node.version++;
|
|
1631
|
-
producerIncrementEpoch();
|
|
1632
|
-
producerNotifyConsumers(node);
|
|
1633
|
-
}
|
|
1634
|
-
/**
|
|
1635
|
-
* @license
|
|
1636
|
-
* Copyright 2024 Bloomberg Finance L.P.
|
|
1637
|
-
*
|
|
1638
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1639
|
-
* you may not use this file except in compliance with the License.
|
|
1640
|
-
* You may obtain a copy of the License at
|
|
1641
|
-
*
|
|
1642
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1643
|
-
*
|
|
1644
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1645
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1646
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1647
|
-
* See the License for the specific language governing permissions and
|
|
1648
|
-
* limitations under the License.
|
|
1649
|
-
*/
|
|
1650
|
-
const NODE = Symbol("node");
|
|
1651
|
-
var Signal;
|
|
1652
|
-
((Signal2) => {
|
|
1653
|
-
var _a2, _brand, _b, _brand2;
|
|
1654
|
-
class State {
|
|
1655
|
-
constructor(initialValue, options = {}) {
|
|
1656
|
-
__privateAdd2(this, _brand);
|
|
1657
|
-
__publicField2(this, _a2);
|
|
1658
|
-
const ref = createSignal(initialValue);
|
|
1659
|
-
const node = ref[SIGNAL];
|
|
1660
|
-
this[NODE] = node;
|
|
1661
|
-
node.wrapper = this;
|
|
1662
|
-
if (options) {
|
|
1663
|
-
const equals = options.equals;
|
|
1664
|
-
if (equals) {
|
|
1665
|
-
node.equal = equals;
|
|
1666
|
-
}
|
|
1667
|
-
node.watched = options[Signal2.subtle.watched];
|
|
1668
|
-
node.unwatched = options[Signal2.subtle.unwatched];
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
get() {
|
|
1672
|
-
if (!(0, Signal2.isState)(this))
|
|
1673
|
-
throw new TypeError("Wrong receiver type for Signal.State.prototype.get");
|
|
1674
|
-
return signalGetFn.call(this[NODE]);
|
|
1675
|
-
}
|
|
1676
|
-
set(newValue) {
|
|
1677
|
-
if (!(0, Signal2.isState)(this))
|
|
1678
|
-
throw new TypeError("Wrong receiver type for Signal.State.prototype.set");
|
|
1679
|
-
if (isInNotificationPhase()) {
|
|
1680
|
-
throw new Error("Writes to signals not permitted during Watcher callback");
|
|
1681
|
-
}
|
|
1682
|
-
const ref = this[NODE];
|
|
1683
|
-
signalSetFn(ref, newValue);
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
_a2 = NODE;
|
|
1687
|
-
_brand = /* @__PURE__ */ new WeakSet();
|
|
1688
|
-
Signal2.isState = (s) => typeof s === "object" && __privateIn(_brand, s);
|
|
1689
|
-
Signal2.State = State;
|
|
1690
|
-
class Computed {
|
|
1691
|
-
// Create a Signal which evaluates to the value returned by the callback.
|
|
1692
|
-
// Callback is called with this signal as the parameter.
|
|
1693
|
-
constructor(computation, options) {
|
|
1694
|
-
__privateAdd2(this, _brand2);
|
|
1695
|
-
__publicField2(this, _b);
|
|
1696
|
-
const ref = createComputed(computation);
|
|
1697
|
-
const node = ref[SIGNAL];
|
|
1698
|
-
node.consumerAllowSignalWrites = true;
|
|
1699
|
-
this[NODE] = node;
|
|
1700
|
-
node.wrapper = this;
|
|
1701
|
-
if (options) {
|
|
1702
|
-
const equals = options.equals;
|
|
1703
|
-
if (equals) {
|
|
1704
|
-
node.equal = equals;
|
|
1705
|
-
}
|
|
1706
|
-
node.watched = options[Signal2.subtle.watched];
|
|
1707
|
-
node.unwatched = options[Signal2.subtle.unwatched];
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
get() {
|
|
1711
|
-
if (!(0, Signal2.isComputed)(this))
|
|
1712
|
-
throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");
|
|
1713
|
-
return computedGet(this[NODE]);
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
_b = NODE;
|
|
1717
|
-
_brand2 = /* @__PURE__ */ new WeakSet();
|
|
1718
|
-
Signal2.isComputed = (c) => typeof c === "object" && __privateIn(_brand2, c);
|
|
1719
|
-
Signal2.Computed = Computed;
|
|
1720
|
-
((subtle2) => {
|
|
1721
|
-
var _a22, _brand3, _assertSignals, assertSignals_fn;
|
|
1722
|
-
function untrack(cb) {
|
|
1723
|
-
let output;
|
|
1724
|
-
let prevActiveConsumer = null;
|
|
1725
|
-
try {
|
|
1726
|
-
prevActiveConsumer = setActiveConsumer(null);
|
|
1727
|
-
output = cb();
|
|
1728
|
-
} finally {
|
|
1729
|
-
setActiveConsumer(prevActiveConsumer);
|
|
1730
|
-
}
|
|
1731
|
-
return output;
|
|
1732
|
-
}
|
|
1733
|
-
subtle2.untrack = untrack;
|
|
1734
|
-
function introspectSources(sink) {
|
|
1735
|
-
var _a3;
|
|
1736
|
-
if (!(0, Signal2.isComputed)(sink) && !(0, Signal2.isWatcher)(sink)) {
|
|
1737
|
-
throw new TypeError("Called introspectSources without a Computed or Watcher argument");
|
|
1738
|
-
}
|
|
1739
|
-
return ((_a3 = sink[NODE].producerNode) == null ? void 0 : _a3.map((n) => n.wrapper)) ?? [];
|
|
1740
|
-
}
|
|
1741
|
-
subtle2.introspectSources = introspectSources;
|
|
1742
|
-
function introspectSinks(signal) {
|
|
1743
|
-
var _a3;
|
|
1744
|
-
if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {
|
|
1745
|
-
throw new TypeError("Called introspectSinks without a Signal argument");
|
|
1746
|
-
}
|
|
1747
|
-
return ((_a3 = signal[NODE].liveConsumerNode) == null ? void 0 : _a3.map((n) => n.wrapper)) ?? [];
|
|
1748
|
-
}
|
|
1749
|
-
subtle2.introspectSinks = introspectSinks;
|
|
1750
|
-
function hasSinks(signal) {
|
|
1751
|
-
if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {
|
|
1752
|
-
throw new TypeError("Called hasSinks without a Signal argument");
|
|
1753
|
-
}
|
|
1754
|
-
const liveConsumerNode = signal[NODE].liveConsumerNode;
|
|
1755
|
-
if (!liveConsumerNode)
|
|
1756
|
-
return false;
|
|
1757
|
-
return liveConsumerNode.length > 0;
|
|
1758
|
-
}
|
|
1759
|
-
subtle2.hasSinks = hasSinks;
|
|
1760
|
-
function hasSources(signal) {
|
|
1761
|
-
if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isWatcher)(signal)) {
|
|
1762
|
-
throw new TypeError("Called hasSources without a Computed or Watcher argument");
|
|
1763
|
-
}
|
|
1764
|
-
const producerNode = signal[NODE].producerNode;
|
|
1765
|
-
if (!producerNode)
|
|
1766
|
-
return false;
|
|
1767
|
-
return producerNode.length > 0;
|
|
1768
|
-
}
|
|
1769
|
-
subtle2.hasSources = hasSources;
|
|
1770
|
-
class Watcher {
|
|
1771
|
-
// When a (recursive) source of Watcher is written to, call this callback,
|
|
1772
|
-
// if it hasn't already been called since the last `watch` call.
|
|
1773
|
-
// No signals may be read or written during the notify.
|
|
1774
|
-
constructor(notify) {
|
|
1775
|
-
__privateAdd2(this, _brand3);
|
|
1776
|
-
__privateAdd2(this, _assertSignals);
|
|
1777
|
-
__publicField2(this, _a22);
|
|
1778
|
-
let node = Object.create(REACTIVE_NODE);
|
|
1779
|
-
node.wrapper = this;
|
|
1780
|
-
node.consumerMarkedDirty = notify;
|
|
1781
|
-
node.consumerIsAlwaysLive = true;
|
|
1782
|
-
node.consumerAllowSignalWrites = false;
|
|
1783
|
-
node.producerNode = [];
|
|
1784
|
-
this[NODE] = node;
|
|
1785
|
-
}
|
|
1786
|
-
// Add these signals to the Watcher's set, and set the watcher to run its
|
|
1787
|
-
// notify callback next time any signal in the set (or one of its dependencies) changes.
|
|
1788
|
-
// Can be called with no arguments just to reset the "notified" state, so that
|
|
1789
|
-
// the notify callback will be invoked again.
|
|
1790
|
-
watch(...signals) {
|
|
1791
|
-
if (!(0, Signal2.isWatcher)(this)) {
|
|
1792
|
-
throw new TypeError("Called unwatch without Watcher receiver");
|
|
1793
|
-
}
|
|
1794
|
-
__privateMethod2(this, _assertSignals, assertSignals_fn).call(this, signals);
|
|
1795
|
-
const node = this[NODE];
|
|
1796
|
-
node.dirty = false;
|
|
1797
|
-
const prev = setActiveConsumer(node);
|
|
1798
|
-
for (const signal of signals) {
|
|
1799
|
-
producerAccessed(signal[NODE]);
|
|
1800
|
-
}
|
|
1801
|
-
setActiveConsumer(prev);
|
|
1802
|
-
}
|
|
1803
|
-
// Remove these signals from the watched set (e.g., for an effect which is disposed)
|
|
1804
|
-
unwatch(...signals) {
|
|
1805
|
-
if (!(0, Signal2.isWatcher)(this)) {
|
|
1806
|
-
throw new TypeError("Called unwatch without Watcher receiver");
|
|
1807
|
-
}
|
|
1808
|
-
__privateMethod2(this, _assertSignals, assertSignals_fn).call(this, signals);
|
|
1809
|
-
const node = this[NODE];
|
|
1810
|
-
assertConsumerNode(node);
|
|
1811
|
-
for (let i = node.producerNode.length - 1; i >= 0; i--) {
|
|
1812
|
-
if (signals.includes(node.producerNode[i].wrapper)) {
|
|
1813
|
-
producerRemoveLiveConsumerAtIndex(node.producerNode[i], node.producerIndexOfThis[i]);
|
|
1814
|
-
const lastIdx = node.producerNode.length - 1;
|
|
1815
|
-
node.producerNode[i] = node.producerNode[lastIdx];
|
|
1816
|
-
node.producerIndexOfThis[i] = node.producerIndexOfThis[lastIdx];
|
|
1817
|
-
node.producerNode.length--;
|
|
1818
|
-
node.producerIndexOfThis.length--;
|
|
1819
|
-
node.nextProducerIndex--;
|
|
1820
|
-
if (i < node.producerNode.length) {
|
|
1821
|
-
const idxConsumer = node.producerIndexOfThis[i];
|
|
1822
|
-
const producer = node.producerNode[i];
|
|
1823
|
-
assertProducerNode(producer);
|
|
1824
|
-
producer.liveConsumerIndexOfThis[idxConsumer] = i;
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
// Returns the set of computeds in the Watcher's set which are still yet
|
|
1830
|
-
// to be re-evaluated
|
|
1831
|
-
getPending() {
|
|
1832
|
-
if (!(0, Signal2.isWatcher)(this)) {
|
|
1833
|
-
throw new TypeError("Called getPending without Watcher receiver");
|
|
1834
|
-
}
|
|
1835
|
-
const node = this[NODE];
|
|
1836
|
-
return node.producerNode.filter((n) => n.dirty).map((n) => n.wrapper);
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
_a22 = NODE;
|
|
1840
|
-
_brand3 = /* @__PURE__ */ new WeakSet();
|
|
1841
|
-
_assertSignals = /* @__PURE__ */ new WeakSet();
|
|
1842
|
-
assertSignals_fn = function(signals) {
|
|
1843
|
-
for (const signal of signals) {
|
|
1844
|
-
if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) {
|
|
1845
|
-
throw new TypeError("Called watch/unwatch without a Computed or State argument");
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
};
|
|
1849
|
-
Signal2.isWatcher = (w) => __privateIn(_brand3, w);
|
|
1850
|
-
subtle2.Watcher = Watcher;
|
|
1851
|
-
function currentComputed() {
|
|
1852
|
-
var _a3;
|
|
1853
|
-
return (_a3 = getActiveConsumer()) == null ? void 0 : _a3.wrapper;
|
|
1854
|
-
}
|
|
1855
|
-
subtle2.currentComputed = currentComputed;
|
|
1856
|
-
subtle2.watched = Symbol("watched");
|
|
1857
|
-
subtle2.unwatched = Symbol("unwatched");
|
|
1858
|
-
})(Signal2.subtle || (Signal2.subtle = {}));
|
|
1859
|
-
})(Signal || (Signal = {}));
|
|
1860
|
-
const createStorage = (initial = null) => new Signal.State(initial, {
|
|
1861
|
-
equals: () => false
|
|
1862
|
-
});
|
|
1863
|
-
const ARRAY_GETTER_METHODS = /* @__PURE__ */ new Set([Symbol.iterator, "concat", "entries", "every", "filter", "find", "findIndex", "flat", "flatMap", "forEach", "includes", "indexOf", "join", "keys", "lastIndexOf", "map", "reduce", "reduceRight", "slice", "some", "values"]);
|
|
1864
|
-
const ARRAY_WRITE_THEN_READ_METHODS = /* @__PURE__ */ new Set(["fill", "push", "unshift"]);
|
|
1865
|
-
function convertToInt(prop) {
|
|
1866
|
-
if (typeof prop === "symbol") return null;
|
|
1867
|
-
const num = Number(prop);
|
|
1868
|
-
if (isNaN(num)) return null;
|
|
1869
|
-
return num % 1 === 0 ? num : null;
|
|
1870
|
-
}
|
|
1871
|
-
const _SignalArray = class _SignalArray {
|
|
1872
|
-
constructor(arr = []) {
|
|
1873
|
-
__privateAdd(this, _SignalArray_instances);
|
|
1874
|
-
__privateAdd(this, _collection, createStorage());
|
|
1875
|
-
__privateAdd(this, _storages, /* @__PURE__ */ new Map());
|
|
1876
|
-
let clone = arr.slice();
|
|
1877
|
-
let self = this;
|
|
1878
|
-
let boundFns = /* @__PURE__ */ new Map();
|
|
1879
|
-
let nativelyAccessingLengthFromPushOrUnshift = false;
|
|
1880
|
-
return new Proxy(clone, {
|
|
1881
|
-
get(target, prop) {
|
|
1882
|
-
var _a2;
|
|
1883
|
-
let index = convertToInt(prop);
|
|
1884
|
-
if (index !== null) {
|
|
1885
|
-
__privateMethod(_a2 = self, _SignalArray_instances, readStorageFor_fn).call(_a2, index);
|
|
1886
|
-
__privateGet(self, _collection).get();
|
|
1887
|
-
return target[index];
|
|
1888
|
-
}
|
|
1889
|
-
if (prop === "length") {
|
|
1890
|
-
if (nativelyAccessingLengthFromPushOrUnshift) {
|
|
1891
|
-
nativelyAccessingLengthFromPushOrUnshift = false;
|
|
1892
|
-
} else {
|
|
1893
|
-
__privateGet(self, _collection).get();
|
|
1894
|
-
}
|
|
1895
|
-
return target[prop];
|
|
1896
|
-
}
|
|
1897
|
-
if (ARRAY_WRITE_THEN_READ_METHODS.has(prop)) {
|
|
1898
|
-
nativelyAccessingLengthFromPushOrUnshift = true;
|
|
1899
|
-
}
|
|
1900
|
-
if (ARRAY_GETTER_METHODS.has(prop)) {
|
|
1901
|
-
let fn = boundFns.get(prop);
|
|
1902
|
-
if (fn === void 0) {
|
|
1903
|
-
fn = (...args) => {
|
|
1904
|
-
__privateGet(self, _collection).get();
|
|
1905
|
-
return target[prop](...args);
|
|
1906
|
-
};
|
|
1907
|
-
boundFns.set(prop, fn);
|
|
1908
|
-
}
|
|
1909
|
-
return fn;
|
|
1910
|
-
}
|
|
1911
|
-
return target[prop];
|
|
1912
|
-
},
|
|
1913
|
-
set(target, prop, value) {
|
|
1914
|
-
var _a2;
|
|
1915
|
-
target[prop] = value;
|
|
1916
|
-
let index = convertToInt(prop);
|
|
1917
|
-
if (index !== null) {
|
|
1918
|
-
__privateMethod(_a2 = self, _SignalArray_instances, dirtyStorageFor_fn).call(_a2, index);
|
|
1919
|
-
__privateGet(self, _collection).set(null);
|
|
1920
|
-
} else if (prop === "length") {
|
|
1921
|
-
__privateGet(self, _collection).set(null);
|
|
1922
|
-
}
|
|
1923
|
-
return true;
|
|
1924
|
-
},
|
|
1925
|
-
getPrototypeOf() {
|
|
1926
|
-
return _SignalArray.prototype;
|
|
1927
|
-
}
|
|
1928
|
-
});
|
|
1929
|
-
}
|
|
1930
|
-
/**
|
|
1931
|
-
* Creates an array from an iterable object.
|
|
1932
|
-
* @param iterable An iterable object to convert to an array.
|
|
1933
|
-
*/
|
|
1934
|
-
/**
|
|
1935
|
-
* Creates an array from an iterable object.
|
|
1936
|
-
* @param iterable An iterable object to convert to an array.
|
|
1937
|
-
* @param mapfn A mapping function to call on every element of the array.
|
|
1938
|
-
* @param thisArg Value of 'this' used to invoke the mapfn.
|
|
1939
|
-
*/
|
|
1940
|
-
static from(iterable, mapfn, thisArg) {
|
|
1941
|
-
return mapfn ? new _SignalArray(Array.from(iterable, mapfn, thisArg)) : new _SignalArray(Array.from(iterable));
|
|
1942
|
-
}
|
|
1943
|
-
static of(...arr) {
|
|
1944
|
-
return new _SignalArray(arr);
|
|
1945
|
-
}
|
|
1946
|
-
};
|
|
1947
|
-
_collection = new WeakMap();
|
|
1948
|
-
_storages = new WeakMap();
|
|
1949
|
-
_SignalArray_instances = new WeakSet();
|
|
1950
|
-
readStorageFor_fn = function(index) {
|
|
1951
|
-
let storage = __privateGet(this, _storages).get(index);
|
|
1952
|
-
if (storage === void 0) {
|
|
1953
|
-
storage = createStorage();
|
|
1954
|
-
__privateGet(this, _storages).set(index, storage);
|
|
1955
|
-
}
|
|
1956
|
-
storage.get();
|
|
1957
|
-
};
|
|
1958
|
-
dirtyStorageFor_fn = function(index) {
|
|
1959
|
-
const storage = __privateGet(this, _storages).get(index);
|
|
1960
|
-
if (storage) {
|
|
1961
|
-
storage.set(null);
|
|
1962
|
-
}
|
|
1963
|
-
};
|
|
1964
|
-
let SignalArray = _SignalArray;
|
|
1965
|
-
Object.setPrototypeOf(SignalArray.prototype, Array.prototype);
|
|
1966
|
-
class SignalMap {
|
|
1967
|
-
constructor(existing) {
|
|
1968
|
-
__publicField(this, "collection", createStorage());
|
|
1969
|
-
__publicField(this, "storages", /* @__PURE__ */ new Map());
|
|
1970
|
-
__publicField(this, "vals");
|
|
1971
|
-
this.vals = existing ? new Map(existing) : /* @__PURE__ */ new Map();
|
|
1972
|
-
}
|
|
1973
|
-
readStorageFor(key) {
|
|
1974
|
-
const {
|
|
1975
|
-
storages
|
|
1976
|
-
} = this;
|
|
1977
|
-
let storage = storages.get(key);
|
|
1978
|
-
if (storage === void 0) {
|
|
1979
|
-
storage = createStorage();
|
|
1980
|
-
storages.set(key, storage);
|
|
1981
|
-
}
|
|
1982
|
-
storage.get();
|
|
1983
|
-
}
|
|
1984
|
-
dirtyStorageFor(key) {
|
|
1985
|
-
const storage = this.storages.get(key);
|
|
1986
|
-
if (storage) {
|
|
1987
|
-
storage.set(null);
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
// **** KEY GETTERS ****
|
|
1991
|
-
get(key) {
|
|
1992
|
-
this.readStorageFor(key);
|
|
1993
|
-
return this.vals.get(key);
|
|
1994
|
-
}
|
|
1995
|
-
has(key) {
|
|
1996
|
-
this.readStorageFor(key);
|
|
1997
|
-
return this.vals.has(key);
|
|
1998
|
-
}
|
|
1999
|
-
// **** ALL GETTERS ****
|
|
2000
|
-
entries() {
|
|
2001
|
-
this.collection.get();
|
|
2002
|
-
return this.vals.entries();
|
|
2003
|
-
}
|
|
2004
|
-
keys() {
|
|
2005
|
-
this.collection.get();
|
|
2006
|
-
return this.vals.keys();
|
|
2007
|
-
}
|
|
2008
|
-
values() {
|
|
2009
|
-
this.collection.get();
|
|
2010
|
-
return this.vals.values();
|
|
2011
|
-
}
|
|
2012
|
-
forEach(fn) {
|
|
2013
|
-
this.collection.get();
|
|
2014
|
-
this.vals.forEach(fn);
|
|
2015
|
-
}
|
|
2016
|
-
get size() {
|
|
2017
|
-
this.collection.get();
|
|
2018
|
-
return this.vals.size;
|
|
2019
|
-
}
|
|
2020
|
-
[Symbol.iterator]() {
|
|
2021
|
-
this.collection.get();
|
|
2022
|
-
return this.vals[Symbol.iterator]();
|
|
2023
|
-
}
|
|
2024
|
-
get [Symbol.toStringTag]() {
|
|
2025
|
-
return this.vals[Symbol.toStringTag];
|
|
2026
|
-
}
|
|
2027
|
-
// **** KEY SETTERS ****
|
|
2028
|
-
set(key, value) {
|
|
2029
|
-
this.dirtyStorageFor(key);
|
|
2030
|
-
this.collection.set(null);
|
|
2031
|
-
this.vals.set(key, value);
|
|
2032
|
-
return this;
|
|
2033
|
-
}
|
|
2034
|
-
delete(key) {
|
|
2035
|
-
this.dirtyStorageFor(key);
|
|
2036
|
-
this.collection.set(null);
|
|
2037
|
-
return this.vals.delete(key);
|
|
2038
|
-
}
|
|
2039
|
-
// **** ALL SETTERS ****
|
|
2040
|
-
clear() {
|
|
2041
|
-
this.storages.forEach((s) => s.set(null));
|
|
2042
|
-
this.collection.set(null);
|
|
2043
|
-
this.vals.clear();
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
Object.setPrototypeOf(SignalMap.prototype, Map.prototype);
|
|
2047
|
-
class SignalSet {
|
|
2048
|
-
constructor(existing) {
|
|
2049
|
-
__publicField(this, "collection", createStorage());
|
|
2050
|
-
__publicField(this, "storages", /* @__PURE__ */ new Map());
|
|
2051
|
-
__publicField(this, "vals");
|
|
2052
|
-
this.vals = new Set(existing);
|
|
2053
|
-
}
|
|
2054
|
-
storageFor(key) {
|
|
2055
|
-
const storages = this.storages;
|
|
2056
|
-
let storage = storages.get(key);
|
|
2057
|
-
if (storage === void 0) {
|
|
2058
|
-
storage = createStorage();
|
|
2059
|
-
storages.set(key, storage);
|
|
2060
|
-
}
|
|
2061
|
-
return storage;
|
|
2062
|
-
}
|
|
2063
|
-
dirtyStorageFor(key) {
|
|
2064
|
-
const storage = this.storages.get(key);
|
|
2065
|
-
if (storage) {
|
|
2066
|
-
storage.set(null);
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
// **** KEY GETTERS ****
|
|
2070
|
-
has(value) {
|
|
2071
|
-
this.storageFor(value).get();
|
|
2072
|
-
return this.vals.has(value);
|
|
2073
|
-
}
|
|
2074
|
-
// **** ALL GETTERS ****
|
|
2075
|
-
entries() {
|
|
2076
|
-
this.collection.get();
|
|
2077
|
-
return this.vals.entries();
|
|
2078
|
-
}
|
|
2079
|
-
keys() {
|
|
2080
|
-
this.collection.get();
|
|
2081
|
-
return this.vals.keys();
|
|
2082
|
-
}
|
|
2083
|
-
values() {
|
|
2084
|
-
this.collection.get();
|
|
2085
|
-
return this.vals.values();
|
|
2086
|
-
}
|
|
2087
|
-
forEach(fn) {
|
|
2088
|
-
this.collection.get();
|
|
2089
|
-
this.vals.forEach(fn);
|
|
2090
|
-
}
|
|
2091
|
-
get size() {
|
|
2092
|
-
this.collection.get();
|
|
2093
|
-
return this.vals.size;
|
|
2094
|
-
}
|
|
2095
|
-
[Symbol.iterator]() {
|
|
2096
|
-
this.collection.get();
|
|
2097
|
-
return this.vals[Symbol.iterator]();
|
|
2098
|
-
}
|
|
2099
|
-
get [Symbol.toStringTag]() {
|
|
2100
|
-
return this.vals[Symbol.toStringTag];
|
|
2101
|
-
}
|
|
2102
|
-
// **** KEY SETTERS ****
|
|
2103
|
-
add(value) {
|
|
2104
|
-
this.dirtyStorageFor(value);
|
|
2105
|
-
this.collection.set(null);
|
|
2106
|
-
this.vals.add(value);
|
|
2107
|
-
return this;
|
|
2108
|
-
}
|
|
2109
|
-
delete(value) {
|
|
2110
|
-
this.dirtyStorageFor(value);
|
|
2111
|
-
this.collection.set(null);
|
|
2112
|
-
return this.vals.delete(value);
|
|
2113
|
-
}
|
|
2114
|
-
// **** ALL SETTERS ****
|
|
2115
|
-
clear() {
|
|
2116
|
-
this.storages.forEach((s) => s.set(null));
|
|
2117
|
-
this.collection.set(null);
|
|
2118
|
-
this.vals.clear();
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
Object.setPrototypeOf(SignalSet.prototype, Set.prototype);
|
|
2122
6
|
var ChatMessageTypeEnum = /* @__PURE__ */ ((ChatMessageTypeEnum2) => {
|
|
2123
7
|
ChatMessageTypeEnum2["MESSAGE"] = "message";
|
|
2124
8
|
ChatMessageTypeEnum2["EVENT"] = "event";
|