@vibes.diy/base 14.3.456 → 14.3.458

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.
@@ -19,7 +19,7 @@ function textAttachment(file, text) {
19
19
  }
20
20
  async function processImage(file) {
21
21
  const bitmap = await decodeToBitmap(file);
22
- if (!bitmap)
22
+ if (bitmap === undefined)
23
23
  return { ok: false, error: "Couldn't decode this image" };
24
24
  const rResult = await exception2Result(async () => {
25
25
  const { width, height } = fitWithin(bitmap.width, bitmap.height, IMAGE_MAX_DIMENSION);
@@ -27,11 +27,11 @@ async function processImage(file) {
27
27
  canvas.width = width;
28
28
  canvas.height = height;
29
29
  const ctx = canvas.getContext("2d");
30
- if (!ctx)
30
+ if (ctx === null)
31
31
  return { ok: false, error: "Couldn't process this image" };
32
32
  ctx.drawImage(bitmap, 0, 0, width, height);
33
33
  const blob = await new Promise((res) => canvas.toBlob(res, "image/jpeg", IMAGE_JPEG_QUALITY));
34
- if (!blob)
34
+ if (blob === null)
35
35
  return { ok: false, error: "Couldn't re-encode this image" };
36
36
  return {
37
37
  ok: true,
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  export function ChatMessageRow({ role, platform, fontSize = "1rem", opacity, rowAttrs, contentAttrs, children, }) {
3
3
  const user = role === "user";
4
4
  return (React.createElement("div", { className: "grid grid-cols-[3.25rem_minmax(0,1fr)] pr-4 pl-2", ...rowAttrs },
5
- React.createElement("div", { className: `pt-[5px] pr-2 text-right font-mono text-[0.6rem] uppercase tracking-wide ${platform ? "text-blue-500 opacity-80 dark:text-blue-400" : "opacity-50"}` }, user && !platform ? "you" : "vibes"),
5
+ React.createElement("div", { className: `pt-[5px] pr-2 text-right font-mono text-[0.6rem] uppercase tracking-wide ${platform ? "text-blue-500 opacity-80 dark:text-blue-400" : "opacity-50"}` }, user && platform !== true ? "you" : "vibes"),
6
6
  React.createElement("div", { ...contentAttrs, className: `relative min-w-0${user ? " bg-black/[0.05] dark:bg-white/[0.06]" : ""}`, style: {
7
7
  borderLeft: `3px solid ${platform ? "rgba(59, 130, 246, 0.55)" : user ? "var(--vibes-card-text)" : "rgba(128,128,128,0.55)"}`,
8
8
  padding: "0.25rem 0.75rem 0.35rem 0.75rem",
@@ -40,7 +40,7 @@ export function NewHandleForm({ busy, onCancel, onCreate, onRandom, }) {
40
40
  const sanitized = sanitizeHandle(draft);
41
41
  const valid = sanitized.length > 0;
42
42
  const submit = () => {
43
- if (valid && !busy)
43
+ if (valid && busy !== true)
44
44
  onCreate(sanitized);
45
45
  };
46
46
  return (React.createElement("div", { style: { padding: "2px 4px 4px" } },
@@ -26,7 +26,7 @@ export function HiddenMenuWrapper({ children, menuContent, triggerBounce, showVi
26
26
  useEffect(() => {
27
27
  const styleId = "vibes-drop-to-close-keyframes";
28
28
  const existingStyle = document.getElementById(styleId);
29
- if (!existingStyle) {
29
+ if (existingStyle === null) {
30
30
  const style = document.createElement("style");
31
31
  style.id = styleId;
32
32
  style.textContent = `
@@ -100,7 +100,7 @@ export function HiddenMenuWrapper({ children, menuContent, triggerBounce, showVi
100
100
  const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
101
101
  useIsomorphicLayoutEffect(() => {
102
102
  const menuEl = menuRef.current;
103
- if (!menuEl)
103
+ if (menuEl === null)
104
104
  return;
105
105
  const scheduleSetHeight = (h) => {
106
106
  if (rafIdRef.current != null && cancelRef.current) {
@@ -153,7 +153,7 @@ export function HiddenMenuWrapper({ children, menuContent, triggerBounce, showVi
153
153
  }, []);
154
154
  useEffect(() => {
155
155
  const menuEl = menuRef.current;
156
- if (!menuEl)
156
+ if (menuEl === null)
157
157
  return;
158
158
  const defer = (cb) => {
159
159
  if (typeof queueMicrotask === "function") {
@@ -1,6 +1,6 @@
1
1
  if (typeof document !== "undefined") {
2
2
  const styleId = "hidden-menu-wrapper-vars";
3
- if (!document.getElementById(styleId)) {
3
+ if (document.getElementById(styleId) === null) {
4
4
  const style = document.createElement("style");
5
5
  style.id = styleId;
6
6
  style.textContent = `
@@ -91,7 +91,7 @@ export function SharePanelView({ url, copied, onCopy, embedSnippet, embedCopied,
91
91
  { value: "request", label: "People you approve" },
92
92
  { value: "public", label: "Anyone with the link" },
93
93
  ].map((opt) => {
94
- const active = !accessPending && opt.value === access;
94
+ const active = accessPending !== true && opt.value === access;
95
95
  const publicAccent = opt.value === "public"
96
96
  ? active
97
97
  ? { background: "var(--vibes-blue, #3b82f6)", borderColor: "var(--vibes-blue, #3b82f6)", color: "#fff" }
@@ -4,10 +4,10 @@ export function SubTabStrip({ tabs, active, onSelect, ariaLabel, compact = false
4
4
  const [moreRight, setMoreRight] = React.useState(false);
5
5
  const ensureActiveVisible = React.useCallback(() => {
6
6
  const list = listRef.current;
7
- if (!list)
7
+ if (list === null)
8
8
  return;
9
9
  const tab = list.querySelector(`[data-tab-key="${CSS.escape(active)}"]`);
10
- if (!tab)
10
+ if (tab === null)
11
11
  return;
12
12
  const style = globalThis.getComputedStyle(list);
13
13
  const padLeft = parseFloat(style.paddingLeft) || 0;
@@ -23,7 +23,7 @@ export function SubTabStrip({ tabs, active, onSelect, ariaLabel, compact = false
23
23
  }, [active]);
24
24
  const measureOverflow = React.useCallback(() => {
25
25
  const list = listRef.current;
26
- if (!list)
26
+ if (list === null)
27
27
  return;
28
28
  setMoreRight(list.scrollWidth - list.clientWidth - list.scrollLeft > 1);
29
29
  }, []);
@@ -31,7 +31,7 @@ export function SubTabStrip({ tabs, active, onSelect, ariaLabel, compact = false
31
31
  ensureActiveVisible();
32
32
  measureOverflow();
33
33
  const list = listRef.current;
34
- if (!list || typeof ResizeObserver === "undefined")
34
+ if (list === null || typeof ResizeObserver === "undefined")
35
35
  return;
36
36
  const ro = new ResizeObserver(() => {
37
37
  ensureActiveVisible();
@@ -34,12 +34,12 @@ export function VibesButton({ variant = "blue", children, onHover, onUnhover, ic
34
34
  isHovered,
35
35
  isActive,
36
36
  isMobile,
37
- hasIcon: !!IconComponent,
37
+ hasIcon: IconComponent !== undefined,
38
38
  });
39
39
  const mergedStyle = VibesButtonStyles.getMergedButtonStyle(baseStyle, ignoreDarkMode, customStyle);
40
- const iconContainerStyle = VibesButtonStyles.getIconContainerStyle(buttonVariant, isMobile, !!IconComponent);
40
+ const iconContainerStyle = VibesButtonStyles.getIconContainerStyle(buttonVariant, isMobile, IconComponent !== undefined);
41
41
  const iconStyle = VibesButtonStyles.getIconStyle(isMobile, isHovered, isActive);
42
- const contentWrapperStyle = VibesButtonStyles.getContentWrapperStyle(isMobile, !!IconComponent);
42
+ const contentWrapperStyle = VibesButtonStyles.getContentWrapperStyle(isMobile, IconComponent !== undefined);
43
43
  return (React.createElement(React.Fragment, null,
44
44
  React.createElement("style", null, bounceKeyframes),
45
45
  React.createElement("button", { ...props, className: className, onMouseEnter: () => setHovered(true), onMouseLeave: () => {
@@ -36,7 +36,7 @@ export function VibesPanel({ style, className, token, } = {}) {
36
36
  };
37
37
  const handleInviteSubmit = (e) => {
38
38
  e.preventDefault();
39
- if (!email.trim())
39
+ if (email.trim() === "")
40
40
  return;
41
41
  setInviteStatus("sending");
42
42
  setInviteMessage("");
@@ -77,7 +77,7 @@ export function VibesPanel({ style, className, token, } = {}) {
77
77
  React.createElement("label", { htmlFor: emailId, style: VibesPanelStyles.getInviteLabelPanelStyle() }, "Invite by email"),
78
78
  React.createElement(BrutalistCard, { size: "md", style: VibesPanelStyles.getInviteInputWrapperPanelStyle() },
79
79
  React.createElement("input", { id: emailId, type: "email", placeholder: "friend@example.com", value: email, onChange: (e) => setEmail(e.target.value), style: VibesPanelStyles.getInviteInputStyle(), autoComplete: "email", required: true })),
80
- React.createElement(VibesButton, { variant: BLUE, type: "submit", disabled: !email.trim() }, "Send Invite"))) : (React.createElement(BrutalistCard, { id: "invite-status", role: "status", "aria-live": "polite", size: "sm", variant: inviteStatus === "sending" ? "default" : inviteStatus === "error" ? "error" : "success", style: VibesPanelStyles.getInviteStatusStyle() }, inviteStatus === "sending" ? "Inviting..." : inviteMessage)),
80
+ React.createElement(VibesButton, { variant: BLUE, type: "submit", disabled: email.trim() === "" }, "Send Invite"))) : (React.createElement(BrutalistCard, { id: "invite-status", role: "status", "aria-live": "polite", size: "sm", variant: inviteStatus === "sending" ? "default" : inviteStatus === "error" ? "error" : "success", style: VibesPanelStyles.getInviteStatusStyle() }, inviteStatus === "sending" ? "Inviting..." : inviteMessage)),
81
81
  React.createElement(VibesButton, { variant: YELLOW, onClick: handleBackClick, icon: "back" }, "Back"))) : (React.createElement(React.Fragment, null,
82
82
  React.createElement(VibesButton, { variant: BLUE, onClick: handleLogoutClick, icon: "login" }, "Logout"),
83
83
  React.createElement(VibesButton, { variant: RED, onClick: handleMutateClick, icon: "remix" }, "Remix"),
@@ -86,7 +86,7 @@ export function ViewerTagView({ slug, displayName, avatarUrl, editable, anonymou
86
86
  }
87
87
  async function handleFileChange(e) {
88
88
  const file = e.target.files?.[0];
89
- if (!file || !onPickFile)
89
+ if (file === undefined || onPickFile === undefined)
90
90
  return;
91
91
  setUploading(true);
92
92
  try {
@@ -1,7 +1,7 @@
1
1
  import type { Result } from "@adviser/cement";
2
2
  export interface ShareFailure {
3
3
  readonly text: string;
4
- retry(): void;
4
+ readonly retry?: () => void;
5
5
  }
6
6
  export type ShareFailures = ReadonlyMap<string, ShareFailure>;
7
7
  export interface ShareActions {
@@ -9,5 +9,9 @@ export interface ShareActions {
9
9
  readonly busy: ReadonlySet<string>;
10
10
  run(key: string, failureText: ShareFailureText, action: () => Promise<Result<void>>): Promise<Result<void>>;
11
11
  }
12
- export type ShareFailureText = string | ((error: Error) => string);
12
+ export interface ShareFinalFailure {
13
+ readonly text: string;
14
+ readonly retry: false;
15
+ }
16
+ export type ShareFailureText = string | ((error: Error) => string | ShareFinalFailure);
13
17
  export declare function useShareActions(): ShareActions;
@@ -1,6 +1,7 @@
1
1
  import { useCallback, useState } from "react";
2
- function failureTextFor(failureText, error) {
3
- return typeof failureText === "string" ? failureText : failureText(error);
2
+ function failureFor(failureText, error, retry) {
3
+ const said = typeof failureText === "string" ? failureText : failureText(error);
4
+ return typeof said === "string" ? { text: said, retry } : { text: said.text };
4
5
  }
5
6
  function withoutKey(failures, key) {
6
7
  if (failures.has(key) === false)
@@ -22,12 +23,9 @@ export function useShareActions() {
22
23
  return next;
23
24
  });
24
25
  if (res.isErr()) {
25
- setFailures((prev) => new Map(prev).set(key, {
26
- text: failureTextFor(failureText, res.Err()),
27
- retry: function retry() {
28
- void runAction(key, failureText, action);
29
- },
30
- }));
26
+ setFailures((prev) => new Map(prev).set(key, failureFor(failureText, res.Err(), function retry() {
27
+ void runAction(key, failureText, action);
28
+ })));
31
29
  }
32
30
  return res;
33
31
  });
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { APPROVE_DATA_ONLY } from "../slices.js";
2
+ import { APPROVE_DATA_ONLY, REQUEST_ALREADY_ANSWERED, REQUEST_ALREADY_IN_OTHER_ROLE } from "../slices.js";
3
3
  import { Chip } from "../parts/Chip.js";
4
4
  import { Row } from "../parts/Row.js";
5
5
  import { MemberRequest, MemberRow, memberDisplayName } from "../parts/MemberRow.js";
@@ -50,7 +50,7 @@ export function FailureLines({ failures, keys }) {
50
50
  return null;
51
51
  return (React.createElement(React.Fragment, null, shown.map(([key, failure]) => (React.createElement("p", { key: key, className: "vm-fail", role: "alert" },
52
52
  React.createElement("span", null, failure.text),
53
- React.createElement(Chip, { label: "Retry", onClick: failure.retry }))))));
53
+ failure.retry === undefined ? null : React.createElement(Chip, { label: "Retry", onClick: failure.retry }))))));
54
54
  }
55
55
  export function PublishLine({ publish }) {
56
56
  if (publish.state === "published")
@@ -63,8 +63,15 @@ export function PublishLine({ publish }) {
63
63
  publish.state === "locked" ? (React.createElement(Chip, { label: "Unlock", onClick: publish.onUnlock })) : (React.createElement(Chip, { label: failed ? "Retry" : "Publish", onClick: publish.onPublish })),
64
64
  publish.state === "old" ? React.createElement(Chip, { label: "View latest", ghost: true, onClick: publish.onViewLatest }) : null));
65
65
  }
66
+ function alreadyAnswered(handle) {
67
+ return { text: `@${handle}'s request was already answered.`, retry: false };
68
+ }
66
69
  function approveFailureText(handle) {
67
70
  return function text(error) {
71
+ if (error.message === REQUEST_ALREADY_ANSWERED)
72
+ return alreadyAnswered(handle);
73
+ if (error.message === REQUEST_ALREADY_IN_OTHER_ROLE)
74
+ return { text: `@${handle} is already in. Change their access under Members.`, retry: false };
68
75
  if (error.message === APPROVE_DATA_ONLY.codeFailed)
69
76
  return `@${handle} has Data access. Code access didn't go through. Try again`;
70
77
  if (error.message === APPROVE_DATA_ONLY.codeNeedsHandle)
@@ -73,7 +80,9 @@ function approveFailureText(handle) {
73
80
  };
74
81
  }
75
82
  export function RequestBlock({ request, share, actions, }) {
76
- return (React.createElement(MemberRequest, { key: request.key, who: request.key, handle: request.handle, ...(request.name === undefined ? {} : { name: request.name }), pending: actions.busy.has(request.key), onApprove: ({ data, code }) => void actions.run(request.key, approveFailureText(request.handle), () => share.onApprove(request.key, data, code)), onDecline: () => void actions.run(request.key, `Couldn't answer @${request.handle}. Try again`, () => share.onDecline(request.key)) }));
83
+ return (React.createElement(MemberRequest, { key: request.key, who: request.key, handle: request.handle, ...(request.name === undefined ? {} : { name: request.name }), pending: actions.busy.has(request.key), onApprove: ({ data, code }) => void actions.run(request.key, approveFailureText(request.handle), () => share.onApprove(request.key, data, code)), onDecline: () => void actions.run(request.key, (error) => error.message === REQUEST_ALREADY_ANSWERED
84
+ ? alreadyAnswered(request.handle)
85
+ : `Couldn't answer @${request.handle}. Try again`, () => share.onDecline(request.key)) }));
77
86
  }
78
87
  export function OwnerMemberRow({ member, share, actions, nav, }) {
79
88
  const failure = `Couldn't change ${memberDisplayName(member)}'s access. Try again`;
@@ -56,7 +56,7 @@ export function nextStepChipText(label) {
56
56
  return `Next: ${head.trimEnd()}…`;
57
57
  }
58
58
  export function nextStepChipLabel(label) {
59
- return `Next idea for your app: ${label.trim()}. Tap to see it and the other ideas.`;
59
+ return `Next idea for your app: ${label.trim()}. Tap to build it.`;
60
60
  }
61
61
  export function pendingChipText(n) {
62
62
  return `${n} waiting`;
@@ -15,10 +15,12 @@ const DETACHED_LAYER_ATTRIBUTES = [
15
15
  "data-vibe-version-menu",
16
16
  "data-vibe-toaster",
17
17
  ];
18
+ const DETACHED_LAYER_CLASSES = ["cl-modalBackdrop"];
18
19
  function isDetachedLayer(node) {
19
20
  if (node instanceof Element === false)
20
21
  return false;
21
- return DETACHED_LAYER_ATTRIBUTES.some((name) => node.hasAttribute(name) === true);
22
+ return (DETACHED_LAYER_ATTRIBUTES.some((name) => node.hasAttribute(name) === true) ||
23
+ DETACHED_LAYER_CLASSES.some((name) => node.classList.contains(name) === true));
22
24
  }
23
25
  function useOutsideClose(input) {
24
26
  const { phase, dispatch, menuRef } = input;
@@ -435,3 +435,5 @@ export declare const APPROVE_DATA_ONLY: Readonly<{
435
435
  readonly codeFailed: "Data access granted. Code access didn't go through.";
436
436
  readonly codeNeedsHandle: "Data access granted. Code access needs their handle.";
437
437
  }>;
438
+ export declare const REQUEST_ALREADY_ANSWERED = "That request was already decided elsewhere.";
439
+ export declare const REQUEST_ALREADY_IN_OTHER_ROLE = "Already in with a different access level.";
@@ -2,3 +2,5 @@ export const APPROVE_DATA_ONLY = Object.freeze({
2
2
  codeFailed: "Data access granted. Code access didn't go through.",
3
3
  codeNeedsHandle: "Data access granted. Code access needs their handle.",
4
4
  });
5
+ export const REQUEST_ALREADY_ANSWERED = "That request was already decided elsewhere.";
6
+ export const REQUEST_ALREADY_IN_OTHER_ROLE = "Already in with a different access level.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/base",
3
- "version": "14.3.456",
3
+ "version": "14.3.458",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -10,10 +10,10 @@
10
10
  "dependencies": {
11
11
  "@adviser/cement": "~0.5.37",
12
12
  "@emotion/css": "~11.13.5",
13
- "@vibes.diy/api-types": "14.3.456",
14
- "@vibes.diy/use-vibes-types": "14.3.456",
15
- "@vibes.diy/vibe-runtime": "14.3.456",
16
- "@vibes.diy/vibe-types": "14.3.456",
13
+ "@vibes.diy/api-types": "14.3.458",
14
+ "@vibes.diy/use-vibes-types": "14.3.458",
15
+ "@vibes.diy/vibe-runtime": "14.3.458",
16
+ "@vibes.diy/vibe-types": "14.3.458",
17
17
  "arktype": "~2.2.10",
18
18
  "officeparser": "~8.9.0",
19
19
  "qrcode-generator": "~2.0.4",
@@ -34,7 +34,7 @@ function encodeCanvas(canvas, mimeType, quality) {
34
34
  }
35
35
  export async function normalizeAvatarImage(file, maxDim = AVATAR_MAX_DIMENSION) {
36
36
  const bitmap = await decodeToBitmap(file);
37
- if (!bitmap)
37
+ if (bitmap === undefined)
38
38
  return file;
39
39
  try {
40
40
  if (!bitmap.width || !bitmap.height)
@@ -46,11 +46,11 @@ export async function normalizeAvatarImage(file, maxDim = AVATAR_MAX_DIMENSION)
46
46
  canvas.width = width;
47
47
  canvas.height = height;
48
48
  const ctx = canvas.getContext("2d");
49
- if (!ctx)
49
+ if (ctx === null)
50
50
  return file;
51
51
  ctx.drawImage(bitmap, 0, 0, width, height);
52
52
  const blob = await encodeCanvas(canvas, "image/webp", WEBP_QUALITY);
53
- if (!blob || !blob.type.startsWith("image/"))
53
+ if (blob === null || !blob.type.startsWith("image/"))
54
54
  return file;
55
55
  const ext = blob.type.slice("image/".length);
56
56
  return new File([blob], `avatar.${ext}`, { type: blob.type });