mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-08-29 01:01:31 +00:00
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.
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" role="img" aria-label="Custom app">
|
||||
<defs>
|
||||
<linearGradient id="background" x1="18" y1="14" x2="110" y2="116" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#57c7ff"/>
|
||||
<stop offset="1" stop-color="#3152d4"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="128" height="128" rx="29" fill="url(#background)"/>
|
||||
<rect x="31" y="31" width="28" height="28" rx="8" fill="#fff" fill-opacity=".96"/>
|
||||
<rect x="69" y="31" width="28" height="28" rx="8" fill="#fff" fill-opacity=".8"/>
|
||||
<rect x="31" y="69" width="28" height="28" rx="8" fill="#fff" fill-opacity=".8"/>
|
||||
<path d="M83 68v30M68 83h30" stroke="#fff" stroke-width="9" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 736 B |
-74
@@ -1,74 +0,0 @@
|
||||
export type SkyPhoneAppContext = {
|
||||
appId: string
|
||||
capabilities: string[]
|
||||
colorScheme: 'dark' | 'light'
|
||||
language: string
|
||||
locale: Record<string, unknown>
|
||||
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<Value = unknown> = {
|
||||
exists: boolean
|
||||
revision: number
|
||||
value?: Value
|
||||
}
|
||||
|
||||
export type SkyPhoneAppStorageWrite = {
|
||||
revision: number
|
||||
}
|
||||
|
||||
export type SkyPhoneAppApi = {
|
||||
readonly appId: string
|
||||
readonly protocolVersion: 1
|
||||
close(): Promise<void>
|
||||
getContext(): SkyPhoneAppContext | null
|
||||
notify(
|
||||
notification: SkyPhoneAppNotification,
|
||||
): Promise<{ notificationId: string | null }>
|
||||
on<EventName extends keyof SkyPhoneAppEvents>(
|
||||
eventName: EventName,
|
||||
listener: (payload: SkyPhoneAppEvents[EventName]) => void,
|
||||
): () => void
|
||||
open(
|
||||
appId: string,
|
||||
data?: Record<string, unknown>,
|
||||
): Promise<{ appId: string }>
|
||||
ready(): boolean
|
||||
request<Result = unknown>(method: string, payload?: unknown): Promise<Result>
|
||||
storage: {
|
||||
get<Value = unknown>(key: string): Promise<SkyPhoneAppStorageEntry<Value>>
|
||||
set(
|
||||
key: string,
|
||||
value: unknown,
|
||||
revision: number,
|
||||
): Promise<SkyPhoneAppStorageWrite>
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
SkyPhoneApp: SkyPhoneAppApi
|
||||
}
|
||||
}
|
||||
|
||||
export {}
|
||||
@@ -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()
|
||||
}
|
||||
})()
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user