commit 6e12dfa61dece1510442a3508f3e7885b3854a7e Author: relikd Date: Tue Jul 29 11:54:12 2025 +0200 Initial diff --git a/App/AppDelegate.swift b/App/AppDelegate.swift new file mode 100644 index 0000000..e068ba5 --- /dev/null +++ b/App/AppDelegate.swift @@ -0,0 +1,18 @@ +import Cocoa + +@main +class AppDelegate: NSObject, NSApplicationDelegate { + @IBOutlet var window: NSWindow! + + func applicationDidFinishLaunching(_ aNotification: Notification) { + // Insert code here to initialize your application + } + + func applicationWillTerminate(_ aNotification: Notification) { + // Insert code here to tear down your application + } + + func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } +} diff --git a/App/AppIcon.icns b/App/AppIcon.icns new file mode 100644 index 0000000..b1a73d2 Binary files /dev/null and b/App/AppIcon.icns differ diff --git a/App/Info.plist b/App/Info.plist new file mode 100644 index 0000000..c369f99 --- /dev/null +++ b/App/Info.plist @@ -0,0 +1,8 @@ + + + + + CFBundleIconFile + AppIcon + + diff --git a/App/MainMenu.xib b/App/MainMenu.xib new file mode 100644 index 0000000..6e0173a --- /dev/null +++ b/App/MainMenu.xib @@ -0,0 +1,712 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Use System Settings to de-/activate +the QuickLook extension + + + + + + + + + + + + + diff --git a/App/QLJSON.entitlements b/App/QLJSON.entitlements new file mode 100644 index 0000000..18aff0c --- /dev/null +++ b/App/QLJSON.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2ae8a0f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 relikd + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/QLJSON.xcodeproj/project.pbxproj b/QLJSON.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e3f112e --- /dev/null +++ b/QLJSON.xcodeproj/project.pbxproj @@ -0,0 +1,517 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + 548076412E38D22300C2D26A /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 548076402E38D22300C2D26A /* Quartz.framework */; }; + 5480764E2E38D22300C2D26A /* QLJSON PreviewExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 5480763E2E38D22300C2D26A /* QLJSON PreviewExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 548078302E38DC7400C2D26A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 548078282E38DC7400C2D26A /* AppDelegate.swift */; }; + 5480783B2E38DC7700C2D26A /* script.js in Resources */ = {isa = PBXBuildFile; fileRef = 548078362E38DC7700C2D26A /* script.js */; }; + 5480783C2E38DC7700C2D26A /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = 548078372E38DC7700C2D26A /* style.css */; }; + 5480783D2E38DC7700C2D26A /* PreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 548078322E38DC7700C2D26A /* PreviewViewController.swift */; }; + 549F368A2E3A518700585F61 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 549F36892E3A518700585F61 /* MainMenu.xib */; }; + 549F368C2E3A519E00585F61 /* PreviewViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 549F368B2E3A519E00585F61 /* PreviewViewController.xib */; }; + 54B0BEC62E3A63FC006BDEC5 /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 54B0BEC52E3A63FC006BDEC5 /* AppIcon.icns */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 5480764C2E38D22300C2D26A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 548076222E38D1C200C2D26A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5480763D2E38D22300C2D26A; + remoteInfo = QLPreview; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 548076532E38D22300C2D26A /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 5480764E2E38D22300C2D26A /* QLJSON PreviewExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 5448B6DE2E396DB900FB70FD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; + 5480762A2E38D1C200C2D26A /* QLJSON.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QLJSON.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 5480763E2E38D22300C2D26A /* QLJSON PreviewExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "QLJSON PreviewExtension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + 548076402E38D22300C2D26A /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; }; + 548078282E38DC7400C2D26A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 5480782C2E38DC7400C2D26A /* QLJSON.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = QLJSON.entitlements; sourceTree = ""; }; + 548078312E38DC7700C2D26A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 548078322E38DC7700C2D26A /* PreviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewViewController.swift; sourceTree = ""; }; + 548078352E38DC7700C2D26A /* QLPreview.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = QLPreview.entitlements; sourceTree = ""; }; + 548078362E38DC7700C2D26A /* script.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = script.js; sourceTree = ""; }; + 548078372E38DC7700C2D26A /* style.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = style.css; sourceTree = ""; }; + 549F36892E3A518700585F61 /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; + 549F368B2E3A519E00585F61 /* PreviewViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PreviewViewController.xib; sourceTree = ""; }; + 54B0BEC52E3A63FC006BDEC5 /* AppIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon.icns; sourceTree = ""; }; + 54B0BEC72E3A64DA006BDEC5 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 548076272E38D1C200C2D26A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5480763B2E38D22300C2D26A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 548076412E38D22300C2D26A /* Quartz.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 548076212E38D1C200C2D26A = { + isa = PBXGroup; + children = ( + 54B0BEC72E3A64DA006BDEC5 /* README.md */, + 5480782D2E38DC7400C2D26A /* App */, + 548078382E38DC7700C2D26A /* QLPreview */, + 5480763F2E38D22300C2D26A /* Frameworks */, + 5480762B2E38D1C200C2D26A /* Products */, + ); + sourceTree = ""; + }; + 5480762B2E38D1C200C2D26A /* Products */ = { + isa = PBXGroup; + children = ( + 5480762A2E38D1C200C2D26A /* QLJSON.app */, + 5480763E2E38D22300C2D26A /* QLJSON PreviewExtension.appex */, + ); + name = Products; + sourceTree = ""; + }; + 5480763F2E38D22300C2D26A /* Frameworks */ = { + isa = PBXGroup; + children = ( + 548076402E38D22300C2D26A /* Quartz.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 5480782D2E38DC7400C2D26A /* App */ = { + isa = PBXGroup; + children = ( + 54B0BEC52E3A63FC006BDEC5 /* AppIcon.icns */, + 5448B6DE2E396DB900FB70FD /* Info.plist */, + 548078282E38DC7400C2D26A /* AppDelegate.swift */, + 549F36892E3A518700585F61 /* MainMenu.xib */, + 5480782C2E38DC7400C2D26A /* QLJSON.entitlements */, + ); + path = App; + sourceTree = ""; + }; + 548078382E38DC7700C2D26A /* QLPreview */ = { + isa = PBXGroup; + children = ( + 548078312E38DC7700C2D26A /* Info.plist */, + 548078322E38DC7700C2D26A /* PreviewViewController.swift */, + 549F368B2E3A519E00585F61 /* PreviewViewController.xib */, + 548078352E38DC7700C2D26A /* QLPreview.entitlements */, + 548078362E38DC7700C2D26A /* script.js */, + 548078372E38DC7700C2D26A /* style.css */, + ); + path = QLPreview; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 548076292E38D1C200C2D26A /* App */ = { + isa = PBXNativeTarget; + buildConfigurationList = 548076372E38D1C300C2D26A /* Build configuration list for PBXNativeTarget "App" */; + buildPhases = ( + 548076262E38D1C200C2D26A /* Sources */, + 548076272E38D1C200C2D26A /* Frameworks */, + 548076282E38D1C200C2D26A /* Resources */, + 548076532E38D22300C2D26A /* Embed Foundation Extensions */, + ); + buildRules = ( + ); + dependencies = ( + 5480764D2E38D22300C2D26A /* PBXTargetDependency */, + ); + name = App; + packageProductDependencies = ( + ); + productName = QLJSON; + productReference = 5480762A2E38D1C200C2D26A /* QLJSON.app */; + productType = "com.apple.product-type.application"; + }; + 5480763D2E38D22300C2D26A /* QL Preview */ = { + isa = PBXNativeTarget; + buildConfigurationList = 548076502E38D22300C2D26A /* Build configuration list for PBXNativeTarget "QL Preview" */; + buildPhases = ( + 5480763A2E38D22300C2D26A /* Sources */, + 5480763B2E38D22300C2D26A /* Frameworks */, + 5480763C2E38D22300C2D26A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "QL Preview"; + packageProductDependencies = ( + ); + productName = QLPreview; + productReference = 5480763E2E38D22300C2D26A /* QLJSON PreviewExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 548076222E38D1C200C2D26A /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1640; + LastUpgradeCheck = 1640; + TargetAttributes = { + 548076292E38D1C200C2D26A = { + CreatedOnToolsVersion = 16.4; + }; + 5480763D2E38D22300C2D26A = { + CreatedOnToolsVersion = 16.4; + }; + }; + }; + buildConfigurationList = 548076252E38D1C200C2D26A /* Build configuration list for PBXProject "QLJSON" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 548076212E38D1C200C2D26A; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = 5480762B2E38D1C200C2D26A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 548076292E38D1C200C2D26A /* App */, + 5480763D2E38D22300C2D26A /* QL Preview */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 548076282E38D1C200C2D26A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 549F368A2E3A518700585F61 /* MainMenu.xib in Resources */, + 54B0BEC62E3A63FC006BDEC5 /* AppIcon.icns in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5480763C2E38D22300C2D26A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 549F368C2E3A519E00585F61 /* PreviewViewController.xib in Resources */, + 5480783B2E38DC7700C2D26A /* script.js in Resources */, + 5480783C2E38DC7700C2D26A /* style.css in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 548076262E38D1C200C2D26A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 548078302E38DC7400C2D26A /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5480763A2E38D22300C2D26A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5480783D2E38DC7700C2D26A /* PreviewViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 5480764D2E38D22300C2D26A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 5480763D2E38D22300C2D26A /* QL Preview */; + targetProxy = 5480764C2E38D22300C2D26A /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 548076352E38D1C300C2D26A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 220; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = UY657LKNHJ; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MARKETING_VERSION = 1.0.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 548076362E38D1C300C2D26A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 220; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = UY657LKNHJ; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MARKETING_VERSION = 1.0.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + 548076382E38D1C300C2D26A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = App/QLJSON.entitlements; + COMBINE_HIDPI_IMAGES = YES; + ENABLE_HARDENED_RUNTIME = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = App/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = QLJSON; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSMainNibFile = MainMenu; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = de.relikd.QLJSON; + PRODUCT_NAME = "$(PROJECT_NAME)"; + REGISTER_APP_GROUPS = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 548076392E38D1C300C2D26A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = App/QLJSON.entitlements; + COMBINE_HIDPI_IMAGES = YES; + ENABLE_HARDENED_RUNTIME = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = App/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = QLJSON; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSMainNibFile = MainMenu; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = de.relikd.QLJSON; + PRODUCT_NAME = "$(PROJECT_NAME)"; + REGISTER_APP_GROUPS = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 548076512E38D22300C2D26A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = QLPreview/QLPreview.entitlements; + ENABLE_HARDENED_RUNTIME = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = QLPreview/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "QLJSON PreviewExtension"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@executable_path/../../../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = de.relikd.QLJSON.Preview; + PRODUCT_NAME = "$(PROJECT_NAME) PreviewExtension"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 548076522E38D22300C2D26A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = QLPreview/QLPreview.entitlements; + ENABLE_HARDENED_RUNTIME = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = QLPreview/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "QLJSON PreviewExtension"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@executable_path/../../../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = de.relikd.QLJSON.Preview; + PRODUCT_NAME = "$(PROJECT_NAME) PreviewExtension"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 548076252E38D1C200C2D26A /* Build configuration list for PBXProject "QLJSON" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 548076352E38D1C300C2D26A /* Debug */, + 548076362E38D1C300C2D26A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 548076372E38D1C300C2D26A /* Build configuration list for PBXNativeTarget "App" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 548076382E38D1C300C2D26A /* Debug */, + 548076392E38D1C300C2D26A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 548076502E38D22300C2D26A /* Build configuration list for PBXNativeTarget "QL Preview" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 548076512E38D22300C2D26A /* Debug */, + 548076522E38D22300C2D26A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 548076222E38D1C200C2D26A /* Project object */; +} diff --git a/QLJSON.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/QLJSON.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/QLJSON.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/QLJSON.xcodeproj/xcshareddata/xcschemes/QL Preview.xcscheme b/QLJSON.xcodeproj/xcshareddata/xcschemes/QL Preview.xcscheme new file mode 100644 index 0000000..b2df42c --- /dev/null +++ b/QLJSON.xcodeproj/xcshareddata/xcschemes/QL Preview.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QLJSON.xcodeproj/xcshareddata/xcschemes/QLJSON.xcscheme b/QLJSON.xcodeproj/xcshareddata/xcschemes/QLJSON.xcscheme new file mode 100644 index 0000000..a87b603 --- /dev/null +++ b/QLJSON.xcodeproj/xcshareddata/xcschemes/QLJSON.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QLPreview/Info.plist b/QLPreview/Info.plist new file mode 100644 index 0000000..166b5a5 --- /dev/null +++ b/QLPreview/Info.plist @@ -0,0 +1,24 @@ + + + + + NSExtension + + NSExtensionAttributes + + QLIsDataBasedPreview + + QLSupportedContentTypes + + public.json + + QLSupportsSearchableItems + + + NSExtensionPointIdentifier + com.apple.quicklook.preview + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).PreviewViewController + + + diff --git a/QLPreview/PreviewViewController.swift b/QLPreview/PreviewViewController.swift new file mode 100644 index 0000000..3dfac2c --- /dev/null +++ b/QLPreview/PreviewViewController.swift @@ -0,0 +1,42 @@ +import Cocoa +import Quartz +import WebKit + +class PreviewViewController: NSViewController, QLPreviewingController { + func bundleFile(filename: String, ext: String) throws -> String { + if let appSupport = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first { + let override = appSupport.appendingPathComponent(filename + "." + ext) + if FileManager.default.fileExists(atPath: override.path) { + return try String(contentsOfFile: override.path, encoding: .utf8) + } + } + // else, load bundle file + let path = Bundle.main.path(forResource: filename, ofType: ext) + return try String(contentsOfFile: path!, encoding: .utf8) + } + + func preparePreviewOfFile(at url: URL) async throws { + let jsonFile = try String(contentsOf: url, encoding: .utf8) + let html = """ + + + + + + + + + + + +""" + + // sure, we could use `WKWebView`, but that requires the `com.apple.security.network.client` entitlement + //let web = WKWebView(frame: self.view.bounds) + let web = WebView(frame: self.view.bounds) + web.autoresizingMask = [.width, .height] + self.view.addSubview(web) + web.mainFrame.loadHTMLString(html, baseURL: nil) // WebView + //web.loadHTMLString(html, baseURL: nil) // WKWebView + } +} diff --git a/QLPreview/PreviewViewController.xib b/QLPreview/PreviewViewController.xib new file mode 100644 index 0000000..32b474e --- /dev/null +++ b/QLPreview/PreviewViewController.xib @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/QLPreview/QLPreview.entitlements b/QLPreview/QLPreview.entitlements new file mode 100644 index 0000000..18aff0c --- /dev/null +++ b/QLPreview/QLPreview.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/QLPreview/script.js b/QLPreview/script.js new file mode 100644 index 0000000..bf47fa7 --- /dev/null +++ b/QLPreview/script.js @@ -0,0 +1,106 @@ +// data types + +function nullV() { return 'null'; } +function boolV(val) { return '' + html(val) + ''; } +function numV(val) { return '' + html(val) + ''; } +function stringV(val) { return '"' + jstr(val) + '"'; } +function linkV(val) { return '"' + jstr(val) + '"'; } +function propK(key) { return '"' + jstr(key) + '"'; } + +function wrapJSONP(callback, json, suffix) { + return `${callback}(${json})${suffix}`; +} +function errorPage(error, json) { + return '

Error parsing JSON:
' + error + '

Content:

' + html(json) + '
'; +} + +// helper + +function indent(nl, level) { return nl ? nl + '  '.repeat(level) : ''; } +function jstr(s) { return html(JSON.stringify(s).slice(1, -1)); } +function html(s) { + return (s + '').replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>'); +} + +// formatter entry point + +function init() { + document.body.innerHTML = parse(document.getElementById('json').textContent); +} + +function parse(raw) { + let data = raw, callback = '', suffix = ''; + // matches "callback({json});" ... original had \s -> [\s\u200B\uFEFF] + let match = /^\s*([\w$\[\]\.]+)\s*\(\s*([\[{][\s\S]*[\]}])\s*\)([\s;]*)$/m.exec(raw); + if (match && match.length === 4) { + callback = match[1]; + data = match[2]; + suffix = match[3].replace(/[^;]+/g, ''); + } + + try { + let root = nested(JSON.parse(data), 0, '
'); + if (callback) + return wrapJSONP(callback, root, suffix); + return root; + } catch (e) { + return errorPage(e, raw); + } +} + +function nested(val, level, nl) { + if (null === val) + return nullV(); + switch (typeof val) { + case 'boolean': return boolV(val); + case 'number': return numV(val); + case 'string': + return (/^(\w+):\/\/[^\s]+$/i.test(val)) ? linkV(val) : stringV(val); + case 'object': + return (Array.isArray(val)) + ? array(val, level + 1, nl) + : dict(val, level + 1, nl); + } + return '<-unsupported-type->'; +} + +function dict(dict, level, nl) { + let output = ''; + for (let key in dict) { + if (output) + output += indent(',
', level); + output += propK(key) + ': ' + nested(dict[key], level, '
'); + } + if (!output) + return '{}'; + return '{' + foldableContent(output, level, nl) + '}'; +} + +function array(arr, level, nl) { + let output = ''; + for (let i = 0; i < arr.length; i++) { + if (i > 0) + output += indent(',
', level); + output += nested(arr[i], level, '
'); + } + if (!output) + return '[]'; + return '[' + foldableContent(output, level, nl) + ']'; +} + +// foldable content + +function foldableContent(output, level, nl) { + let collapsible = ''; + return collapsible + '' + indent(nl, level) + output + indent('
', level - 1) + '
' + collapsible +} + +function fold(sender) { + let folder = sender.parentNode; + folder.classList.toggle('closed'); +} + +function highlight(sender, show) { + let folder = sender.parentNode; + show ? folder.classList.add('highlight') : folder.classList.remove('highlight'); +} diff --git a/QLPreview/style.css b/QLPreview/style.css new file mode 100644 index 0000000..89f4f9f --- /dev/null +++ b/QLPreview/style.css @@ -0,0 +1,88 @@ +body { + background: #fff; + color: #444; +} +.bool, .null, .num { + color: red; +} +.callback { + color: purple; +} +.string { + color: green; +} +a { + color: #0065FF +} +a:hover { + color: #0052CC +} + +@media (prefers-color-scheme: dark) { + body { + background: #222; + color: #eee; + } + .callback { + color: violet; + } + .string { + color: yellowgreen; + } + a { + color: #2684FF; + } + a:hover { + color: #4C9AFF; + } +} + +body, pre { + font-family: monospace; + white-space: pre-wrap; + line-break: anywhere; +} +.prop { + font-weight: bold; +} +.bool, .null { + font-style: italic; +} + +/* Error handling */ +h1 { + font-size: 1.2em; +} +.error { + border-radius: 8px; + border: 2px solid #900; + margin: 5px; + padding: .4em .8em; +} + +/* Collapsible */ +.closed>span { + position: absolute; + height: 0; + width: 0; + overflow: hidden; +} +.folder>i:nth-child(1):before { + content: "↙️"; +} +.folder>i:nth-child(3):before { + content: "↗️"; +} +i { + font-style: unset; + cursor: pointer; + opacity: .25; + /* position: absolute; + left: 2px; */ +} +.highlight { + background: #7777; +} +.closed { + background: orange; +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..d235c79 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +![macOS 10.15+](https://img.shields.io/badge/macOS-10.15+-888) +[![Current release](https://img.shields.io/github/release/relikd/QLJSON)](https://github.com/relikd/QLJSON/releases) +[![GitHub license](https://img.shields.io/github/license/relikd/QLJSON)](LICENSE) + + +QLJSON +====== + +![screenshot](screenshot.png) + +Just a simple tool for QuickLook-ing `.json` files. + +I have been using [QuicklookJSON][1] until recently but it has no support for macOS 15. +I copied some parts of [QuickJSON][2] but did through away almost everything. +The remaining code was heavily refactored. + + +## Features + +- Dark Mode +- Foldable structure +- Customizable CSS / JS + + +### How to customize CSS / JS + +1. Right click on the app and select "Show Package Contents" +2. Copy `Contents/Resources/style.css` (or `script.js`) +3. Open `~/Library/Containers/de.relikd.QLJSON.Preview/Data/Documents/` +4. Paste the previous file and modify it to your liking (e.g. change text colors) + + +[1]: http://www.sagtau.com/quicklookjson.html +[2]: https://github.com/johan/QuickJSON diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..590c3bb Binary files /dev/null and b/screenshot.png differ