@melite/formats 0.0.0-stage → 0.1.5-pre-alpha
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/LICENSE +557 -0
- package/README.md +37 -2
- package/lib/b64.d.ts +2 -0
- package/lib/b64.js +7 -0
- package/lib/bodyPresets.d.ts +40 -0
- package/lib/bodyPresets.js +77 -0
- package/lib/captionSplitter.d.ts +49 -0
- package/lib/captionSplitter.js +172 -0
- package/lib/cardMutations.d.ts +52 -0
- package/lib/cardMutations.js +67 -0
- package/lib/downloads.d.ts +18 -0
- package/lib/downloads.js +64 -0
- package/lib/extractVideoFrame.d.ts +23 -0
- package/lib/extractVideoFrame.js +114 -0
- package/lib/glbLoad.d.ts +54 -0
- package/lib/glbLoad.js +96 -0
- package/lib/glbSkin.d.ts +14 -0
- package/lib/glbSkin.js +124 -0
- package/lib/handPose.d.ts +46 -0
- package/lib/handPose.js +122 -0
- package/lib/index.d.ts +25 -0
- package/lib/index.js +25 -0
- package/lib/keyframeExtract.d.ts +46 -0
- package/lib/keyframeExtract.js +89 -0
- package/lib/maskPrep.d.ts +88 -0
- package/lib/maskPrep.js +386 -0
- package/lib/motionConstraints.d.ts +237 -0
- package/lib/motionConstraints.js +369 -0
- package/lib/motionEnvelope.d.ts +56 -0
- package/lib/motionEnvelope.js +59 -0
- package/lib/motionNpz.d.ts +120 -0
- package/lib/motionNpz.js +497 -0
- package/lib/npz.d.ts +24 -0
- package/lib/npz.js +158 -0
- package/lib/openPoseCanvas.d.ts +17 -0
- package/lib/openPoseCanvas.js +90 -0
- package/lib/pngMeta.d.ts +42 -0
- package/lib/pngMeta.js +212 -0
- package/lib/pngMetaInfo.d.ts +14 -0
- package/lib/pngMetaInfo.js +127 -0
- package/lib/poseCodec.d.ts +20 -0
- package/lib/poseCodec.js +61 -0
- package/lib/poseTransforms.d.ts +66 -0
- package/lib/poseTransforms.js +227 -0
- package/lib/poserSkin.d.ts +75 -0
- package/lib/poserSkin.js +141 -0
- package/lib/prompt-tags.json +132 -0
- package/lib/promptTags.d.ts +42 -0
- package/lib/promptTags.js +116 -0
- package/lib/psdExport.d.ts +28 -0
- package/lib/psdExport.js +272 -0
- package/lib/readFile.d.ts +9 -0
- package/lib/readFile.js +16 -0
- package/lib/renderSnapshot.d.ts +34 -0
- package/lib/renderSnapshot.js +55 -0
- package/lib/somaSkin.d.ts +82 -0
- package/lib/somaSkin.js +267 -0
- package/lib/textToPose.d.ts +394 -0
- package/lib/textToPose.js +607 -0
- package/lib/uploadToEstate.d.ts +25 -0
- package/lib/uploadToEstate.js +97 -0
- package/package.json +149 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
import { readAsDataURL } from "./readFile.js";
|
|
26
|
+
const IMAGE_TYPES = new Set(["image/png", "image/jpeg", "image/webp"]);
|
|
27
|
+
// Shared readAsDataURL (@melite/ui SlotSquare — the ONE read path). The
|
|
28
|
+
// picker-specific guidance survives as a catch mapping: the shared read
|
|
29
|
+
// rejects bare, and only this rail knows what to tell the operator next.
|
|
30
|
+
function readUploadFile(file) {
|
|
31
|
+
return readAsDataURL(file).catch(() => {
|
|
32
|
+
throw new Error(`The browser could not read "${file.name}" at its source ` +
|
|
33
|
+
"(the drag handed over a file the browser can't open — this " +
|
|
34
|
+
"happens when the file was moved/deleted, or the drag came " +
|
|
35
|
+
"from a recent-files list or another app). " +
|
|
36
|
+
"Drag it from its actual folder, or CLICK the square and browse — " +
|
|
37
|
+
"the picker path reads through the OS dialog and works.");
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export class UploadRefusedError extends Error {
|
|
41
|
+
}
|
|
42
|
+
/** The rail: File → POST /v1/uploads → the estate path. */
|
|
43
|
+
export async function uploadToEstate(file) {
|
|
44
|
+
if (!IMAGE_TYPES.has(file.type)) {
|
|
45
|
+
throw new UploadRefusedError(`${file.name}: only png / jpeg / webp upload (got ${file.type || "unknown type"})`);
|
|
46
|
+
}
|
|
47
|
+
const data = await readUploadFile(file);
|
|
48
|
+
let resp;
|
|
49
|
+
try {
|
|
50
|
+
resp = await fetch("/v1/uploads", {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: { "Content-Type": "application/json" },
|
|
53
|
+
body: JSON.stringify({ filename: file.name, data }),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
throw new Error(`Upload failed (network): ${e.message}`);
|
|
58
|
+
}
|
|
59
|
+
const text = await resp.text();
|
|
60
|
+
let body = {};
|
|
61
|
+
try {
|
|
62
|
+
body = JSON.parse(text);
|
|
63
|
+
}
|
|
64
|
+
catch { /* refused below */ }
|
|
65
|
+
if (!resp.ok || !body.path) {
|
|
66
|
+
throw new Error(body.error ?? `Upload failed (HTTP ${resp.status})`);
|
|
67
|
+
}
|
|
68
|
+
return body.path;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
export function estateInputUrl(value) {
|
|
90
|
+
if (/^(data:|blob:|https?:)/i.test(value)
|
|
91
|
+
|| /^\/(assets|api|v1\/assets)\//.test(value)) {
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
const m = /^data\/input\/([A-Za-z0-9_-]+\.(?:png|jpe?g|webp))$/i.exec(value);
|
|
95
|
+
return m ? `/v1/assets/inputs/${m[1]}` : null;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=uploadToEstate.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,151 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@melite/formats",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"license": "SSPL-1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@melite/catalog": "0.1.5-pre-alpha",
|
|
7
|
+
"@melite/contracts": "0.1.5-pre-alpha",
|
|
8
|
+
"@melite/three-client": "0.1.5-pre-alpha"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
"./b64": {
|
|
12
|
+
"types": "./lib/b64.d.ts",
|
|
13
|
+
"default": "./lib/b64.js"
|
|
14
|
+
},
|
|
15
|
+
"./bodyPresets": {
|
|
16
|
+
"types": "./lib/bodyPresets.d.ts",
|
|
17
|
+
"default": "./lib/bodyPresets.js"
|
|
18
|
+
},
|
|
19
|
+
"./captionSplitter": {
|
|
20
|
+
"types": "./lib/captionSplitter.d.ts",
|
|
21
|
+
"default": "./lib/captionSplitter.js"
|
|
22
|
+
},
|
|
23
|
+
"./cardMutations": {
|
|
24
|
+
"types": "./lib/cardMutations.d.ts",
|
|
25
|
+
"default": "./lib/cardMutations.js"
|
|
26
|
+
},
|
|
27
|
+
"./downloads": {
|
|
28
|
+
"types": "./lib/downloads.d.ts",
|
|
29
|
+
"default": "./lib/downloads.js"
|
|
30
|
+
},
|
|
31
|
+
"./extractVideoFrame": {
|
|
32
|
+
"types": "./lib/extractVideoFrame.d.ts",
|
|
33
|
+
"default": "./lib/extractVideoFrame.js"
|
|
34
|
+
},
|
|
35
|
+
"./glbLoad": {
|
|
36
|
+
"types": "./lib/glbLoad.d.ts",
|
|
37
|
+
"default": "./lib/glbLoad.js"
|
|
38
|
+
},
|
|
39
|
+
"./glbSkin": {
|
|
40
|
+
"types": "./lib/glbSkin.d.ts",
|
|
41
|
+
"default": "./lib/glbSkin.js"
|
|
42
|
+
},
|
|
43
|
+
"./handPose": {
|
|
44
|
+
"types": "./lib/handPose.d.ts",
|
|
45
|
+
"default": "./lib/handPose.js"
|
|
46
|
+
},
|
|
47
|
+
"./keyframeExtract": {
|
|
48
|
+
"types": "./lib/keyframeExtract.d.ts",
|
|
49
|
+
"default": "./lib/keyframeExtract.js"
|
|
50
|
+
},
|
|
51
|
+
"./maskPrep": {
|
|
52
|
+
"types": "./lib/maskPrep.d.ts",
|
|
53
|
+
"default": "./lib/maskPrep.js"
|
|
54
|
+
},
|
|
55
|
+
"./motionConstraints": {
|
|
56
|
+
"types": "./lib/motionConstraints.d.ts",
|
|
57
|
+
"default": "./lib/motionConstraints.js"
|
|
58
|
+
},
|
|
59
|
+
"./motionEnvelope": {
|
|
60
|
+
"types": "./lib/motionEnvelope.d.ts",
|
|
61
|
+
"default": "./lib/motionEnvelope.js"
|
|
62
|
+
},
|
|
63
|
+
"./motionNpz": {
|
|
64
|
+
"types": "./lib/motionNpz.d.ts",
|
|
65
|
+
"default": "./lib/motionNpz.js"
|
|
66
|
+
},
|
|
67
|
+
"./npz": {
|
|
68
|
+
"types": "./lib/npz.d.ts",
|
|
69
|
+
"default": "./lib/npz.js"
|
|
70
|
+
},
|
|
71
|
+
"./openPoseCanvas": {
|
|
72
|
+
"types": "./lib/openPoseCanvas.d.ts",
|
|
73
|
+
"default": "./lib/openPoseCanvas.js"
|
|
74
|
+
},
|
|
75
|
+
"./package.json": "./package.json",
|
|
76
|
+
"./pngMeta": {
|
|
77
|
+
"types": "./lib/pngMeta.d.ts",
|
|
78
|
+
"default": "./lib/pngMeta.js"
|
|
79
|
+
},
|
|
80
|
+
"./pngMetaInfo": {
|
|
81
|
+
"types": "./lib/pngMetaInfo.d.ts",
|
|
82
|
+
"default": "./lib/pngMetaInfo.js"
|
|
83
|
+
},
|
|
84
|
+
"./poseCodec": {
|
|
85
|
+
"types": "./lib/poseCodec.d.ts",
|
|
86
|
+
"default": "./lib/poseCodec.js"
|
|
87
|
+
},
|
|
88
|
+
"./poseTransforms": {
|
|
89
|
+
"types": "./lib/poseTransforms.d.ts",
|
|
90
|
+
"default": "./lib/poseTransforms.js"
|
|
91
|
+
},
|
|
92
|
+
"./poserSkin": {
|
|
93
|
+
"types": "./lib/poserSkin.d.ts",
|
|
94
|
+
"default": "./lib/poserSkin.js"
|
|
95
|
+
},
|
|
96
|
+
"./promptTags": {
|
|
97
|
+
"types": "./lib/promptTags.d.ts",
|
|
98
|
+
"default": "./lib/promptTags.js"
|
|
99
|
+
},
|
|
100
|
+
"./psdExport": {
|
|
101
|
+
"types": "./lib/psdExport.d.ts",
|
|
102
|
+
"default": "./lib/psdExport.js"
|
|
103
|
+
},
|
|
104
|
+
"./readFile": {
|
|
105
|
+
"types": "./lib/readFile.d.ts",
|
|
106
|
+
"default": "./lib/readFile.js"
|
|
107
|
+
},
|
|
108
|
+
"./uploadToEstate": {
|
|
109
|
+
"types": "./lib/uploadToEstate.d.ts",
|
|
110
|
+
"default": "./lib/uploadToEstate.js"
|
|
111
|
+
},
|
|
112
|
+
"./textToPose": {
|
|
113
|
+
"types": "./lib/textToPose.d.ts",
|
|
114
|
+
"default": "./lib/textToPose.js"
|
|
115
|
+
},
|
|
116
|
+
"./renderSnapshot": {
|
|
117
|
+
"types": "./lib/renderSnapshot.d.ts",
|
|
118
|
+
"default": "./lib/renderSnapshot.js"
|
|
119
|
+
},
|
|
120
|
+
"./somaSkin": {
|
|
121
|
+
"types": "./lib/somaSkin.d.ts",
|
|
122
|
+
"default": "./lib/somaSkin.js"
|
|
123
|
+
},
|
|
124
|
+
".": {
|
|
125
|
+
"types": "./lib/index.d.ts",
|
|
126
|
+
"default": "./lib/index.js"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"version": "0.1.5-pre-alpha",
|
|
130
|
+
"types": "./src/index.ts",
|
|
131
|
+
"devDependencies": {
|
|
132
|
+
"@types/node": "^22.20.0",
|
|
133
|
+
"@types/react": "^19.3.0",
|
|
134
|
+
"@types/react-dom": "^19.3.0",
|
|
135
|
+
"@types/three": "^0.184.1",
|
|
136
|
+
"typescript": "^5.9.3"
|
|
137
|
+
},
|
|
138
|
+
"files": [
|
|
139
|
+
"lib/index.js",
|
|
140
|
+
"lib/**/*.js",
|
|
141
|
+
"lib/**/*.d.ts",
|
|
142
|
+
"lib/**/*.json"
|
|
143
|
+
],
|
|
144
|
+
"scripts": {
|
|
145
|
+
"build": "tsc -p tsconfig.build.json",
|
|
146
|
+
"typecheck": "tsc --noEmit"
|
|
147
|
+
},
|
|
148
|
+
"publishConfig": {
|
|
149
|
+
"access": "public"
|
|
150
|
+
}
|
|
151
|
+
}
|