@calcit/procs 0.8.41 → 0.8.43
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/lib/custom-formatter.mjs +29 -10
- package/lib/js-set.mjs +9 -0
- package/lib/package.json +3 -3
- package/package.json +3 -3
- package/ts-src/custom-formatter.mts +45 -17
- package/ts-src/js-set.mts +10 -1
package/lib/custom-formatter.mjs
CHANGED
|
@@ -79,8 +79,8 @@ let saveString = (v) => {
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
export let load_console_formatter_$x_ = () => {
|
|
82
|
-
if (typeof
|
|
83
|
-
|
|
82
|
+
if (typeof globalThis === "object") {
|
|
83
|
+
globalThis["devtoolsFormatters"] = [
|
|
84
84
|
{
|
|
85
85
|
header: (obj, config) => {
|
|
86
86
|
if (obj instanceof CalcitTag) {
|
|
@@ -104,12 +104,13 @@ export let load_console_formatter_$x_ = () => {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
return div({
|
|
107
|
-
color: hasCollection ? hsl(280, 80, 60, 0.4) :
|
|
107
|
+
color: hasCollection ? hsl(280, 80, 60, 0.4) : hsl(280, 80, 60),
|
|
108
|
+
marginRight: "16px",
|
|
108
109
|
}, `[]`, span({
|
|
109
110
|
fontSize: "8px",
|
|
110
111
|
verticalAlign: "middle",
|
|
111
112
|
color: hsl(280, 80, 80, 0.8),
|
|
112
|
-
}, `${obj.len()}`),
|
|
113
|
+
}, `${obj.len()}`), preview);
|
|
113
114
|
}
|
|
114
115
|
if (obj instanceof CalcitMap || obj instanceof CalcitSliceMap) {
|
|
115
116
|
let preview = "";
|
|
@@ -125,10 +126,27 @@ export let load_console_formatter_$x_ = () => {
|
|
|
125
126
|
break;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
return div({ color: hasCollection ? hsl(280, 80, 60, 0.4) :
|
|
129
|
+
return div({ color: hasCollection ? hsl(280, 80, 60, 0.4) : hsl(280, 80, 60), marginRight: "16px", maxWidth: "100%", whiteSpace: "normal" }, "{}", preview);
|
|
129
130
|
}
|
|
130
131
|
if (obj instanceof CalcitSet) {
|
|
131
|
-
|
|
132
|
+
let preview = "";
|
|
133
|
+
let hasCollection = false;
|
|
134
|
+
for (let item of obj.values()) {
|
|
135
|
+
preview += " ";
|
|
136
|
+
if (isLiteral(item)) {
|
|
137
|
+
preview += saveString(item);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
preview += "..";
|
|
141
|
+
hasCollection = true;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return div({ color: hasCollection ? hsl(280, 80, 60, 0.4) : hsl(280, 80, 60), marginRight: "16px" }, "#{}", span({
|
|
146
|
+
fontSize: "8px",
|
|
147
|
+
verticalAlign: "middle",
|
|
148
|
+
color: hsl(280, 80, 80, 0.8),
|
|
149
|
+
}, `${obj.len()}`), preview);
|
|
132
150
|
}
|
|
133
151
|
if (obj instanceof CalcitRecord) {
|
|
134
152
|
let ret = div({ color: hsl(280, 80, 60, 0.4), maxWidth: "100%" }, `%{} ${obj.name} ...`);
|
|
@@ -136,14 +154,14 @@ export let load_console_formatter_$x_ = () => {
|
|
|
136
154
|
}
|
|
137
155
|
if (obj instanceof CalcitTuple) {
|
|
138
156
|
if (obj.klass) {
|
|
139
|
-
let ret = div({}, div({ display: "inline-block", color: hsl(300, 100, 40) }, "%::"), div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.klass)), div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.tag)));
|
|
157
|
+
let ret = div({ marginRight: "16px" }, div({ display: "inline-block", color: hsl(300, 100, 40) }, "%::"), div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.klass)), div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.tag)));
|
|
140
158
|
for (let idx = 0; idx < obj.extra.length; idx++) {
|
|
141
159
|
ret.push(div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.extra[idx])));
|
|
142
160
|
}
|
|
143
161
|
return ret;
|
|
144
162
|
}
|
|
145
163
|
else {
|
|
146
|
-
let ret = div({}, div({ display: "inline-block", color: hsl(300, 100, 40) }, "::"), div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.tag)));
|
|
164
|
+
let ret = div({ marginRight: "16px" }, div({ display: "inline-block", color: hsl(300, 100, 40) }, "::"), div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.tag)));
|
|
147
165
|
for (let idx = 0; idx < obj.extra.length; idx++) {
|
|
148
166
|
ret.push(div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.extra[idx])));
|
|
149
167
|
}
|
|
@@ -156,7 +174,7 @@ export let load_console_formatter_$x_ = () => {
|
|
|
156
174
|
}, `Ref ${obj.path}`, div({ color: hsl(280, 80, 60) }, div({ marginLeft: "8px" }, embedObject(obj.value))));
|
|
157
175
|
}
|
|
158
176
|
if (obj instanceof CalcitCirruQuote) {
|
|
159
|
-
return div({ color: hsl(280, 80, 60), display: "flex" }, `CirruQuote`, div({ color: hsl(280, 80, 60), padding: "4px 4px", margin: "0 4px 2px", border: "1px solid hsl(0,70%,90%)", borderRadius: "4px" }, obj.textForm().trim()));
|
|
177
|
+
return div({ color: hsl(280, 80, 60), display: "flex", marginRight: "16px" }, `CirruQuote`, div({ color: hsl(280, 80, 60), padding: "4px 4px", margin: "0 4px 2px", border: "1px solid hsl(0,70%,90%)", borderRadius: "4px" }, obj.textForm().trim()));
|
|
160
178
|
}
|
|
161
179
|
return null;
|
|
162
180
|
},
|
|
@@ -170,7 +188,8 @@ export let load_console_formatter_$x_ = () => {
|
|
|
170
188
|
return obj.len() > 0 && hasCollection;
|
|
171
189
|
}
|
|
172
190
|
if (obj instanceof CalcitSet) {
|
|
173
|
-
|
|
191
|
+
let hasCollection = obj.nestedDataInChildren();
|
|
192
|
+
return obj.len() > 0 && hasCollection;
|
|
174
193
|
}
|
|
175
194
|
if (obj instanceof CalcitRecord) {
|
|
176
195
|
return obj.fields.length > 0;
|
package/lib/js-set.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isLiteral } from "./js-primes.mjs";
|
|
1
2
|
import { toString } from "./calcit-data.mjs";
|
|
2
3
|
import { mapLen, assocMap, dissocMap, toPairsArray, contains, initTernaryTreeMapFromArray, initEmptyTernaryTreeMap, } from "@calcit/ternary-tree";
|
|
3
4
|
import * as ternaryTree from "@calcit/ternary-tree";
|
|
@@ -87,4 +88,12 @@ export class CalcitSet {
|
|
|
87
88
|
values() {
|
|
88
89
|
return [...ternaryTree.toKeys(this.value)];
|
|
89
90
|
}
|
|
91
|
+
nestedDataInChildren() {
|
|
92
|
+
for (let k of ternaryTree.toKeys(this.value)) {
|
|
93
|
+
if (!isLiteral(k)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
90
99
|
}
|
package/lib/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calcit/procs",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.43",
|
|
4
4
|
"main": "./lib/calcit.procs.mjs",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@types/node": "^20.11.
|
|
7
|
-
"typescript": "^5.
|
|
6
|
+
"@types/node": "^20.11.28",
|
|
7
|
+
"typescript": "^5.4.2"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"compile": "rm -rfv lib/* && tsc",
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calcit/procs",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.43",
|
|
4
4
|
"main": "./lib/calcit.procs.mjs",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@types/node": "^20.11.
|
|
7
|
-
"typescript": "^5.
|
|
6
|
+
"@types/node": "^20.11.28",
|
|
7
|
+
"typescript": "^5.4.2"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"compile": "rm -rfv lib/* && tsc",
|
|
@@ -9,13 +9,12 @@ import { CalcitTuple } from "./js-tuple.mjs";
|
|
|
9
9
|
import { CalcitCirruQuote } from "./js-cirru.mjs";
|
|
10
10
|
|
|
11
11
|
declare global {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
12
|
+
// https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
|
|
13
|
+
var devtoolsFormatters: {
|
|
14
|
+
header: (obj: any, config: any) => any[];
|
|
15
|
+
hasBody: (obj: any) => boolean;
|
|
16
|
+
body: (obj: any, config: any) => any[];
|
|
17
|
+
}[];
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
let embedObject = (x: CalcitValue) => {
|
|
@@ -94,8 +93,8 @@ let saveString = (v: CalcitValue) => {
|
|
|
94
93
|
};
|
|
95
94
|
|
|
96
95
|
export let load_console_formatter_$x_ = () => {
|
|
97
|
-
if (typeof
|
|
98
|
-
|
|
96
|
+
if (typeof globalThis === "object") {
|
|
97
|
+
globalThis["devtoolsFormatters"] = [
|
|
99
98
|
{
|
|
100
99
|
header: (obj, config) => {
|
|
101
100
|
if (obj instanceof CalcitTag) {
|
|
@@ -119,7 +118,8 @@ export let load_console_formatter_$x_ = () => {
|
|
|
119
118
|
}
|
|
120
119
|
return div(
|
|
121
120
|
{
|
|
122
|
-
color: hasCollection ? hsl(280, 80, 60, 0.4) :
|
|
121
|
+
color: hasCollection ? hsl(280, 80, 60, 0.4) : hsl(280, 80, 60),
|
|
122
|
+
marginRight: "16px",
|
|
123
123
|
},
|
|
124
124
|
`[]`,
|
|
125
125
|
span(
|
|
@@ -130,7 +130,6 @@ export let load_console_formatter_$x_ = () => {
|
|
|
130
130
|
},
|
|
131
131
|
`${obj.len()}`
|
|
132
132
|
),
|
|
133
|
-
" ",
|
|
134
133
|
preview
|
|
135
134
|
);
|
|
136
135
|
}
|
|
@@ -147,10 +146,38 @@ export let load_console_formatter_$x_ = () => {
|
|
|
147
146
|
break;
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
|
-
return div(
|
|
149
|
+
return div(
|
|
150
|
+
{ color: hasCollection ? hsl(280, 80, 60, 0.4) : hsl(280, 80, 60), marginRight: "16px", maxWidth: "100%", whiteSpace: "normal" },
|
|
151
|
+
"{}",
|
|
152
|
+
preview
|
|
153
|
+
);
|
|
151
154
|
}
|
|
152
155
|
if (obj instanceof CalcitSet) {
|
|
153
|
-
|
|
156
|
+
let preview = "";
|
|
157
|
+
let hasCollection = false;
|
|
158
|
+
for (let item of obj.values()) {
|
|
159
|
+
preview += " ";
|
|
160
|
+
if (isLiteral(item)) {
|
|
161
|
+
preview += saveString(item);
|
|
162
|
+
} else {
|
|
163
|
+
preview += "..";
|
|
164
|
+
hasCollection = true;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return div(
|
|
169
|
+
{ color: hasCollection ? hsl(280, 80, 60, 0.4) : hsl(280, 80, 60), marginRight: "16px" },
|
|
170
|
+
"#{}",
|
|
171
|
+
span(
|
|
172
|
+
{
|
|
173
|
+
fontSize: "8px",
|
|
174
|
+
verticalAlign: "middle",
|
|
175
|
+
color: hsl(280, 80, 80, 0.8),
|
|
176
|
+
},
|
|
177
|
+
`${obj.len()}`
|
|
178
|
+
),
|
|
179
|
+
preview
|
|
180
|
+
);
|
|
154
181
|
}
|
|
155
182
|
if (obj instanceof CalcitRecord) {
|
|
156
183
|
let ret: any[] = div({ color: hsl(280, 80, 60, 0.4), maxWidth: "100%" }, `%{} ${obj.name} ...`);
|
|
@@ -159,7 +186,7 @@ export let load_console_formatter_$x_ = () => {
|
|
|
159
186
|
if (obj instanceof CalcitTuple) {
|
|
160
187
|
if (obj.klass) {
|
|
161
188
|
let ret: any[] = div(
|
|
162
|
-
{},
|
|
189
|
+
{ marginRight: "16px" },
|
|
163
190
|
div({ display: "inline-block", color: hsl(300, 100, 40) }, "%::"),
|
|
164
191
|
div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.klass)),
|
|
165
192
|
div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.tag))
|
|
@@ -170,7 +197,7 @@ export let load_console_formatter_$x_ = () => {
|
|
|
170
197
|
return ret;
|
|
171
198
|
} else {
|
|
172
199
|
let ret: any[] = div(
|
|
173
|
-
{},
|
|
200
|
+
{ marginRight: "16px" },
|
|
174
201
|
div({ display: "inline-block", color: hsl(300, 100, 40) }, "::"),
|
|
175
202
|
div({ marginLeft: "6px", display: "inline-block" }, embedObject(obj.tag))
|
|
176
203
|
);
|
|
@@ -191,7 +218,7 @@ export let load_console_formatter_$x_ = () => {
|
|
|
191
218
|
}
|
|
192
219
|
if (obj instanceof CalcitCirruQuote) {
|
|
193
220
|
return div(
|
|
194
|
-
{ color: hsl(280, 80, 60), display: "flex" },
|
|
221
|
+
{ color: hsl(280, 80, 60), display: "flex", marginRight: "16px" },
|
|
195
222
|
`CirruQuote`,
|
|
196
223
|
div(
|
|
197
224
|
{ color: hsl(280, 80, 60), padding: "4px 4px", margin: "0 4px 2px", border: "1px solid hsl(0,70%,90%)", borderRadius: "4px" },
|
|
@@ -211,7 +238,8 @@ export let load_console_formatter_$x_ = () => {
|
|
|
211
238
|
return obj.len() > 0 && hasCollection;
|
|
212
239
|
}
|
|
213
240
|
if (obj instanceof CalcitSet) {
|
|
214
|
-
|
|
241
|
+
let hasCollection = obj.nestedDataInChildren();
|
|
242
|
+
return obj.len() > 0 && hasCollection;
|
|
215
243
|
}
|
|
216
244
|
if (obj instanceof CalcitRecord) {
|
|
217
245
|
return obj.fields.length > 0;
|
package/ts-src/js-set.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CalcitValue } from "./js-primes.mjs";
|
|
1
|
+
import { CalcitValue, isLiteral } from "./js-primes.mjs";
|
|
2
2
|
import { toString } from "./calcit-data.mjs";
|
|
3
3
|
import {
|
|
4
4
|
TernaryTreeMap,
|
|
@@ -110,4 +110,13 @@ export class CalcitSet {
|
|
|
110
110
|
values() {
|
|
111
111
|
return [...ternaryTree.toKeys(this.value)];
|
|
112
112
|
}
|
|
113
|
+
|
|
114
|
+
nestedDataInChildren(): boolean {
|
|
115
|
+
for (let k of ternaryTree.toKeys(this.value)) {
|
|
116
|
+
if (!isLiteral(k)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
113
122
|
}
|