@davidsouther/jiffies 1.0.0 → 1.1.0

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.
Files changed (172) hide show
  1. package/build/assert.d.ts +23 -23
  2. package/build/assert.js +33 -33
  3. package/build/case.d.ts +1 -1
  4. package/build/case.js +5 -5
  5. package/build/components/button_bar.d.ts +8 -8
  6. package/build/components/button_bar.js +27 -27
  7. package/build/components/inline_edit.d.ts +12 -12
  8. package/build/components/inline_edit.js +48 -48
  9. package/build/components/logger.d.ts +6 -7
  10. package/build/components/logger.js +22 -22
  11. package/build/components/select.d.ts +13 -10
  12. package/build/components/select.js +3 -3
  13. package/build/components/test.d.ts +1 -1
  14. package/build/components/test.js +2 -2
  15. package/build/components/virtual_scroll.d.ts +40 -41
  16. package/build/components/virtual_scroll.js +94 -94
  17. package/build/components/virtual_scroll.test.d.ts +1 -1
  18. package/build/components/virtual_scroll.test.js +21 -21
  19. package/build/context.d.ts +15 -15
  20. package/build/context.js +43 -43
  21. package/build/context.test.d.ts +1 -1
  22. package/build/context.test.js +46 -46
  23. package/build/debounce.d.ts +1 -1
  24. package/build/debounce.js +7 -7
  25. package/build/display.d.ts +5 -5
  26. package/build/display.js +11 -11
  27. package/build/dom/css/border.d.ts +11 -11
  28. package/build/dom/css/border.js +27 -27
  29. package/build/dom/css/constants.d.ts +31 -31
  30. package/build/dom/css/constants.js +28 -28
  31. package/build/dom/css/core.d.ts +5 -5
  32. package/build/dom/css/core.js +24 -24
  33. package/build/dom/css/fstyle.d.ts +5 -5
  34. package/build/dom/css/fstyle.js +32 -32
  35. package/build/dom/css/sizing.d.ts +5 -5
  36. package/build/dom/css/sizing.js +10 -10
  37. package/build/dom/dom.d.ts +26 -27
  38. package/build/dom/dom.js +95 -95
  39. package/build/dom/fc.d.ts +14 -14
  40. package/build/dom/fc.js +36 -35
  41. package/build/dom/fc.test.d.ts +1 -1
  42. package/build/dom/fc.test.js +21 -21
  43. package/build/dom/form/form.app.d.ts +1 -1
  44. package/build/dom/form/form.app.js +23 -23
  45. package/build/dom/form/form.d.ts +26 -26
  46. package/build/dom/form/form.js +34 -34
  47. package/build/dom/form/form.test.js +1 -1
  48. package/build/dom/html.d.ts +113 -117
  49. package/build/dom/html.js +114 -114
  50. package/build/dom/html.test.d.ts +1 -1
  51. package/build/dom/html.test.js +58 -58
  52. package/build/dom/provide.d.ts +3 -3
  53. package/build/dom/provide.js +7 -7
  54. package/build/dom/router/link.d.ts +6 -6
  55. package/build/dom/router/link.js +3 -3
  56. package/build/dom/router/router.d.ts +12 -12
  57. package/build/dom/router/router.js +49 -49
  58. package/build/dom/svg.d.ts +64 -64
  59. package/build/dom/svg.js +65 -65
  60. package/build/dom/test.d.ts +1 -1
  61. package/build/dom/test.js +2 -2
  62. package/build/dom/types/css.d.ts +6612 -6612
  63. package/build/dom/types/css.js +23 -23
  64. package/build/dom/types/dom.js +1 -1
  65. package/build/dom/types/html.d.ts +616 -616
  66. package/build/dom/types/html.js +1 -1
  67. package/build/dom/xml.d.ts +1 -1
  68. package/build/dom/xml.js +4 -5
  69. package/build/equal.d.ts +5 -5
  70. package/build/equal.js +37 -37
  71. package/build/equal.test.d.ts +1 -1
  72. package/build/equal.test.js +20 -20
  73. package/build/flags.d.ts +7 -7
  74. package/build/flags.js +48 -48
  75. package/build/flags.test.d.ts +1 -1
  76. package/build/flags.test.js +35 -35
  77. package/build/fs.d.ts +48 -48
  78. package/build/fs.js +144 -144
  79. package/build/fs.test.d.ts +1 -1
  80. package/build/fs.test.js +43 -43
  81. package/build/generator.d.ts +1 -1
  82. package/build/generator.js +10 -10
  83. package/build/generator.test.d.ts +1 -1
  84. package/build/generator.test.js +24 -24
  85. package/build/is_browser.d.ts +1 -1
  86. package/build/is_browser.js +1 -1
  87. package/build/loader.d.mts +22 -22
  88. package/build/loader.mjs +35 -35
  89. package/build/lock.d.ts +1 -1
  90. package/build/lock.js +23 -23
  91. package/build/lock.test.d.ts +1 -1
  92. package/build/lock.test.js +16 -16
  93. package/build/log.d.ts +26 -26
  94. package/build/log.js +46 -46
  95. package/build/observable/observable.d.ts +83 -0
  96. package/build/observable/observable.js +148 -0
  97. package/build/observable/observable.test.d.ts +1 -0
  98. package/build/observable/observable.test.js +21 -0
  99. package/build/range.d.ts +1 -1
  100. package/build/range.js +7 -7
  101. package/build/result.d.ts +31 -31
  102. package/build/result.js +65 -65
  103. package/build/result.test.d.ts +1 -1
  104. package/build/result.test.js +71 -71
  105. package/build/safe.d.ts +1 -1
  106. package/build/safe.js +10 -10
  107. package/build/scope/describe.d.ts +18 -14
  108. package/build/scope/describe.js +61 -52
  109. package/build/scope/display/console.d.ts +2 -2
  110. package/build/scope/display/console.js +21 -21
  111. package/build/scope/display/dom.d.ts +3 -3
  112. package/build/scope/display/dom.js +26 -26
  113. package/build/scope/display/junit.d.ts +2 -2
  114. package/build/scope/display/junit.js +17 -17
  115. package/build/scope/execute.d.ts +12 -12
  116. package/build/scope/execute.js +85 -85
  117. package/build/scope/expect.d.ts +23 -23
  118. package/build/scope/expect.js +108 -108
  119. package/build/scope/fix.d.ts +4 -4
  120. package/build/scope/fix.js +22 -22
  121. package/build/scope/index.d.ts +3 -3
  122. package/build/scope/index.js +3 -3
  123. package/build/scope/scope.d.ts +17 -17
  124. package/build/scope/scope.js +1 -1
  125. package/build/server/http/apps.d.ts +5 -5
  126. package/build/server/http/apps.js +23 -23
  127. package/build/server/http/css.d.ts +5 -5
  128. package/build/server/http/css.js +50 -47
  129. package/build/server/http/index.d.ts +21 -21
  130. package/build/server/http/index.js +73 -73
  131. package/build/server/http/response.d.ts +4 -4
  132. package/build/server/http/response.js +40 -40
  133. package/build/server/http/sitemap.d.ts +2 -2
  134. package/build/server/http/sitemap.js +42 -42
  135. package/build/server/http/static.d.ts +2 -2
  136. package/build/server/http/static.js +21 -21
  137. package/build/server/http/typescript.d.ts +5 -5
  138. package/build/server/http/typescript.js +40 -40
  139. package/build/server/main.d.ts +2 -2
  140. package/build/server/main.js +9 -9
  141. package/build/test.d.mts +2 -2
  142. package/build/test.mjs +23 -23
  143. package/build/test_all.d.ts +7 -7
  144. package/build/test_all.js +18 -18
  145. package/build/transpile.d.mts +3 -3
  146. package/build/transpile.mjs +18 -18
  147. package/package.json +3 -3
  148. package/src/components/logger.ts +2 -3
  149. package/src/components/virtual_scroll.test.ts +4 -4
  150. package/src/components/virtual_scroll.ts +8 -8
  151. package/src/diff.test.ts +48 -0
  152. package/src/diff.ts +84 -0
  153. package/src/dom/dom.ts +73 -61
  154. package/src/dom/fc.ts +10 -9
  155. package/src/dom/html.test.ts +5 -5
  156. package/src/dom/html.ts +7 -10
  157. package/src/dom/observable.test.ts +43 -0
  158. package/src/dom/observable.ts +11 -0
  159. package/src/dom/router/router.ts +4 -4
  160. package/src/dom/test.ts +5 -1
  161. package/src/dom/xml.ts +1 -2
  162. package/src/index.html +6 -3
  163. package/src/observable/_notes +21 -8
  164. package/src/observable/event.ts +93 -0
  165. package/src/observable/observable.test.ts +73 -0
  166. package/src/observable/observable.ts +403 -0
  167. package/src/scope/describe.ts +14 -1
  168. package/src/scope/display/dom.ts +2 -2
  169. package/src/scope/execute.ts +2 -5
  170. package/src/server/http/css.ts +3 -1
  171. package/src/test_all.ts +10 -8
  172. package/src/observable/observable._js +0 -175
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1 +1 @@
1
- export declare function xml(tag: string, attributes: Record<string, string | number | boolean>, children?: string[]): string;
1
+ export declare function xml(tag: string, attributes: Record<string, string | number | boolean>, children?: string[]): string;
package/build/dom/xml.js CHANGED
@@ -1,5 +1,4 @@
1
- export function xml(tag, attributes, children = []) {
2
- const attrs = Object.entries(attributes).reduce((attrs, [attr, val]) => `${attrs} ${attr}="${val}"`, "");
3
- const kids = children.join("");
4
- return `<${tag} ${attrs}>${kids}</${tag}>`;
5
- }
1
+ export function xml(tag, attributes, children = []) {
2
+ const attrs = Object.entries(attributes).reduce((attrs, [attr, val]) => `${attrs} ${attr}="${val}"`, "");
3
+ return `<${tag} ${attrs}>${children.join("")}</${tag}>`;
4
+ }
package/build/equal.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export declare function compareArrays<T>(equal: (a: T, b: T, partial: boolean) => boolean): (A: T[], B: T[], partial?: boolean) => boolean;
2
- export declare const equalArrays: (A: any[], B: any[], partial?: boolean) => boolean;
3
- export declare const matchArrays: <A>(a: A[], b: A[], partial?: boolean) => boolean;
4
- export declare const matchObjects: (a: {}, b: {}, partial?: boolean) => boolean;
5
- export declare function equals<A>(a: A | A[], b: A | A[], partial?: boolean): boolean;
1
+ export declare function compareArrays<T>(equal: (a: T, b: T, partial: boolean) => boolean): (A: T[], B: T[], partial?: boolean) => boolean;
2
+ export declare const equalArrays: (A: any[], B: any[], partial?: boolean) => boolean;
3
+ export declare const matchArrays: <A>(a: A[], b: A[], partial?: boolean) => boolean;
4
+ export declare const matchObjects: (a: {}, b: {}, partial?: boolean) => boolean;
5
+ export declare function equals<A>(a: A | A[], b: A | A[], partial?: boolean): boolean;
package/build/equal.js CHANGED
@@ -1,37 +1,37 @@
1
- export function compareArrays(equal) {
2
- return (a, b, partial = false) => a.length === b.length && a.every((e, i) => equal(e, b[i], partial));
3
- }
4
- export const equalArrays = compareArrays(Object.is);
5
- export const matchArrays = compareArrays(equals);
6
- function asArray(a) {
7
- return Object.entries(a).sort((a, b) => a[0].localeCompare(b[0]));
8
- }
9
- export const matchObjects = (a, b, partial = true) => {
10
- for (const [k, v] of Object.entries(a)) {
11
- if (!b.hasOwnProperty(k) && partial)
12
- continue;
13
- // @ts-ignore
14
- if (!equals(v, b[k], partial))
15
- return false;
16
- }
17
- return true;
18
- };
19
- export function equals(a, b, partial = false) {
20
- // runtime type checking
21
- switch (typeof a) {
22
- case "object":
23
- if (b === undefined) {
24
- return false;
25
- }
26
- if (a instanceof Array && b instanceof Array) {
27
- return matchArrays(a, b, partial);
28
- }
29
- else {
30
- return matchObjects(a, b, partial);
31
- }
32
- case "function":
33
- return a.name == b.name;
34
- default:
35
- return Object.is(a, b);
36
- }
37
- }
1
+ export function compareArrays(equal) {
2
+ return (a, b, partial = false) => a.length === b.length && a.every((e, i) => equal(e, b[i], partial));
3
+ }
4
+ export const equalArrays = compareArrays(Object.is);
5
+ export const matchArrays = compareArrays(equals);
6
+ function asArray(a) {
7
+ return Object.entries(a).sort((a, b) => a[0].localeCompare(b[0]));
8
+ }
9
+ export const matchObjects = (a, b, partial = true) => {
10
+ for (const [k, v] of Object.entries(a)) {
11
+ if (!b.hasOwnProperty(k) && partial)
12
+ continue;
13
+ // @ts-ignore
14
+ if (!equals(v, b[k], partial))
15
+ return false;
16
+ }
17
+ return true;
18
+ };
19
+ export function equals(a, b, partial = false) {
20
+ // runtime type checking
21
+ switch (typeof a) {
22
+ case "object":
23
+ if (b === undefined) {
24
+ return false;
25
+ }
26
+ if (a instanceof Array && b instanceof Array) {
27
+ return matchArrays(a, b, partial);
28
+ }
29
+ else {
30
+ return matchObjects(a, b, partial);
31
+ }
32
+ case "function":
33
+ return a.name == b.name;
34
+ default:
35
+ return Object.is(a, b);
36
+ }
37
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,20 +1,20 @@
1
- import { describe, it, expect } from "./scope/index.js";
2
- import { equalArrays, equals, matchArrays } from "./equal.js";
3
- describe("Equality", () => {
4
- it("compares objects", () => {
5
- expect(equals({ a: 1, b: 2 }, { b: 2, a: 1 })).toBe(true);
6
- expect(equals({ a: 1, b: 2 }, { b: 1, a: 2 })).toBe(false);
7
- });
8
- it("compares primitives", () => {
9
- expect(equals(1, 1)).toBe(true);
10
- expect(equals(1, -1)).toBe(false);
11
- expect(equals(0, -0)).toBe(false);
12
- expect(equals(NaN, NaN)).toBe(true);
13
- });
14
- it("compares arrays", () => {
15
- expect(equalArrays([1, 2, 3], [1, 2, 3])).toBe(true);
16
- expect(equalArrays([1], [2, 3])).toBe(false);
17
- expect(equalArrays([{ a: 1 }], [{ a: 1 }])).toBe(false);
18
- expect(matchArrays([{ a: 1 }], [{ a: 1 }])).toBe(true);
19
- });
20
- });
1
+ import { describe, it, expect } from "./scope/index.js";
2
+ import { equalArrays, equals, matchArrays } from "./equal.js";
3
+ describe("Equality", () => {
4
+ it("compares objects", () => {
5
+ expect(equals({ a: 1, b: 2 }, { b: 2, a: 1 })).toBe(true);
6
+ expect(equals({ a: 1, b: 2 }, { b: 1, a: 2 })).toBe(false);
7
+ });
8
+ it("compares primitives", () => {
9
+ expect(equals(1, 1)).toBe(true);
10
+ expect(equals(1, -1)).toBe(false);
11
+ expect(equals(0, -0)).toBe(false);
12
+ expect(equals(NaN, NaN)).toBe(true);
13
+ });
14
+ it("compares arrays", () => {
15
+ expect(equalArrays([1, 2, 3], [1, 2, 3])).toBe(true);
16
+ expect(equalArrays([1], [2, 3])).toBe(false);
17
+ expect(equalArrays([{ a: 1 }], [{ a: 1 }])).toBe(false);
18
+ expect(matchArrays([{ a: 1 }], [{ a: 1 }])).toBe(true);
19
+ });
20
+ });
package/build/flags.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export declare const parse: (parseArgs: string[]) => {
2
- readonly argv0: string;
3
- readonly args: readonly string[];
4
- get(flag: string, def?: boolean): boolean;
5
- asNumber(param: string, def?: number): number;
6
- asString(param: string, def?: string): string;
7
- };
1
+ export declare const parse: (parseArgs: string[]) => {
2
+ readonly argv0: string;
3
+ readonly args: readonly string[];
4
+ get(flag: string, def?: boolean): boolean;
5
+ asNumber(param: string, def?: number): number;
6
+ asString(param: string, def?: string): string;
7
+ };
package/build/flags.js CHANGED
@@ -1,48 +1,48 @@
1
- export const parse = (parseArgs) => {
2
- const fromNode = parseArgs[0].endsWith("node");
3
- const argv = parseArgs[fromNode ? 1 : 0];
4
- const params = new Map();
5
- const flags = new Map();
6
- const args = [];
7
- let index = fromNode ? 2 : 1;
8
- const hasNext = () => index < parseArgs.length;
9
- const peek = () => parseArgs[index];
10
- const advance = () => parseArgs[index++];
11
- const parseLong = (arg) => {
12
- if (arg.substr(0, 3) === "no-") {
13
- flags.set(arg.substr(3), false);
14
- }
15
- else if (!arg.includes("=")) {
16
- flags.set(arg, true);
17
- }
18
- else {
19
- const [param, ...value] = arg.split("=");
20
- params.set(param, value.join("="));
21
- }
22
- };
23
- while (hasNext()) {
24
- if (peek().substr(0, 2) == "--") {
25
- parseLong(advance().substr(2));
26
- }
27
- else {
28
- args.push(advance());
29
- }
30
- }
31
- return {
32
- get argv0() {
33
- return argv;
34
- },
35
- get args() {
36
- return args;
37
- },
38
- get(flag, def = false) {
39
- return flags.get(flag) ?? def;
40
- },
41
- asNumber(param, def = 0) {
42
- return Number.parseFloat(params.get(param) ?? `${def}`);
43
- },
44
- asString(param, def = "") {
45
- return params.get(param) ?? def;
46
- },
47
- };
48
- };
1
+ export const parse = (parseArgs) => {
2
+ const fromNode = parseArgs[0].endsWith("node");
3
+ const argv = parseArgs[fromNode ? 1 : 0];
4
+ const params = new Map();
5
+ const flags = new Map();
6
+ const args = [];
7
+ let index = fromNode ? 2 : 1;
8
+ const hasNext = () => index < parseArgs.length;
9
+ const peek = () => parseArgs[index];
10
+ const advance = () => parseArgs[index++];
11
+ const parseLong = (arg) => {
12
+ if (arg.substr(0, 3) === "no-") {
13
+ flags.set(arg.substr(3), false);
14
+ }
15
+ else if (!arg.includes("=")) {
16
+ flags.set(arg, true);
17
+ }
18
+ else {
19
+ const [param, ...value] = arg.split("=");
20
+ params.set(param, value.join("="));
21
+ }
22
+ };
23
+ while (hasNext()) {
24
+ if (peek().substr(0, 2) == "--") {
25
+ parseLong(advance().substr(2));
26
+ }
27
+ else {
28
+ args.push(advance());
29
+ }
30
+ }
31
+ return {
32
+ get argv0() {
33
+ return argv;
34
+ },
35
+ get args() {
36
+ return args;
37
+ },
38
+ get(flag, def = false) {
39
+ return flags.get(flag) ?? def;
40
+ },
41
+ asNumber(param, def = 0) {
42
+ return Number.parseFloat(params.get(param) ?? `${def}`);
43
+ },
44
+ asString(param, def = "") {
45
+ return params.get(param) ?? def;
46
+ },
47
+ };
48
+ };
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,35 +1,35 @@
1
- import { describe, it, expect } from "./scope/index.js";
2
- import { parse } from "./flags.js";
3
- const TEST_CASES = {
4
- SIMPLE: "program",
5
- NODE: "/usr/local/bin/node program",
6
- ONE_FLAG: "program --fun",
7
- ONE_PARAM: "program --fun=100",
8
- ONE_ARG: "program cat",
9
- ONE_NO_FLAG: "program --no-fun",
10
- MIXED: "program --fun=dog cat --port=8080 mouse --hamster --no-bird",
11
- };
12
- const makeFlags = (commandLine) => {
13
- return parse(commandLine.split(" "));
14
- };
15
- describe("Flags", () => {
16
- it("stores the program name", () => {
17
- const flags = makeFlags(TEST_CASES.SIMPLE);
18
- expect(flags.argv0).toEqual("program");
19
- expect(flags.args).toEqual([]);
20
- });
21
- it("stores the program name ignoring node", () => {
22
- const flags = makeFlags(TEST_CASES.NODE);
23
- expect(flags.argv0).toEqual("program");
24
- expect(flags.args).toEqual([]);
25
- });
26
- it("parses a flag", () => {
27
- const flags = makeFlags(TEST_CASES.ONE_FLAG);
28
- expect(flags.get("fun")).toBe(true);
29
- });
30
- it("parses a flag with a default value", () => {
31
- const flags = makeFlags(TEST_CASES.SIMPLE);
32
- expect(flags.get("missing")).toBe(false);
33
- expect(flags.get("missing", true)).toBe(true);
34
- });
35
- });
1
+ import { describe, it, expect } from "./scope/index.js";
2
+ import { parse } from "./flags.js";
3
+ const TEST_CASES = {
4
+ SIMPLE: "program",
5
+ NODE: "/usr/local/bin/node program",
6
+ ONE_FLAG: "program --fun",
7
+ ONE_PARAM: "program --fun=100",
8
+ ONE_ARG: "program cat",
9
+ ONE_NO_FLAG: "program --no-fun",
10
+ MIXED: "program --fun=dog cat --port=8080 mouse --hamster --no-bird",
11
+ };
12
+ const makeFlags = (commandLine) => {
13
+ return parse(commandLine.split(" "));
14
+ };
15
+ describe("Flags", () => {
16
+ it("stores the program name", () => {
17
+ const flags = makeFlags(TEST_CASES.SIMPLE);
18
+ expect(flags.argv0).toEqual("program");
19
+ expect(flags.args).toEqual([]);
20
+ });
21
+ it("stores the program name ignoring node", () => {
22
+ const flags = makeFlags(TEST_CASES.NODE);
23
+ expect(flags.argv0).toEqual("program");
24
+ expect(flags.args).toEqual([]);
25
+ });
26
+ it("parses a flag", () => {
27
+ const flags = makeFlags(TEST_CASES.ONE_FLAG);
28
+ expect(flags.get("fun")).toBe(true);
29
+ });
30
+ it("parses a flag with a default value", () => {
31
+ const flags = makeFlags(TEST_CASES.SIMPLE);
32
+ expect(flags.get("missing")).toBe(false);
33
+ expect(flags.get("missing", true)).toBe(true);
34
+ });
35
+ });
package/build/fs.d.ts CHANGED
@@ -1,48 +1,48 @@
1
- export declare type PathLike = string;
2
- export interface Stats {
3
- isDirectory(): boolean;
4
- isFile(): boolean;
5
- }
6
- interface FileSystemAdapter {
7
- stat(path: PathLike): Promise<Stats>;
8
- readdir(path: PathLike): Promise<string[]>;
9
- copyFile(from: PathLike, to: PathLike): Promise<void>;
10
- readFile(path: PathLike): Promise<string>;
11
- writeFile(path: PathLike, contents: string): Promise<void>;
12
- rm(path: PathLike): Promise<void>;
13
- }
14
- export declare class FileSystem implements FileSystemAdapter {
15
- protected adapter: ObjectFileSystemAdapter;
16
- protected wd: string;
17
- protected stack: string[];
18
- constructor(adapter?: ObjectFileSystemAdapter);
19
- cwd(): string;
20
- cd(dir: string): void;
21
- pushd(dir: string): void;
22
- popd(): void;
23
- stat(path: PathLike): Promise<Stats>;
24
- readdir(path: PathLike): Promise<string[]>;
25
- copyFile(from: PathLike, to: PathLike): Promise<void>;
26
- readFile(path: PathLike): Promise<string>;
27
- writeFile(path: PathLike, contents: string): Promise<void>;
28
- rm(path: PathLike): Promise<void>;
29
- private p;
30
- }
31
- export declare class ObjectFileSystemAdapter implements FileSystemAdapter {
32
- private fs;
33
- constructor(fs?: Record<string, string>);
34
- stat(path: PathLike): Promise<Stats>;
35
- readdir(path: PathLike): Promise<string[]>;
36
- copyFile(from: PathLike, to: PathLike): Promise<void>;
37
- readFile(path: PathLike): Promise<string>;
38
- writeFile(path: PathLike, contents: string): Promise<void>;
39
- rm(path: PathLike): Promise<void>;
40
- }
41
- export declare class LocalStorageFileSystemAdapter extends ObjectFileSystemAdapter {
42
- constructor();
43
- }
44
- export interface Tree {
45
- [k: string]: string | Tree;
46
- }
47
- export declare function reset(fs: FileSystem, tree: Tree): Promise<void>;
48
- export {};
1
+ export declare type PathLike = string;
2
+ export interface Stats {
3
+ isDirectory(): boolean;
4
+ isFile(): boolean;
5
+ }
6
+ interface FileSystemAdapter {
7
+ stat(path: PathLike): Promise<Stats>;
8
+ readdir(path: PathLike): Promise<string[]>;
9
+ copyFile(from: PathLike, to: PathLike): Promise<void>;
10
+ readFile(path: PathLike): Promise<string>;
11
+ writeFile(path: PathLike, contents: string): Promise<void>;
12
+ rm(path: PathLike): Promise<void>;
13
+ }
14
+ export declare class FileSystem implements FileSystemAdapter {
15
+ protected adapter: ObjectFileSystemAdapter;
16
+ protected wd: string;
17
+ protected stack: string[];
18
+ constructor(adapter?: ObjectFileSystemAdapter);
19
+ cwd(): string;
20
+ cd(dir: string): void;
21
+ pushd(dir: string): void;
22
+ popd(): void;
23
+ stat(path: PathLike): Promise<Stats>;
24
+ readdir(path: PathLike): Promise<string[]>;
25
+ copyFile(from: PathLike, to: PathLike): Promise<void>;
26
+ readFile(path: PathLike): Promise<string>;
27
+ writeFile(path: PathLike, contents: string): Promise<void>;
28
+ rm(path: PathLike): Promise<void>;
29
+ private p;
30
+ }
31
+ export declare class ObjectFileSystemAdapter implements FileSystemAdapter {
32
+ private fs;
33
+ constructor(fs?: Record<string, string>);
34
+ stat(path: PathLike): Promise<Stats>;
35
+ readdir(path: PathLike): Promise<string[]>;
36
+ copyFile(from: PathLike, to: PathLike): Promise<void>;
37
+ readFile(path: PathLike): Promise<string>;
38
+ writeFile(path: PathLike, contents: string): Promise<void>;
39
+ rm(path: PathLike): Promise<void>;
40
+ }
41
+ export declare class LocalStorageFileSystemAdapter extends ObjectFileSystemAdapter {
42
+ constructor();
43
+ }
44
+ export interface Tree {
45
+ [k: string]: string | Tree;
46
+ }
47
+ export declare function reset(fs: FileSystem, tree: Tree): Promise<void>;
48
+ export {};