@dxos/util 0.8.4-main.cb12b3f963 → 0.8.4-main.d05539e30a
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/LICENSE +102 -5
- package/dist/lib/browser/index.mjs +41 -25
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +41 -25
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/id.d.ts +30 -0
- package/dist/types/src/id.d.ts.map +1 -0
- package/dist/types/src/id.test.d.ts +2 -0
- package/dist/types/src/id.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/position.d.ts +4 -4
- package/dist/types/src/position.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/id.test.ts +109 -0
- package/src/id.ts +48 -0
- package/src/index.ts +1 -0
- package/src/position.test.ts +38 -44
- package/src/position.ts +7 -11
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -1060,6 +1060,19 @@ var humanize = (value) => {
|
|
|
1060
1060
|
return hasher.humanize(value);
|
|
1061
1061
|
};
|
|
1062
1062
|
|
|
1063
|
+
// src/id.ts
|
|
1064
|
+
var PART = /^[a-zA-Z][a-zA-Z0-9]{0,62}$/;
|
|
1065
|
+
var ID = /^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)$/;
|
|
1066
|
+
function id(strings, ...values) {
|
|
1067
|
+
const raw = strings.reduce((out, str, i) => out + str + (i < values.length ? String(values[i]) : ""), "");
|
|
1068
|
+
if (!ID.test(raw)) {
|
|
1069
|
+
throw new Error(`Invalid id (expected AT Protocol NSID): ${JSON.stringify(raw)}`);
|
|
1070
|
+
}
|
|
1071
|
+
return raw;
|
|
1072
|
+
}
|
|
1073
|
+
var isWellFormedId = (value) => ID.test(value);
|
|
1074
|
+
var isWellFormedIdPart = (value) => PART.test(value);
|
|
1075
|
+
|
|
1063
1076
|
// src/map.ts
|
|
1064
1077
|
var defaultMap = (map, key, def) => {
|
|
1065
1078
|
let value = map.get(key);
|
|
@@ -1079,12 +1092,12 @@ var getPrototypeSpecificInstanceId = (instance) => {
|
|
|
1079
1092
|
nextId: 0,
|
|
1080
1093
|
instanceIds: /* @__PURE__ */ new WeakMap()
|
|
1081
1094
|
}));
|
|
1082
|
-
let
|
|
1083
|
-
if (
|
|
1084
|
-
|
|
1085
|
-
instanceCtx.instanceIds.set(instance,
|
|
1095
|
+
let id2 = instanceCtx.instanceIds.get(instance);
|
|
1096
|
+
if (id2 === void 0) {
|
|
1097
|
+
id2 = instanceCtx.nextId++;
|
|
1098
|
+
instanceCtx.instanceIds.set(instance, id2);
|
|
1086
1099
|
}
|
|
1087
|
-
return
|
|
1100
|
+
return id2;
|
|
1088
1101
|
};
|
|
1089
1102
|
var getDebugName = (instance) => {
|
|
1090
1103
|
if (instance == null) {
|
|
@@ -1365,27 +1378,27 @@ var orderKeys = (obj, order) => {
|
|
|
1365
1378
|
|
|
1366
1379
|
// src/order.ts
|
|
1367
1380
|
var inferObjectOrder = (objectMap, order = []) => {
|
|
1368
|
-
const orderedObjects = order.reduce((acc,
|
|
1369
|
-
if (
|
|
1370
|
-
acc.objects.push(objectMap[
|
|
1371
|
-
acc.ids.add(
|
|
1381
|
+
const orderedObjects = order.reduce((acc, id2) => {
|
|
1382
|
+
if (id2 in objectMap) {
|
|
1383
|
+
acc.objects.push(objectMap[id2]);
|
|
1384
|
+
acc.ids.add(id2);
|
|
1372
1385
|
}
|
|
1373
1386
|
return acc;
|
|
1374
1387
|
}, {
|
|
1375
1388
|
objects: [],
|
|
1376
1389
|
ids: /* @__PURE__ */ new Set()
|
|
1377
1390
|
});
|
|
1378
|
-
const { objects } = Object.keys(objectMap).reduce((acc,
|
|
1379
|
-
if (!acc.ids.has(
|
|
1380
|
-
acc.objects.push(objectMap[
|
|
1391
|
+
const { objects } = Object.keys(objectMap).reduce((acc, id2) => {
|
|
1392
|
+
if (!acc.ids.has(id2)) {
|
|
1393
|
+
acc.objects.push(objectMap[id2]);
|
|
1381
1394
|
}
|
|
1382
1395
|
return acc;
|
|
1383
1396
|
}, orderedObjects);
|
|
1384
1397
|
return objects;
|
|
1385
1398
|
};
|
|
1386
1399
|
var inferRecordOrder = (objectMap, order = []) => {
|
|
1387
|
-
return Object.assign(order.filter((
|
|
1388
|
-
acc[
|
|
1400
|
+
return Object.assign(order.filter((id2) => id2 in objectMap).reduce((acc, id2) => {
|
|
1401
|
+
acc[id2] = null;
|
|
1389
1402
|
return acc;
|
|
1390
1403
|
}, {}), objectMap);
|
|
1391
1404
|
};
|
|
@@ -1471,12 +1484,12 @@ var getHostPlatform = () => {
|
|
|
1471
1484
|
};
|
|
1472
1485
|
|
|
1473
1486
|
// src/position.ts
|
|
1474
|
-
var byPosition = ({ position: a
|
|
1487
|
+
var byPosition = ({ position: a }, { position: b }) => {
|
|
1475
1488
|
if (a === b) {
|
|
1476
1489
|
return 0;
|
|
1477
|
-
} else if (a === "
|
|
1490
|
+
} else if (a === "first" || b === "last") {
|
|
1478
1491
|
return -1;
|
|
1479
|
-
} else if (b === "
|
|
1492
|
+
} else if (b === "first" || a === "last") {
|
|
1480
1493
|
return 1;
|
|
1481
1494
|
} else {
|
|
1482
1495
|
return 0;
|
|
@@ -2118,8 +2131,8 @@ var Tracer = class {
|
|
|
2118
2131
|
keys() {
|
|
2119
2132
|
return Array.from(this._events.keys());
|
|
2120
2133
|
}
|
|
2121
|
-
get(
|
|
2122
|
-
const events = this._events.get(
|
|
2134
|
+
get(id2, filter) {
|
|
2135
|
+
const events = this._events.get(id2);
|
|
2123
2136
|
if (filter) {
|
|
2124
2137
|
return events?.filter((event) => Object.entries(filter).every(([key, value]) => event?.value[key] === value));
|
|
2125
2138
|
}
|
|
@@ -2136,11 +2149,11 @@ var Tracer = class {
|
|
|
2136
2149
|
this._recording = false;
|
|
2137
2150
|
return this;
|
|
2138
2151
|
}
|
|
2139
|
-
emit(
|
|
2140
|
-
this._post(this._createEvent(
|
|
2152
|
+
emit(id2, value) {
|
|
2153
|
+
this._post(this._createEvent(id2, value));
|
|
2141
2154
|
}
|
|
2142
|
-
mark(
|
|
2143
|
-
const event = this._createEvent(
|
|
2155
|
+
mark(id2, value) {
|
|
2156
|
+
const event = this._createEvent(id2, value);
|
|
2144
2157
|
const start = performance.now();
|
|
2145
2158
|
return {
|
|
2146
2159
|
start,
|
|
@@ -2150,9 +2163,9 @@ var Tracer = class {
|
|
|
2150
2163
|
}
|
|
2151
2164
|
};
|
|
2152
2165
|
}
|
|
2153
|
-
_createEvent(
|
|
2166
|
+
_createEvent(id2, value) {
|
|
2154
2167
|
const event = {
|
|
2155
|
-
id,
|
|
2168
|
+
id: id2,
|
|
2156
2169
|
timestamp: Date.now()
|
|
2157
2170
|
};
|
|
2158
2171
|
if (value !== void 0) {
|
|
@@ -2567,6 +2580,7 @@ export {
|
|
|
2567
2580
|
hexToHue,
|
|
2568
2581
|
humanize,
|
|
2569
2582
|
hyphenize,
|
|
2583
|
+
id,
|
|
2570
2584
|
idEmoji,
|
|
2571
2585
|
idHue,
|
|
2572
2586
|
inferObjectOrder,
|
|
@@ -2581,6 +2595,8 @@ export {
|
|
|
2581
2595
|
isNonNullable,
|
|
2582
2596
|
isTauri,
|
|
2583
2597
|
isTruthy,
|
|
2598
|
+
isWellFormedId,
|
|
2599
|
+
isWellFormedIdPart,
|
|
2584
2600
|
joinTables,
|
|
2585
2601
|
jsonKeyReplacer,
|
|
2586
2602
|
jsonReplacer,
|