@davidsouther/jiffies 2.1.5 → 2.1.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/lib/cjs/components/button_bar.d.ts +1 -1
- package/lib/cjs/components/button_bar.js +7 -7
- package/lib/cjs/components/inline_edit.d.ts +1 -1
- package/lib/cjs/components/inline_edit.js +9 -9
- package/lib/cjs/components/logger.d.ts +1 -1
- package/lib/cjs/components/logger.js +12 -12
- package/lib/cjs/components/select.d.ts +2 -2
- package/lib/cjs/components/select.js +3 -3
- package/lib/cjs/components/test.js +1 -1
- package/lib/cjs/fs.js +30 -11
- package/lib/cjs/loader-register.d.mts +1 -0
- package/lib/cjs/loader-register.d.ts +1 -0
- package/lib/cjs/loader-register.js +4 -0
- package/lib/cjs/loader-register.mjs +4 -0
- package/lib/cjs/log.d.ts +1 -1
- package/lib/cjs/result.d.ts +1 -1
- package/lib/cjs/result.js +3 -3
- package/lib/cjs/result.test.js +5 -0
- package/lib/cjs/scope/expect.js +4 -8
- package/lib/cjs/test_all.js +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/components/button_bar.d.ts +1 -1
- package/lib/esm/components/button_bar.js +3 -3
- package/lib/esm/components/inline_edit.d.ts +1 -1
- package/lib/esm/components/inline_edit.js +3 -3
- package/lib/esm/components/logger.d.ts +1 -1
- package/lib/esm/components/logger.js +3 -3
- package/lib/esm/components/select.d.ts +2 -2
- package/lib/esm/components/select.js +2 -2
- package/lib/esm/components/test.js +1 -1
- package/lib/esm/fs.js +30 -11
- package/lib/esm/loader-register.d.mts +1 -0
- package/lib/esm/loader-register.d.ts +1 -0
- package/lib/esm/loader-register.js +2 -0
- package/lib/esm/loader-register.mjs +2 -0
- package/lib/esm/log.d.ts +1 -1
- package/lib/esm/result.d.ts +1 -1
- package/lib/esm/result.js +3 -3
- package/lib/esm/result.test.js +5 -0
- package/lib/esm/scope/expect.js +4 -8
- package/lib/esm/test_all.js +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/button_bar.ts +3 -3
- package/src/components/inline_edit.ts +3 -3
- package/src/components/logger.ts +3 -3
- package/src/components/select.ts +3 -3
- package/src/fs.ts +35 -9
- package/src/index.html +6 -6
- package/src/log.ts +1 -1
- package/src/scope/expect.ts +4 -4
- package/src/test_all.ts +1 -1
- /package/src/{loader-register.js → loader-register.mjs} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const display_js_1 = require("../display.js");
|
|
4
|
+
const fc_js_1 = require("../dom/fc.js");
|
|
5
|
+
const html_js_1 = require("../dom/html.js");
|
|
6
6
|
let buttonBarId = 1;
|
|
7
7
|
let nextId = () => buttonBarId++;
|
|
8
|
-
const ButtonBar = (0,
|
|
8
|
+
const ButtonBar = (0, fc_js_1.FC)("button-bar", (el, { value, values, events }) => {
|
|
9
9
|
const name = `button-bar-${nextId()}`;
|
|
10
|
-
return (0,
|
|
10
|
+
return (0, html_js_1.fieldset)({ class: "input-group" }, ...values
|
|
11
11
|
.map((option) => {
|
|
12
12
|
const opt = `${option}`.replace(/\s+/g, "_").toLowerCase();
|
|
13
13
|
const id = `${name}-${opt}`;
|
|
14
14
|
return [
|
|
15
|
-
(0,
|
|
15
|
+
(0, html_js_1.label)({ role: "button", htmlFor: id }, (0, html_js_1.input)({
|
|
16
16
|
type: "radio",
|
|
17
17
|
id,
|
|
18
18
|
name,
|
|
@@ -21,7 +21,7 @@ const ButtonBar = (0, fc_1.FC)("button-bar", (el, { value, values, events }) =>
|
|
|
21
21
|
events: {
|
|
22
22
|
change: () => events.onSelect(option),
|
|
23
23
|
},
|
|
24
|
-
}), (0,
|
|
24
|
+
}), (0, display_js_1.display)(option)),
|
|
25
25
|
];
|
|
26
26
|
})
|
|
27
27
|
.flat());
|
|
@@ -2,7 +2,7 @@ export interface InlineEditState {
|
|
|
2
2
|
mode: number;
|
|
3
3
|
value: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const InlineEdit: import("../dom/fc").FCComponentCtor<{
|
|
5
|
+
export declare const InlineEdit: import("../dom/fc.js").FCComponentCtor<{
|
|
6
6
|
mode?: number | undefined;
|
|
7
7
|
value: string;
|
|
8
8
|
events: {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InlineEdit = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const sizing_js_1 = require("../dom/css/sizing.js");
|
|
5
|
+
const fc_js_1 = require("../dom/fc.js");
|
|
6
|
+
const html_js_1 = require("../dom/html.js");
|
|
7
7
|
const Mode = { VIEW: 0, EDIT: 1 };
|
|
8
|
-
exports.InlineEdit = (0,
|
|
9
|
-
const state = (el[
|
|
8
|
+
exports.InlineEdit = (0, fc_js_1.FC)("inline-edit", (el, { mode = Mode.VIEW, value, events }) => {
|
|
9
|
+
const state = (el[fc_js_1.State] ??= { mode, value });
|
|
10
10
|
const render = () => {
|
|
11
11
|
switch (state.mode) {
|
|
12
12
|
case Mode.EDIT:
|
|
@@ -14,11 +14,11 @@ exports.InlineEdit = (0, fc_1.FC)("inline-edit", (el, { mode = Mode.VIEW, value,
|
|
|
14
14
|
case Mode.VIEW:
|
|
15
15
|
return view();
|
|
16
16
|
default:
|
|
17
|
-
return (0,
|
|
17
|
+
return (0, html_js_1.span)();
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
const view = () => (0,
|
|
21
|
-
style: { cursor: "text", ...(0,
|
|
20
|
+
const view = () => (0, html_js_1.span)({
|
|
21
|
+
style: { cursor: "text", ...(0, sizing_js_1.width)("full", "inline") },
|
|
22
22
|
events: {
|
|
23
23
|
click: () => {
|
|
24
24
|
state.mode = Mode.EDIT;
|
|
@@ -27,7 +27,7 @@ exports.InlineEdit = (0, fc_1.FC)("inline-edit", (el, { mode = Mode.VIEW, value,
|
|
|
27
27
|
},
|
|
28
28
|
}, state.value ?? "");
|
|
29
29
|
const edit = () => {
|
|
30
|
-
const edit = (0,
|
|
30
|
+
const edit = (0, html_js_1.span)({ style: { display: "block", position: "relative" } }, (0, html_js_1.input)({
|
|
31
31
|
style: {
|
|
32
32
|
zIndex: "10",
|
|
33
33
|
position: "absolute",
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeHTMLLogger = exports.isHTMLLogger = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const display_js_1 = require("../display.js");
|
|
5
|
+
const html_js_1 = require("../dom/html.js");
|
|
6
|
+
const log_js_1 = require("../log.js");
|
|
7
7
|
function isHTMLLogger(logger) {
|
|
8
8
|
return logger.root != undefined;
|
|
9
9
|
}
|
|
10
10
|
exports.isHTMLLogger = isHTMLLogger;
|
|
11
11
|
function makeHTMLLogger(name) {
|
|
12
12
|
let log;
|
|
13
|
-
const root = (0,
|
|
14
|
-
const logger = { level:
|
|
13
|
+
const root = (0, html_js_1.div)((0, html_js_1.div)((0, html_js_1.span)(name)), (log = (0, html_js_1.ul)()));
|
|
14
|
+
const logger = { level: log_js_1.LEVEL.INFO, root };
|
|
15
15
|
function append(message) {
|
|
16
|
-
log.appendChild((0,
|
|
16
|
+
log.appendChild((0, html_js_1.li)((0, html_js_1.pre)((0, html_js_1.code)(message))));
|
|
17
17
|
}
|
|
18
|
-
const logAt = (level) => (message) => level >= (logger.level ??
|
|
19
|
-
? append((0,
|
|
18
|
+
const logAt = (level) => (message) => level >= (logger.level ?? log_js_1.LEVEL.ERROR)
|
|
19
|
+
? append((0, display_js_1.display)(message))
|
|
20
20
|
: undefined;
|
|
21
|
-
logger.debug = logAt(
|
|
22
|
-
logger.info = logAt(
|
|
23
|
-
logger.warn = logAt(
|
|
24
|
-
logger.error = logAt(
|
|
21
|
+
logger.debug = logAt(log_js_1.LEVEL.VERBOSE);
|
|
22
|
+
logger.info = logAt(log_js_1.LEVEL.INFO);
|
|
23
|
+
logger.warn = logAt(log_js_1.LEVEL.WARN);
|
|
24
|
+
logger.error = logAt(log_js_1.LEVEL.ERROR);
|
|
25
25
|
return logger;
|
|
26
26
|
}
|
|
27
27
|
exports.makeHTMLLogger = makeHTMLLogger;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventHandler } from "../dom/dom";
|
|
2
|
-
export declare const Select: import("../dom/fc").FCComponentCtor<{
|
|
1
|
+
import { EventHandler } from "../dom/dom.js";
|
|
2
|
+
export declare const Select: import("../dom/fc.js").FCComponentCtor<{
|
|
3
3
|
name: string;
|
|
4
4
|
value: string;
|
|
5
5
|
events: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Select = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
exports.Select = (0,
|
|
4
|
+
const fc_js_1 = require("../dom/fc.js");
|
|
5
|
+
const html_js_1 = require("../dom/html.js");
|
|
6
|
+
exports.Select = (0, fc_js_1.FC)("jiffies-select", (el, { name, events: { change }, disabled, value, options }) => (0, html_js_1.select)({ name, events: { change }, disabled }, ...options.map(([v, name]) => (0, html_js_1.option)({ value: v, selected: value === v }, `${name}`))));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadTests = void 0;
|
|
4
4
|
async function loadTests() {
|
|
5
|
-
await
|
|
5
|
+
// await import("./virtual_scroll.test.js");
|
|
6
6
|
}
|
|
7
7
|
exports.loadTests = loadTests;
|
package/lib/cjs/fs.js
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reset = exports.ObjectFileSystemAdapter = exports.LocalStorageFileSystemAdapter = exports.RecordFileSystemAdapter = exports.FileSystem = exports.basename = void 0;
|
|
4
|
+
const PLATFORM_PARTS = (() => {
|
|
5
|
+
if (typeof process !== "undefined" && process.platform == "win32") {
|
|
6
|
+
return {
|
|
7
|
+
SEP: "\\",
|
|
8
|
+
WD: "C:\\\\",
|
|
9
|
+
isAbsolute: (path) => Boolean(path.match(new RegExp("^[a-zA-Z]:\\\\"))),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return {
|
|
14
|
+
SEP: "/",
|
|
15
|
+
WD: "/",
|
|
16
|
+
isAbsolute: (path) => path[0] == "/",
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
const SEP = PLATFORM_PARTS.SEP;
|
|
21
|
+
const WD = PLATFORM_PARTS.WD;
|
|
22
|
+
const isAbsolute = PLATFORM_PARTS.isAbsolute;
|
|
4
23
|
function basename(filename) {
|
|
5
|
-
if (filename.endsWith(
|
|
24
|
+
if (filename.endsWith(SEP)) {
|
|
6
25
|
filename = filename.substring(0, filename.length - 1);
|
|
7
26
|
}
|
|
8
|
-
const basename = filename.split(
|
|
27
|
+
const basename = filename.split(SEP).at(-1) ?? "";
|
|
9
28
|
return basename;
|
|
10
29
|
}
|
|
11
30
|
exports.basename = basename;
|
|
12
31
|
function join(...paths) {
|
|
13
32
|
const pathParts = [];
|
|
14
33
|
for (const path of paths) {
|
|
15
|
-
for (const part of path.split(
|
|
34
|
+
for (const part of path.split(SEP)) {
|
|
16
35
|
switch (part) {
|
|
17
36
|
case "":
|
|
18
37
|
case ".":
|
|
@@ -25,11 +44,11 @@ function join(...paths) {
|
|
|
25
44
|
}
|
|
26
45
|
}
|
|
27
46
|
}
|
|
28
|
-
return
|
|
47
|
+
return SEP + pathParts.join(SEP);
|
|
29
48
|
}
|
|
30
49
|
class FileSystem {
|
|
31
50
|
adapter;
|
|
32
|
-
wd =
|
|
51
|
+
wd = WD;
|
|
33
52
|
stack = [];
|
|
34
53
|
constructor(adapter = new RecordFileSystemAdapter()) {
|
|
35
54
|
this.adapter = adapter;
|
|
@@ -74,7 +93,7 @@ class FileSystem {
|
|
|
74
93
|
return this.adapter.rm(this.p(path));
|
|
75
94
|
}
|
|
76
95
|
p(path) {
|
|
77
|
-
return path
|
|
96
|
+
return isAbsolute(path) ? path : join(this.cwd(), path);
|
|
78
97
|
}
|
|
79
98
|
}
|
|
80
99
|
exports.FileSystem = FileSystem;
|
|
@@ -96,8 +115,8 @@ class RecordFileSystemAdapter {
|
|
|
96
115
|
},
|
|
97
116
|
});
|
|
98
117
|
}
|
|
99
|
-
if (!path.endsWith(
|
|
100
|
-
path +=
|
|
118
|
+
if (!path.endsWith(SEP))
|
|
119
|
+
path += SEP;
|
|
101
120
|
for (let filename of Object.keys(this.fs)) {
|
|
102
121
|
if (filename.startsWith(path)) {
|
|
103
122
|
return resolve({
|
|
@@ -129,13 +148,13 @@ class RecordFileSystemAdapter {
|
|
|
129
148
|
});
|
|
130
149
|
}
|
|
131
150
|
readdir(path) {
|
|
132
|
-
if (!path.endsWith(
|
|
133
|
-
path +=
|
|
151
|
+
if (!path.endsWith(SEP))
|
|
152
|
+
path += SEP;
|
|
134
153
|
return new Promise((resolve) => {
|
|
135
154
|
let dir = new Set();
|
|
136
155
|
for (const filename of Object.keys(this.fs)) {
|
|
137
156
|
if (filename.startsWith(path)) {
|
|
138
|
-
const end = filename.indexOf(
|
|
157
|
+
const end = filename.indexOf(SEP, path.length + 1);
|
|
139
158
|
const basename = filename.substring(path.length, end === -1 ? undefined : end);
|
|
140
159
|
dir.add(basename);
|
|
141
160
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/cjs/log.d.ts
CHANGED
package/lib/cjs/result.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare const isOk: <T, E>(t: Result<T, E>) => t is Ok<T>;
|
|
|
19
19
|
export declare const isErr: <T, E>(e: Result<T, E>) => e is Err<E>;
|
|
20
20
|
export declare const isResult: <T, E>(t: Result<T, E>) => t is Result<T, E>;
|
|
21
21
|
export declare function Ok<T>(ok: Ok<T>): T;
|
|
22
|
-
export declare function Ok<T>(t
|
|
22
|
+
export declare function Ok<T>(t?: T): Ok<T>;
|
|
23
23
|
export declare function Err<E>(e: Err<E>): E;
|
|
24
24
|
export declare function Err<E>(e: E): Err<E>;
|
|
25
25
|
export declare function Err<E>(e: string): Err<E>;
|
package/lib/cjs/result.js
CHANGED
|
@@ -13,14 +13,14 @@ function Some(t) {
|
|
|
13
13
|
return t;
|
|
14
14
|
}
|
|
15
15
|
exports.Some = Some;
|
|
16
|
-
const isOk = (t) => t
|
|
16
|
+
const isOk = (t) => Object.prototype.hasOwnProperty.call(t ?? {}, "ok");
|
|
17
17
|
exports.isOk = isOk;
|
|
18
|
-
const isErr = (e) => e
|
|
18
|
+
const isErr = (e) => Object.prototype.hasOwnProperty.call(e, "err");
|
|
19
19
|
exports.isErr = isErr;
|
|
20
20
|
const isResult = (t) => (0, exports.isOk)(t) || (0, exports.isErr)(t);
|
|
21
21
|
exports.isResult = isResult;
|
|
22
22
|
function Ok(t) {
|
|
23
|
-
return t
|
|
23
|
+
return (0, exports.isOk)(t)
|
|
24
24
|
? t.ok
|
|
25
25
|
: {
|
|
26
26
|
ok: t,
|
package/lib/cjs/result.test.js
CHANGED
|
@@ -70,4 +70,9 @@ const expect_js_1 = require("./scope/expect.js");
|
|
|
70
70
|
(0, expect_js_1.expect)((0, result_js_1.unwrapOrElse)(d, () => "z")).toBe("z");
|
|
71
71
|
(0, expect_js_1.expect)((0, result_js_1.unwrapOrElse)(e, () => "z")).toBe("else");
|
|
72
72
|
});
|
|
73
|
+
(0, describe_js_1.it)("allows Result<void> with Ok()", () => {
|
|
74
|
+
let a;
|
|
75
|
+
a = (0, result_js_1.Ok)();
|
|
76
|
+
(0, expect_js_1.expect)((0, result_js_1.unwrap)(a)).toBe(undefined);
|
|
77
|
+
});
|
|
73
78
|
});
|
package/lib/cjs/scope/expect.js
CHANGED
|
@@ -46,10 +46,8 @@ class Matcher {
|
|
|
46
46
|
// @ts-expect-error
|
|
47
47
|
result = this.actual();
|
|
48
48
|
}
|
|
49
|
-
catch (
|
|
50
|
-
(0, assert_js_1.assert)(
|
|
51
|
-
// @ts-expect-error
|
|
52
|
-
(e ?? "").match(message), () => `Expected thrown message to match ${message}, got ${e}`);
|
|
49
|
+
catch (e) {
|
|
50
|
+
(0, assert_js_1.assert)((e.message ?? "").match(message) !== null, () => `Expected thrown message to match ${message}, got ${e}`);
|
|
53
51
|
didThrow = true;
|
|
54
52
|
}
|
|
55
53
|
(0, assert_js_1.assert)(didThrow, () => `Expected throw but got ${JSON.stringify(result)}`);
|
|
@@ -98,10 +96,8 @@ class NotMatcher {
|
|
|
98
96
|
// @ts-expect-error
|
|
99
97
|
result = this.actual();
|
|
100
98
|
}
|
|
101
|
-
catch (
|
|
102
|
-
(0, assert_js_1.assert)(
|
|
103
|
-
// @ts-expect-error
|
|
104
|
-
(e ?? "").match(message), () => `Expected thrown message to match ${message}, got ${e}`);
|
|
99
|
+
catch (e) {
|
|
100
|
+
(0, assert_js_1.assert)((e.message ?? "").match(message) !== null, () => `Expected thrown message to match ${message}, got ${e}`);
|
|
105
101
|
didThrow = true;
|
|
106
102
|
}
|
|
107
103
|
(0, assert_js_1.assert)(!didThrow, () => `Expected throw but got ${JSON.stringify(result)}`);
|
package/lib/cjs/test_all.js
CHANGED
|
@@ -20,7 +20,7 @@ require("./generator.test.js");
|
|
|
20
20
|
require("./lock.test.js");
|
|
21
21
|
require("./result.test.js");
|
|
22
22
|
require("./observable/observable.test.js");
|
|
23
|
-
if (process
|
|
23
|
+
if (typeof process != "undefined" && process.env.CI?.toLowerCase() !== "true") {
|
|
24
24
|
(async () => {
|
|
25
25
|
const components = await Promise.resolve().then(() => require("./components/test.js"));
|
|
26
26
|
const dom = await Promise.resolve().then(() => require("./dom/test.js"));
|