Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 51 additions & 51 deletions dist/lite/markedit-preview.js

Large diffs are not rendered by default.

608 changes: 304 additions & 304 deletions dist/markedit-preview.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { enableHoverPreview } from './src/features/image';
import { startObserving } from './src/scroll';
import { checkForUpdates, checkForUpdatesThrottled, downloadLatestBuild, fetchLatestRelease, renderUpdatePill } from './src/support/updater';
import { imageHoverPreview, keyboardShortcut, updateBehavior } from './src/support/settings';
import { hasFullHost } from './src/support/host';
import { hasFullHost, hasExtensionManager } from './src/support/host';
import { copyToSharedContainer, setUpQuickLook } from './src/quicklook';
import { localized } from './src/shared/strings';
import { macOSTahoe, hasFilePathInfo } from './src/shared/utils';
Expand Down Expand Up @@ -109,7 +109,7 @@ if (hasFullHost()) {
title: `${localized('checkReleases')} (GitHub)`,
action: () => open('https://github.com/MarkEdit-app/MarkEdit-preview/releases/latest'),
},
...(hasFilePathInfo() ? [{
...(hasFilePathInfo() && !hasExtensionManager() ? [{
title: localized('updateAndRelaunch'),
action: async () => {
const release = await fetchLatestRelease();
Expand Down
14 changes: 14 additions & 0 deletions src/support/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@ import { MarkEdit } from 'markedit-api';
export function hasFullHost(): boolean {
return typeof MarkEdit.addExtension === 'function';
}

/**
* Whether the host ships its own extension manager (MarkEdit 1.34.0+),
* which makes this extension's self-update mechanism redundant.
*/
export function hasExtensionManager(): boolean {
if (typeof MarkEdit.runtimeInfo !== 'function') {
return false;
}

// appVersion is always 3 numeric segments, so numeric collation is a safe comparison
const appVersion = MarkEdit.runtimeInfo().appVersion;
return appVersion.localeCompare('1.34.0', undefined, { numeric: true }) >= 0;
}
Comment thread
cyanzhong marked this conversation as resolved.
5 changes: 5 additions & 0 deletions src/support/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MarkEdit } from 'markedit-api';
import { hasExtensionManager } from './host';
import type { JSONObject, JSONValue } from 'markedit-api';
import type { PresetName } from 'markdown-it';
import type { ColorScheme } from '../shared/types';
Expand All @@ -19,6 +20,10 @@ const updateBehaviors = ['automatic', 'quiet', 'notify', 'never'] as const;
export type UpdateBehavior = (typeof updateBehaviors)[number];

export const updateBehavior: UpdateBehavior = (() => {
if (hasExtensionManager()) {
return 'never';
}
Comment thread
cyanzhong marked this conversation as resolved.

const behavior = rootValue.updateBehavior as string | undefined;
if (behavior && (updateBehaviors as readonly string[]).includes(behavior)) {
return behavior as UpdateBehavior;
Expand Down