rimecms 1.1.0 → 1.1.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.
@@ -77,7 +77,9 @@ export class BlocksBuilder extends FormFieldBuilder {
77
77
  .map((block) => {
78
78
  const blockTypeName = `Block${toPascalCase(block.name)}`;
79
79
  blockNames.push(blockTypeName);
80
- const fieldsType = joinMemberTypes(block.get.fields.map((f) => f.use.generateType()));
80
+ // `type` is written above as the block's name, so its hidden field stays out.
81
+ const fields = block.get.fields.filter((f) => f.name !== 'type');
82
+ const fieldsType = joinMemberTypes(fields.map((f) => f.use.generateType()));
81
83
  return dedent `
82
84
  //@shared:start ${blockTypeName}
83
85
  export type ${blockTypeName} = {
@@ -3,30 +3,18 @@ import type { Relation } from './index.js';
3
3
  /**
4
4
  * Checks if a relation field's value is populated with full documents.
5
5
  *
6
- * A relation is considered populated if it is an array of objects that do not
7
- * contain only the relation identifiers (`id`, `relationTo`, `documentId`).
8
- * If the value is a string or an array of relation identifier objects,
9
- * it is considered not populated.
6
+ * A relation is populated when it is a non-empty array of documents: objects that are not
7
+ * relation references (`id`, `relationTo`, `documentId`). Anything else is not populated.
10
8
  *
11
9
  * @example
12
- * // Returns: false
13
- * isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd');
14
- *
15
- * @example
16
- * // Returns: false
17
- * isRelationPopulated([]);
18
- *
19
- * @example
20
- * // Returns: false
21
- * isRelationPopulated([
22
- * {
23
- * id: '7674e91b-598a-4a72-a5cd-9594736a34dd',
24
- * relationTo: 'articles',
25
- * documentId: 'b674e91b-598a-4a72-a5cd-9594736a34dd'
26
- * }
27
- * ]);
10
+ * isRelationPopulated([{ id: '7674…', title: 'Home' }]); // true
11
+ * isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd'); // false
12
+ * isRelationPopulated([{ id: '7674…', relationTo: 'articles', documentId: 'b674…' }]); // false
13
+ * isRelationPopulated([]); // false
14
+ * isRelationPopulated(undefined); // false
15
+ * isRelationPopulated(null); // false
28
16
  */
29
- export declare const isRelationPopulated: <T>(value: RelationValue<T>) => value is T[];
17
+ export declare const isRelationPopulated: <T>(value: RelationValue<T> | null | undefined) => value is T[];
30
18
  /**
31
19
  * Checks if a relation value is resolved (contains the actual referenced document).
32
20
  *
@@ -2,38 +2,21 @@ import { hasProps, isObjectLiteral } from '../../util/object.js';
2
2
  /**
3
3
  * Checks if a relation field's value is populated with full documents.
4
4
  *
5
- * A relation is considered populated if it is an array of objects that do not
6
- * contain only the relation identifiers (`id`, `relationTo`, `documentId`).
7
- * If the value is a string or an array of relation identifier objects,
8
- * it is considered not populated.
5
+ * A relation is populated when it is a non-empty array of documents: objects that are not
6
+ * relation references (`id`, `relationTo`, `documentId`). Anything else is not populated.
9
7
  *
10
8
  * @example
11
- * // Returns: false
12
- * isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd');
13
- *
14
- * @example
15
- * // Returns: false
16
- * isRelationPopulated([]);
17
- *
18
- * @example
19
- * // Returns: false
20
- * isRelationPopulated([
21
- * {
22
- * id: '7674e91b-598a-4a72-a5cd-9594736a34dd',
23
- * relationTo: 'articles',
24
- * documentId: 'b674e91b-598a-4a72-a5cd-9594736a34dd'
25
- * }
26
- * ]);
9
+ * isRelationPopulated([{ id: '7674…', title: 'Home' }]); // true
10
+ * isRelationPopulated('7674e91b-598a-4a72-a5cd-9594736a34dd'); // false
11
+ * isRelationPopulated([{ id: '7674…', relationTo: 'articles', documentId: 'b674…' }]); // false
12
+ * isRelationPopulated([]); // false
13
+ * isRelationPopulated(undefined); // false
14
+ * isRelationPopulated(null); // false
27
15
  */
28
16
  export const isRelationPopulated = (value) => {
29
- if (Array.isArray(value)) {
30
- if (value.length === 0)
31
- return false;
32
- return value.every((v) => {
33
- return isObjectLiteral(v) && !hasProps(['id', 'relationTo', 'documentId'], v);
34
- });
35
- }
36
- return typeof value !== 'string';
17
+ if (!Array.isArray(value) || value.length === 0)
18
+ return false;
19
+ return value.every((v) => isObjectLiteral(v) && !hasProps(['id', 'relationTo', 'documentId'], v));
37
20
  };
38
21
  /**
39
22
  * Checks if a relation value is resolved (contains the actual referenced document).
@@ -1,16 +1,20 @@
1
1
  import { page } from '$app/state';
2
- import { env } from '$env/dynamic/public';
3
2
  import { PARAMS } from '../core/constants.js';
4
3
  import { getContext, setContext } from 'svelte';
5
4
  import { getValueAtPath, setValueAtPath } from '../util/object.js';
6
5
  import { populate } from '../fields/relation/populate.js';
7
6
  export const LIVE_KEY = Symbol('rime.live');
7
+ /**
8
+ * The panel's origin, the only one whose messages are read. `$env/dynamic/public` loads with the
9
+ * first message, so `rimecms/public` imports outside a SvelteKit page, in a component spec.
10
+ */
11
+ let panelOrigin;
12
+ const getPanelOrigin = () => (panelOrigin ??= import('$env/dynamic/public').then(({ env }) => new URL(env.PUBLIC_RIME_URL).origin));
8
13
  function createStore(href) {
9
14
  let enabled = $state(false);
10
15
  let doc = $state();
11
16
  const liveStore = $state({});
12
17
  let activePanelKey = $state(null);
13
- const origin = new URL(env.PUBLIC_RIME_URL).origin;
14
18
  /**
15
19
  * Handles navigation within iframe to maintain live editing mode
16
20
  */
@@ -28,7 +32,7 @@ function createStore(href) {
28
32
  */
29
33
  const onMessage = async (e) => {
30
34
  // Only accept messages from the trusted panel origin
31
- if (e.origin !== origin)
35
+ if (e.origin !== (await getPanelOrigin()))
32
36
  return;
33
37
  // Handle handshake request
34
38
  if (e.data.handshake) {
@@ -12,7 +12,6 @@
12
12
  let {
13
13
  open = $bindable(false),
14
14
  ref = $bindable(null),
15
- value = $bindable(''),
16
15
  preventScroll = true,
17
16
  onCloseAutoFocus,
18
17
  children,
@@ -26,14 +25,9 @@
26
25
  } = $props();
27
26
  </script>
28
27
 
28
+ <!-- The command mounts with each opening, so its selection starts on the first line. -->
29
29
  <Dialog.Root bind:open {...restProps}>
30
30
  <Dialog.Content class="rz-command-dialog-content" {preventScroll} {onCloseAutoFocus}>
31
- <Command
32
- class="rz-command-dialog-content__command"
33
- {...restProps}
34
- bind:value
35
- bind:ref
36
- {children}
37
- />
31
+ <Command class="rz-command-dialog-content__command" {...restProps} bind:ref {children} />
38
32
  </Dialog.Content>
39
33
  </Dialog.Root>
@@ -7,6 +7,6 @@ type $$ComponentProps = WithoutChildrenOrChild<DialogPrimitive.RootProps> & With
7
7
  /** The dialog is giving the focus back to where it was. */
8
8
  onCloseAutoFocus?: (event: Event) => void;
9
9
  };
10
- declare const CommandDialog: import("svelte").Component<$$ComponentProps, {}, "value" | "ref" | "open">;
10
+ declare const CommandDialog: import("svelte").Component<$$ComponentProps, {}, "ref" | "open">;
11
11
  type CommandDialog = ReturnType<typeof CommandDialog>;
12
12
  export default CommandDialog;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimecms",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "homepage": "https://github.com/bienbiendev/rime",
5
5
  "packageManager": "bun@1.3.0",
6
6
  "scripts": {
@@ -235,7 +235,7 @@
235
235
  "ast-kit": "^2.1.2",
236
236
  "autoprefixer": "^10.4.21",
237
237
  "better-auth": "1.7.4",
238
- "bits-ui": "2.8.0",
238
+ "bits-ui": "2.19.3",
239
239
  "camelcase": "^8.0.0",
240
240
  "chalk": "^5.6.2",
241
241
  "clone-deep": "^4.0.1",
@@ -1,7 +0,0 @@
1
- import { Tooltip as TooltipPrimitive } from 'bits-ui';
2
- import Content from './tooltip-content.svelte';
3
- declare const Root: import("svelte").Component<TooltipPrimitive.RootProps, {}, "open">;
4
- declare const Portal: import("svelte").Component<TooltipPrimitive.PortalProps, {}, "">;
5
- declare const Trigger: import("svelte").Component<TooltipPrimitive.TriggerProps, {}, "ref">;
6
- declare const Provider: import("svelte").Component<TooltipPrimitive.ProviderProps, {}, "">;
7
- export { Root, Portal, Trigger, Content, Provider, Root as Tooltip, Portal as TooltipPortal, Content as TooltipContent, Trigger as TooltipTrigger, Provider as TooltipProvider };