@blueking/ai-ui-sdk 0.0.15-beta.23 → 0.0.15-beta.24
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/component/render-input/index.vue.css +17 -17
- package/dist/component/render-input/index.vue.js +1 -1
- package/dist/component/render-input/render-drag.vue.css +5 -5
- package/dist/component/render-input/render-drag.vue.js +1 -1
- package/dist/component/render-input/render-quill.script.vue.js +2 -2
- package/dist/component/render-knowledge-icon/index.vue.css +1 -1
- package/dist/component/render-knowledge-icon/index.vue.js +1 -1
- package/dist/component/render-markdown/mark-down.js +1 -1
- package/dist/component/render-message/openai-message.vue.css +15 -15
- package/dist/component/render-message/openai-message.vue.js +1 -1
- package/dist/component/render-message/skeleton-message.vue.css +1 -1
- package/dist/component/render-message/skeleton-message.vue.js +1 -1
- package/dist/component/render-message/system-message.vue.css +2 -2
- package/dist/component/render-message/system-message.vue.js +1 -1
- package/dist/component/render-message/time-message.vue.css +1 -1
- package/dist/component/render-message/time-message.vue.js +1 -1
- package/dist/component/render-message/token-expired-message.vue.css +9 -9
- package/dist/component/render-message/token-expired-message.vue.js +1 -1
- package/dist/component/render-message/user-message.vue.css +15 -15
- package/dist/component/render-message/user-message.vue.js +1 -1
- package/dist/component/render-stop/index.vue.css +2 -2
- package/dist/component/render-stop/index.vue.js +1 -1
- package/package.json +11 -11
- package/dist/node_modules/call-bind/index.js +0 -24
- package/dist/node_modules/call-bind-apply-helpers/actualApply.js +0 -10
- package/dist/node_modules/call-bind-apply-helpers/applyBind.js +0 -10
- package/dist/node_modules/call-bind-apply-helpers/functionApply.js +0 -4
- package/dist/node_modules/call-bind-apply-helpers/functionCall.js +0 -4
- package/dist/node_modules/call-bind-apply-helpers/index.js +0 -15
- package/dist/node_modules/call-bind-apply-helpers/reflectApply.js +0 -4
- package/dist/node_modules/call-bound/index.js +0 -19
- package/dist/node_modules/deep-equal/index.js +0 -112
- package/dist/node_modules/define-data-property/index.js +0 -56
- package/dist/node_modules/define-properties/index.js +0 -47
- package/dist/node_modules/dunder-proto/get.js +0 -30
- package/dist/node_modules/es-define-property/index.js +0 -14
- package/dist/node_modules/es-errors/eval.js +0 -4
- package/dist/node_modules/es-errors/index.js +0 -4
- package/dist/node_modules/es-errors/range.js +0 -4
- package/dist/node_modules/es-errors/ref.js +0 -4
- package/dist/node_modules/es-errors/syntax.js +0 -4
- package/dist/node_modules/es-errors/type.js +0 -4
- package/dist/node_modules/es-errors/uri.js +0 -4
- package/dist/node_modules/es-object-atoms/index.js +0 -4
- package/dist/node_modules/extend/index.js +0 -117
- package/dist/node_modules/fast-diff/diff.js +0 -738
- package/dist/node_modules/function-bind/implementation.js +0 -84
- package/dist/node_modules/function-bind/index.js +0 -5
- package/dist/node_modules/functions-have-names/index.js +0 -31
- package/dist/node_modules/get-intrinsic/index.js +0 -378
- package/dist/node_modules/get-proto/Object.getPrototypeOf.js +0 -6
- package/dist/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -4
- package/dist/node_modules/get-proto/index.js +0 -27
- package/dist/node_modules/gopd/gOPD.js +0 -4
- package/dist/node_modules/gopd/index.js +0 -15
- package/dist/node_modules/has-property-descriptors/index.js +0 -22
- package/dist/node_modules/has-symbols/index.js +0 -14
- package/dist/node_modules/has-symbols/shams.js +0 -45
- package/dist/node_modules/has-tostringtag/shams.js +0 -8
- package/dist/node_modules/hasown/index.js +0 -8
- package/dist/node_modules/is-arguments/index.js +0 -44
- package/dist/node_modules/is-date-object/index.js +0 -27
- package/dist/node_modules/is-regex/index.js +0 -69
- package/dist/node_modules/math-intrinsics/abs.js +0 -4
- package/dist/node_modules/math-intrinsics/floor.js +0 -4
- package/dist/node_modules/math-intrinsics/isNaN.js +0 -6
- package/dist/node_modules/math-intrinsics/max.js +0 -4
- package/dist/node_modules/math-intrinsics/min.js +0 -4
- package/dist/node_modules/math-intrinsics/pow.js +0 -4
- package/dist/node_modules/math-intrinsics/round.js +0 -4
- package/dist/node_modules/math-intrinsics/sign.js +0 -11
- package/dist/node_modules/object-is/implementation.js +0 -19
- package/dist/node_modules/object-is/index.js +0 -18
- package/dist/node_modules/object-is/polyfill.js +0 -7
- package/dist/node_modules/object-is/shim.js +0 -14
- package/dist/node_modules/object-keys/implementation.js +0 -122
- package/dist/node_modules/object-keys/index.js +0 -32
- package/dist/node_modules/object-keys/isArguments.js +0 -17
- package/dist/node_modules/quill/dist/quill.js +0 -11562
- package/dist/node_modules/quill-delta/lib/delta.js +0 -344
- package/dist/node_modules/quill-delta/lib/op.js +0 -155
- package/dist/node_modules/regexp.prototype.flags/implementation.js +0 -39
- package/dist/node_modules/regexp.prototype.flags/index.js +0 -18
- package/dist/node_modules/regexp.prototype.flags/polyfill.js +0 -39
- package/dist/node_modules/regexp.prototype.flags/shim.js +0 -26
- package/dist/node_modules/set-function-length/index.js +0 -42
- package/dist/node_modules/set-function-name/index.js +0 -23
- package/dist/node_modules/x-mavon-editor/dist/mavon-editor.js +0 -31
@@ -1,344 +0,0 @@
|
|
1
|
-
var diff = require('../../fast-diff/diff.js');
|
2
|
-
var equal = require('../../deep-equal/index.js');
|
3
|
-
var extend = require('../../extend/index.js');
|
4
|
-
var op = require('./op.js');
|
5
|
-
|
6
|
-
|
7
|
-
var NULL_CHARACTER = String.fromCharCode(0); // Placeholder char for embed in diff()
|
8
|
-
|
9
|
-
|
10
|
-
var Delta = function (ops) {
|
11
|
-
// Assume we are given a well formed ops
|
12
|
-
if (Array.isArray(ops)) {
|
13
|
-
this.ops = ops;
|
14
|
-
} else if (ops != null && Array.isArray(ops.ops)) {
|
15
|
-
this.ops = ops.ops;
|
16
|
-
} else {
|
17
|
-
this.ops = [];
|
18
|
-
}
|
19
|
-
};
|
20
|
-
|
21
|
-
|
22
|
-
Delta.prototype.insert = function (text, attributes) {
|
23
|
-
var newOp = {};
|
24
|
-
if (text.length === 0) return this;
|
25
|
-
newOp.insert = text;
|
26
|
-
if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
|
27
|
-
newOp.attributes = attributes;
|
28
|
-
}
|
29
|
-
return this.push(newOp);
|
30
|
-
};
|
31
|
-
|
32
|
-
Delta.prototype['delete'] = function (length) {
|
33
|
-
if (length <= 0) return this;
|
34
|
-
return this.push({ 'delete': length });
|
35
|
-
};
|
36
|
-
|
37
|
-
Delta.prototype.retain = function (length, attributes) {
|
38
|
-
if (length <= 0) return this;
|
39
|
-
var newOp = { retain: length };
|
40
|
-
if (attributes != null && typeof attributes === 'object' && Object.keys(attributes).length > 0) {
|
41
|
-
newOp.attributes = attributes;
|
42
|
-
}
|
43
|
-
return this.push(newOp);
|
44
|
-
};
|
45
|
-
|
46
|
-
Delta.prototype.push = function (newOp) {
|
47
|
-
var index = this.ops.length;
|
48
|
-
var lastOp = this.ops[index - 1];
|
49
|
-
newOp = extend(true, {}, newOp);
|
50
|
-
if (typeof lastOp === 'object') {
|
51
|
-
if (typeof newOp['delete'] === 'number' && typeof lastOp['delete'] === 'number') {
|
52
|
-
this.ops[index - 1] = { 'delete': lastOp['delete'] + newOp['delete'] };
|
53
|
-
return this;
|
54
|
-
}
|
55
|
-
// Since it does not matter if we insert before or after deleting at the same index,
|
56
|
-
// always prefer to insert first
|
57
|
-
if (typeof lastOp['delete'] === 'number' && newOp.insert != null) {
|
58
|
-
index -= 1;
|
59
|
-
lastOp = this.ops[index - 1];
|
60
|
-
if (typeof lastOp !== 'object') {
|
61
|
-
this.ops.unshift(newOp);
|
62
|
-
return this;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
if (equal(newOp.attributes, lastOp.attributes)) {
|
66
|
-
if (typeof newOp.insert === 'string' && typeof lastOp.insert === 'string') {
|
67
|
-
this.ops[index - 1] = { insert: lastOp.insert + newOp.insert };
|
68
|
-
if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
|
69
|
-
return this;
|
70
|
-
} else if (typeof newOp.retain === 'number' && typeof lastOp.retain === 'number') {
|
71
|
-
this.ops[index - 1] = { retain: lastOp.retain + newOp.retain };
|
72
|
-
if (typeof newOp.attributes === 'object') this.ops[index - 1].attributes = newOp.attributes
|
73
|
-
return this;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
if (index === this.ops.length) {
|
78
|
-
this.ops.push(newOp);
|
79
|
-
} else {
|
80
|
-
this.ops.splice(index, 0, newOp);
|
81
|
-
}
|
82
|
-
return this;
|
83
|
-
};
|
84
|
-
|
85
|
-
Delta.prototype.chop = function () {
|
86
|
-
var lastOp = this.ops[this.ops.length - 1];
|
87
|
-
if (lastOp && lastOp.retain && !lastOp.attributes) {
|
88
|
-
this.ops.pop();
|
89
|
-
}
|
90
|
-
return this;
|
91
|
-
};
|
92
|
-
|
93
|
-
Delta.prototype.filter = function (predicate) {
|
94
|
-
return this.ops.filter(predicate);
|
95
|
-
};
|
96
|
-
|
97
|
-
Delta.prototype.forEach = function (predicate) {
|
98
|
-
this.ops.forEach(predicate);
|
99
|
-
};
|
100
|
-
|
101
|
-
Delta.prototype.map = function (predicate) {
|
102
|
-
return this.ops.map(predicate);
|
103
|
-
};
|
104
|
-
|
105
|
-
Delta.prototype.partition = function (predicate) {
|
106
|
-
var passed = [], failed = [];
|
107
|
-
this.forEach(function(op) {
|
108
|
-
var target = predicate(op) ? passed : failed;
|
109
|
-
target.push(op);
|
110
|
-
});
|
111
|
-
return [passed, failed];
|
112
|
-
};
|
113
|
-
|
114
|
-
Delta.prototype.reduce = function (predicate, initial) {
|
115
|
-
return this.ops.reduce(predicate, initial);
|
116
|
-
};
|
117
|
-
|
118
|
-
Delta.prototype.changeLength = function () {
|
119
|
-
return this.reduce(function (length, elem) {
|
120
|
-
if (elem.insert) {
|
121
|
-
return length + op.length(elem);
|
122
|
-
} else if (elem.delete) {
|
123
|
-
return length - elem.delete;
|
124
|
-
}
|
125
|
-
return length;
|
126
|
-
}, 0);
|
127
|
-
};
|
128
|
-
|
129
|
-
Delta.prototype.length = function () {
|
130
|
-
return this.reduce(function (length, elem) {
|
131
|
-
return length + op.length(elem);
|
132
|
-
}, 0);
|
133
|
-
};
|
134
|
-
|
135
|
-
Delta.prototype.slice = function (start, end) {
|
136
|
-
start = start || 0;
|
137
|
-
if (typeof end !== 'number') end = Infinity;
|
138
|
-
var ops = [];
|
139
|
-
var iter = op.iterator(this.ops);
|
140
|
-
var index = 0;
|
141
|
-
while (index < end && iter.hasNext()) {
|
142
|
-
var nextOp;
|
143
|
-
if (index < start) {
|
144
|
-
nextOp = iter.next(start - index);
|
145
|
-
} else {
|
146
|
-
nextOp = iter.next(end - index);
|
147
|
-
ops.push(nextOp);
|
148
|
-
}
|
149
|
-
index += op.length(nextOp);
|
150
|
-
}
|
151
|
-
return new Delta(ops);
|
152
|
-
};
|
153
|
-
|
154
|
-
|
155
|
-
Delta.prototype.compose = function (other) {
|
156
|
-
var thisIter = op.iterator(this.ops);
|
157
|
-
var otherIter = op.iterator(other.ops);
|
158
|
-
var ops = [];
|
159
|
-
var firstOther = otherIter.peek();
|
160
|
-
if (firstOther != null && typeof firstOther.retain === 'number' && firstOther.attributes == null) {
|
161
|
-
var firstLeft = firstOther.retain;
|
162
|
-
while (thisIter.peekType() === 'insert' && thisIter.peekLength() <= firstLeft) {
|
163
|
-
firstLeft -= thisIter.peekLength();
|
164
|
-
ops.push(thisIter.next());
|
165
|
-
}
|
166
|
-
if (firstOther.retain - firstLeft > 0) {
|
167
|
-
otherIter.next(firstOther.retain - firstLeft);
|
168
|
-
}
|
169
|
-
}
|
170
|
-
var delta = new Delta(ops);
|
171
|
-
while (thisIter.hasNext() || otherIter.hasNext()) {
|
172
|
-
if (otherIter.peekType() === 'insert') {
|
173
|
-
delta.push(otherIter.next());
|
174
|
-
} else if (thisIter.peekType() === 'delete') {
|
175
|
-
delta.push(thisIter.next());
|
176
|
-
} else {
|
177
|
-
var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
|
178
|
-
var thisOp = thisIter.next(length);
|
179
|
-
var otherOp = otherIter.next(length);
|
180
|
-
if (typeof otherOp.retain === 'number') {
|
181
|
-
var newOp = {};
|
182
|
-
if (typeof thisOp.retain === 'number') {
|
183
|
-
newOp.retain = length;
|
184
|
-
} else {
|
185
|
-
newOp.insert = thisOp.insert;
|
186
|
-
}
|
187
|
-
// Preserve null when composing with a retain, otherwise remove it for inserts
|
188
|
-
var attributes = op.attributes.compose(thisOp.attributes, otherOp.attributes, typeof thisOp.retain === 'number');
|
189
|
-
if (attributes) newOp.attributes = attributes;
|
190
|
-
delta.push(newOp);
|
191
|
-
|
192
|
-
// Optimization if rest of other is just retain
|
193
|
-
if (!otherIter.hasNext() && equal(delta.ops[delta.ops.length - 1], newOp)) {
|
194
|
-
var rest = new Delta(thisIter.rest());
|
195
|
-
return delta.concat(rest).chop();
|
196
|
-
}
|
197
|
-
|
198
|
-
// Other op should be delete, we could be an insert or retain
|
199
|
-
// Insert + delete cancels out
|
200
|
-
} else if (typeof otherOp['delete'] === 'number' && typeof thisOp.retain === 'number') {
|
201
|
-
delta.push(otherOp);
|
202
|
-
}
|
203
|
-
}
|
204
|
-
}
|
205
|
-
return delta.chop();
|
206
|
-
};
|
207
|
-
|
208
|
-
Delta.prototype.concat = function (other) {
|
209
|
-
var delta = new Delta(this.ops.slice());
|
210
|
-
if (other.ops.length > 0) {
|
211
|
-
delta.push(other.ops[0]);
|
212
|
-
delta.ops = delta.ops.concat(other.ops.slice(1));
|
213
|
-
}
|
214
|
-
return delta;
|
215
|
-
};
|
216
|
-
|
217
|
-
Delta.prototype.diff = function (other, index) {
|
218
|
-
if (this.ops === other.ops) {
|
219
|
-
return new Delta();
|
220
|
-
}
|
221
|
-
var strings = [this, other].map(function (delta) {
|
222
|
-
return delta.map(function (op) {
|
223
|
-
if (op.insert != null) {
|
224
|
-
return typeof op.insert === 'string' ? op.insert : NULL_CHARACTER;
|
225
|
-
}
|
226
|
-
var prep = (delta === other) ? 'on' : 'with';
|
227
|
-
throw new Error('diff() called ' + prep + ' non-document');
|
228
|
-
}).join('');
|
229
|
-
});
|
230
|
-
var delta = new Delta();
|
231
|
-
var diffResult = diff(strings[0], strings[1], index);
|
232
|
-
var thisIter = op.iterator(this.ops);
|
233
|
-
var otherIter = op.iterator(other.ops);
|
234
|
-
diffResult.forEach(function (component) {
|
235
|
-
var length = component[1].length;
|
236
|
-
while (length > 0) {
|
237
|
-
var opLength = 0;
|
238
|
-
switch (component[0]) {
|
239
|
-
case diff.INSERT:
|
240
|
-
opLength = Math.min(otherIter.peekLength(), length);
|
241
|
-
delta.push(otherIter.next(opLength));
|
242
|
-
break;
|
243
|
-
case diff.DELETE:
|
244
|
-
opLength = Math.min(length, thisIter.peekLength());
|
245
|
-
thisIter.next(opLength);
|
246
|
-
delta['delete'](opLength);
|
247
|
-
break;
|
248
|
-
case diff.EQUAL:
|
249
|
-
opLength = Math.min(thisIter.peekLength(), otherIter.peekLength(), length);
|
250
|
-
var thisOp = thisIter.next(opLength);
|
251
|
-
var otherOp = otherIter.next(opLength);
|
252
|
-
if (equal(thisOp.insert, otherOp.insert)) {
|
253
|
-
delta.retain(opLength, op.attributes.diff(thisOp.attributes, otherOp.attributes));
|
254
|
-
} else {
|
255
|
-
delta.push(otherOp)['delete'](opLength);
|
256
|
-
}
|
257
|
-
break;
|
258
|
-
}
|
259
|
-
length -= opLength;
|
260
|
-
}
|
261
|
-
});
|
262
|
-
return delta.chop();
|
263
|
-
};
|
264
|
-
|
265
|
-
Delta.prototype.eachLine = function (predicate, newline) {
|
266
|
-
newline = newline || '\n';
|
267
|
-
var iter = op.iterator(this.ops);
|
268
|
-
var line = new Delta();
|
269
|
-
var i = 0;
|
270
|
-
while (iter.hasNext()) {
|
271
|
-
if (iter.peekType() !== 'insert') return;
|
272
|
-
var thisOp = iter.peek();
|
273
|
-
var start = op.length(thisOp) - iter.peekLength();
|
274
|
-
var index = typeof thisOp.insert === 'string' ?
|
275
|
-
thisOp.insert.indexOf(newline, start) - start : -1;
|
276
|
-
if (index < 0) {
|
277
|
-
line.push(iter.next());
|
278
|
-
} else if (index > 0) {
|
279
|
-
line.push(iter.next(index));
|
280
|
-
} else {
|
281
|
-
if (predicate(line, iter.next(1).attributes || {}, i) === false) {
|
282
|
-
return;
|
283
|
-
}
|
284
|
-
i += 1;
|
285
|
-
line = new Delta();
|
286
|
-
}
|
287
|
-
}
|
288
|
-
if (line.length() > 0) {
|
289
|
-
predicate(line, {}, i);
|
290
|
-
}
|
291
|
-
};
|
292
|
-
|
293
|
-
Delta.prototype.transform = function (other, priority) {
|
294
|
-
priority = !!priority;
|
295
|
-
if (typeof other === 'number') {
|
296
|
-
return this.transformPosition(other, priority);
|
297
|
-
}
|
298
|
-
var thisIter = op.iterator(this.ops);
|
299
|
-
var otherIter = op.iterator(other.ops);
|
300
|
-
var delta = new Delta();
|
301
|
-
while (thisIter.hasNext() || otherIter.hasNext()) {
|
302
|
-
if (thisIter.peekType() === 'insert' && (priority || otherIter.peekType() !== 'insert')) {
|
303
|
-
delta.retain(op.length(thisIter.next()));
|
304
|
-
} else if (otherIter.peekType() === 'insert') {
|
305
|
-
delta.push(otherIter.next());
|
306
|
-
} else {
|
307
|
-
var length = Math.min(thisIter.peekLength(), otherIter.peekLength());
|
308
|
-
var thisOp = thisIter.next(length);
|
309
|
-
var otherOp = otherIter.next(length);
|
310
|
-
if (thisOp['delete']) {
|
311
|
-
// Our delete either makes their delete redundant or removes their retain
|
312
|
-
continue;
|
313
|
-
} else if (otherOp['delete']) {
|
314
|
-
delta.push(otherOp);
|
315
|
-
} else {
|
316
|
-
// We retain either their retain or insert
|
317
|
-
delta.retain(length, op.attributes.transform(thisOp.attributes, otherOp.attributes, priority));
|
318
|
-
}
|
319
|
-
}
|
320
|
-
}
|
321
|
-
return delta.chop();
|
322
|
-
};
|
323
|
-
|
324
|
-
Delta.prototype.transformPosition = function (index, priority) {
|
325
|
-
priority = !!priority;
|
326
|
-
var thisIter = op.iterator(this.ops);
|
327
|
-
var offset = 0;
|
328
|
-
while (thisIter.hasNext() && offset <= index) {
|
329
|
-
var length = thisIter.peekLength();
|
330
|
-
var nextType = thisIter.peekType();
|
331
|
-
thisIter.next();
|
332
|
-
if (nextType === 'delete') {
|
333
|
-
index -= Math.min(length, index - offset);
|
334
|
-
continue;
|
335
|
-
} else if (nextType === 'insert' && (offset < index || !priority)) {
|
336
|
-
index += length;
|
337
|
-
}
|
338
|
-
offset += length;
|
339
|
-
}
|
340
|
-
return index;
|
341
|
-
};
|
342
|
-
|
343
|
-
|
344
|
-
module.exports = Delta;
|
@@ -1,155 +0,0 @@
|
|
1
|
-
var equal = require('../../deep-equal/index.js');
|
2
|
-
var extend = require('../../extend/index.js');
|
3
|
-
|
4
|
-
|
5
|
-
var lib = {
|
6
|
-
attributes: {
|
7
|
-
compose: function (a, b, keepNull) {
|
8
|
-
if (typeof a !== 'object') a = {};
|
9
|
-
if (typeof b !== 'object') b = {};
|
10
|
-
var attributes = extend(true, {}, b);
|
11
|
-
if (!keepNull) {
|
12
|
-
attributes = Object.keys(attributes).reduce(function (copy, key) {
|
13
|
-
if (attributes[key] != null) {
|
14
|
-
copy[key] = attributes[key];
|
15
|
-
}
|
16
|
-
return copy;
|
17
|
-
}, {});
|
18
|
-
}
|
19
|
-
for (var key in a) {
|
20
|
-
if (a[key] !== undefined && b[key] === undefined) {
|
21
|
-
attributes[key] = a[key];
|
22
|
-
}
|
23
|
-
}
|
24
|
-
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
25
|
-
},
|
26
|
-
|
27
|
-
diff: function(a, b) {
|
28
|
-
if (typeof a !== 'object') a = {};
|
29
|
-
if (typeof b !== 'object') b = {};
|
30
|
-
var attributes = Object.keys(a).concat(Object.keys(b)).reduce(function (attributes, key) {
|
31
|
-
if (!equal(a[key], b[key])) {
|
32
|
-
attributes[key] = b[key] === undefined ? null : b[key];
|
33
|
-
}
|
34
|
-
return attributes;
|
35
|
-
}, {});
|
36
|
-
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
37
|
-
},
|
38
|
-
|
39
|
-
transform: function (a, b, priority) {
|
40
|
-
if (typeof a !== 'object') return b;
|
41
|
-
if (typeof b !== 'object') return undefined;
|
42
|
-
if (!priority) return b; // b simply overwrites us without priority
|
43
|
-
var attributes = Object.keys(b).reduce(function (attributes, key) {
|
44
|
-
if (a[key] === undefined) attributes[key] = b[key]; // null is a valid value
|
45
|
-
return attributes;
|
46
|
-
}, {});
|
47
|
-
return Object.keys(attributes).length > 0 ? attributes : undefined;
|
48
|
-
}
|
49
|
-
},
|
50
|
-
|
51
|
-
iterator: function (ops) {
|
52
|
-
return new Iterator(ops);
|
53
|
-
},
|
54
|
-
|
55
|
-
length: function (op) {
|
56
|
-
if (typeof op['delete'] === 'number') {
|
57
|
-
return op['delete'];
|
58
|
-
} else if (typeof op.retain === 'number') {
|
59
|
-
return op.retain;
|
60
|
-
} else {
|
61
|
-
return typeof op.insert === 'string' ? op.insert.length : 1;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
};
|
65
|
-
|
66
|
-
|
67
|
-
function Iterator(ops) {
|
68
|
-
this.ops = ops;
|
69
|
-
this.index = 0;
|
70
|
-
this.offset = 0;
|
71
|
-
};
|
72
|
-
|
73
|
-
Iterator.prototype.hasNext = function () {
|
74
|
-
return this.peekLength() < Infinity;
|
75
|
-
};
|
76
|
-
|
77
|
-
Iterator.prototype.next = function (length) {
|
78
|
-
if (!length) length = Infinity;
|
79
|
-
var nextOp = this.ops[this.index];
|
80
|
-
if (nextOp) {
|
81
|
-
var offset = this.offset;
|
82
|
-
var opLength = lib.length(nextOp)
|
83
|
-
if (length >= opLength - offset) {
|
84
|
-
length = opLength - offset;
|
85
|
-
this.index += 1;
|
86
|
-
this.offset = 0;
|
87
|
-
} else {
|
88
|
-
this.offset += length;
|
89
|
-
}
|
90
|
-
if (typeof nextOp['delete'] === 'number') {
|
91
|
-
return { 'delete': length };
|
92
|
-
} else {
|
93
|
-
var retOp = {};
|
94
|
-
if (nextOp.attributes) {
|
95
|
-
retOp.attributes = nextOp.attributes;
|
96
|
-
}
|
97
|
-
if (typeof nextOp.retain === 'number') {
|
98
|
-
retOp.retain = length;
|
99
|
-
} else if (typeof nextOp.insert === 'string') {
|
100
|
-
retOp.insert = nextOp.insert.substr(offset, length);
|
101
|
-
} else {
|
102
|
-
// offset should === 0, length should === 1
|
103
|
-
retOp.insert = nextOp.insert;
|
104
|
-
}
|
105
|
-
return retOp;
|
106
|
-
}
|
107
|
-
} else {
|
108
|
-
return { retain: Infinity };
|
109
|
-
}
|
110
|
-
};
|
111
|
-
|
112
|
-
Iterator.prototype.peek = function () {
|
113
|
-
return this.ops[this.index];
|
114
|
-
};
|
115
|
-
|
116
|
-
Iterator.prototype.peekLength = function () {
|
117
|
-
if (this.ops[this.index]) {
|
118
|
-
// Should never return 0 if our index is being managed correctly
|
119
|
-
return lib.length(this.ops[this.index]) - this.offset;
|
120
|
-
} else {
|
121
|
-
return Infinity;
|
122
|
-
}
|
123
|
-
};
|
124
|
-
|
125
|
-
Iterator.prototype.peekType = function () {
|
126
|
-
if (this.ops[this.index]) {
|
127
|
-
if (typeof this.ops[this.index]['delete'] === 'number') {
|
128
|
-
return 'delete';
|
129
|
-
} else if (typeof this.ops[this.index].retain === 'number') {
|
130
|
-
return 'retain';
|
131
|
-
} else {
|
132
|
-
return 'insert';
|
133
|
-
}
|
134
|
-
}
|
135
|
-
return 'retain';
|
136
|
-
};
|
137
|
-
|
138
|
-
Iterator.prototype.rest = function () {
|
139
|
-
if (!this.hasNext()) {
|
140
|
-
return [];
|
141
|
-
} else if (this.offset === 0) {
|
142
|
-
return this.ops.slice(this.index);
|
143
|
-
} else {
|
144
|
-
var offset = this.offset;
|
145
|
-
var index = this.index;
|
146
|
-
var next = this.next();
|
147
|
-
var rest = this.ops.slice(this.index);
|
148
|
-
this.offset = offset;
|
149
|
-
this.index = index;
|
150
|
-
return [next].concat(rest);
|
151
|
-
}
|
152
|
-
};
|
153
|
-
|
154
|
-
|
155
|
-
module.exports = lib;
|
@@ -1,39 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var setFunctionName = require('../set-function-name/index.js');
|
4
|
-
var $TypeError = require('../es-errors/type.js');
|
5
|
-
|
6
|
-
var $Object = Object;
|
7
|
-
|
8
|
-
module.exports = setFunctionName(function flags() {
|
9
|
-
if (this == null || this !== $Object(this)) {
|
10
|
-
throw new $TypeError('RegExp.prototype.flags getter called on non-object');
|
11
|
-
}
|
12
|
-
var result = '';
|
13
|
-
if (this.hasIndices) {
|
14
|
-
result += 'd';
|
15
|
-
}
|
16
|
-
if (this.global) {
|
17
|
-
result += 'g';
|
18
|
-
}
|
19
|
-
if (this.ignoreCase) {
|
20
|
-
result += 'i';
|
21
|
-
}
|
22
|
-
if (this.multiline) {
|
23
|
-
result += 'm';
|
24
|
-
}
|
25
|
-
if (this.dotAll) {
|
26
|
-
result += 's';
|
27
|
-
}
|
28
|
-
if (this.unicode) {
|
29
|
-
result += 'u';
|
30
|
-
}
|
31
|
-
if (this.unicodeSets) {
|
32
|
-
result += 'v';
|
33
|
-
}
|
34
|
-
if (this.sticky) {
|
35
|
-
result += 'y';
|
36
|
-
}
|
37
|
-
return result;
|
38
|
-
}, 'get flags', true);
|
39
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var define = require('../define-properties/index.js');
|
4
|
-
var callBind = require('../call-bind/index.js');
|
5
|
-
|
6
|
-
var implementation = require('./implementation.js');
|
7
|
-
var getPolyfill = require('./polyfill.js');
|
8
|
-
var shim = require('./shim.js');
|
9
|
-
|
10
|
-
var flagsBound = callBind(getPolyfill());
|
11
|
-
|
12
|
-
define(flagsBound, {
|
13
|
-
getPolyfill: getPolyfill,
|
14
|
-
implementation: implementation,
|
15
|
-
shim: shim
|
16
|
-
});
|
17
|
-
|
18
|
-
module.exports = flagsBound;
|
@@ -1,39 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var implementation = require('./implementation.js');
|
4
|
-
|
5
|
-
var supportsDescriptors = require('../define-properties/index.js').supportsDescriptors;
|
6
|
-
var $gOPD = Object.getOwnPropertyDescriptor;
|
7
|
-
|
8
|
-
module.exports = function getPolyfill() {
|
9
|
-
if (supportsDescriptors && (/a/mig).flags === 'gim') {
|
10
|
-
var descriptor = $gOPD(RegExp.prototype, 'flags');
|
11
|
-
if (
|
12
|
-
descriptor
|
13
|
-
&& typeof descriptor.get === 'function'
|
14
|
-
&& 'dotAll' in RegExp.prototype
|
15
|
-
&& 'hasIndices' in RegExp.prototype
|
16
|
-
) {
|
17
|
-
/* eslint getter-return: 0 */
|
18
|
-
var calls = '';
|
19
|
-
var o = {};
|
20
|
-
Object.defineProperty(o, 'hasIndices', {
|
21
|
-
get: function () {
|
22
|
-
calls += 'd';
|
23
|
-
}
|
24
|
-
});
|
25
|
-
Object.defineProperty(o, 'sticky', {
|
26
|
-
get: function () {
|
27
|
-
calls += 'y';
|
28
|
-
}
|
29
|
-
});
|
30
|
-
|
31
|
-
descriptor.get.call(o);
|
32
|
-
|
33
|
-
if (calls === 'dy') {
|
34
|
-
return descriptor.get;
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|
38
|
-
return implementation;
|
39
|
-
};
|
@@ -1,26 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var supportsDescriptors = require('../define-properties/index.js').supportsDescriptors;
|
4
|
-
var getPolyfill = require('./polyfill.js');
|
5
|
-
var gOPD = require('../gopd/index.js');
|
6
|
-
var defineProperty = Object.defineProperty;
|
7
|
-
var $TypeError = require('../es-errors/index.js');
|
8
|
-
var getProto = require('../get-proto/index.js');
|
9
|
-
var regex = /a/;
|
10
|
-
|
11
|
-
module.exports = function shimFlags() {
|
12
|
-
if (!supportsDescriptors || !getProto) {
|
13
|
-
throw new $TypeError('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
|
14
|
-
}
|
15
|
-
var polyfill = getPolyfill();
|
16
|
-
var proto = getProto(regex);
|
17
|
-
var descriptor = gOPD(proto, 'flags');
|
18
|
-
if (!descriptor || descriptor.get !== polyfill) {
|
19
|
-
defineProperty(proto, 'flags', {
|
20
|
-
configurable: true,
|
21
|
-
enumerable: false,
|
22
|
-
get: polyfill
|
23
|
-
});
|
24
|
-
}
|
25
|
-
return polyfill;
|
26
|
-
};
|
@@ -1,42 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var GetIntrinsic = require('../get-intrinsic/index.js');
|
4
|
-
var define = require('../define-data-property/index.js');
|
5
|
-
var hasDescriptors = require('../has-property-descriptors/index.js')();
|
6
|
-
var gOPD = require('../gopd/index.js');
|
7
|
-
|
8
|
-
var $TypeError = require('../es-errors/type.js');
|
9
|
-
var $floor = GetIntrinsic('%Math.floor%');
|
10
|
-
|
11
|
-
/** @type {import('.')} */
|
12
|
-
module.exports = function setFunctionLength(fn, length) {
|
13
|
-
if (typeof fn !== 'function') {
|
14
|
-
throw new $TypeError('`fn` is not a function');
|
15
|
-
}
|
16
|
-
if (typeof length !== 'number' || length < 0 || length > 0xFFFFFFFF || $floor(length) !== length) {
|
17
|
-
throw new $TypeError('`length` must be a positive 32-bit integer');
|
18
|
-
}
|
19
|
-
|
20
|
-
var loose = arguments.length > 2 && !!arguments[2];
|
21
|
-
|
22
|
-
var functionLengthIsConfigurable = true;
|
23
|
-
var functionLengthIsWritable = true;
|
24
|
-
if ('length' in fn && gOPD) {
|
25
|
-
var desc = gOPD(fn, 'length');
|
26
|
-
if (desc && !desc.configurable) {
|
27
|
-
functionLengthIsConfigurable = false;
|
28
|
-
}
|
29
|
-
if (desc && !desc.writable) {
|
30
|
-
functionLengthIsWritable = false;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
if (functionLengthIsConfigurable || functionLengthIsWritable || !loose) {
|
35
|
-
if (hasDescriptors) {
|
36
|
-
define(/** @type {Parameters<define>[0]} */ (fn), 'length', length, true, true);
|
37
|
-
} else {
|
38
|
-
define(/** @type {Parameters<define>[0]} */ (fn), 'length', length);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
return fn;
|
42
|
-
};
|
@@ -1,23 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var define = require('../define-data-property/index.js');
|
4
|
-
var hasDescriptors = require('../has-property-descriptors/index.js')();
|
5
|
-
var functionsHaveConfigurableNames = require('../functions-have-names/index.js').functionsHaveConfigurableNames();
|
6
|
-
|
7
|
-
var $TypeError = require('../es-errors/type.js');
|
8
|
-
|
9
|
-
/** @type {import('.')} */
|
10
|
-
module.exports = function setFunctionName(fn, name) {
|
11
|
-
if (typeof fn !== 'function') {
|
12
|
-
throw new $TypeError('`fn` is not a function');
|
13
|
-
}
|
14
|
-
var loose = arguments.length > 2 && !!arguments[2];
|
15
|
-
if (!loose || functionsHaveConfigurableNames) {
|
16
|
-
if (hasDescriptors) {
|
17
|
-
define(/** @type {Parameters<define>[0]} */ (fn), 'name', name, true, true);
|
18
|
-
} else {
|
19
|
-
define(/** @type {Parameters<define>[0]} */ (fn), 'name', name);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
return fn;
|
23
|
-
};
|