From bbcdc50ad0afd6f963f55d78822f630850bf4b5a Mon Sep 17 00:00:00 2001 From: "Leon.Schmidt" Date: Tue, 11 Aug 2026 17:01:27 +0200 Subject: [PATCH] CLN - remove custom app packaging Remove the bundled custom-app SDK assets and stop including custom app manifests, scripts, web assets, and escrow exclusions in the resource manifest. --- sky_phone/custom_apps/_sdk/default-icon.svg | 13 -- sky_phone/custom_apps/_sdk/sky-phone-app.d.ts | 74 ------ sky_phone/custom_apps/_sdk/sky-phone-app.js | 211 ------------------ sky_phone/fxmanifest.lua | 11 - 4 files changed, 309 deletions(-) delete mode 100644 sky_phone/custom_apps/_sdk/default-icon.svg delete mode 100644 sky_phone/custom_apps/_sdk/sky-phone-app.d.ts delete mode 100644 sky_phone/custom_apps/_sdk/sky-phone-app.js diff --git a/sky_phone/custom_apps/_sdk/default-icon.svg b/sky_phone/custom_apps/_sdk/default-icon.svg deleted file mode 100644 index 751a276..0000000 --- a/sky_phone/custom_apps/_sdk/default-icon.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/sky_phone/custom_apps/_sdk/sky-phone-app.d.ts b/sky_phone/custom_apps/_sdk/sky-phone-app.d.ts deleted file mode 100644 index 48c6b8d..0000000 --- a/sky_phone/custom_apps/_sdk/sky-phone-app.d.ts +++ /dev/null @@ -1,74 +0,0 @@ -export type SkyPhoneAppContext = { - appId: string - capabilities: string[] - colorScheme: 'dark' | 'light' - language: string - locale: Record - phoneScale: number - protocolVersion: 1 - safeArea: { - bottom: number - left: number - right: number - top: number - } -} - -export type SkyPhoneAppEvents = { - context: SkyPhoneAppContext | null - message: unknown - open: unknown -} - -export type SkyPhoneAppNotification = { - sound?: 'chime' | 'signal' | 'soft' - subtitle?: string - text: string - title: string -} - -export type SkyPhoneAppStorageEntry = { - exists: boolean - revision: number - value?: Value -} - -export type SkyPhoneAppStorageWrite = { - revision: number -} - -export type SkyPhoneAppApi = { - readonly appId: string - readonly protocolVersion: 1 - close(): Promise - getContext(): SkyPhoneAppContext | null - notify( - notification: SkyPhoneAppNotification, - ): Promise<{ notificationId: string | null }> - on( - eventName: EventName, - listener: (payload: SkyPhoneAppEvents[EventName]) => void, - ): () => void - open( - appId: string, - data?: Record, - ): Promise<{ appId: string }> - ready(): boolean - request(method: string, payload?: unknown): Promise - storage: { - get(key: string): Promise> - set( - key: string, - value: unknown, - revision: number, - ): Promise - } -} - -declare global { - interface Window { - SkyPhoneApp: SkyPhoneAppApi - } -} - -export {} diff --git a/sky_phone/custom_apps/_sdk/sky-phone-app.js b/sky_phone/custom_apps/_sdk/sky-phone-app.js deleted file mode 100644 index 4688c59..0000000 --- a/sky_phone/custom_apps/_sdk/sky-phone-app.js +++ /dev/null @@ -1,211 +0,0 @@ -(function bootstrapSkyPhoneApp() { - 'use strict' - - const protocolVersion = 1 - const requestTimeoutMs = 8000 - const query = new URLSearchParams(window.location.search) - const appId = - query.get('skyPhoneAppId') || - document.documentElement.dataset.skyPhoneAppId || - document.currentScript?.dataset.appId || - '' - const listeners = new Map() - const pendingRequests = new Map() - let context = null - let nextRequestId = 1 - let readySent = false - - function emit(eventName, payload) { - const eventListeners = listeners.get(eventName) - if (eventListeners) { - for (const listener of [...eventListeners]) listener(payload) - } - window.dispatchEvent( - new CustomEvent(`sky-phone-app:${eventName}`, { detail: payload }), - ) - } - - function send(message) { - if (!appId) { - console.error('[Sky Phone App] Missing skyPhoneAppId in the frame URL.') - return false - } - - window.parent.postMessage( - { - ...message, - appId, - protocolVersion, - }, - '*', - ) - return true - } - - function ready() { - if (readySent) return true - readySent = send({ type: 'sky-phone-app:ready' }) - return readySent - } - - function on(eventName, listener) { - if (typeof eventName !== 'string' || typeof listener !== 'function') { - throw new TypeError('SkyPhoneApp.on requires an event name and a function.') - } - - const eventListeners = listeners.get(eventName) || new Set() - eventListeners.add(listener) - listeners.set(eventName, eventListeners) - return function unsubscribe() { - eventListeners.delete(listener) - if (eventListeners.size === 0) listeners.delete(eventName) - } - } - - function request(method, payload) { - if (typeof method !== 'string' || !method) { - return Promise.reject(new TypeError('A bridge method is required.')) - } - - const requestId = `${Date.now().toString(36)}-${nextRequestId++}` - return new Promise((resolve, reject) => { - const timeout = window.setTimeout(() => { - pendingRequests.delete(requestId) - reject(new Error(`Sky Phone request timed out: ${method}`)) - }, requestTimeoutMs) - - pendingRequests.set(requestId, { reject, resolve, timeout }) - if ( - !send({ - type: 'sky-phone-app:request', - method, - payload, - requestId, - }) - ) { - window.clearTimeout(timeout) - pendingRequests.delete(requestId) - reject(new Error('Sky Phone bridge is unavailable.')) - } - }) - } - - function close() { - return request('app.close') - } - - function open(targetAppId, data) { - if (typeof targetAppId !== 'string' || !targetAppId) { - return Promise.reject(new TypeError('A target app ID is required.')) - } - - return request('app.open', { - appId: targetAppId, - ...(data === undefined ? {} : { data }), - }) - } - - function notify(notification) { - if (!notification || typeof notification !== 'object') { - return Promise.reject(new TypeError('A notification is required.')) - } - - return request('notification.create', notification) - } - - const storage = Object.freeze({ - get(key) { - return request('device.storage.get', { key }) - }, - set(key, value, revision) { - return request('device.storage.set', { key, revision, value }) - }, - }) - - function applyContext(nextContext) { - if (!nextContext || typeof nextContext !== 'object') return - - const root = document.documentElement - if ( - nextContext.colorScheme === 'dark' || - nextContext.colorScheme === 'light' - ) { - root.dataset.theme = nextContext.colorScheme - root.style.colorScheme = nextContext.colorScheme - } - if (typeof nextContext.language === 'string' && nextContext.language) { - root.lang = nextContext.language - } - if (typeof nextContext.phoneScale === 'number') { - root.style.setProperty('--sky-phone-scale', String(nextContext.phoneScale)) - } - if (nextContext.safeArea && typeof nextContext.safeArea === 'object') { - for (const edge of ['top', 'right', 'bottom', 'left']) { - const value = nextContext.safeArea[edge] - if (typeof value === 'number') { - root.style.setProperty(`--sky-safe-area-${edge}`, `${value}px`) - } - } - } - } - - window.addEventListener('message', (event) => { - if (event.source !== window.parent) return - const message = event.data - if ( - !message || - typeof message !== 'object' || - message.appId !== appId || - message.protocolVersion !== protocolVersion - ) { - return - } - - if (message.type === 'sky-phone-app:context') { - context = message.context || null - applyContext(context) - emit('context', context) - } else if (message.type === 'sky-phone-app:message') { - emit('message', message.payload) - } else if (message.type === 'sky-phone-app:open') { - emit('open', message.data) - } else if (message.type === 'sky-phone-app:response') { - const pending = pendingRequests.get(message.requestId) - if (!pending) return - window.clearTimeout(pending.timeout) - pendingRequests.delete(message.requestId) - if (message.success) pending.resolve(message.data) - else pending.reject(new Error(message.error || 'Sky Phone request failed.')) - } - }) - - const api = Object.freeze({ - appId, - close, - getContext: () => context, - notify, - on, - open, - protocolVersion, - ready, - request, - storage, - }) - - if (window.SkyPhoneApp) { - console.error('[Sky Phone App] window.SkyPhoneApp is already defined.') - return - } - Object.defineProperty(window, 'SkyPhoneApp', { - configurable: false, - enumerable: true, - value: api, - writable: false, - }) - - if (document.readyState === 'loading') { - document.addEventListener('DOMContentLoaded', ready, { once: true }) - } else { - ready() - } -})() diff --git a/sky_phone/fxmanifest.lua b/sky_phone/fxmanifest.lua index 9d0db07..cfc540c 100644 --- a/sky_phone/fxmanifest.lua +++ b/sky_phone/fxmanifest.lua @@ -13,12 +13,6 @@ provide 'high-phone' provide 'qs-smartphone' provide 'yseries' -escrow_ignore { - 'config/**', - 'custom_apps/**', - 'source/bridge/**', -} - shared_scripts { 'config/init.lua', 'source/bridge/shared.lua', @@ -26,7 +20,6 @@ shared_scripts { 'source/shared/sim_number.lua', 'source/shared/custom_apps.lua', 'source/shared/custom_app_compat.lua', - 'custom_apps/**/manifest.lua', } client_scripts { @@ -46,7 +39,6 @@ client_scripts { 'source/client/payphones.lua', 'source/client/custom_apps.lua', 'source/client/custom_app_compat.lua', - 'custom_apps/**/client.lua', 'source/client/main.lua', 'source/client/radio.lua', } @@ -96,7 +88,6 @@ server_scripts { 'source/server/calendar.lua', 'source/server/music.lua', 'source/server/radio.lua', - 'custom_apps/**/server.lua', } files { @@ -104,8 +95,6 @@ files { 'source/html/assets/**', 'source/html/img/**', 'config/music/**', - 'custom_apps/**/web/**', - 'custom_apps/_sdk/**', } ui_page 'source/html/index.html'