Skip to content

Commit b0d81f2

Browse files
updates to how apps provide data for registration
1 parent 76c652f commit b0d81f2

4 files changed

Lines changed: 48 additions & 44 deletions

File tree

appdata/browser.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Browser</title>
8-
<script type="application/json" for="ntxSetup">
8+
<script type="application/json" data-for="ntxSetup">
99
{
1010
"author":"runnova",
1111
"include": ["nova.css", "material-symbols-rounded"],

appdata/calculator.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<script type="application/json" for="ntxSetup">
7+
<script type="application/json" data-for="ntxSetup">
88
{
99
"author":"runnova",
1010
"aspect-ratio": "3/4",

appdata/store.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Store App</title>
8-
<meta name="capabilities" content="content_store, onStartup">
9-
<meta name="nova-include" content="nova.css material-symbols-rounded">
10-
<meta name="permissions" content="fileSet, settings, fileGet, appStorage, unsandboxed">
11-
<meta name="nova-icon"
12-
content="<svg width='232' height='232' viewBox='0 0 232 232' fill='none' xmlns='http://www.w3.org/2000/svg'> <g clip-path='url(#clip0_0_1)'> <rect y='47' width='232' height='185' rx='40' fill='#384AAE'/> <rect y='71' width='232' height='161' rx='40' fill='#6179FF'/> <path d='M189 105C189 51.9807 156.093 9 115.5 9C74.9071 9 42 51.9807 42 105' stroke='#6179FF' stroke-width='18'/> <path d='M92.3167 143.277C93.4444 140.963 94.6125 138.732 95.8208 136.583C97.0292 134.435 98.3583 132.286 99.8083 130.138L93.0417 128.774L82.8917 139.186L92.3167 143.277ZM150.558 109.189C144.919 109.354 138.898 111.048 132.494 114.271C126.09 117.494 120.269 121.791 115.033 127.163C111.65 130.633 108.629 134.352 105.971 138.319C103.312 142.285 101.339 146.004 100.05 149.475L113.825 163.482C117.208 162.16 120.833 160.135 124.7 157.408C128.567 154.681 132.192 151.582 135.575 148.111C140.811 142.74 145 136.79 148.142 130.261C151.283 123.733 152.935 117.576 153.096 111.792C153.096 111.461 153.035 111.131 152.915 110.8C152.794 110.469 152.612 110.18 152.371 109.932C152.129 109.684 151.847 109.498 151.525 109.374C151.203 109.251 150.881 109.189 150.558 109.189ZM123.975 138.939C122.122 137.038 121.196 134.703 121.196 131.935C121.196 129.166 122.122 126.832 123.975 124.931C125.828 123.031 128.124 122.08 130.862 122.08C133.601 122.08 135.897 123.031 137.75 124.931C139.603 126.832 140.529 129.166 140.529 131.935C140.529 134.703 139.603 137.038 137.75 138.939C135.897 140.839 133.601 141.79 130.862 141.79C128.124 141.79 125.828 140.839 123.975 138.939ZM119.867 171.416L123.854 181.208L134.004 170.796L132.675 163.854C130.581 165.342 128.486 166.685 126.392 167.883C124.297 169.081 122.122 170.259 119.867 171.416ZM162.279 105.222C162.924 114.312 161.474 123.175 157.929 131.811C154.385 140.447 148.786 148.69 141.133 156.541L143.55 168.813C143.872 170.465 143.792 172.077 143.308 173.647C142.825 175.217 142.019 176.581 140.892 177.738L125.667 193.356C124.458 194.596 123.008 195.071 121.317 194.782C119.625 194.493 118.457 193.522 117.812 191.869L110.442 174.143L89.7792 152.946L72.5 145.384C70.8889 144.723 69.9222 143.525 69.6 141.79C69.2778 140.054 69.7208 138.567 70.9292 137.327L86.1542 121.708C87.2819 120.551 88.6312 119.725 90.2021 119.229C91.7729 118.733 93.3639 118.651 94.975 118.981L106.937 121.46C114.59 113.61 122.626 107.866 131.044 104.23C139.462 100.594 148.101 99.1066 156.962 99.7677C157.607 99.8503 158.251 100.036 158.896 100.326C159.54 100.615 160.104 101.007 160.587 101.503C161.071 101.999 161.453 102.577 161.735 103.239C162.017 103.9 162.199 104.561 162.279 105.222ZM76.9708 166.209C79.7903 163.317 83.234 161.85 87.3021 161.809C91.3701 161.768 94.8139 163.193 97.6333 166.085C100.453 168.978 101.842 172.511 101.802 176.684C101.762 180.857 100.332 184.39 97.5125 187.282C93.6458 191.249 89.0743 193.604 83.7979 194.348C78.5215 195.092 73.225 195.835 67.9083 196.579C68.6333 191.125 69.3583 185.691 70.0833 180.279C70.8083 174.866 73.1042 170.176 76.9708 166.209ZM83.8583 173.151C82.4889 174.556 81.5424 176.25 81.0187 178.233C80.4951 180.217 80.0722 182.241 79.75 184.307C81.7639 183.977 83.7375 183.564 85.6708 183.068C87.6042 182.572 89.2556 181.622 90.625 180.217C91.5917 179.225 92.1153 178.027 92.1958 176.622C92.2764 175.217 91.8333 174.019 90.8667 173.027C89.9 172.035 88.7319 171.56 87.3625 171.602C85.9931 171.643 84.825 172.159 83.8583 173.151Z' fill='#9CABFF'/> </g> <defs> <clipPath id='clip0_0_1'> <rect width='232' height='232' fill='white'/> </clipPath> </defs> </svg>">
8+
<script type="application/json" data-for="ntxSetup">
9+
{
10+
"author":"runnova",
11+
"include": ["nova.css", "material-symbols-rounded"],
12+
"special-features":["onStartup"],
13+
"permissions":["fileSet", "settings", "fileGet", "appStorage", "unsandboxed"],
14+
"nova-icon": "<svg width='232' height='232' viewBox='0 0 232 232' fill='none' xmlns='http://www.w3.org/2000/svg'> <g clip-path='url(#clip0_0_1)'> <rect y='47' width='232' height='185' rx='40' fill='#384AAE'/> <rect y='71' width='232' height='161' rx='40' fill='#6179FF'/> <path d='M189 105C189 51.9807 156.093 9 115.5 9C74.9071 9 42 51.9807 42 105' stroke='#6179FF' stroke-width='18'/> <path d='M92.3167 143.277C93.4444 140.963 94.6125 138.732 95.8208 136.583C97.0292 134.435 98.3583 132.286 99.8083 130.138L93.0417 128.774L82.8917 139.186L92.3167 143.277ZM150.558 109.189C144.919 109.354 138.898 111.048 132.494 114.271C126.09 117.494 120.269 121.791 115.033 127.163C111.65 130.633 108.629 134.352 105.971 138.319C103.312 142.285 101.339 146.004 100.05 149.475L113.825 163.482C117.208 162.16 120.833 160.135 124.7 157.408C128.567 154.681 132.192 151.582 135.575 148.111C140.811 142.74 145 136.79 148.142 130.261C151.283 123.733 152.935 117.576 153.096 111.792C153.096 111.461 153.035 111.131 152.915 110.8C152.794 110.469 152.612 110.18 152.371 109.932C152.129 109.684 151.847 109.498 151.525 109.374C151.203 109.251 150.881 109.189 150.558 109.189ZM123.975 138.939C122.122 137.038 121.196 134.703 121.196 131.935C121.196 129.166 122.122 126.832 123.975 124.931C125.828 123.031 128.124 122.08 130.862 122.08C133.601 122.08 135.897 123.031 137.75 124.931C139.603 126.832 140.529 129.166 140.529 131.935C140.529 134.703 139.603 137.038 137.75 138.939C135.897 140.839 133.601 141.79 130.862 141.79C128.124 141.79 125.828 140.839 123.975 138.939ZM119.867 171.416L123.854 181.208L134.004 170.796L132.675 163.854C130.581 165.342 128.486 166.685 126.392 167.883C124.297 169.081 122.122 170.259 119.867 171.416ZM162.279 105.222C162.924 114.312 161.474 123.175 157.929 131.811C154.385 140.447 148.786 148.69 141.133 156.541L143.55 168.813C143.872 170.465 143.792 172.077 143.308 173.647C142.825 175.217 142.019 176.581 140.892 177.738L125.667 193.356C124.458 194.596 123.008 195.071 121.317 194.782C119.625 194.493 118.457 193.522 117.812 191.869L110.442 174.143L89.7792 152.946L72.5 145.384C70.8889 144.723 69.9222 143.525 69.6 141.79C69.2778 140.054 69.7208 138.567 70.9292 137.327L86.1542 121.708C87.2819 120.551 88.6312 119.725 90.2021 119.229C91.7729 118.733 93.3639 118.651 94.975 118.981L106.937 121.46C114.59 113.61 122.626 107.866 131.044 104.23C139.462 100.594 148.101 99.1066 156.962 99.7677C157.607 99.8503 158.251 100.036 158.896 100.326C159.54 100.615 160.104 101.007 160.587 101.503C161.071 101.999 161.453 102.577 161.735 103.239C162.017 103.9 162.199 104.561 162.279 105.222ZM76.9708 166.209C79.7903 163.317 83.234 161.85 87.3021 161.809C91.3701 161.768 94.8139 163.193 97.6333 166.085C100.453 168.978 101.842 172.511 101.802 176.684C101.762 180.857 100.332 184.39 97.5125 187.282C93.6458 191.249 89.0743 193.604 83.7979 194.348C78.5215 195.092 73.225 195.835 67.9083 196.579C68.6333 191.125 69.3583 185.691 70.0833 180.279C70.8083 174.866 73.1042 170.176 76.9708 166.209ZM83.8583 173.151C82.4889 174.556 81.5424 176.25 81.0187 178.233C80.4951 180.217 80.0722 182.241 79.75 184.307C81.7639 183.977 83.7375 183.564 85.6708 183.068C87.6042 182.572 89.2556 181.622 90.625 180.217C91.5917 179.225 92.1153 178.027 92.1958 176.622C92.2764 175.217 91.8333 174.019 90.8667 173.027C89.9 172.035 88.7319 171.56 87.3625 171.602C85.9931 171.643 84.825 172.159 83.8583 173.151Z' fill='#9CABFF'/> </g> <defs> <clipPath id='clip0_0_1'> <rect width='232' height='232' fill='white'/> </clipPath> </defs> </svg>"
15+
}
16+
</script>
1317

1418
<style>
1519
* {

scripts/script.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -801,19 +801,19 @@ async function extractAndRegisterCapabilities(appId, content) {
801801
let parser = new DOMParser();
802802
let doc = parser.parseFromString(content, "text/html");
803803

804-
let metaTag = doc.querySelector('meta[name="capabilities"]');
804+
const el = doc.querySelector('script[type="application/json"][data-for="ntxSetup"]')
805+
const setupScriptData = el ? JSON.parse(el.textContent) : false;
805806
let capabilities = [];
806-
if (metaTag) {
807-
capabilities = metaTag.getAttribute("content").split(',').map(s => s.trim());
808-
} else {
809-
console.log(`No capabilities: ${appId}`);
807+
if (setupScriptData) {
808+
capabilities = setupScriptData["capabilities"];
810809
}
810+
811811
let onlyDefPerms = false;
812812
let totalperms = ['utility', 'sysUI'];
813-
let metaTag2 = doc.querySelector('meta[name="permissions"]');
813+
let permsRegAvble = setupScriptData["permissions"]?.length > 0;
814814
let requestedperms = [];
815-
if (metaTag2) {
816-
requestedperms = metaTag2.getAttribute("content").split(',').map(s => s.trim());
815+
if (permsRegAvble) {
816+
requestedperms = setupScriptData["permissions"].map(s => s.trim());
817817
} else {
818818
console.log(`No permissions: ${appId}`);
819819
onlyDefPerms = true
@@ -832,6 +832,7 @@ async function extractAndRegisterCapabilities(appId, content) {
832832
onlyDefPerms = (onlyDefPerms) ? true : arraysEqualIgnoreOrder(requestedperms, totalperms);
833833

834834
let permissions = Array.from(new Set([...totalperms, ...requestedperms]));
835+
let specialsFlags = setupScriptData["special-features"];
835836

836837
if (!onlyDefPerms) {
837838
let modal = gid("AppInstDia");
@@ -840,25 +841,21 @@ async function extractAndRegisterCapabilities(appId, content) {
840841
gid("app_inst_mod_app_name").innerText = appName;
841842
let listelement = gid("app_inst_mod_li");
842843
listelement.innerHTML = '';
843-
if (capabilities.length > 0) {
844-
let handlerList = capabilities.filter(c => !c.startsWith('.') && c !== 'onStartup').join(', ');
845-
if (handlerList) {
846-
let span = document.createElement("li");
847-
span.innerHTML = `Function as ${handlerList}`;
848-
listelement.appendChild(span);
849-
}
850-
851-
let fileTypes = capabilities.filter(c => c.startsWith('.')).join(', ');
844+
if (capabilities?.length > 0) {
845+
let fileTypes = capabilities.join(', ');
852846
if (fileTypes) {
853847
let span = document.createElement("li");
854848
span.innerHTML = `Open ${fileTypes} by default`;
855849
listelement.appendChild(span);
856850
}
857851

858-
if (capabilities.includes('onStartup')) {
859-
let span = document.createElement("li");
860-
span.innerHTML = "Run during startup";
861-
listelement.appendChild(span);
852+
if (specialsFlags) {
853+
if (specialsFlags.includes("onStartup")) {
854+
855+
let span = document.createElement("li");
856+
span.innerHTML = "Run during startup";
857+
listelement.appendChild(span);
858+
}
862859
}
863860
}
864861

@@ -908,7 +905,7 @@ async function extractAndRegisterCapabilities(appId, content) {
908905
totalperms.push(perm);
909906
}
910907
});
911-
await registerApp(appId, capabilities);
908+
await registerApp(appId, capabilities, specialsFlags);
912909

913910
let registry = {};
914911
registry.perms = totalperms;
@@ -918,28 +915,31 @@ async function extractAndRegisterCapabilities(appId, content) {
918915
console.error("Error extracting and registering capabilities:", error);
919916
}
920917
}
921-
async function registerApp(appId, capabilities) {
922-
for (let rawCapability of capabilities) {
923-
let capability = rawCapability.trim();
924-
if (capability === 'onStartup') continue;
925-
if (capability.startsWith('.')) {
926-
fileTypeAssociations[capability] = [appId];
927-
} else {
928-
handlers[capability] = appId;
918+
async function registerApp(appId, capabilities, specialsFlags) {
919+
if (capabilities?.length) {
920+
for (let rawCapability of capabilities) {
921+
let capability = rawCapability.trim();
922+
if (capability.startsWith('.')) {
923+
fileTypeAssociations[capability] = [appId];
924+
} else {
925+
handlers[capability] = appId;
926+
}
929927
}
930928
}
929+
931930
await setSetting('fileTypeAssociations', fileTypeAssociations);
932-
await setSetting('handlers', handlers);
933931

934-
if (capabilities.includes('onStartup')) {
935-
let startupApps = await getSetting('RunOnStartup') || [];
936-
if (!startupApps.includes(appId)) startupApps.push(appId);
937-
await setSetting('RunOnStartup', startupApps);
932+
if (specialsFlags) {
933+
if (specialsFlags.includes("onStartup")) {
934+
let startupApps = await getSetting('RunOnStartup') || [];
935+
if (!startupApps.includes(appId)) startupApps.push(appId);
936+
await setSetting('RunOnStartup', startupApps);
937+
}
938938
}
939939

940940
if (!initialization)
941-
notify(await getFileNameByID(appId) + " installed", "Registered " + capabilities.toString(), "NovaOS System");
942-
return capabilities.toString();
941+
notify(await getFileNameByID(appId) + " installed", "Now handles " + capabilities?.toString(), "NovaOS System");
942+
return capabilities?.toString() || "";
943943
}
944944

945945
async function cleanupInvalidAssociations() {

0 commit comments

Comments
 (0)