akanjs 3.0.0-alpha.106 → 3.0.0-alpha.107
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/constant/types.ts +6 -2
- package/local/apps/serverLifecycle/serverLifecycle-local.db-shm +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-shm +0 -0
- package/package.json +1 -1
- package/store/action.ts +15 -12
- package/types/constant/types.d.ts +5 -2
- package/types/store/action.d.ts +2 -2
- package/types/ui/CsrImage.d.ts +2 -2
- package/types/ui/Image.d.ts +3 -3
- package/ui/CsrImage.tsx +2 -2
- package/ui/Image.tsx +3 -3
package/constant/types.ts
CHANGED
|
@@ -63,18 +63,22 @@ export class BaseInsight {
|
|
|
63
63
|
declare count: number;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export interface
|
|
66
|
+
export interface ProtoLightFile {
|
|
67
67
|
id: string;
|
|
68
68
|
filename: string;
|
|
69
69
|
abstractData: string | null;
|
|
70
70
|
imageSize: [number, number];
|
|
71
|
-
progress
|
|
71
|
+
progress?: number | null;
|
|
72
72
|
url: string;
|
|
73
73
|
size: number;
|
|
74
74
|
status: string;
|
|
75
75
|
createdAt: Dayjs;
|
|
76
76
|
updatedAt: Dayjs;
|
|
77
77
|
removedAt: Dayjs | null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ProtoFile extends ProtoLightFile {
|
|
81
|
+
progress: number | null;
|
|
78
82
|
mimetype: string;
|
|
79
83
|
encoding: string;
|
|
80
84
|
origin: string | null;
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/store/action.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type FieldState,
|
|
19
19
|
immerify,
|
|
20
20
|
type ProtoFile,
|
|
21
|
+
type ProtoLightFile,
|
|
21
22
|
withSharedInstances,
|
|
22
23
|
} from "akanjs/constant";
|
|
23
24
|
import type { BaseFilterSortKey, ExtractSort, FilterInstance } from "akanjs/document";
|
|
@@ -241,7 +242,7 @@ type FormSetter<
|
|
|
241
242
|
ArrayFieldAddSetters<RefName, _CapitalizedRefName, _DefaultState> &
|
|
242
243
|
ArrayFieldSubSetters<RefName, _CapitalizedRefName, _DefaultState> &
|
|
243
244
|
ArrayFieldAddOrSubSetters<RefName, _CapitalizedRefName, _DefaultState> & {
|
|
244
|
-
[K in keyof _DefaultState as _DefaultState[K] extends (
|
|
245
|
+
[K in keyof _DefaultState as _DefaultState[K] extends (ProtoLightFile | null) | ProtoLightFile[]
|
|
245
246
|
? K extends string
|
|
246
247
|
? SetterKey<"upload", K, RefName, _CapitalizedRefName>
|
|
247
248
|
: never
|
|
@@ -412,19 +413,23 @@ export const makeFormSetter = (refName: string, fetch: FetchProxy<any>) => {
|
|
|
412
413
|
form.id,
|
|
413
414
|
);
|
|
414
415
|
if (field.isArray) {
|
|
415
|
-
const idx = index ?? (form[namesOfField.field] as
|
|
416
|
-
this.set((state: { [key: string]: { [key: string]:
|
|
416
|
+
const idx = index ?? (form[namesOfField.field] as ProtoLightFile[]).length;
|
|
417
|
+
this.set((state: { [key: string]: { [key: string]: ProtoLightFile[] } }) => {
|
|
417
418
|
state[names.modelForm][namesOfField.field] = [
|
|
418
|
-
...(form[namesOfField.field] as
|
|
419
|
+
...(form[namesOfField.field] as ProtoLightFile[]).slice(0, idx),
|
|
419
420
|
...files,
|
|
420
|
-
...(form[namesOfField.field] as
|
|
421
|
+
...(form[namesOfField.field] as ProtoLightFile[]).slice(idx),
|
|
421
422
|
];
|
|
422
423
|
});
|
|
423
424
|
} else {
|
|
424
|
-
this.set((state: { [key: string]: { [key: string]:
|
|
425
|
+
this.set((state: { [key: string]: { [key: string]: ProtoLightFile | null } }) => {
|
|
425
426
|
state[names.modelForm][namesOfField.field] = files[0];
|
|
426
427
|
});
|
|
427
428
|
}
|
|
429
|
+
|
|
430
|
+
const fileReadName = ConstantRegistry.isLight(field.modelRef)
|
|
431
|
+
? `light${capitalize(fileUploadRefName)}`
|
|
432
|
+
: fileUploadRefName;
|
|
428
433
|
files.forEach((file) => {
|
|
429
434
|
let attemptsLeft = UPLOAD_POLL_ATTEMPTS;
|
|
430
435
|
const intervalKey = setInterval(() => {
|
|
@@ -433,25 +438,23 @@ export const makeFormSetter = (refName: string, fetch: FetchProxy<any>) => {
|
|
|
433
438
|
attemptsLeft -= 1;
|
|
434
439
|
try {
|
|
435
440
|
const currentFile = await (
|
|
436
|
-
(fetch as { [key: string]: any })[
|
|
437
|
-
id: string,
|
|
438
|
-
) => Promise<ProtoFile>
|
|
441
|
+
(fetch as { [key: string]: any })[fileReadName] as (id: string) => Promise<ProtoLightFile>
|
|
439
442
|
)(file.id);
|
|
440
443
|
if (field.isArray)
|
|
441
|
-
this.set((state: { [key: string]: { [key: string]:
|
|
444
|
+
this.set((state: { [key: string]: { [key: string]: ProtoLightFile[] } }) => {
|
|
442
445
|
state[names.modelForm][namesOfField.field] = state[names.modelForm][namesOfField.field].map(
|
|
443
446
|
(file) => (file.id === currentFile.id ? currentFile : file),
|
|
444
447
|
);
|
|
445
448
|
});
|
|
446
449
|
else
|
|
447
|
-
this.set((state: { [key: string]: { [key: string]:
|
|
450
|
+
this.set((state: { [key: string]: { [key: string]: ProtoLightFile | null } }) => {
|
|
448
451
|
state[names.modelForm][namesOfField.field] = currentFile;
|
|
449
452
|
});
|
|
450
453
|
if (currentFile.status !== "uploading" || attemptsLeft <= 0) clearInterval(intervalKey);
|
|
451
454
|
} catch (error) {
|
|
452
455
|
clearInterval(intervalKey);
|
|
453
456
|
Logger.warn(
|
|
454
|
-
`Upload poll for ${
|
|
457
|
+
`Upload poll for ${fileReadName} ${file.id} stopped: ${
|
|
455
458
|
error instanceof Error ? error.message : String(error)
|
|
456
459
|
}`,
|
|
457
460
|
);
|
|
@@ -29,18 +29,21 @@ export declare class BaseObject {
|
|
|
29
29
|
export declare class BaseInsight {
|
|
30
30
|
count: number;
|
|
31
31
|
}
|
|
32
|
-
export interface
|
|
32
|
+
export interface ProtoLightFile {
|
|
33
33
|
id: string;
|
|
34
34
|
filename: string;
|
|
35
35
|
abstractData: string | null;
|
|
36
36
|
imageSize: [number, number];
|
|
37
|
-
progress
|
|
37
|
+
progress?: number | null;
|
|
38
38
|
url: string;
|
|
39
39
|
size: number;
|
|
40
40
|
status: string;
|
|
41
41
|
createdAt: Dayjs;
|
|
42
42
|
updatedAt: Dayjs;
|
|
43
43
|
removedAt: Dayjs | null;
|
|
44
|
+
}
|
|
45
|
+
export interface ProtoFile extends ProtoLightFile {
|
|
46
|
+
progress: number | null;
|
|
44
47
|
mimetype: string;
|
|
45
48
|
encoding: string;
|
|
46
49
|
origin: string | null;
|
package/types/store/action.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type GetStateObject } from "akanjs/base";
|
|
2
2
|
import { type FetchPolicy } from "akanjs/common";
|
|
3
|
-
import { type DefaultOf, type FieldState, type
|
|
3
|
+
import { type DefaultOf, type FieldState, type ProtoLightFile } from "akanjs/constant";
|
|
4
4
|
import type { ExtractSort, FilterInstance } from "akanjs/document";
|
|
5
5
|
import type { FetchInitForm, FetchProxy } from "akanjs/fetch";
|
|
6
6
|
import type { SerializedSlice, SlceCnstCapitalizedRefName, SlceCnstDefault, SlceCnstDefaultInput, SlceCnstFull, SlceCnstInput, SlceCnstLight, SlceCnstRefName, SlceDbFilter, SlceDbSort, SliceCls } from "akanjs/signal";
|
|
@@ -129,7 +129,7 @@ type ArrayFieldAddOrSubSetters<RefName extends string, _CapRef extends string, _
|
|
|
129
129
|
}) => void;
|
|
130
130
|
};
|
|
131
131
|
type FormSetter<Full, RefName extends string, _CapitalizedRefName extends string = Capitalize<RefName>, _DefaultState = DefaultOf<Full>> = FieldFormSetter<_DefaultState, RefName, _CapitalizedRefName> & ArrayFieldAddSetters<RefName, _CapitalizedRefName, _DefaultState> & ArrayFieldSubSetters<RefName, _CapitalizedRefName, _DefaultState> & ArrayFieldAddOrSubSetters<RefName, _CapitalizedRefName, _DefaultState> & {
|
|
132
|
-
[K in keyof _DefaultState as _DefaultState[K] extends (
|
|
132
|
+
[K in keyof _DefaultState as _DefaultState[K] extends (ProtoLightFile | null) | ProtoLightFile[] ? K extends string ? SetterKey<"upload", K, RefName, _CapitalizedRefName> : never : never]: (fileList: FileList | File[], idx?: number) => Promise<void>;
|
|
133
133
|
} & {
|
|
134
134
|
[K in `writeOn${_CapitalizedRefName}`]: (path: string | (string | number)[], value: any) => void;
|
|
135
135
|
};
|
package/types/ui/CsrImage.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProtoLightFile } from "akanjs/constant";
|
|
2
2
|
import type { ImgHTMLAttributes } from "react";
|
|
3
3
|
type CsrImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "alt" | "src"> & {
|
|
4
4
|
src?: string;
|
|
5
|
-
file?:
|
|
5
|
+
file?: ProtoLightFile | {
|
|
6
6
|
url: string;
|
|
7
7
|
imageSize: [number, number];
|
|
8
8
|
abstractData?: string | null;
|
package/types/ui/Image.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProtoLightFile } from "akanjs/constant";
|
|
2
2
|
import type { ImgHTMLAttributes } from "react";
|
|
3
|
-
type ImageLikeFile =
|
|
3
|
+
type ImageLikeFile = ProtoLightFile | {
|
|
4
4
|
url: string;
|
|
5
5
|
imageSize: [number, number];
|
|
6
6
|
abstractData?: string | null;
|
|
@@ -33,7 +33,7 @@ type AkanImageProps = NativeImageProps & {
|
|
|
33
33
|
};
|
|
34
34
|
export declare const Image: ({ src, file, className, abstractData, alt, quality, priority, preload, unoptimized, ...props }: AkanImageProps & ({
|
|
35
35
|
src?: string;
|
|
36
|
-
file?:
|
|
36
|
+
file?: ProtoLightFile;
|
|
37
37
|
abstractData?: string | null;
|
|
38
38
|
alt?: string;
|
|
39
39
|
} | {
|
package/ui/CsrImage.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProtoLightFile } from "akanjs/constant";
|
|
3
3
|
import type { ImgHTMLAttributes } from "react";
|
|
4
4
|
|
|
5
5
|
type CsrImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "alt" | "src"> & {
|
|
6
6
|
src?: string;
|
|
7
|
-
file?:
|
|
7
|
+
file?: ProtoLightFile | { url: string; imageSize: [number, number]; abstractData?: string | null } | null;
|
|
8
8
|
abstractData?: string | null;
|
|
9
9
|
priority?: boolean;
|
|
10
10
|
preload?: boolean;
|
package/ui/Image.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getEnv } from "akanjs/base";
|
|
2
2
|
import { cn } from "akanjs/client";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ProtoLightFile } from "akanjs/constant";
|
|
4
4
|
import type { ImgHTMLAttributes } from "react";
|
|
5
5
|
import { preload as preloadResource } from "react-dom";
|
|
6
6
|
|
|
7
7
|
import { CsrImage } from "./CsrImage";
|
|
8
8
|
|
|
9
|
-
type ImageLikeFile =
|
|
9
|
+
type ImageLikeFile = ProtoLightFile | { url: string; imageSize: [number, number]; abstractData?: string | null } | null;
|
|
10
10
|
|
|
11
11
|
const DEFAULT_IMAGE_DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
|
|
12
12
|
const DEFAULT_IMAGE_SIZES = [32, 48, 64, 96, 128, 256, 384];
|
|
@@ -58,7 +58,7 @@ export const Image = ({
|
|
|
58
58
|
(
|
|
59
59
|
| {
|
|
60
60
|
src?: string;
|
|
61
|
-
file?:
|
|
61
|
+
file?: ProtoLightFile;
|
|
62
62
|
abstractData?: string | null;
|
|
63
63
|
alt?: string;
|
|
64
64
|
}
|