sliftutils 0.7.0 → 0.7.1
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/builders/generateIndexDts.js +46 -0
- package/builders/setup.ts +8 -18
- package/builders/webRun.js +1 -1
- package/index.d.ts +332 -0
- package/package.json +10 -2
- package/render-utils/DropdownCustom.d.ts +23 -0
- package/render-utils/FullscreenModal.d.ts +12 -0
- package/render-utils/Input.d.ts +39 -0
- package/render-utils/InputLabel.d.ts +35 -0
- package/render-utils/InputPicker.d.ts +35 -0
- package/render-utils/LocalStorageParam.d.ts +12 -0
- package/render-utils/SyncedController.d.ts +38 -0
- package/render-utils/SyncedLoadingIndicator.d.ts +8 -0
- package/render-utils/Table.d.ts +32 -0
- package/render-utils/URLParam.d.ts +13 -0
- package/render-utils/asyncObservable.d.ts +3 -0
- package/render-utils/mobxTyped.d.ts +1 -0
- package/render-utils/modal.d.ts +6 -0
- package/render-utils/observer.d.ts +17 -0
- package/spec.txt +3 -34
- package/tsconfig.declarations.json +18 -0
- package/render-utils/browser.tsx +0 -31
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
function getAllDtsFiles(dir, fileList = []) {
|
|
5
|
+
const files = fs.readdirSync(dir);
|
|
6
|
+
|
|
7
|
+
for (const file of files) {
|
|
8
|
+
const filePath = path.join(dir, file);
|
|
9
|
+
const stat = fs.statSync(filePath);
|
|
10
|
+
|
|
11
|
+
if (stat.isDirectory()) {
|
|
12
|
+
getAllDtsFiles(filePath, fileList);
|
|
13
|
+
} else if (file.endsWith(".d.ts")) {
|
|
14
|
+
fileList.push(filePath);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return fileList;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function generateIndexDts() {
|
|
22
|
+
const renderUtilsPath = path.join(__dirname, "..", "render-utils");
|
|
23
|
+
const dtsFiles = getAllDtsFiles(renderUtilsPath);
|
|
24
|
+
|
|
25
|
+
const modules = dtsFiles
|
|
26
|
+
.map(filePath => {
|
|
27
|
+
const relativePath = path.relative(renderUtilsPath, filePath);
|
|
28
|
+
const withoutExt = relativePath.replace(/\.d\.ts$/, "");
|
|
29
|
+
const modulePath = "sliftutils/render-utils/" + withoutExt.replace(/\\/g, "/");
|
|
30
|
+
|
|
31
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
32
|
+
|
|
33
|
+
return `declare module "${modulePath}" {\n${content}\n}`;
|
|
34
|
+
})
|
|
35
|
+
.sort()
|
|
36
|
+
.join("\n\n");
|
|
37
|
+
|
|
38
|
+
const outputPath = path.join(__dirname, "..", "index.d.ts");
|
|
39
|
+
const header = `// Auto-generated file. Do not edit manually.\n// Generated by: yarn generate-index-dts\n\n`;
|
|
40
|
+
|
|
41
|
+
fs.writeFileSync(outputPath, header + modules + "\n", "utf8");
|
|
42
|
+
console.log(`Generated ${outputPath} with ${dtsFiles.length} module declarations`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
generateIndexDts();
|
|
46
|
+
|
package/builders/setup.ts
CHANGED
|
@@ -136,45 +136,35 @@ function updatePackageJson(packageJsonPath: string) {
|
|
|
136
136
|
packageJson.scripts = {};
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
// Add type script
|
|
139
|
+
// Add type script (copied from source)
|
|
140
140
|
if (!packageJson.scripts.type) {
|
|
141
141
|
packageJson.scripts.type = sourcePackageJson.scripts.type;
|
|
142
142
|
console.log(" Added 'type' script");
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
//
|
|
146
|
-
let
|
|
147
|
-
for (let cmd of
|
|
145
|
+
// Copy run commands from source (except run-web)
|
|
146
|
+
let copiedCommands = ["run-nodejs", "run-nodejs-dev", "run-electron"];
|
|
147
|
+
for (let cmd of copiedCommands) {
|
|
148
148
|
if (!packageJson.scripts[cmd]) {
|
|
149
149
|
packageJson.scripts[cmd] = sourcePackageJson.scripts[cmd];
|
|
150
150
|
console.log(` Added '${cmd}' script`);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
// Add
|
|
155
|
-
let
|
|
154
|
+
// Add hard-coded commands
|
|
155
|
+
let hardCodedCommands: { [key: string]: string } = {
|
|
156
|
+
"run-web": "node ./node_modules/sliftutils/builders/webRun.js",
|
|
156
157
|
"build-nodejs": "build-nodejs",
|
|
157
158
|
"build-web": "build-web",
|
|
158
159
|
"build-extension": "build-extension",
|
|
159
160
|
"build-electron": "build-electron",
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
for (let [scriptName, binName] of Object.entries(buildCommands)) {
|
|
163
|
-
if (!packageJson.scripts[scriptName]) {
|
|
164
|
-
packageJson.scripts[scriptName] = binName;
|
|
165
|
-
console.log(` Added '${scriptName}' script`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Add watch commands with ports
|
|
170
|
-
let watchCommands = {
|
|
171
161
|
"watch-nodejs": "slift-watch --port 9876 \"nodejs/*.ts\" \"nodejs/*.tsx\" \"yarn build-nodejs\"",
|
|
172
162
|
"watch-web": "slift-watch --port 9877 \"web/*.ts\" \"web/*.tsx\" \"yarn build-web\"",
|
|
173
163
|
"watch-extension": "slift-watch --port 9878 \"extension/*.ts\" \"extension/*.tsx\" \"yarn build-extension\"",
|
|
174
164
|
"watch-electron": "slift-watch --port 9879 \"electron/*.ts\" \"electron/*.tsx\" \"yarn build-electron\"",
|
|
175
165
|
};
|
|
176
166
|
|
|
177
|
-
for (let [scriptName, command] of Object.entries(
|
|
167
|
+
for (let [scriptName, command] of Object.entries(hardCodedCommands)) {
|
|
178
168
|
if (!packageJson.scripts[scriptName]) {
|
|
179
169
|
packageJson.scripts[scriptName] = command;
|
|
180
170
|
console.log(` Added '${scriptName}' script`);
|
package/builders/webRun.js
CHANGED
package/index.d.ts
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// Auto-generated file. Do not edit manually.
|
|
2
|
+
// Generated by: yarn generate-index-dts
|
|
3
|
+
|
|
4
|
+
declare module "sliftutils/render-utils/DropdownCustom" {
|
|
5
|
+
import preact from "preact";
|
|
6
|
+
import { LengthOrPercentage } from "typesafecss/cssTypes";
|
|
7
|
+
export declare class DropdownCustom<T> extends preact.Component<{
|
|
8
|
+
class?: string;
|
|
9
|
+
optionClass?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
value: T;
|
|
12
|
+
onChange: (value: T, index: number) => void;
|
|
13
|
+
maxWidth?: LengthOrPercentage;
|
|
14
|
+
options: {
|
|
15
|
+
value: T;
|
|
16
|
+
label: (isOpen: boolean) => preact.ComponentChild;
|
|
17
|
+
}[];
|
|
18
|
+
}> {
|
|
19
|
+
synced: {
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
tempIndexSelected: number | null;
|
|
22
|
+
};
|
|
23
|
+
onUnmount: (() => void)[];
|
|
24
|
+
componentDidMount(): void;
|
|
25
|
+
componentDidUnmount(): void;
|
|
26
|
+
render(): preact.JSX.Element;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module "sliftutils/render-utils/FullscreenModal" {
|
|
32
|
+
import preact from "preact";
|
|
33
|
+
export declare function showFullscreenModal(contents: preact.ComponentChildren): void;
|
|
34
|
+
export declare class FullscreenModal extends preact.Component<{
|
|
35
|
+
parentState?: {
|
|
36
|
+
open: boolean;
|
|
37
|
+
};
|
|
38
|
+
onCancel?: () => void;
|
|
39
|
+
style?: preact.JSX.CSSProperties;
|
|
40
|
+
outerStyle?: preact.JSX.CSSProperties;
|
|
41
|
+
}> {
|
|
42
|
+
render(): preact.JSX.Element;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare module "sliftutils/render-utils/Input" {
|
|
48
|
+
import preact from "preact";
|
|
49
|
+
export type InputProps = (preact.JSX.HTMLAttributes<HTMLInputElement> & {
|
|
50
|
+
/** ONLY throttles onChangeValue */
|
|
51
|
+
throttle?: number;
|
|
52
|
+
flavor?: "large" | "small" | "none";
|
|
53
|
+
focusOnMount?: boolean;
|
|
54
|
+
textarea?: boolean;
|
|
55
|
+
/** Update on key stroke, not on blur (just does onInput = onChange, as onInput already does this) */
|
|
56
|
+
hot?: boolean;
|
|
57
|
+
/** Updates arrow keys with modifier behavior to use larger numbers, instead of decimals. */
|
|
58
|
+
integer?: boolean;
|
|
59
|
+
/** Only works with number/integer */
|
|
60
|
+
reverseArrowKeyDirection?: boolean;
|
|
61
|
+
inputRef?: (x: HTMLInputElement | null) => void;
|
|
62
|
+
/** Don't blur on enter key */
|
|
63
|
+
noEnterKeyBlur?: boolean;
|
|
64
|
+
noFocusSelect?: boolean;
|
|
65
|
+
inputKey?: string;
|
|
66
|
+
fillWidth?: boolean;
|
|
67
|
+
autocompleteValues?: string[];
|
|
68
|
+
/** Forces the input to update when focused. Usually we hold updates, to prevent the user's
|
|
69
|
+
* typing to be interrupted by background updates.
|
|
70
|
+
* NOTE: "hot" is usually required when using this.
|
|
71
|
+
*/
|
|
72
|
+
forceInputValueUpdatesWhenFocused?: boolean;
|
|
73
|
+
onChangeValue?: (value: string) => void;
|
|
74
|
+
});
|
|
75
|
+
export declare class Input extends preact.Component<InputProps> {
|
|
76
|
+
onFocusText: string;
|
|
77
|
+
firstFocus: boolean;
|
|
78
|
+
elem: HTMLInputElement | null;
|
|
79
|
+
lastValue: unknown;
|
|
80
|
+
lastChecked: unknown;
|
|
81
|
+
onChangeThrottle: undefined | {
|
|
82
|
+
throttle: number;
|
|
83
|
+
run: (newValue: string) => void;
|
|
84
|
+
};
|
|
85
|
+
render(): preact.JSX.Element;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare module "sliftutils/render-utils/InputLabel" {
|
|
91
|
+
import preact from "preact";
|
|
92
|
+
import { InputProps } from "./Input";
|
|
93
|
+
import { URLParamStr } from "./URLParam";
|
|
94
|
+
export type InputLabelProps = Omit<InputProps, "label" | "title"> & {
|
|
95
|
+
label?: preact.ComponentChild;
|
|
96
|
+
number?: boolean;
|
|
97
|
+
/** A number, AND, an integer. Changes behavior arrow arrow keys as well */
|
|
98
|
+
integer?: boolean;
|
|
99
|
+
checkbox?: boolean;
|
|
100
|
+
edit?: boolean;
|
|
101
|
+
alwaysShowPencil?: boolean;
|
|
102
|
+
outerClass?: string;
|
|
103
|
+
maxDecimals?: number;
|
|
104
|
+
percent?: boolean;
|
|
105
|
+
editClass?: string;
|
|
106
|
+
fontSize?: number;
|
|
107
|
+
tooltip?: string;
|
|
108
|
+
fillWidth?: boolean;
|
|
109
|
+
useDateUI?: boolean;
|
|
110
|
+
};
|
|
111
|
+
export declare const startGuessDateRange: number;
|
|
112
|
+
export declare const endGuessDateRange: number;
|
|
113
|
+
export declare class InputLabel extends preact.Component<InputLabelProps> {
|
|
114
|
+
synced: {
|
|
115
|
+
editting: boolean;
|
|
116
|
+
editInputValue: string;
|
|
117
|
+
editUpdateSeqNum: number;
|
|
118
|
+
};
|
|
119
|
+
render(): preact.JSX.Element;
|
|
120
|
+
}
|
|
121
|
+
export declare class InputLabelURL extends preact.Component<InputLabelProps & {
|
|
122
|
+
persisted: URLParamStr;
|
|
123
|
+
}> {
|
|
124
|
+
render(): preact.JSX.Element;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare module "sliftutils/render-utils/InputPicker" {
|
|
130
|
+
import preact from "preact";
|
|
131
|
+
export type InputOption<T> = {
|
|
132
|
+
value: T;
|
|
133
|
+
label?: preact.ComponentChild;
|
|
134
|
+
matchText?: string;
|
|
135
|
+
};
|
|
136
|
+
export type FullInputOption<T> = {
|
|
137
|
+
value: T;
|
|
138
|
+
label: preact.ComponentChild;
|
|
139
|
+
matchText: string;
|
|
140
|
+
};
|
|
141
|
+
export declare class InputPickerURL extends preact.Component<{
|
|
142
|
+
label?: preact.ComponentChild;
|
|
143
|
+
options: (string | InputOption<string>)[];
|
|
144
|
+
allowNonOptions?: boolean;
|
|
145
|
+
value: {
|
|
146
|
+
value: string;
|
|
147
|
+
};
|
|
148
|
+
}> {
|
|
149
|
+
render(): preact.JSX.Element;
|
|
150
|
+
}
|
|
151
|
+
export declare class InputPicker<T> extends preact.Component<{
|
|
152
|
+
label?: preact.ComponentChild;
|
|
153
|
+
picked: T[];
|
|
154
|
+
options: InputOption<T>[];
|
|
155
|
+
addPicked: (value: T) => void;
|
|
156
|
+
removePicked: (value: T) => void;
|
|
157
|
+
allowNonOptions?: boolean;
|
|
158
|
+
}> {
|
|
159
|
+
synced: {
|
|
160
|
+
pendingText: string;
|
|
161
|
+
focused: boolean;
|
|
162
|
+
};
|
|
163
|
+
render(): preact.JSX.Element;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare module "sliftutils/render-utils/LocalStorageParam" {
|
|
169
|
+
export declare class LocalStorageParamStr {
|
|
170
|
+
readonly storageKey: string;
|
|
171
|
+
private defaultValue;
|
|
172
|
+
private state;
|
|
173
|
+
lastSetValue: string;
|
|
174
|
+
constructor(storageKey: string, defaultValue?: string);
|
|
175
|
+
forceUpdate(): void;
|
|
176
|
+
get(): string;
|
|
177
|
+
set(value: string): void;
|
|
178
|
+
get value(): string;
|
|
179
|
+
set value(value: string);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare module "sliftutils/render-utils/SyncedController" {
|
|
185
|
+
import { SocketRegistered } from "socket-function/SocketFunctionTypes";
|
|
186
|
+
type RemapFunction<T> = T extends (...args: infer Args) => Promise<infer Return> ? {
|
|
187
|
+
(...args: Args): Return | undefined;
|
|
188
|
+
promise(...args: Args): Promise<Return>;
|
|
189
|
+
refresh(...args: Args): void;
|
|
190
|
+
refreshAll(): void;
|
|
191
|
+
reset(...args: Args): void;
|
|
192
|
+
resetAll(): void;
|
|
193
|
+
isLoading(...args: Args): boolean;
|
|
194
|
+
setCache(cache: {
|
|
195
|
+
args: Args;
|
|
196
|
+
result: Return;
|
|
197
|
+
}): void;
|
|
198
|
+
} : T;
|
|
199
|
+
export declare function getSyncedController<T extends SocketRegistered>(controller: T, config?: {
|
|
200
|
+
/** When a controller call for a write finishes, we refresh all readers.
|
|
201
|
+
* - Invalidation is global, across all controllers.
|
|
202
|
+
*/
|
|
203
|
+
reads?: {
|
|
204
|
+
[key in keyof T["nodes"][""]]?: string[];
|
|
205
|
+
};
|
|
206
|
+
writes?: {
|
|
207
|
+
[key in keyof T["nodes"][""]]?: string[];
|
|
208
|
+
};
|
|
209
|
+
}): {
|
|
210
|
+
(nodeId: string): {
|
|
211
|
+
[fnc in keyof T["nodes"][""]]: RemapFunction<T["nodes"][""][fnc]>;
|
|
212
|
+
} & {
|
|
213
|
+
resetAll(): void;
|
|
214
|
+
refreshAll(): void;
|
|
215
|
+
anyPending(): boolean;
|
|
216
|
+
};
|
|
217
|
+
resetAll(): void;
|
|
218
|
+
refreshAll(): void;
|
|
219
|
+
anyPending(): boolean;
|
|
220
|
+
rerenderAll(): void;
|
|
221
|
+
};
|
|
222
|
+
export {};
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare module "sliftutils/render-utils/SyncedLoadingIndicator" {
|
|
227
|
+
import * as preact from "preact";
|
|
228
|
+
export declare class SyncedLoadingIndicator extends preact.Component<{
|
|
229
|
+
controller: {
|
|
230
|
+
anyPending: () => boolean;
|
|
231
|
+
};
|
|
232
|
+
}> {
|
|
233
|
+
render(): preact.JSX.Element | null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
declare module "sliftutils/render-utils/Table" {
|
|
239
|
+
import preact from "preact";
|
|
240
|
+
import { JSXFormatter } from "./GenericFormat";
|
|
241
|
+
export type ColumnType<T = unknown, Row extends RowType = RowType> = undefined | null | {
|
|
242
|
+
center?: boolean;
|
|
243
|
+
title?: preact.ComponentChild;
|
|
244
|
+
formatter?: JSXFormatter<T, Row>;
|
|
245
|
+
};
|
|
246
|
+
export type RowType = {
|
|
247
|
+
[columnName: string]: unknown;
|
|
248
|
+
};
|
|
249
|
+
export type ColumnsType = {
|
|
250
|
+
[columnName: string]: ColumnType;
|
|
251
|
+
};
|
|
252
|
+
export type TableType<RowT extends RowType = RowType> = {
|
|
253
|
+
columns: {
|
|
254
|
+
[columnName in keyof RowT]?: ColumnType<RowT[columnName], RowT>;
|
|
255
|
+
};
|
|
256
|
+
rows: RowT[];
|
|
257
|
+
};
|
|
258
|
+
export declare class Table<RowT extends RowType> extends preact.Component<TableType<RowT> & {
|
|
259
|
+
class?: string;
|
|
260
|
+
cellClass?: string;
|
|
261
|
+
initialLimit?: number;
|
|
262
|
+
lineLimit?: number;
|
|
263
|
+
characterLimit?: number;
|
|
264
|
+
excludeEmptyColumns?: boolean;
|
|
265
|
+
}> {
|
|
266
|
+
state: {
|
|
267
|
+
limit: number;
|
|
268
|
+
};
|
|
269
|
+
render(): preact.JSX.Element;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare module "sliftutils/render-utils/URLParam" {
|
|
275
|
+
export declare class URLParamStr {
|
|
276
|
+
readonly urlKey: string;
|
|
277
|
+
private state;
|
|
278
|
+
lastSetValue: string;
|
|
279
|
+
constructor(urlKey: string);
|
|
280
|
+
forceUpdate(): void;
|
|
281
|
+
get(): string;
|
|
282
|
+
set(value: string): void;
|
|
283
|
+
get value(): string;
|
|
284
|
+
set value(value: string);
|
|
285
|
+
}
|
|
286
|
+
export declare function batchUrlUpdate<T>(code: () => T): T;
|
|
287
|
+
export declare function createLink(params: [URLParamStr, string][]): string;
|
|
288
|
+
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
declare module "sliftutils/render-utils/asyncObservable" {
|
|
292
|
+
export declare function asyncCache<Args, T>(getValue: (args: Args) => Promise<T>): {
|
|
293
|
+
(args: Args): T | undefined;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
declare module "sliftutils/render-utils/mobxTyped" {
|
|
299
|
+
export declare function configureMobxNextFrameScheduler(): void;
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
declare module "sliftutils/render-utils/modal" {
|
|
304
|
+
import preact from "preact";
|
|
305
|
+
export declare function showModal(config: {
|
|
306
|
+
contents: preact.ComponentChildren;
|
|
307
|
+
}): {
|
|
308
|
+
close: () => void;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
declare module "sliftutils/render-utils/observer" {
|
|
314
|
+
import * as preact from "preact";
|
|
315
|
+
import { Reaction } from "mobx";
|
|
316
|
+
export declare function observer<T extends {
|
|
317
|
+
new (...args: any[]): {
|
|
318
|
+
render(): preact.ComponentChild;
|
|
319
|
+
forceUpdate(callback?: () => void): void;
|
|
320
|
+
componentWillUnmount?(): void;
|
|
321
|
+
};
|
|
322
|
+
}>(Constructor: T): {
|
|
323
|
+
new (...args: any[]): {
|
|
324
|
+
reaction: Reaction;
|
|
325
|
+
componentWillUnmount(): void;
|
|
326
|
+
render(...args: any[]): preact.ComponentChild;
|
|
327
|
+
forceUpdate(callback?: () => void): void;
|
|
328
|
+
};
|
|
329
|
+
readonly name: string;
|
|
330
|
+
} & T;
|
|
331
|
+
|
|
332
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sliftutils",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"type": "yarn tsc --noEmit",
|
|
8
|
+
"emit-dts": "yarn tsc --project tsconfig.declarations.json",
|
|
9
|
+
"generate-index-dts": "node ./builders/generateIndexDts.js",
|
|
8
10
|
"run-nodejs": "node ./build-nodejs/server.js",
|
|
9
11
|
"run-nodejs-dev": "typenode ./nodejs/server.ts",
|
|
10
12
|
"run-web": "node ./builders/webRun.js",
|
|
@@ -21,11 +23,17 @@
|
|
|
21
23
|
},
|
|
22
24
|
"bin": {
|
|
23
25
|
"build-nodejs": "./builders/nodeJSBuildRun.js",
|
|
26
|
+
"buildnodejs": "./builders/nodeJSBuildRun.js",
|
|
24
27
|
"build-extension": "./builders/extensionBuildRun.js",
|
|
28
|
+
"buildextension": "./builders/extensionBuildRun.js",
|
|
25
29
|
"build-web": "./builders/webBuildRun.js",
|
|
30
|
+
"buildweb": "./builders/webBuildRun.js",
|
|
26
31
|
"build-electron": "./builders/electronBuildRun.js",
|
|
32
|
+
"buildelectron": "./builders/electronBuildRun.js",
|
|
27
33
|
"slift-watch": "./builders/watchRun.js",
|
|
28
|
-
"
|
|
34
|
+
"sliftwatch": "./builders/watchRun.js",
|
|
35
|
+
"slift-setup": "./builders/setupRun.js",
|
|
36
|
+
"sliftsetup": "./builders/setupRun.js"
|
|
29
37
|
},
|
|
30
38
|
"dependencies": {
|
|
31
39
|
"@types/shell-quote": "^1.7.5",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import preact from "preact";
|
|
2
|
+
import { LengthOrPercentage } from "typesafecss/cssTypes";
|
|
3
|
+
export declare class DropdownCustom<T> extends preact.Component<{
|
|
4
|
+
class?: string;
|
|
5
|
+
optionClass?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
value: T;
|
|
8
|
+
onChange: (value: T, index: number) => void;
|
|
9
|
+
maxWidth?: LengthOrPercentage;
|
|
10
|
+
options: {
|
|
11
|
+
value: T;
|
|
12
|
+
label: (isOpen: boolean) => preact.ComponentChild;
|
|
13
|
+
}[];
|
|
14
|
+
}> {
|
|
15
|
+
synced: {
|
|
16
|
+
isOpen: boolean;
|
|
17
|
+
tempIndexSelected: number | null;
|
|
18
|
+
};
|
|
19
|
+
onUnmount: (() => void)[];
|
|
20
|
+
componentDidMount(): void;
|
|
21
|
+
componentDidUnmount(): void;
|
|
22
|
+
render(): preact.JSX.Element;
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import preact from "preact";
|
|
2
|
+
export declare function showFullscreenModal(contents: preact.ComponentChildren): void;
|
|
3
|
+
export declare class FullscreenModal extends preact.Component<{
|
|
4
|
+
parentState?: {
|
|
5
|
+
open: boolean;
|
|
6
|
+
};
|
|
7
|
+
onCancel?: () => void;
|
|
8
|
+
style?: preact.JSX.CSSProperties;
|
|
9
|
+
outerStyle?: preact.JSX.CSSProperties;
|
|
10
|
+
}> {
|
|
11
|
+
render(): preact.JSX.Element;
|
|
12
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import preact from "preact";
|
|
2
|
+
export type InputProps = (preact.JSX.HTMLAttributes<HTMLInputElement> & {
|
|
3
|
+
/** ONLY throttles onChangeValue */
|
|
4
|
+
throttle?: number;
|
|
5
|
+
flavor?: "large" | "small" | "none";
|
|
6
|
+
focusOnMount?: boolean;
|
|
7
|
+
textarea?: boolean;
|
|
8
|
+
/** Update on key stroke, not on blur (just does onInput = onChange, as onInput already does this) */
|
|
9
|
+
hot?: boolean;
|
|
10
|
+
/** Updates arrow keys with modifier behavior to use larger numbers, instead of decimals. */
|
|
11
|
+
integer?: boolean;
|
|
12
|
+
/** Only works with number/integer */
|
|
13
|
+
reverseArrowKeyDirection?: boolean;
|
|
14
|
+
inputRef?: (x: HTMLInputElement | null) => void;
|
|
15
|
+
/** Don't blur on enter key */
|
|
16
|
+
noEnterKeyBlur?: boolean;
|
|
17
|
+
noFocusSelect?: boolean;
|
|
18
|
+
inputKey?: string;
|
|
19
|
+
fillWidth?: boolean;
|
|
20
|
+
autocompleteValues?: string[];
|
|
21
|
+
/** Forces the input to update when focused. Usually we hold updates, to prevent the user's
|
|
22
|
+
* typing to be interrupted by background updates.
|
|
23
|
+
* NOTE: "hot" is usually required when using this.
|
|
24
|
+
*/
|
|
25
|
+
forceInputValueUpdatesWhenFocused?: boolean;
|
|
26
|
+
onChangeValue?: (value: string) => void;
|
|
27
|
+
});
|
|
28
|
+
export declare class Input extends preact.Component<InputProps> {
|
|
29
|
+
onFocusText: string;
|
|
30
|
+
firstFocus: boolean;
|
|
31
|
+
elem: HTMLInputElement | null;
|
|
32
|
+
lastValue: unknown;
|
|
33
|
+
lastChecked: unknown;
|
|
34
|
+
onChangeThrottle: undefined | {
|
|
35
|
+
throttle: number;
|
|
36
|
+
run: (newValue: string) => void;
|
|
37
|
+
};
|
|
38
|
+
render(): preact.JSX.Element;
|
|
39
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import preact from "preact";
|
|
2
|
+
import { InputProps } from "./Input";
|
|
3
|
+
import { URLParamStr } from "./URLParam";
|
|
4
|
+
export type InputLabelProps = Omit<InputProps, "label" | "title"> & {
|
|
5
|
+
label?: preact.ComponentChild;
|
|
6
|
+
number?: boolean;
|
|
7
|
+
/** A number, AND, an integer. Changes behavior arrow arrow keys as well */
|
|
8
|
+
integer?: boolean;
|
|
9
|
+
checkbox?: boolean;
|
|
10
|
+
edit?: boolean;
|
|
11
|
+
alwaysShowPencil?: boolean;
|
|
12
|
+
outerClass?: string;
|
|
13
|
+
maxDecimals?: number;
|
|
14
|
+
percent?: boolean;
|
|
15
|
+
editClass?: string;
|
|
16
|
+
fontSize?: number;
|
|
17
|
+
tooltip?: string;
|
|
18
|
+
fillWidth?: boolean;
|
|
19
|
+
useDateUI?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare const startGuessDateRange: number;
|
|
22
|
+
export declare const endGuessDateRange: number;
|
|
23
|
+
export declare class InputLabel extends preact.Component<InputLabelProps> {
|
|
24
|
+
synced: {
|
|
25
|
+
editting: boolean;
|
|
26
|
+
editInputValue: string;
|
|
27
|
+
editUpdateSeqNum: number;
|
|
28
|
+
};
|
|
29
|
+
render(): preact.JSX.Element;
|
|
30
|
+
}
|
|
31
|
+
export declare class InputLabelURL extends preact.Component<InputLabelProps & {
|
|
32
|
+
persisted: URLParamStr;
|
|
33
|
+
}> {
|
|
34
|
+
render(): preact.JSX.Element;
|
|
35
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import preact from "preact";
|
|
2
|
+
export type InputOption<T> = {
|
|
3
|
+
value: T;
|
|
4
|
+
label?: preact.ComponentChild;
|
|
5
|
+
matchText?: string;
|
|
6
|
+
};
|
|
7
|
+
export type FullInputOption<T> = {
|
|
8
|
+
value: T;
|
|
9
|
+
label: preact.ComponentChild;
|
|
10
|
+
matchText: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class InputPickerURL extends preact.Component<{
|
|
13
|
+
label?: preact.ComponentChild;
|
|
14
|
+
options: (string | InputOption<string>)[];
|
|
15
|
+
allowNonOptions?: boolean;
|
|
16
|
+
value: {
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
}> {
|
|
20
|
+
render(): preact.JSX.Element;
|
|
21
|
+
}
|
|
22
|
+
export declare class InputPicker<T> extends preact.Component<{
|
|
23
|
+
label?: preact.ComponentChild;
|
|
24
|
+
picked: T[];
|
|
25
|
+
options: InputOption<T>[];
|
|
26
|
+
addPicked: (value: T) => void;
|
|
27
|
+
removePicked: (value: T) => void;
|
|
28
|
+
allowNonOptions?: boolean;
|
|
29
|
+
}> {
|
|
30
|
+
synced: {
|
|
31
|
+
pendingText: string;
|
|
32
|
+
focused: boolean;
|
|
33
|
+
};
|
|
34
|
+
render(): preact.JSX.Element;
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class LocalStorageParamStr {
|
|
2
|
+
readonly storageKey: string;
|
|
3
|
+
private defaultValue;
|
|
4
|
+
private state;
|
|
5
|
+
lastSetValue: string;
|
|
6
|
+
constructor(storageKey: string, defaultValue?: string);
|
|
7
|
+
forceUpdate(): void;
|
|
8
|
+
get(): string;
|
|
9
|
+
set(value: string): void;
|
|
10
|
+
get value(): string;
|
|
11
|
+
set value(value: string);
|
|
12
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SocketRegistered } from "socket-function/SocketFunctionTypes";
|
|
2
|
+
type RemapFunction<T> = T extends (...args: infer Args) => Promise<infer Return> ? {
|
|
3
|
+
(...args: Args): Return | undefined;
|
|
4
|
+
promise(...args: Args): Promise<Return>;
|
|
5
|
+
refresh(...args: Args): void;
|
|
6
|
+
refreshAll(): void;
|
|
7
|
+
reset(...args: Args): void;
|
|
8
|
+
resetAll(): void;
|
|
9
|
+
isLoading(...args: Args): boolean;
|
|
10
|
+
setCache(cache: {
|
|
11
|
+
args: Args;
|
|
12
|
+
result: Return;
|
|
13
|
+
}): void;
|
|
14
|
+
} : T;
|
|
15
|
+
export declare function getSyncedController<T extends SocketRegistered>(controller: T, config?: {
|
|
16
|
+
/** When a controller call for a write finishes, we refresh all readers.
|
|
17
|
+
* - Invalidation is global, across all controllers.
|
|
18
|
+
*/
|
|
19
|
+
reads?: {
|
|
20
|
+
[key in keyof T["nodes"][""]]?: string[];
|
|
21
|
+
};
|
|
22
|
+
writes?: {
|
|
23
|
+
[key in keyof T["nodes"][""]]?: string[];
|
|
24
|
+
};
|
|
25
|
+
}): {
|
|
26
|
+
(nodeId: string): {
|
|
27
|
+
[fnc in keyof T["nodes"][""]]: RemapFunction<T["nodes"][""][fnc]>;
|
|
28
|
+
} & {
|
|
29
|
+
resetAll(): void;
|
|
30
|
+
refreshAll(): void;
|
|
31
|
+
anyPending(): boolean;
|
|
32
|
+
};
|
|
33
|
+
resetAll(): void;
|
|
34
|
+
refreshAll(): void;
|
|
35
|
+
anyPending(): boolean;
|
|
36
|
+
rerenderAll(): void;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import preact from "preact";
|
|
2
|
+
import { JSXFormatter } from "./GenericFormat";
|
|
3
|
+
export type ColumnType<T = unknown, Row extends RowType = RowType> = undefined | null | {
|
|
4
|
+
center?: boolean;
|
|
5
|
+
title?: preact.ComponentChild;
|
|
6
|
+
formatter?: JSXFormatter<T, Row>;
|
|
7
|
+
};
|
|
8
|
+
export type RowType = {
|
|
9
|
+
[columnName: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type ColumnsType = {
|
|
12
|
+
[columnName: string]: ColumnType;
|
|
13
|
+
};
|
|
14
|
+
export type TableType<RowT extends RowType = RowType> = {
|
|
15
|
+
columns: {
|
|
16
|
+
[columnName in keyof RowT]?: ColumnType<RowT[columnName], RowT>;
|
|
17
|
+
};
|
|
18
|
+
rows: RowT[];
|
|
19
|
+
};
|
|
20
|
+
export declare class Table<RowT extends RowType> extends preact.Component<TableType<RowT> & {
|
|
21
|
+
class?: string;
|
|
22
|
+
cellClass?: string;
|
|
23
|
+
initialLimit?: number;
|
|
24
|
+
lineLimit?: number;
|
|
25
|
+
characterLimit?: number;
|
|
26
|
+
excludeEmptyColumns?: boolean;
|
|
27
|
+
}> {
|
|
28
|
+
state: {
|
|
29
|
+
limit: number;
|
|
30
|
+
};
|
|
31
|
+
render(): preact.JSX.Element;
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class URLParamStr {
|
|
2
|
+
readonly urlKey: string;
|
|
3
|
+
private state;
|
|
4
|
+
lastSetValue: string;
|
|
5
|
+
constructor(urlKey: string);
|
|
6
|
+
forceUpdate(): void;
|
|
7
|
+
get(): string;
|
|
8
|
+
set(value: string): void;
|
|
9
|
+
get value(): string;
|
|
10
|
+
set value(value: string);
|
|
11
|
+
}
|
|
12
|
+
export declare function batchUrlUpdate<T>(code: () => T): T;
|
|
13
|
+
export declare function createLink(params: [URLParamStr, string][]): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function configureMobxNextFrameScheduler(): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as preact from "preact";
|
|
2
|
+
import { Reaction } from "mobx";
|
|
3
|
+
export declare function observer<T extends {
|
|
4
|
+
new (...args: any[]): {
|
|
5
|
+
render(): preact.ComponentChild;
|
|
6
|
+
forceUpdate(callback?: () => void): void;
|
|
7
|
+
componentWillUnmount?(): void;
|
|
8
|
+
};
|
|
9
|
+
}>(Constructor: T): {
|
|
10
|
+
new (...args: any[]): {
|
|
11
|
+
reaction: Reaction;
|
|
12
|
+
componentWillUnmount(): void;
|
|
13
|
+
render(...args: any[]): preact.ComponentChild;
|
|
14
|
+
forceUpdate(callback?: () => void): void;
|
|
15
|
+
};
|
|
16
|
+
readonly name: string;
|
|
17
|
+
} & T;
|
package/spec.txt
CHANGED
|
@@ -1,38 +1,7 @@
|
|
|
1
|
+
Okay Omit our typings, and then I guess we have to merge them all into one file. Although, if they reference each other, that's going to be difficult.
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- HELPER bin to setup the project with:
|
|
6
|
-
(Only if the files don't exist)
|
|
7
|
-
tsconfig.json
|
|
8
|
-
.gitignore
|
|
9
|
-
.vscode (for format on save)
|
|
10
|
-
.eslintrc.js
|
|
11
|
-
.cursorrules
|
|
12
|
-
Add dependencies to package.json
|
|
13
|
-
(Any dependencies our helper project has should be dev dependencies)
|
|
14
|
-
- typenode
|
|
15
|
-
- socket-function
|
|
16
|
-
- typesafecss
|
|
17
|
-
- typedev
|
|
18
|
-
add the basic entry points for Node.js, the browser, the browser HTML file, and even some files for a Chrome extension, and even for an Electron app.
|
|
19
|
-
- We'll make Electron optional though, and so they'll have to manually install Electron if they want to make an Electron app. We can check for this and warn if they try to build electron without having electron installed.
|
|
20
|
-
Add build and type commands to package.json
|
|
21
|
-
- We have the binaries for the build commands, but adding them to packs.json makes it a lot more discoverable.
|
|
22
|
-
- And it's just very good practice to add the type command to package.json. That way you could just say, what does this command do to the AI? and it'll tell you exactly what it does, instead of nesting
|
|
23
|
-
|
|
24
|
-
EXPOSE our helpers in our main export, in an index.ts file?
|
|
25
|
-
- Will this let us just import them? Hmm...
|
|
26
|
-
5) Test it in a new test repo
|
|
27
|
-
- Test it with:
|
|
28
|
-
single html browser site
|
|
29
|
-
nodejs bundled running
|
|
30
|
-
electron
|
|
31
|
-
chrome extension
|
|
32
|
-
- Make sure sourcemaps are preserved and work
|
|
33
|
-
5.1) Use the new project and bundler in voice-cloner
|
|
34
|
-
|
|
35
|
-
|
|
3
|
+
Fix our typings.
|
|
4
|
+
ALSO, go fix our typings in socket-function as well
|
|
36
5
|
|
|
37
6
|
TODO:
|
|
38
7
|
- vscode extension as well
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"emitDeclarationOnly": true,
|
|
6
|
+
"outDir": "./render-utils",
|
|
7
|
+
"rootDir": "./render-utils"
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"render-utils/**/*.ts",
|
|
11
|
+
"render-utils/**/*.tsx"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"node_modules",
|
|
15
|
+
"*_venv"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
package/render-utils/browser.tsx
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as preact from "preact";
|
|
2
|
-
import { observable } from "mobx";
|
|
3
|
-
import { observer } from "./observer";
|
|
4
|
-
import { isNode } from "typesafecss";
|
|
5
|
-
|
|
6
|
-
@observer
|
|
7
|
-
class App extends preact.Component {
|
|
8
|
-
synced = observable({
|
|
9
|
-
count: 0,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
render() {
|
|
13
|
-
return (
|
|
14
|
-
<div>
|
|
15
|
-
<h1>Hello from Web!</h1>
|
|
16
|
-
<p>Count: {this.synced.count}</p>
|
|
17
|
-
<button onClick={() => this.synced.count++}>
|
|
18
|
-
Increment
|
|
19
|
-
</button>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function main() {
|
|
26
|
-
if (isNode()) return;
|
|
27
|
-
preact.render(<App />, document.getElementById("app")!);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
main().catch(console.error);
|
|
31
|
-
|