rimecms 0.31.0 → 0.31.2
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/dist/core/dev/cli/generate/index.server.js +4 -0
- package/dist/core/dev/generate/runtime/index.server.d.ts +4 -0
- package/dist/core/dev/generate/runtime/index.server.js +13 -6
- package/dist/core/dev/vite/index.server.d.ts +1 -0
- package/dist/core/dev/vite/index.server.js +26 -43
- package/dist/fields/relation/component/Relation.svelte +0 -6
- package/dist/fields/rich-text/core/build-editor-config.js +1 -2
- package/dist/panel/components/sections/collection/header/DisplayMode.svelte +1 -1
- package/dist/panel/components/sections/collection/header/Header.svelte +1 -1
- package/dist/panel/components/sections/collection/header/SearchInput.svelte +1 -1
- package/dist/panel/components/sections/collection/header/SelectUI.svelte +1 -1
- package/dist/panel/components/sections/collection/list/header/Header.svelte +1 -1
- package/dist/panel/context/api-proxy.svelte.d.ts +3 -5
- package/dist/panel/context/api-proxy.svelte.js +5 -7
- package/dist/panel/context/collection.svelte.d.ts +3 -8
- package/dist/panel/context/collection.svelte.js +5 -34
- package/dist/panel/context/documentForm.svelte.js +0 -4
- package/dist/panel/context/errors.svelte.d.ts +1 -0
- package/dist/panel/context/errors.svelte.js +1 -1
- package/dist/panel/context/live.svelte.d.ts +1 -0
- package/dist/panel/context/live.svelte.js +1 -1
- package/dist/panel/index.d.ts +8 -0
- package/dist/panel/index.js +15 -0
- package/dist/panel/pages/collection/Collection.svelte +1 -1
- package/package.json +3 -1
|
@@ -2,6 +2,7 @@ import { RIME_DEV_CACHE_DIR } from '../../../constant.server.js';
|
|
|
2
2
|
import cache from '../../cache/index.server.js';
|
|
3
3
|
import { sanitize } from '../../generate/sanitize/index.server.js';
|
|
4
4
|
import { ensureGeneratedConfig, ensureUserConfigExist } from '../../../ensure.server.js';
|
|
5
|
+
import { regenerateModulesDeclaration } from '../../vite/index.server.js';
|
|
5
6
|
import { logger } from '../../../logger/index.server.js';
|
|
6
7
|
import { trycatch } from '../../../../util/function.js';
|
|
7
8
|
import { mkdirSync, rmSync } from 'fs';
|
|
@@ -67,6 +68,9 @@ export const generate = async (args) => {
|
|
|
67
68
|
try {
|
|
68
69
|
ensureUserConfigExist();
|
|
69
70
|
await sanitizeConfig();
|
|
71
|
+
// Normal `vite dev` writes this from `configureServer`'s `listening` event, which never
|
|
72
|
+
// fires here — this command's own Vite server runs in `middlewareMode` (no `httpServer`).
|
|
73
|
+
regenerateModulesDeclaration();
|
|
70
74
|
const importPathJS = ensureGeneratedConfig();
|
|
71
75
|
logger.info('Starting vite server...');
|
|
72
76
|
const vite = await createServer();
|
|
@@ -32,6 +32,10 @@ export declare function findModulePair(root: string, name: string): RuntimeRegis
|
|
|
32
32
|
* `src/lib`-rooted scan registers as `fields/relation`. Used by the `$rime/modules` barrel
|
|
33
33
|
* (live, dev-mode only) and by `generate-manifest` (once, at prepack, scanning `dist/`).
|
|
34
34
|
*
|
|
35
|
+
* A pair sitting directly in `root` itself (e.g. `src/lib/module.ts`, no subfolder) registers
|
|
36
|
+
* under the key `.` — same convention `package.json`'s own `exports` map uses for a package's
|
|
37
|
+
* root, and a folder literally named `.` can't exist, so it can never collide with a real one.
|
|
38
|
+
*
|
|
35
39
|
* Either file alone is enough to register (single-sided is legitimate — a server-only piece,
|
|
36
40
|
* e.g. a collection's hooks, never needs a hand-written client stub; the missing side is just
|
|
37
41
|
* an empty string here, same convention `findModulePair` above uses). `rime.generated/` is
|
|
@@ -57,6 +57,10 @@ export function findModulePair(root, name) {
|
|
|
57
57
|
* `src/lib`-rooted scan registers as `fields/relation`. Used by the `$rime/modules` barrel
|
|
58
58
|
* (live, dev-mode only) and by `generate-manifest` (once, at prepack, scanning `dist/`).
|
|
59
59
|
*
|
|
60
|
+
* A pair sitting directly in `root` itself (e.g. `src/lib/module.ts`, no subfolder) registers
|
|
61
|
+
* under the key `.` — same convention `package.json`'s own `exports` map uses for a package's
|
|
62
|
+
* root, and a folder literally named `.` can't exist, so it can never collide with a real one.
|
|
63
|
+
*
|
|
60
64
|
* Either file alone is enough to register (single-sided is legitimate — a server-only piece,
|
|
61
65
|
* e.g. a collection's hooks, never needs a hand-written client stub; the missing side is just
|
|
62
66
|
* an empty string here, same convention `findModulePair` above uses). `rime.generated/` is
|
|
@@ -66,17 +70,20 @@ export function scanModulePairs(root) {
|
|
|
66
70
|
const registry = new Map();
|
|
67
71
|
if (!fs.existsSync(root))
|
|
68
72
|
return registry;
|
|
73
|
+
const register = (dir, key) => {
|
|
74
|
+
const client = findModuleFile(dir, 'module');
|
|
75
|
+
const server = findModuleFile(dir, 'module.server');
|
|
76
|
+
if (client || server) {
|
|
77
|
+
registry.set(key, { client: client ?? '', server: server ?? '' });
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
register(root, '.');
|
|
69
81
|
const walk = (dir) => {
|
|
70
82
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
71
83
|
if (!entry.isDirectory() || entry.name === OUTPUT_DIR)
|
|
72
84
|
continue;
|
|
73
85
|
const fullPath = path.join(dir, entry.name);
|
|
74
|
-
|
|
75
|
-
const server = findModuleFile(fullPath, 'module.server');
|
|
76
|
-
if (client || server) {
|
|
77
|
-
const key = path.relative(root, fullPath).split(path.sep).join('/');
|
|
78
|
-
registry.set(key, { client: client ?? '', server: server ?? '' });
|
|
79
|
-
}
|
|
86
|
+
register(fullPath, path.relative(root, fullPath).split(path.sep).join('/'));
|
|
80
87
|
walk(fullPath);
|
|
81
88
|
}
|
|
82
89
|
};
|
|
@@ -38,6 +38,20 @@ function splitPackageSpecifier(rest) {
|
|
|
38
38
|
const subpath = segments.slice(pkgName.split('/').length).join('/');
|
|
39
39
|
return { pkgName, subpath };
|
|
40
40
|
}
|
|
41
|
+
// Writes the local-dev $rime/modules barrel types from every module.(server.)ts pair under
|
|
42
|
+
// src/lib. Exported so the CLI `generate` command can call it too — its Vite server runs in
|
|
43
|
+
// middlewareMode, which never fires the `listening` event `rime()` normally hooks this to.
|
|
44
|
+
export function regenerateModulesDeclaration() {
|
|
45
|
+
const libDir = path.resolve(process.cwd(), 'src/lib');
|
|
46
|
+
const pairs = scanModulePairs(libDir);
|
|
47
|
+
const exports = Array.from(pairs.values())
|
|
48
|
+
.map((entry) => entry.server || entry.client)
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.map((file) => `$lib/${path.relative(libDir, file).split(path.sep).join('/')}`.replace(/\.ts$/, '.js'))
|
|
51
|
+
.map((aliased) => ` export * from '${aliased}';`)
|
|
52
|
+
.join('\n');
|
|
53
|
+
writeFileSync(path.resolve(process.cwd(), 'src/rime.modules.generated.d.ts'), `declare module '$rime/modules' {\n${exports}\n}\n`);
|
|
54
|
+
}
|
|
41
55
|
export function rime() {
|
|
42
56
|
/** Two reserved names, always resolved to *the currently running app's* generated
|
|
43
57
|
* config/schema, independent of who's asking — a third-party plugin importing
|
|
@@ -46,28 +60,19 @@ export function rime() {
|
|
|
46
60
|
* namespace only by convention. */
|
|
47
61
|
const VCoreId = '$rime/config';
|
|
48
62
|
const VSchemaId = '$rime/schema';
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
63
|
+
/**
|
|
64
|
+
* `$rime/modules` lets a package split its code into client and server files.
|
|
65
|
+
*
|
|
66
|
+
* While developing, you can just write `$rime/modules` with no path and it scans this
|
|
67
|
+
* project's own `src/lib` for every split. Before the package is published, that gets
|
|
68
|
+
* rewritten into explicit imports like `$rime/modules/<pkg>/<path>` — so anyone installing
|
|
69
|
+
* the package never sees the bare form, only real paths.
|
|
70
|
+
*
|
|
71
|
+
* When resolving one of those explicit imports: if `<pkg>` is this same project, we read
|
|
72
|
+
* straight from `src/lib`. Otherwise it's a real dependency, so we find it in
|
|
73
|
+
* `node_modules` and read the file list it shipped.
|
|
51
74
|
*
|
|
52
|
-
|
|
53
|
-
* only, live-scans this project's own `src/lib` for every `module.(server.)ts` pair (see
|
|
54
|
-
* `regenerateModulesDeclaration` below for the matching local-dev `.d.ts`). Never ships:
|
|
55
|
-
* a prepack step (the `generate-manifest` CLI command) AST-rewrites every `$rime/modules`
|
|
56
|
-
* import into the qualified form below before publish, so a consumer never sees the
|
|
57
|
-
* barrel at all.
|
|
58
|
-
* - The qualified form, `$rime/modules/<pkg>/<path>`, always package-qualified — even for a
|
|
59
|
-
* package's own internal references to itself. Two ways it resolves, both in `resolveId`
|
|
60
|
-
* (not `load`, which never receives `importer`): `<pkg>` equals this project's own
|
|
61
|
-
* `package.json` name → self-reference, resolved directly off this project's own
|
|
62
|
-
* `src/lib`. Otherwise → an installed dependency, its root found by walking up
|
|
63
|
-
* `node_modules/<pkg>` from the importer's own directory (`findInstalledPackageRoot` —
|
|
64
|
-
* pure directory existence, no `exports`-conditions matching, since a package whose
|
|
65
|
-
* `exports` map declares only conditions neither `require.resolve` nor
|
|
66
|
-
* `import.meta.resolve` use fails to resolve through either) and its shipped
|
|
67
|
-
* `dist/.rime-modules.json` read directly — no directory-convention guessing beyond that,
|
|
68
|
-
* immune to Vite's dep-optimizer flattening a package (reading a known filename off disk
|
|
69
|
-
* never touches the import graph the optimizer rewrites). Full design:
|
|
70
|
-
* docs/plans/imports.md. */
|
|
75
|
+
*/
|
|
71
76
|
const VModulesId = '$rime/modules';
|
|
72
77
|
const VModulesPrefix = '$rime/modules/';
|
|
73
78
|
const ownPackageName = getPackageInfoByKey('name');
|
|
@@ -77,25 +82,6 @@ export function rime() {
|
|
|
77
82
|
// doesn't receive importer); the barrel and self-reference cases carry no baked-in root.
|
|
78
83
|
const ROOT_SEP = '\x01';
|
|
79
84
|
const resolvedVModule = (name) => '\0' + name;
|
|
80
|
-
// Local-dev types for the $rime/modules barrel — declares every module.(server.)ts pair
|
|
81
|
-
// currently under this project's own src/lib, live. Regenerated on startup and whenever a
|
|
82
|
-
// module file appears/changes/disappears (see the watcher below) — never ships, gitignored,
|
|
83
|
-
// same treatment as app.generated.d.ts/rime.generated.d.ts.
|
|
84
|
-
//
|
|
85
|
-
// $lib/-aliased paths, not bare relative/absolute ones — verified directly (a plain relative
|
|
86
|
-
// or absolute `export * from` inside a `declare module` block silently resolves to no
|
|
87
|
-
// exports at all; TS only picks up the re-exported names through a real configured alias).
|
|
88
|
-
function regenerateModulesDeclaration() {
|
|
89
|
-
const libDir = path.resolve(process.cwd(), 'src/lib');
|
|
90
|
-
const pairs = scanModulePairs(libDir);
|
|
91
|
-
const exports = Array.from(pairs.values())
|
|
92
|
-
.map((entry) => entry.server || entry.client)
|
|
93
|
-
.filter(Boolean)
|
|
94
|
-
.map((file) => `$lib/${path.relative(libDir, file).split(path.sep).join('/')}`.replace(/\.ts$/, '.js'))
|
|
95
|
-
.map((aliased) => ` export * from '${aliased}';`)
|
|
96
|
-
.join('\n');
|
|
97
|
-
writeFileSync(path.resolve(process.cwd(), 'src/rime.modules.generated.d.ts'), `declare module '$rime/modules' {\n${exports}\n}\n`);
|
|
98
|
-
}
|
|
99
85
|
return {
|
|
100
86
|
name: 'virtual-rime',
|
|
101
87
|
configureServer(server) {
|
|
@@ -196,9 +182,6 @@ export function rime() {
|
|
|
196
182
|
},
|
|
197
183
|
server: {
|
|
198
184
|
watch: {
|
|
199
|
-
// db/*.sqlite (+ its -wal/-shm sidecars) and logs/ are runtime data, not source —
|
|
200
|
-
// every write (e.g. saving a document) touches them, and without this Vite's default
|
|
201
|
-
// whole-project-root watch treats that churn as a source change and force-reloads.
|
|
202
185
|
ignored: ['**/db/**', '**/logs/**']
|
|
203
186
|
}
|
|
204
187
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import type { GenericDoc } from '../../../core/types/doc.js';
|
|
4
4
|
import { fieldset } from '../../../panel/components/fields/fieldset.svelte.js';
|
|
5
5
|
import { Field } from '../../../panel/components/fields/index.js';
|
|
6
|
-
import { getCollectionContext } from '../../../panel/context/collection.svelte.js';
|
|
7
6
|
import { getConfigContext } from '../../../panel/context/config.svelte.js';
|
|
8
7
|
import { type DocumentFormContext } from '../../../panel/context/documentForm.svelte.js';
|
|
9
8
|
import type { FormContext } from '../../../panel/context/form.svelte.js';
|
|
@@ -33,7 +32,6 @@
|
|
|
33
32
|
const field = $derived(form.useField(path, config));
|
|
34
33
|
// svelte-ignore state_referenced_locally
|
|
35
34
|
const relationConfig = getCollection(config.get.relationTo);
|
|
36
|
-
const relationCollectionCtx = getCollectionContext(relationConfig.slug);
|
|
37
35
|
|
|
38
36
|
let initialized = $state(false);
|
|
39
37
|
// the fetched items
|
|
@@ -205,10 +203,6 @@
|
|
|
205
203
|
}
|
|
206
204
|
// update resssource
|
|
207
205
|
ressource.data?.docs.push(doc);
|
|
208
|
-
// update collection if present
|
|
209
|
-
if (relationCollectionCtx) {
|
|
210
|
-
relationCollectionCtx.addDoc(doc);
|
|
211
|
-
}
|
|
212
206
|
// Set value if not full
|
|
213
207
|
if (isFull) return;
|
|
214
208
|
selectedItems = [...selectedItems, documentToRelationFieldItem(doc)];
|
|
@@ -67,8 +67,7 @@ export function buildEditorConfig(args) {
|
|
|
67
67
|
const titleContext = getTitleContext();
|
|
68
68
|
contexts.set(TITLE_CTX, titleContext);
|
|
69
69
|
contexts.set(CONFIG_CTX, configContext);
|
|
70
|
-
contexts.set(
|
|
71
|
-
contexts.set(API_PROXY.ROOT, apiProxyContext);
|
|
70
|
+
contexts.set(API_PROXY, apiProxyContext);
|
|
72
71
|
contexts.set(USER_CTX, userContext);
|
|
73
72
|
contexts.set(LOCALE_CTX, localeContext);
|
|
74
73
|
feature.extension.config.addOptions = () => {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
} from '../../../../context/collection.svelte.js';
|
|
8
8
|
import { LayoutGrid, List, TextQuote } from '@lucide/svelte';
|
|
9
9
|
|
|
10
|
-
const collection = getCollectionContext(
|
|
10
|
+
const collection = getCollectionContext();
|
|
11
11
|
const listIconClass = $derived(collection.isList() ? 'rz-header-display-mode__icon--active' : '');
|
|
12
12
|
const gridIconClass = $derived(collection.isGrid() ? 'rz-header-display-mode__icon--active' : '');
|
|
13
13
|
const nestedIconClass = $derived(
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import SelectUI from './SelectUI.svelte';
|
|
5
5
|
import Separator from './Separator.svelte';
|
|
6
6
|
|
|
7
|
-
const collection = getCollectionContext(
|
|
7
|
+
const collection = getCollectionContext();
|
|
8
8
|
const showSelectUI = $derived(!collection.isNested());
|
|
9
9
|
const showDisplayMode = $derived(collection.isUpload || collection.config.nested);
|
|
10
10
|
</script>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { getCollectionContext } from '../../../../context/collection.svelte.js';
|
|
5
5
|
import { Search } from '@lucide/svelte';
|
|
6
6
|
|
|
7
|
-
const collection = getCollectionContext(
|
|
7
|
+
const collection = getCollectionContext();
|
|
8
8
|
let searchValue = $state('');
|
|
9
9
|
|
|
10
10
|
$effect(() => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { getCollectionContext } from '../../../../context/collection.svelte.js';
|
|
5
5
|
import { ListChecks, SquareCheck, SquareMinus, Trash } from '@lucide/svelte';
|
|
6
6
|
|
|
7
|
-
const collection = getCollectionContext(
|
|
7
|
+
const collection = getCollectionContext();
|
|
8
8
|
const selectedCount = $derived(collection.selected.length);
|
|
9
9
|
const pluralSuffix = $derived(selectedCount > 1 ? 's' : '');
|
|
10
10
|
const activeListClass = $derived(collection.selectMode ? 'rz-header-select__icon--active' : '');
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
type TableColumn = Partial<FormField> & { name: string; label?: string };
|
|
8
8
|
|
|
9
|
-
const collection = getCollectionContext(
|
|
9
|
+
const collection = getCollectionContext();
|
|
10
10
|
let gridTemplateColumn = $state('grid-template-columns: 2fr repeat(1, minmax(0, 1fr));');
|
|
11
11
|
|
|
12
12
|
$effect(() => {
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
export declare function setAPIProxyContext(
|
|
1
|
+
export declare function setAPIProxyContext(): {
|
|
2
2
|
getRessource: <T>(url: string, options?: GetResourcesOptions<T>) => Resource<T>;
|
|
3
3
|
invalidateAll: () => void;
|
|
4
4
|
invalidate: (pattern: string | RegExp) => void;
|
|
5
5
|
readonly urls: string[];
|
|
6
6
|
};
|
|
7
|
-
export declare function getAPIProxyContext(
|
|
7
|
+
export declare function getAPIProxyContext(): {
|
|
8
8
|
getRessource: <T>(url: string, options?: GetResourcesOptions<T>) => Resource<T>;
|
|
9
9
|
invalidateAll: () => void;
|
|
10
10
|
invalidate: (pattern: string | RegExp) => void;
|
|
11
11
|
readonly urls: string[];
|
|
12
12
|
};
|
|
13
|
-
export declare const API_PROXY:
|
|
14
|
-
ROOT: symbol;
|
|
15
|
-
};
|
|
13
|
+
export declare const API_PROXY: unique symbol;
|
|
16
14
|
export type Resource<T = any> = {
|
|
17
15
|
data: T | null;
|
|
18
16
|
isLoading: boolean;
|
|
@@ -79,13 +79,11 @@ function createAPIProxy() {
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
export function setAPIProxyContext(
|
|
82
|
+
export function setAPIProxyContext() {
|
|
83
83
|
const apiProxy = createAPIProxy();
|
|
84
|
-
return setContext(
|
|
84
|
+
return setContext(API_PROXY, apiProxy);
|
|
85
85
|
}
|
|
86
|
-
export function getAPIProxyContext(
|
|
87
|
-
return getContext(
|
|
86
|
+
export function getAPIProxyContext() {
|
|
87
|
+
return getContext(API_PROXY);
|
|
88
88
|
}
|
|
89
|
-
export const API_PROXY =
|
|
90
|
-
ROOT: Symbol('api-proxy.root')
|
|
91
|
-
};
|
|
89
|
+
export const API_PROXY = Symbol('rime.api-proxy');
|
|
@@ -9,7 +9,8 @@ export declare const DISPLAY_MODE: {
|
|
|
9
9
|
readonly GRID: "display_grid";
|
|
10
10
|
readonly NESTED: "display_nested";
|
|
11
11
|
};
|
|
12
|
-
export declare
|
|
12
|
+
export declare const COLLECTION_CTX: unique symbol;
|
|
13
|
+
export declare function setCollectionContext(args: Args): {
|
|
13
14
|
readonly stamp: number;
|
|
14
15
|
readonly title: string;
|
|
15
16
|
readonly hasDraft: boolean | undefined;
|
|
@@ -43,9 +44,6 @@ export declare function setCollectionContext(key: string, args: Args): {
|
|
|
43
44
|
currentPath: `root${string}`;
|
|
44
45
|
parentDirectory: Directory | null;
|
|
45
46
|
};
|
|
46
|
-
addDoc: (doc: GenericDoc) => void;
|
|
47
|
-
updateDoc: (incomingDoc: GenericDoc) => void;
|
|
48
|
-
deleteDoc: (id: string) => Promise<void>;
|
|
49
47
|
deleteDocs: (ids: string[]) => Promise<void>;
|
|
50
48
|
docs: GenericDoc[];
|
|
51
49
|
readonly length: number;
|
|
@@ -62,7 +60,7 @@ export declare function setCollectionContext(key: string, args: Args): {
|
|
|
62
60
|
};
|
|
63
61
|
}) => Promise<boolean | undefined>;
|
|
64
62
|
};
|
|
65
|
-
export declare function getCollectionContext(
|
|
63
|
+
export declare function getCollectionContext(): {
|
|
66
64
|
readonly stamp: number;
|
|
67
65
|
readonly title: string;
|
|
68
66
|
readonly hasDraft: boolean | undefined;
|
|
@@ -96,9 +94,6 @@ export declare function getCollectionContext(key?: string): {
|
|
|
96
94
|
currentPath: `root${string}`;
|
|
97
95
|
parentDirectory: Directory | null;
|
|
98
96
|
};
|
|
99
|
-
addDoc: (doc: GenericDoc) => void;
|
|
100
|
-
updateDoc: (incomingDoc: GenericDoc) => void;
|
|
101
|
-
deleteDoc: (id: string) => Promise<void>;
|
|
102
97
|
deleteDocs: (ids: string[]) => Promise<void>;
|
|
103
98
|
docs: GenericDoc[];
|
|
104
99
|
readonly length: number;
|
|
@@ -303,32 +303,6 @@ function createCollectionStore(args) {
|
|
|
303
303
|
docs = [...initialDocs];
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
async function deleteDoc(id) {
|
|
307
|
-
const res = await fetch(`/api/${config.kebab}/${id}`, {
|
|
308
|
-
method: 'DELETE',
|
|
309
|
-
headers: {
|
|
310
|
-
'content-type': 'application/json'
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
if (res.status === 200) {
|
|
314
|
-
docs = [...docs].filter((doc) => doc.id !== id);
|
|
315
|
-
}
|
|
316
|
-
else if (res.status === 404) {
|
|
317
|
-
console.error('not found');
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
function addDoc(doc) {
|
|
321
|
-
docs.push(doc);
|
|
322
|
-
sortBy(sortingBy, false);
|
|
323
|
-
}
|
|
324
|
-
function updateDoc(incomingDoc) {
|
|
325
|
-
for (const [index, doc] of docs.entries()) {
|
|
326
|
-
if (doc.id === incomingDoc.id) {
|
|
327
|
-
docs[index] = incomingDoc;
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
306
|
return {
|
|
333
307
|
get stamp() {
|
|
334
308
|
return stamp;
|
|
@@ -412,9 +386,6 @@ function createCollectionStore(args) {
|
|
|
412
386
|
set upload(value) {
|
|
413
387
|
upload = value;
|
|
414
388
|
},
|
|
415
|
-
addDoc,
|
|
416
|
-
updateDoc,
|
|
417
|
-
deleteDoc,
|
|
418
389
|
deleteDocs,
|
|
419
390
|
get docs() {
|
|
420
391
|
return docs;
|
|
@@ -432,11 +403,11 @@ function createCollectionStore(args) {
|
|
|
432
403
|
handleNestedDocumentMove
|
|
433
404
|
};
|
|
434
405
|
}
|
|
435
|
-
const
|
|
436
|
-
export function setCollectionContext(
|
|
406
|
+
export const COLLECTION_CTX = Symbol('rime.collection');
|
|
407
|
+
export function setCollectionContext(args) {
|
|
437
408
|
const store = createCollectionStore(args);
|
|
438
|
-
return setContext(
|
|
409
|
+
return setContext(COLLECTION_CTX, store);
|
|
439
410
|
}
|
|
440
|
-
export function getCollectionContext(
|
|
441
|
-
return getContext(
|
|
411
|
+
export function getCollectionContext() {
|
|
412
|
+
return getContext(COLLECTION_CTX);
|
|
442
413
|
}
|
|
@@ -17,7 +17,6 @@ import { moveItem } from '../../util/array.js';
|
|
|
17
17
|
import { getValueAtPath, setValueAtPath } from '../../util/object.js';
|
|
18
18
|
import { snapshot } from '../../util/state.js';
|
|
19
19
|
import { getAPIProxyContext } from './api-proxy.svelte.js';
|
|
20
|
-
import { getCollectionContext } from './collection.svelte.js';
|
|
21
20
|
import { setErrorsContext } from './errors.svelte.js';
|
|
22
21
|
import { getLocaleContext } from './locale.svelte.js';
|
|
23
22
|
import { getTitleContext } from './title.js';
|
|
@@ -35,7 +34,6 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
35
34
|
const user = getUserContext();
|
|
36
35
|
const errors = setErrorsContext(key);
|
|
37
36
|
const isCollection = documentConfig.type === 'collection';
|
|
38
|
-
const collection = isCollection ? getCollectionContext(documentConfig.slug) : null;
|
|
39
37
|
const hasError = $derived(errors.length);
|
|
40
38
|
const canSubmit = $derived(!isDisabled && !readOnly && Object.keys(changes).length > 0 && !hasError);
|
|
41
39
|
const nestedLevel = initLevel();
|
|
@@ -103,8 +101,6 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
103
101
|
};
|
|
104
102
|
function setValue(path, value) {
|
|
105
103
|
doc = setValueAtPath(path, doc, value);
|
|
106
|
-
if (collection && operation === 'update')
|
|
107
|
-
collection.updateDoc(doc);
|
|
108
104
|
if (onDataChange)
|
|
109
105
|
onDataChange({ path, value });
|
|
110
106
|
}
|
|
@@ -39,7 +39,7 @@ function createErrorsStore() {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const ERRORS_KEY = 'rime.errors';
|
|
42
|
+
export const ERRORS_KEY = 'rime.errors';
|
|
43
43
|
export function setErrorsContext(key = 'root') {
|
|
44
44
|
const errors = createErrorsStore();
|
|
45
45
|
return setContext(`${ERRORS_KEY}.${key}`, errors);
|
|
@@ -5,7 +5,7 @@ import { apiUrl } from '../../util/index.js';
|
|
|
5
5
|
import { toKebabCase } from '../../util/string.js';
|
|
6
6
|
import { getContext, setContext } from 'svelte';
|
|
7
7
|
import { getValueAtPath, isObjectLiteral, setValueAtPath } from '../../util/object.js';
|
|
8
|
-
const LIVE_KEY = Symbol('rime.live');
|
|
8
|
+
export const LIVE_KEY = Symbol('rime.live');
|
|
9
9
|
function createStore(href) {
|
|
10
10
|
let enabled = $state(false);
|
|
11
11
|
let doc = $state();
|
package/dist/panel/index.d.ts
CHANGED
|
@@ -19,6 +19,14 @@ import Dashboard from './pages/dashboard/Dashboard.svelte';
|
|
|
19
19
|
import Live from './pages/live/Live.svelte';
|
|
20
20
|
import type { Route } from './types.js';
|
|
21
21
|
export { Area, AreaVersionsDoc, Button, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, ForgotPassword, Input, Live, Panel, ResetPassword, SignIn, SpinLoader };
|
|
22
|
+
export declare const CONTEXT: {
|
|
23
|
+
COLLECTION: symbol;
|
|
24
|
+
LIVE: symbol;
|
|
25
|
+
API_PROXY: symbol;
|
|
26
|
+
USER: symbol;
|
|
27
|
+
LOCALE: symbol;
|
|
28
|
+
TITLE: string;
|
|
29
|
+
};
|
|
22
30
|
export type { DocumentFormContext } from './context/documentForm.svelte.js';
|
|
23
31
|
export type CollectionProps = {
|
|
24
32
|
data: {
|
package/dist/panel/index.js
CHANGED
|
@@ -4,6 +4,12 @@ import Doc from './components/sections/document/Document.svelte';
|
|
|
4
4
|
import Button from './components/ui/button/button.svelte';
|
|
5
5
|
import Input from './components/ui/input/input.svelte';
|
|
6
6
|
import SpinLoader from './components/ui/spin-loader/SpinLoader.svelte';
|
|
7
|
+
import { API_PROXY } from './context/api-proxy.svelte.js';
|
|
8
|
+
import { COLLECTION_CTX } from './context/collection.svelte.js';
|
|
9
|
+
import { LIVE_KEY } from './context/live.svelte.js';
|
|
10
|
+
import { LOCALE_CTX } from './context/locale.svelte.js';
|
|
11
|
+
import { USER_CTX } from './context/user.svelte.js';
|
|
12
|
+
import { TITLE_CTX } from './context/title.js';
|
|
7
13
|
import Area from './pages/area/Area.svelte';
|
|
8
14
|
import AreaVersionsDoc from './pages/area/AreaVersionsDoc.svelte';
|
|
9
15
|
import ForgotPassword from './pages/auth/forgot-password/ForgotPassword.svelte';
|
|
@@ -17,3 +23,12 @@ import Live from './pages/live/Live.svelte';
|
|
|
17
23
|
export {
|
|
18
24
|
// Components
|
|
19
25
|
Area, AreaVersionsDoc, Button, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, ForgotPassword, Input, Live, Panel, ResetPassword, SignIn, SpinLoader };
|
|
26
|
+
// Context keys, for a plugin/field that needs to read a context rime's own panel sets
|
|
27
|
+
export const CONTEXT = {
|
|
28
|
+
COLLECTION: COLLECTION_CTX,
|
|
29
|
+
LIVE: LIVE_KEY,
|
|
30
|
+
API_PROXY,
|
|
31
|
+
USER: USER_CTX,
|
|
32
|
+
LOCALE: LOCALE_CTX,
|
|
33
|
+
TITLE: TITLE_CTX
|
|
34
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rimecms",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.2",
|
|
4
4
|
"homepage": "https://github.com/bienbiendev/rime",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -96,6 +96,8 @@
|
|
|
96
96
|
"vite": "^8.0.8"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
+
"@changesets/changelog-github": "^1.0.0",
|
|
100
|
+
"@changesets/cli": "^3.0.1",
|
|
99
101
|
"@eslint/compat": "^1.2.5",
|
|
100
102
|
"@eslint/js": "^9.18.0",
|
|
101
103
|
"@sveltejs/adapter-node": "^5.5.4",
|