@rebasepro/app 0.22.0 → 0.23.0

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.
@@ -20,6 +20,17 @@ export declare function removeEntityFromMemoryCache(path: string): void;
20
20
  */
21
21
  export declare function saveEntityToMemoryCache(path: string, data: object): void;
22
22
  export declare function getEntityFromMemoryCache(path: string): object | undefined;
23
+ /**
24
+ * Drops every edit in flight. They were parked by a user who is no longer
25
+ * signed in, so nobody is taking them over.
26
+ */
27
+ export declare function clearEntityMemoryCache(): void;
28
+ /**
29
+ * Drops the whole local-changes backup: every draft in `sessionStorage`, for
30
+ * every record. For when the drafts belong to somebody other than the user now
31
+ * signed in.
32
+ */
33
+ export declare function clearEntityDrafts(): void;
23
34
  /**
24
35
  * Retrieves a entity from the local-changes backup in `sessionStorage`.
25
36
  *
@@ -50,6 +50,12 @@ export declare function transformCollectionSource(code: string, id: string): {
50
50
  * every call site.
51
51
  */
52
52
  export declare function rebaseCollectionsPlugin(options: RebaseCollectionsPluginOptions): Plugin;
53
+ /**
54
+ * Whether a module id is a file inside `directory`, whichever separators
55
+ * either was written with. On a whole path segment, so `collections-old/` is
56
+ * not inside `collections`.
57
+ */
58
+ export declare function isInsideDirectory(id: string, directory: string): boolean;
53
59
  /**
54
60
  * How the admin's dependencies are split into cached chunks.
55
61
  *
@@ -61,10 +61,13 @@ function rebaseCollectionsPlugin(options) {
61
61
  const virtualModuleId = "virtual:rebase-collections";
62
62
  const resolvedVirtualModuleId = "\0" + virtualModuleId;
63
63
  let resolvedCollectionsDir;
64
+ let collectionsDirGlob;
64
65
  return {
65
66
  name: "rebase-collections-plugin",
66
67
  configResolved(config) {
67
68
  resolvedCollectionsDir = path.isAbsolute(options.collectionsDir) ? options.collectionsDir : path.resolve(config.root, options.collectionsDir);
69
+ const fromRoot = toModuleIdPath(path.relative(config.root, resolvedCollectionsDir));
70
+ collectionsDirGlob = fromRoot ? "/" + fromRoot : "";
68
71
  },
69
72
  /**
70
73
  * Watch the collections directory itself, not just the files in it.
@@ -103,10 +106,13 @@ function rebaseCollectionsPlugin(options) {
103
106
  },
104
107
  load(id) {
105
108
  if (id === resolvedVirtualModuleId) {
106
- const globPath = options.collectionsDir.startsWith("/") ? `${options.collectionsDir}/*.ts` : `/${options.collectionsDir}/*.ts`;
109
+ const globPatterns = [
110
+ `${collectionsDirGlob}/*.ts`,
111
+ `!${collectionsDirGlob}/*.test.*`
112
+ ];
107
113
  return `
108
114
  // GENERATED BY @rebasepro/app Vite Plugin
109
- const collectionModules = import.meta.glob('${globPath}', { eager: true });
115
+ const collectionModules = import.meta.glob(${JSON.stringify(globPatterns)}, { eager: true });
110
116
 
111
117
  // index exports the directory's defaults, not a collection \u2014
112
118
  // it has no default export, so it drops out of the list below.
@@ -159,12 +165,19 @@ function rebaseCollectionsPlugin(options) {
159
165
  */
160
166
  transform(code, id) {
161
167
  if (!resolvedCollectionsDir) return null;
162
- if (!id.startsWith(resolvedCollectionsDir)) return null;
168
+ if (!isInsideDirectory(id, resolvedCollectionsDir)) return null;
163
169
  if (!/\.tsx?$/.test(id)) return null;
164
170
  return transformCollectionSource(code, id);
165
171
  }
166
172
  };
167
173
  }
174
+ function toModuleIdPath(filePath) {
175
+ return filePath.replace(/\\/g, "/");
176
+ }
177
+ function isInsideDirectory(id, directory) {
178
+ const dir = toModuleIdPath(directory);
179
+ return toModuleIdPath(id).startsWith(dir.endsWith("/") ? dir : dir + "/");
180
+ }
168
181
  function rebaseManualChunks(id) {
169
182
  if (id.includes("commonjsHelpers") || id.includes("commonjs-dynamic-modules")) return "vendor-commonjs-helpers";
170
183
  if (id.includes("exceljs")) return "vendor-exceljs";
@@ -190,6 +203,7 @@ function rebaseManualChunks(id) {
190
203
  return void 0;
191
204
  }
192
205
  export {
206
+ isInsideDirectory,
193
207
  rebaseCollectionsPlugin,
194
208
  rebaseManualChunks,
195
209
  transformCollectionSource
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/app",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Rebase core — framework-agnostic runtime for data-driven admin panels",
5
5
  "keywords": [
6
6
  "rebase",
@@ -63,12 +63,12 @@
63
63
  "magic-string": "^0.30.0",
64
64
  "notistack": "^3.0.2",
65
65
  "react-i18next": "^17.0.11",
66
- "@rebasepro/cms-types": "0.22.0",
67
- "@rebasepro/forms": "0.22.0",
68
- "@rebasepro/utils": "0.22.0",
69
- "@rebasepro/common": "0.22.0",
70
- "@rebasepro/ui": "0.22.0",
71
- "@rebasepro/types": "0.22.0"
66
+ "@rebasepro/cms-types": "0.23.0",
67
+ "@rebasepro/types": "0.23.0",
68
+ "@rebasepro/common": "0.23.0",
69
+ "@rebasepro/ui": "0.23.0",
70
+ "@rebasepro/forms": "0.23.0",
71
+ "@rebasepro/utils": "0.23.0"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "react": "^19.2.7",