astro-md-editor 0.0.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/.output/nitro.json +17 -0
- package/.output/public/assets/index-Cc7yKB0o.js +19 -0
- package/.output/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/.output/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/.output/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/.output/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/.output/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/.output/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/.output/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/.output/public/assets/main-DDBjVFnt.js +17 -0
- package/.output/public/assets/styles-ggfdUHMo.css +1 -0
- package/.output/public/favicon.ico +0 -0
- package/.output/public/logo192.png +0 -0
- package/.output/public/logo512.png +0 -0
- package/.output/public/manifest.json +25 -0
- package/.output/public/robots.txt +3 -0
- package/.output/server/__root-C09LBXMv.mjs +40 -0
- package/.output/server/_chunks/ssr-renderer.mjs +21 -0
- package/.output/server/_libs/ajv-formats.mjs +330 -0
- package/.output/server/_libs/ajv.mjs +5484 -0
- package/.output/server/_libs/base-ui__react.mjs +8712 -0
- package/.output/server/_libs/base-ui__utils.mjs +980 -0
- package/.output/server/_libs/class-variance-authority.mjs +44 -0
- package/.output/server/_libs/clsx.mjs +16 -0
- package/.output/server/_libs/cookie-es.mjs +58 -0
- package/.output/server/_libs/croner.mjs +1 -0
- package/.output/server/_libs/crossws.mjs +1 -0
- package/.output/server/_libs/date-fns.mjs +1716 -0
- package/.output/server/_libs/date-fns__tz.mjs +217 -0
- package/.output/server/_libs/extend-shallow.mjs +35 -0
- package/.output/server/_libs/fast-deep-equal.mjs +38 -0
- package/.output/server/_libs/fast-uri.mjs +725 -0
- package/.output/server/_libs/floating-ui__core.mjs +663 -0
- package/.output/server/_libs/floating-ui__dom.mjs +624 -0
- package/.output/server/_libs/floating-ui__react-dom.mjs +279 -0
- package/.output/server/_libs/floating-ui__utils.mjs +322 -0
- package/.output/server/_libs/gray-matter.mjs +393 -0
- package/.output/server/_libs/h3-v2.mjs +276 -0
- package/.output/server/_libs/h3.mjs +400 -0
- package/.output/server/_libs/hookable.mjs +1 -0
- package/.output/server/_libs/is-extendable.mjs +13 -0
- package/.output/server/_libs/isbot.mjs +20 -0
- package/.output/server/_libs/js-yaml.mjs +2822 -0
- package/.output/server/_libs/json-schema-traverse.mjs +91 -0
- package/.output/server/_libs/kind-of.mjs +125 -0
- package/.output/server/_libs/lucide-react.mjs +177 -0
- package/.output/server/_libs/ohash.mjs +1 -0
- package/.output/server/_libs/react-day-picker.mjs +2216 -0
- package/.output/server/_libs/react-dom.mjs +10779 -0
- package/.output/server/_libs/react-resizable-panels.mjs +2024 -0
- package/.output/server/_libs/react.mjs +513 -0
- package/.output/server/_libs/reselect.mjs +326 -0
- package/.output/server/_libs/rou3.mjs +8 -0
- package/.output/server/_libs/section-matter.mjs +112 -0
- package/.output/server/_libs/seroval-plugins.mjs +58 -0
- package/.output/server/_libs/seroval.mjs +1765 -0
- package/.output/server/_libs/srvx.mjs +736 -0
- package/.output/server/_libs/strip-bom-string.mjs +16 -0
- package/.output/server/_libs/tabbable.mjs +342 -0
- package/.output/server/_libs/tailwind-merge.mjs +3175 -0
- package/.output/server/_libs/tanstack__history.mjs +217 -0
- package/.output/server/_libs/tanstack__react-router.mjs +1464 -0
- package/.output/server/_libs/tanstack__react-store.mjs +1 -0
- package/.output/server/_libs/tanstack__router-core.mjs +4912 -0
- package/.output/server/_libs/tanstack__store.mjs +1 -0
- package/.output/server/_libs/tiny-invariant.mjs +12 -0
- package/.output/server/_libs/tiny-warning.mjs +5 -0
- package/.output/server/_libs/ufo.mjs +54 -0
- package/.output/server/_libs/unctx.mjs +1 -0
- package/.output/server/_libs/unstorage.mjs +1 -0
- package/.output/server/_libs/use-sync-external-store.mjs +139 -0
- package/.output/server/_libs/zod.mjs +3634 -0
- package/.output/server/_libs/zustand.mjs +43 -0
- package/.output/server/_ssr/RightSidebar-RSY9M7XF.mjs +218 -0
- package/.output/server/_ssr/collections.server-D6U2tEsT.mjs +120 -0
- package/.output/server/_ssr/createServerRpc-29xaFZcb.mjs +12 -0
- package/.output/server/_ssr/index-BaqV4cZC.mjs +2083 -0
- package/.output/server/_ssr/index-sQBM6rwN.mjs +115 -0
- package/.output/server/_ssr/index.mjs +1448 -0
- package/.output/server/_ssr/router-D4G1DGr3.mjs +155 -0
- package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-CYEHh_qB.mjs +4 -0
- package/.output/server/index.mjs +451 -0
- package/README.md +118 -0
- package/index.mjs +21 -0
- package/package.json +86 -0
- package/scripts/bootstrap-collections.mjs +1201 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { a as React } from "./react.mjs";
|
|
2
|
+
const createStoreImpl = (createState) => {
|
|
3
|
+
let state;
|
|
4
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
5
|
+
const setState = (partial, replace) => {
|
|
6
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
7
|
+
if (!Object.is(nextState, state)) {
|
|
8
|
+
const previousState = state;
|
|
9
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
10
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const getState = () => state;
|
|
14
|
+
const getInitialState = () => initialState;
|
|
15
|
+
const subscribe = (listener) => {
|
|
16
|
+
listeners.add(listener);
|
|
17
|
+
return () => listeners.delete(listener);
|
|
18
|
+
};
|
|
19
|
+
const api = { setState, getState, getInitialState, subscribe };
|
|
20
|
+
const initialState = state = createState(setState, getState, api);
|
|
21
|
+
return api;
|
|
22
|
+
};
|
|
23
|
+
const createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
24
|
+
const identity = (arg) => arg;
|
|
25
|
+
function useStore(api, selector = identity) {
|
|
26
|
+
const slice = React.useSyncExternalStore(
|
|
27
|
+
api.subscribe,
|
|
28
|
+
React.useCallback(() => selector(api.getState()), [api, selector]),
|
|
29
|
+
React.useCallback(() => selector(api.getInitialState()), [api, selector])
|
|
30
|
+
);
|
|
31
|
+
React.useDebugValue(slice);
|
|
32
|
+
return slice;
|
|
33
|
+
}
|
|
34
|
+
const createImpl = (createState) => {
|
|
35
|
+
const api = createStore(createState);
|
|
36
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
|
37
|
+
Object.assign(useBoundStore, api);
|
|
38
|
+
return useBoundStore;
|
|
39
|
+
};
|
|
40
|
+
const create = ((createState) => createState ? createImpl(createState) : createImpl);
|
|
41
|
+
export {
|
|
42
|
+
create as c
|
|
43
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { c as createServerRpc } from "./createServerRpc-29xaFZcb.mjs";
|
|
2
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, resolve, relative, join, extname } from "node:path";
|
|
4
|
+
import { getCollectionsRootPath } from "./collections.server-D6U2tEsT.mjs";
|
|
5
|
+
import { c as createServerFn } from "./index.mjs";
|
|
6
|
+
import "../_libs/tanstack__history.mjs";
|
|
7
|
+
import "../_libs/tanstack__router-core.mjs";
|
|
8
|
+
import "../_libs/cookie-es.mjs";
|
|
9
|
+
import "../_libs/tiny-invariant.mjs";
|
|
10
|
+
import "../_libs/seroval.mjs";
|
|
11
|
+
import "../_libs/seroval-plugins.mjs";
|
|
12
|
+
import "node:stream/web";
|
|
13
|
+
import "node:stream";
|
|
14
|
+
import "node:async_hooks";
|
|
15
|
+
import "../_libs/h3-v2.mjs";
|
|
16
|
+
import "../_libs/rou3.mjs";
|
|
17
|
+
import "../_libs/srvx.mjs";
|
|
18
|
+
import "node:http";
|
|
19
|
+
import "node:https";
|
|
20
|
+
import "node:http2";
|
|
21
|
+
import "../_libs/react.mjs";
|
|
22
|
+
import "../_libs/tanstack__react-router.mjs";
|
|
23
|
+
import "../_libs/react-dom.mjs";
|
|
24
|
+
import "util";
|
|
25
|
+
import "crypto";
|
|
26
|
+
import "async_hooks";
|
|
27
|
+
import "stream";
|
|
28
|
+
import "../_libs/isbot.mjs";
|
|
29
|
+
import "../_libs/tiny-warning.mjs";
|
|
30
|
+
const IMAGE_MIME_TYPES = {
|
|
31
|
+
".png": "image/png",
|
|
32
|
+
".jpg": "image/jpeg",
|
|
33
|
+
".jpeg": "image/jpeg",
|
|
34
|
+
".webp": "image/webp",
|
|
35
|
+
".avif": "image/avif",
|
|
36
|
+
".gif": "image/gif",
|
|
37
|
+
".svg": "image/svg+xml"
|
|
38
|
+
};
|
|
39
|
+
let cachedRootDir;
|
|
40
|
+
let cachedAssets;
|
|
41
|
+
let cachedAssetsById;
|
|
42
|
+
function toPosix(pathLike) {
|
|
43
|
+
return pathLike.replaceAll("\\", "/");
|
|
44
|
+
}
|
|
45
|
+
function toRelativePath(fromPath, toPath) {
|
|
46
|
+
const rawRelative = toPosix(relative(fromPath, toPath));
|
|
47
|
+
if (rawRelative.length === 0) {
|
|
48
|
+
return "./";
|
|
49
|
+
}
|
|
50
|
+
return rawRelative.startsWith(".") ? rawRelative : `./${rawRelative}`;
|
|
51
|
+
}
|
|
52
|
+
function getMimeType(fileName) {
|
|
53
|
+
const extension = extname(fileName).toLowerCase();
|
|
54
|
+
return IMAGE_MIME_TYPES[extension];
|
|
55
|
+
}
|
|
56
|
+
async function collectImageAssetsForSource(params) {
|
|
57
|
+
const sourceRoot = resolve(params.rootDir, params.source);
|
|
58
|
+
async function walkDirectory(dirPath) {
|
|
59
|
+
let entries;
|
|
60
|
+
try {
|
|
61
|
+
entries = await readdir(dirPath, {
|
|
62
|
+
withFileTypes: true
|
|
63
|
+
});
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error.code === "ENOENT") {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
const assets = [];
|
|
71
|
+
for (const entry of entries) {
|
|
72
|
+
const absolutePath = join(dirPath, entry.name);
|
|
73
|
+
if (entry.isDirectory()) {
|
|
74
|
+
assets.push(...await walkDirectory(absolutePath));
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (!entry.isFile()) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const mimeType = getMimeType(entry.name);
|
|
81
|
+
if (!mimeType) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const sourceRelativePath = toPosix(relative(sourceRoot, absolutePath));
|
|
85
|
+
assets.push({
|
|
86
|
+
id: `${params.source}:${sourceRelativePath}`,
|
|
87
|
+
source: params.source,
|
|
88
|
+
absolutePath,
|
|
89
|
+
sourceRelativePath,
|
|
90
|
+
mimeType
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return assets;
|
|
94
|
+
}
|
|
95
|
+
return walkDirectory(sourceRoot);
|
|
96
|
+
}
|
|
97
|
+
async function buildImageAssetIndex(rootDir) {
|
|
98
|
+
const [srcAssets, publicAssets] = await Promise.all([
|
|
99
|
+
collectImageAssetsForSource({
|
|
100
|
+
rootDir,
|
|
101
|
+
source: "src"
|
|
102
|
+
}),
|
|
103
|
+
collectImageAssetsForSource({
|
|
104
|
+
rootDir,
|
|
105
|
+
source: "public"
|
|
106
|
+
})
|
|
107
|
+
]);
|
|
108
|
+
return [...srcAssets, ...publicAssets].sort((a, b) => {
|
|
109
|
+
if (a.source !== b.source) {
|
|
110
|
+
return a.source.localeCompare(b.source);
|
|
111
|
+
}
|
|
112
|
+
return a.sourceRelativePath.localeCompare(b.sourceRelativePath);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async function getImageIndex() {
|
|
116
|
+
const rootDir = getCollectionsRootPath();
|
|
117
|
+
if (cachedRootDir === rootDir && cachedAssets && cachedAssetsById) {
|
|
118
|
+
return cachedAssets;
|
|
119
|
+
}
|
|
120
|
+
const assets = await buildImageAssetIndex(rootDir);
|
|
121
|
+
cachedRootDir = rootDir;
|
|
122
|
+
cachedAssets = assets;
|
|
123
|
+
cachedAssetsById = new Map(assets.map((asset) => [asset.id, asset]));
|
|
124
|
+
return assets;
|
|
125
|
+
}
|
|
126
|
+
async function listImageAssetsForFile(currentFilePath, sourceMode = "asset") {
|
|
127
|
+
const targetSource = sourceMode === "public" ? "public" : "src";
|
|
128
|
+
const assets = (await getImageIndex()).filter((asset) => {
|
|
129
|
+
return asset.source === targetSource;
|
|
130
|
+
});
|
|
131
|
+
const fileDirectory = dirname(resolve(currentFilePath));
|
|
132
|
+
return assets.map((asset) => {
|
|
133
|
+
const value = asset.source === "public" ? `/${asset.sourceRelativePath}` : toRelativePath(fileDirectory, asset.absolutePath);
|
|
134
|
+
return {
|
|
135
|
+
id: asset.id,
|
|
136
|
+
source: asset.source,
|
|
137
|
+
displayPath: asset.sourceRelativePath,
|
|
138
|
+
value
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async function readImageAssetPreviewById(assetId) {
|
|
143
|
+
await getImageIndex();
|
|
144
|
+
const asset = cachedAssetsById?.get(assetId);
|
|
145
|
+
if (!asset) {
|
|
146
|
+
throw new Error(`Image asset not found: ${assetId}`);
|
|
147
|
+
}
|
|
148
|
+
const bytes = await readFile(asset.absolutePath);
|
|
149
|
+
return {
|
|
150
|
+
bytes,
|
|
151
|
+
mimeType: asset.mimeType
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function isObjectRecord(value) {
|
|
155
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
156
|
+
}
|
|
157
|
+
const listImageAssets_createServerFn_handler = createServerRpc({
|
|
158
|
+
id: "c39d1a9dd4bf0ef421bf4f2daf36aab12030ba358e594364ba10b3659b27b480",
|
|
159
|
+
name: "listImageAssets",
|
|
160
|
+
filename: "src/components/editor/RightSidebar.tsx"
|
|
161
|
+
}, (opts) => listImageAssets.__executeServer(opts));
|
|
162
|
+
const listImageAssets = createServerFn({
|
|
163
|
+
method: "POST"
|
|
164
|
+
}).inputValidator((payload) => {
|
|
165
|
+
if (!isObjectRecord(payload)) {
|
|
166
|
+
throw new Error("Invalid asset list payload.");
|
|
167
|
+
}
|
|
168
|
+
const currentFilePath = payload.currentFilePath;
|
|
169
|
+
if (typeof currentFilePath !== "string" || currentFilePath.length === 0) {
|
|
170
|
+
throw new Error("Missing current file path.");
|
|
171
|
+
}
|
|
172
|
+
const sourceMode = payload.sourceMode;
|
|
173
|
+
if (sourceMode !== "asset" && sourceMode !== "public") {
|
|
174
|
+
throw new Error("Invalid image source mode.");
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
currentFilePath,
|
|
178
|
+
sourceMode
|
|
179
|
+
};
|
|
180
|
+
}).handler(listImageAssets_createServerFn_handler, async ({
|
|
181
|
+
data
|
|
182
|
+
}) => {
|
|
183
|
+
return listImageAssetsForFile(data.currentFilePath, data.sourceMode);
|
|
184
|
+
});
|
|
185
|
+
const getImageAssetPreview_createServerFn_handler = createServerRpc({
|
|
186
|
+
id: "91a56e4138efcf4efad5b435140f056a882a5f54203e1c4d3b0f274ea2f876f5",
|
|
187
|
+
name: "getImageAssetPreview",
|
|
188
|
+
filename: "src/components/editor/RightSidebar.tsx"
|
|
189
|
+
}, (opts) => getImageAssetPreview.__executeServer(opts));
|
|
190
|
+
const getImageAssetPreview = createServerFn({
|
|
191
|
+
method: "POST"
|
|
192
|
+
}).inputValidator((payload) => {
|
|
193
|
+
if (!isObjectRecord(payload)) {
|
|
194
|
+
throw new Error("Invalid asset preview payload.");
|
|
195
|
+
}
|
|
196
|
+
const assetId = payload.assetId;
|
|
197
|
+
if (typeof assetId !== "string" || assetId.length === 0) {
|
|
198
|
+
throw new Error("Missing asset id.");
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
assetId
|
|
202
|
+
};
|
|
203
|
+
}).handler(getImageAssetPreview_createServerFn_handler, async ({
|
|
204
|
+
data
|
|
205
|
+
}) => {
|
|
206
|
+
const preview = await readImageAssetPreviewById(data.assetId);
|
|
207
|
+
const bodyBytes = new Uint8Array(preview.bytes);
|
|
208
|
+
return new Response(bodyBytes, {
|
|
209
|
+
headers: {
|
|
210
|
+
"Content-Type": preview.mimeType,
|
|
211
|
+
"Cache-Control": "public, max-age=300"
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
export {
|
|
216
|
+
getImageAssetPreview_createServerFn_handler,
|
|
217
|
+
listImageAssets_createServerFn_handler
|
|
218
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const COLLECTIONS_JSON_B64_ENV_KEY = "APP_COLLECTIONS_JSON_B64";
|
|
2
|
+
const COLLECTIONS_ROOT_ENV_KEY = "APP_COLLECTIONS_ROOT";
|
|
3
|
+
let cachedCollectionsRaw;
|
|
4
|
+
let cachedCollectionsData;
|
|
5
|
+
let hasParsedCollectionsData = false;
|
|
6
|
+
function requireEnvValue(key) {
|
|
7
|
+
const value = process.env[key];
|
|
8
|
+
if (!value) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
`[collections] Missing ${key}. Start the app with the bootstrap launcher.`
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
function getCollectionsRaw() {
|
|
16
|
+
if (cachedCollectionsRaw !== void 0) {
|
|
17
|
+
return cachedCollectionsRaw;
|
|
18
|
+
}
|
|
19
|
+
const encoded = requireEnvValue(COLLECTIONS_JSON_B64_ENV_KEY);
|
|
20
|
+
cachedCollectionsRaw = Buffer.from(encoded, "base64").toString("utf8");
|
|
21
|
+
return cachedCollectionsRaw;
|
|
22
|
+
}
|
|
23
|
+
function asObjectRecord(value) {
|
|
24
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
function asFieldUiMap(value) {
|
|
30
|
+
const record = asObjectRecord(value);
|
|
31
|
+
if (!record) {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
const parsed = {};
|
|
35
|
+
for (const [key, rawValue] of Object.entries(record)) {
|
|
36
|
+
if (rawValue === "image" || rawValue === "imageArray" || rawValue === "color") {
|
|
37
|
+
if (rawValue === "color") {
|
|
38
|
+
parsed[key] = { kind: "color" };
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
parsed[key] = {
|
|
42
|
+
kind: rawValue,
|
|
43
|
+
mode: "asset"
|
|
44
|
+
};
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const rawConfig = asObjectRecord(rawValue);
|
|
48
|
+
if (!rawConfig || typeof rawConfig.kind !== "string") {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (rawConfig.kind === "image" || rawConfig.kind === "imageArray") {
|
|
52
|
+
parsed[key] = {
|
|
53
|
+
kind: rawConfig.kind,
|
|
54
|
+
mode: rawConfig.mode === "public" ? "public" : "asset"
|
|
55
|
+
};
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (rawConfig.kind === "color") {
|
|
59
|
+
parsed[key] = {
|
|
60
|
+
kind: "color"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return Object.keys(parsed).length > 0 ? parsed : void 0;
|
|
65
|
+
}
|
|
66
|
+
function cloneObjectRecord(value) {
|
|
67
|
+
return JSON.parse(JSON.stringify(value));
|
|
68
|
+
}
|
|
69
|
+
function getParsedCollectionsData() {
|
|
70
|
+
if (hasParsedCollectionsData) {
|
|
71
|
+
return cachedCollectionsData;
|
|
72
|
+
}
|
|
73
|
+
const raw = getCollectionsRaw();
|
|
74
|
+
cachedCollectionsData = JSON.parse(raw);
|
|
75
|
+
hasParsedCollectionsData = true;
|
|
76
|
+
return cachedCollectionsData;
|
|
77
|
+
}
|
|
78
|
+
function getCollectionsData() {
|
|
79
|
+
const data = getParsedCollectionsData();
|
|
80
|
+
return data.collections.map((collection) => ({
|
|
81
|
+
name: collection.name,
|
|
82
|
+
hasSchema: collection.hasSchema,
|
|
83
|
+
schema: asObjectRecord(collection.schema),
|
|
84
|
+
fieldUi: asFieldUiMap(collection.fieldUi),
|
|
85
|
+
files: (collection.files ?? []).map((file) => ({
|
|
86
|
+
...file,
|
|
87
|
+
data: cloneObjectRecord(asObjectRecord(file.data) ?? {})
|
|
88
|
+
}))
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
function updateCollectionsFileCache(params) {
|
|
92
|
+
const parsed = getParsedCollectionsData();
|
|
93
|
+
const targetCollection = parsed.collections.find(
|
|
94
|
+
(collection) => collection.name === params.collectionName
|
|
95
|
+
);
|
|
96
|
+
if (!targetCollection?.files) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const targetFile = targetCollection.files.find(
|
|
100
|
+
(file) => file.id === params.fileId
|
|
101
|
+
);
|
|
102
|
+
if (!targetFile) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
targetFile.data = cloneObjectRecord(params.data);
|
|
106
|
+
targetFile.content = params.content;
|
|
107
|
+
cachedCollectionsRaw = JSON.stringify(parsed);
|
|
108
|
+
cachedCollectionsData = parsed;
|
|
109
|
+
hasParsedCollectionsData = true;
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
function getCollectionsRootPath() {
|
|
113
|
+
return requireEnvValue(COLLECTIONS_ROOT_ENV_KEY);
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
getCollectionsData,
|
|
117
|
+
getCollectionsRaw,
|
|
118
|
+
getCollectionsRootPath,
|
|
119
|
+
updateCollectionsFileCache
|
|
120
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { T as TSS_SERVER_FUNCTION } from "./index.mjs";
|
|
2
|
+
const createServerRpc = (serverFnMeta, splitImportFn) => {
|
|
3
|
+
const url = "/_serverFn/" + serverFnMeta.id;
|
|
4
|
+
return Object.assign(splitImportFn, {
|
|
5
|
+
url,
|
|
6
|
+
serverFnMeta,
|
|
7
|
+
[TSS_SERVER_FUNCTION]: true
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
createServerRpc as c
|
|
12
|
+
};
|