@gjsify/app-settings 0.64.2 → 0.64.3-next.258
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ settings.get_int('window-width');
|
|
|
19
19
|
settings.connect('changed::window-width', (_s, key) => {});
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Supported: `get/set_{boolean,int,uint,double,string}`, `connect('changed[::key]')`, `disconnect`, `schema_id`, `path`.
|
|
23
|
-
Key types: `b i u d s
|
|
22
|
+
Supported: `get/set_{boolean,int,uint,double,string}`, `get_value`/`set_value` with `GLib.Variant`, `connect('changed[::key]')`, `disconnect`, `schema_id`, `path`.
|
|
23
|
+
Key types: `b i u d s` and the arrays `ab ai au ad as` (ADR 0118). An array key is read and written through `get_value`/`set_value` and stored as its GVariant text (`print(false)`). Everything else (`list_keys`, `get_strv`, `reset`, `apply`, `delay`, `Gio.Settings.new`) is refused by name, and `bind()` throws.
|
|
24
24
|
|
|
25
25
|
## Schema
|
|
26
26
|
|
package/lib/esm/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{defineSettings as e}from"./settings.js";const
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{defineSettings as e,isArrayKeyType as t,parseArrayValue as n,printArrayValue as r}from"./settings.js";const i=new Set;function decode(e,r,a){let o;if(t(r))try{o=n(r,a)}catch{o=void 0}else if(r===`s`)o=a;else if(r===`b`)o=a===`true`?!0:a===`false`?!1:void 0;else{let e=Number(a);o=a.trim()!==``&&Number.isFinite(e)&&(r===`d`||Number.isInteger(e))?e:void 0}return o===void 0&&!i.has(e)&&(i.add(e),console.warn(`Gio.Settings: stored value of '${e}' is not a '${r}'; using the default`)),o}const a={read(e,t){let n=globalThis.localStorage.getItem(e);return n===null?void 0:decode(e,t,n)},write(e,n,i){try{let a=t(n)?r(n,i):String(i);globalThis.localStorage.setItem(e,a)}catch(t){throw Error(`Gio.Settings: cannot store '${e}': ${t.message}`)}}},o=e(a);typeof globalThis.addEventListener==`function`&&globalThis.addEventListener(`storage`,e=>{let{key:t}=e;t!==null&&o.notifyStorage(t)});export{o as Settings,e as defineSettings,a as localStorageStorage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";const e={id:`eu.jumplink.Learn6502`,path:`/eu/jumplink/Learn6502/`,keys:{"ui-font":{type:`s`,default:`Sans 11`},"primary-color":{type:`s`,default:``},"accent-color":{type:`s`,default:``},"font-name":{type:`s`,default:`Monospace 12`},"color-scheme":{type:`i`,default:0},"window-width":{type:`i`,default:1e3},"window-height":{type:`i`,default:700},"is-maximized":{type:`b`,default:!1},"show-line-numbers":{type:`b`,default:!0},"auto-indent":{type:`b`,default:!0},count:{type:`u`,default:7},ratio:{type:`d`,default:1.5}}},t=`<?xml version="1.0" encoding="UTF-8"?>
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";const e={id:`eu.jumplink.Learn6502`,path:`/eu/jumplink/Learn6502/`,keys:{"ui-font":{type:`s`,default:`Sans 11`},"primary-color":{type:`s`,default:``},"accent-color":{type:`s`,default:``},"font-name":{type:`s`,default:`Monospace 12`},"color-scheme":{type:`i`,default:0},"window-width":{type:`i`,default:1e3},"window-height":{type:`i`,default:700},"is-maximized":{type:`b`,default:!1},"show-line-numbers":{type:`b`,default:!0},"auto-indent":{type:`b`,default:!0},count:{type:`u`,default:7},ratio:{type:`d`,default:1.5},"support-prompt-years":{type:`ai`,default:[]},tags:{type:`as`,default:[`a`,`b'c`]}}},t=`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<schemalist>
|
|
3
3
|
<schema id="eu.jumplink.Learn6502" path="/eu/jumplink/Learn6502/">
|
|
4
4
|
<key name="ui-font" type="s"><default>'Sans 11'</default></key>
|
|
@@ -13,6 +13,8 @@ import"../_virtual/_rolldown/runtime.js";const e={id:`eu.jumplink.Learn6502`,pat
|
|
|
13
13
|
<key name="auto-indent" type="b"><default>true</default></key>
|
|
14
14
|
<key name="count" type="u"><default>7</default></key>
|
|
15
15
|
<key name="ratio" type="d"><default>1.5</default></key>
|
|
16
|
+
<key name="support-prompt-years" type="ai"><default>[]</default></key>
|
|
17
|
+
<key name="tags" type="as"><default>['a', "b'c"]</default></key>
|
|
16
18
|
</schema>
|
|
17
19
|
</schemalist>
|
|
18
|
-
`,n=e.id,threw=e=>{try{return e(),null}catch(e){return e.message}},make=e=>new e.Settings({schema_id:n}),r=[{row:`defaults`,rule:`a never-written key returns the schema default, for each of b i u d s`,run:e=>{let t=make(e);return[t.get_boolean(`show-line-numbers`),t.get_int(`window-width`),t.get_uint(`count`),t.get_double(`ratio`),t.get_string(`font-name`)]},shows:[!0,1e3,7,1.5,`Monospace 12`]},{row:`roundtrip`,rule:`set then get returns the value, for each of b i u d s`,run:e=>{let t=make(e);return t.set_boolean(`is-maximized`,!0),t.set_int(`window-width`,-5),t.set_uint(`count`,4e9),t.set_double(`ratio`,.25),t.set_string(`font-name`,`Mono 9`),[t.get_boolean(`is-maximized`),t.get_int(`window-width`),t.get_uint(`count`),t.get_double(`ratio`),t.get_string(`font-name`)]},shows:[!0,-5,4e9,.25,`Mono 9`]},{row:`instances`,rule:`a second instance on the schema sees the value and hears the change`,run:e=>{let t=make(e),n=make(e),r=[];return n.connect(`changed::window-width`,(e,t)=>r.push(t)),t.set_int(`window-width`,640),[n.get_int(`window-width`),r]},shows:[640,[`window-width`]]},{row:`changed`,rule:`changed::key runs once per differing set with the key; changed::other does not; changed runs for every key`,run:e=>{let t=make(e),n=[];return t.connect(`changed::window-width`,(e,t)=>n.push(`w:${t}`)),t.connect(`changed::window-height`,(e,t)=>n.push(`h:${t}`)),t.connect(`changed`,(e,t)=>n.push(`any:${t}`)),t.set_int(`window-width`,1),t.set_int(`window-width`,2),n},shows:[`w:window-width`,`any:window-width`,`w:window-width`,`any:window-width`]},{row:`equal`,rule:`the first write of the default fires (the key was unset); a write equal to the stored value is silent (memory backend)`,run:e=>{let t=make(e),n=0;return t.connect(`changed::window-width`,()=>n+=1),t.set_int(`window-width`,1e3),t.set_int(`window-width`,1e3),t.set_int(`window-width`,5),t.set_int(`window-width`,5),n},shows:2},{row:`disconnect`,rule:`disconnect stops the handler`,run:e=>{let t=make(e),n=0,r=t.connect(`changed::window-width`,()=>n+=1);return t.set_int(`window-width`,1),t.disconnect(r),t.set_int(`window-width`,2),n},shows:1},{row:`properties`,rule:`schema_id and path read back; the schema path is taken when the call gives none`,run:e=>{let t=make(e);return[t.schema_id,t.path]},shows:[n,e.path]},{row:`errors`,rule:`an unknown key, an out-of-range uint, an unknown signal and an unknown schema throw`,run:e=>{let t=make(e);return[threw(()=>t.get_int(`nope`))!==null,threw(()=>t.set_uint(`count`,-1))!==null,threw(()=>t.connect(`bogus`,()=>{}))!==null,threw(()=>new e.Settings({schema_id:`no.such`}))!==null]},shows:[!0,!0,!0,!0]},{row:`refusal-type`,rule:`a wrong-type getter or setter throws, naming the key (GJS only logs a GLib-CRITICAL and goes on)`,subsetOnly:!0,run:e=>{let t=make(e);return[(threw(()=>t.get_int(`is-maximized`))??``).includes(`is-maximized`),(threw(()=>t.set_int(`is-maximized`,1))??``).includes(`is-maximized`)]},shows:[!0,!0]},{row:`refusal`,rule:`every row ADR 0099 § 2 refuses throws, naming itself`,subsetOnly:!0,run:e=>{let t=make(e);return[`list_keys`,`
|
|
20
|
+
`,n=e.id,threw=e=>{try{return e(),null}catch(e){return e.message}},make=e=>new e.Settings({schema_id:n}),r=[{row:`defaults`,rule:`a never-written key returns the schema default, for each of b i u d s`,run:e=>{let t=make(e);return[t.get_boolean(`show-line-numbers`),t.get_int(`window-width`),t.get_uint(`count`),t.get_double(`ratio`),t.get_string(`font-name`)]},shows:[!0,1e3,7,1.5,`Monospace 12`]},{row:`roundtrip`,rule:`set then get returns the value, for each of b i u d s`,run:e=>{let t=make(e);return t.set_boolean(`is-maximized`,!0),t.set_int(`window-width`,-5),t.set_uint(`count`,4e9),t.set_double(`ratio`,.25),t.set_string(`font-name`,`Mono 9`),[t.get_boolean(`is-maximized`),t.get_int(`window-width`),t.get_uint(`count`),t.get_double(`ratio`),t.get_string(`font-name`)]},shows:[!0,-5,4e9,.25,`Mono 9`]},{row:`instances`,rule:`a second instance on the schema sees the value and hears the change`,run:e=>{let t=make(e),n=make(e),r=[];return n.connect(`changed::window-width`,(e,t)=>r.push(t)),t.set_int(`window-width`,640),[n.get_int(`window-width`),r]},shows:[640,[`window-width`]]},{row:`changed`,rule:`changed::key runs once per differing set with the key; changed::other does not; changed runs for every key`,run:e=>{let t=make(e),n=[];return t.connect(`changed::window-width`,(e,t)=>n.push(`w:${t}`)),t.connect(`changed::window-height`,(e,t)=>n.push(`h:${t}`)),t.connect(`changed`,(e,t)=>n.push(`any:${t}`)),t.set_int(`window-width`,1),t.set_int(`window-width`,2),n},shows:[`w:window-width`,`any:window-width`,`w:window-width`,`any:window-width`]},{row:`equal`,rule:`the first write of the default fires (the key was unset); a write equal to the stored value is silent (memory backend)`,run:e=>{let t=make(e),n=0;return t.connect(`changed::window-width`,()=>n+=1),t.set_int(`window-width`,1e3),t.set_int(`window-width`,1e3),t.set_int(`window-width`,5),t.set_int(`window-width`,5),n},shows:2},{row:`disconnect`,rule:`disconnect stops the handler`,run:e=>{let t=make(e),n=0,r=t.connect(`changed::window-width`,()=>n+=1);return t.set_int(`window-width`,1),t.disconnect(r),t.set_int(`window-width`,2),n},shows:1},{row:`properties`,rule:`schema_id and path read back; the schema path is taken when the call gives none`,run:e=>{let t=make(e);return[t.schema_id,t.path]},shows:[n,e.path]},{row:`errors`,rule:`an unknown key, an out-of-range uint, an unknown signal and an unknown schema throw`,run:e=>{let t=make(e);return[threw(()=>t.get_int(`nope`))!==null,threw(()=>t.set_uint(`count`,-1))!==null,threw(()=>t.connect(`bogus`,()=>{}))!==null,threw(()=>new e.Settings({schema_id:`no.such`}))!==null]},shows:[!0,!0,!0,!0]},{row:`value-defaults`,rule:`get_value of a never-written key is a Variant of the key type holding the default, for an array and a basic key`,run:e=>{let t=make(e),n=t.get_value(`support-prompt-years`),r=t.get_value(`tags`),i=t.get_value(`window-width`);return[n.get_type_string(),n.deepUnpack(),r.get_type_string(),r.deepUnpack(),i.get_type_string(),i.deepUnpack()]},shows:[`ai`,[],`as`,[`a`,`b'c`],`i`,1e3]},{row:`value-roundtrip`,rule:`set_value returns true and get_value reads the value back; a basic key set through set_value reads through its typed getter`,run:e=>{let t=make(e);return[t.set_value(`support-prompt-years`,new e.Variant(`ai`,[2024,2025])),t.set_value(`tags`,new e.Variant(`as`,[])),t.set_value(`window-width`,new e.Variant(`i`,640)),t.get_value(`support-prompt-years`).deepUnpack(),t.get_value(`tags`).deepUnpack(),t.get_int(`window-width`)]},shows:[!0,!0,!0,[2024,2025],[],640]},{row:`value-changed`,rule:`an array key fires changed::key when the stored value differs: the first write of the default fires, an EQUAL array is silent (memory backend)`,run:e=>{let t=make(e),n=0;return t.connect(`changed::support-prompt-years`,()=>n+=1),t.set_value(`support-prompt-years`,new e.Variant(`ai`,[])),t.set_value(`support-prompt-years`,new e.Variant(`ai`,[])),t.set_value(`support-prompt-years`,new e.Variant(`ai`,[1,2])),t.set_value(`support-prompt-years`,new e.Variant(`ai`,[1,2])),t.set_value(`support-prompt-years`,new e.Variant(`ai`,[2,1])),n},shows:3},{row:`value-errors`,rule:`get_value and set_value of an unknown key throw; set_value of something that is not a Variant throws TypeError`,run:e=>{let t=make(e),n=``;try{t.set_value(`support-prompt-years`,[1])}catch(e){n=e.constructor.name}return[threw(()=>t.get_value(`nope`))!==null,threw(()=>t.set_value(`nope`,new e.Variant(`ai`,[])))!==null,n]},shows:[!0,!0,`TypeError`]},{row:`refusal-value-type`,rule:`set_value with a Variant of another type throws, naming key, expected and actual type string (GJS returns false and logs a GLib-CRITICAL)`,subsetOnly:!0,run:e=>{let t=make(e),n=threw(()=>t.set_value(`support-prompt-years`,new e.Variant(`as`,[])))??``;return[n.includes(`support-prompt-years`),n.includes(`'ai'`),n.includes(`'as'`)]},shows:[!0,!0,!0]},{row:`refusal-type`,rule:`a wrong-type getter or setter throws, naming the key (GJS only logs a GLib-CRITICAL and goes on)`,subsetOnly:!0,run:e=>{let t=make(e);return[(threw(()=>t.get_int(`is-maximized`))??``).includes(`is-maximized`),(threw(()=>t.set_int(`is-maximized`,1))??``).includes(`is-maximized`)]},shows:[!0,!0]},{row:`refusal`,rule:`every row ADR 0099 § 2 refuses throws, naming itself`,subsetOnly:!0,run:e=>{let t=make(e);return[`list_keys`,`get_strv`,`set_strv`,`get_user_value`,`get_default_value`,`reset`,`apply`,`delay`,`revert`,`sync`,`bind`,`create_action`,`get_child`].map(e=>(threw(()=>t[e](`k`))??``).includes(e))},shows:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0]},{row:`refusal-construct`,rule:`the backend construct property and a foreign path are refused`,subsetOnly:!0,run:e=>[threw(()=>new e.Settings({schema_id:n,backend:{}}))!==null,threw(()=>new e.Settings({schema_id:n,path:`/other/`}))!==null],shows:[!0,!0]}];async function driveSettingsVectors(e,{describe:t,it:n,expect:i}){await t(`Gio.Settings vectors: ${e.name}`,async()=>{for(let t of r)t.subsetOnly&&e.isOracle||await n(`${t.row}: ${t.rule}`,()=>{e.reset(),i(t.run(e)).toStrictEqual(t.shows)})})}export{e as FIXTURE_SCHEMA,t as FIXTURE_SCHEMA_XML,r as SETTINGS_VECTORS,driveSettingsVectors};
|
package/lib/esm/nativescript.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{defineSettings as e}from"./settings.js";import{ApplicationSettings as
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{defineSettings as e,isArrayKeyType as t,parseArrayValue as n,printArrayValue as r}from"./settings.js";import{ApplicationSettings as i}from"@nativescript/core";const a=new Set;function readArray(e,t){try{return n(t,i.getString(e))}catch{a.has(e)||(a.add(e),console.warn(`Gio.Settings: stored value of '${e}' is not a '${t}'; using the default`));return}}const o={read(e,n){if(i.hasKey(e))return t(n)?readArray(e,n):n===`b`?i.getBoolean(e):n===`s`?i.getString(e):i.getNumber(e)},write(e,n,a){t(n)?i.setString(e,r(n,a)):n===`b`?i.setBoolean(e,a):n===`s`?i.setString(e,a):i.setNumber(e,a)}},s=e(o);export{s as Settings,o as applicationSettingsStorage,e as defineSettings};
|
package/lib/esm/settings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";const
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{GLibVariant as e}from"@gjsify/adwaita-core";const t=[`list_keys`,`get_strv`,`set_strv`,`get_user_value`,`get_default_value`,`reset`,`apply`,`delay`,`revert`,`sync`,`get_has_unapplied`,`is_writable`,`list_children`,`get_child`,`bind`,`bind_with_mapping`,`bind_writable`,`create_action`],n={min:-(2**31),max:2**31-1},r={min:0,max:2**32-1},i={b:`boolean`,i:`int`,u:`uint`,d:`double`,s:`string`,ab:`boolean array`,ai:`int array`,au:`uint array`,ad:`double array`,as:`string array`},a=new Set([`b`,`i`,`u`,`d`,`s`,`ab`,`ai`,`au`,`ad`,`as`]);function isArrayKeyType(e){return e.length===2}function printArrayValue(t,n){return new e(t,n).print(!1)}function parseArrayValue(t,n){return e.parseText(t,n).deepUnpack()}function sameValue(e,t){return!Array.isArray(e)||!Array.isArray(t)?e===t:e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]))}function refuse(e,t){return Error(`Gio.Settings: ${e} ${t}, which is outside the Gio.Settings subset (ADR 0099 § 2).`)}function checkValue(e,t,a){let bad=()=>TypeError(`Gio.Settings: key '${a}' is of type '${e}', not ${typeof t}`);if(e===`b`){if(typeof t!=`boolean`)throw bad()}else if(e===`s`){if(typeof t!=`string`)throw bad()}else{if(typeof t!=`number`||Number.isNaN(t))throw bad();if(e!==`d`){let o=e===`i`?n:r;if(!Number.isInteger(t)||t<o.min||t>o.max)throw RangeError(`Gio.Settings: value ${t} for key '${a}' is out of range for ${i[e]}`)}}}function defineSettings(n){let r=new Map,o=new Map;class Settings{schema_id;path;#e;#t=1;#n=new Map;static register(e){if(!e.path)throw Error(`Gio.Settings: schema '${e.id}' has no path`);for(let[t,n]of Object.entries(e.keys))if(!a.has(n.type))throw refuse(`key '${t}' of type '${n.type}' in schema '${e.id}'`,`is not a b i u d s key or an array of one`);r.set(e.id,e)}constructor(e){for(let t of Object.keys(e??{}))if(t!==`schema_id`&&t!==`path`)throw refuse(`the '${t}' construct property`,`is not implemented`);let t=r.get(e?.schema_id);if(!t)throw Error(`GSettings schema ${e?.schema_id} not found`);if(e.path!==void 0&&e.path!==t.path)throw Error(`Gio.Settings: path '${e.path}' differs from the schema's '${t.path}'`);this.#e=t,this.schema_id=t.id,this.path=t.path;let n=o.get(t.path);n||o.set(t.path,n=new Set),n.add(this)}#r(e){let t=this.#e.keys[e];if(!t)throw Error(`GSettings key ${e} not found in schema ${this.schema_id}`);return t}#i(e,t){let n=this.#r(e);if(n.type!==t)throw TypeError(`Gio.Settings: key '${e}' is of type '${n.type}', not '${t}' (${i[t]})`);return n}#a(e,t){let r=this.#i(e,t),i=n.read(this.path+e,t);return i===void 0?r.default:i}#o(e,t,r){this.#i(e,t),isArrayKeyType(t)||checkValue(t,r,e);let i=this.path+e,a=n.read(i,t);return n.write(i,t,r),sameValue(a,r)||this.notifyAll(e),!0}notifyAll(e){Settings.#s(this.path,e)}static#s(e,t){for(let n of o.get(e)??[])n.#c(t)}static notifyStorage(e){for(let[t,n]of o){if(!e.startsWith(t))continue;let r=e.slice(t.length),[i]=n;i&&r in i.#e.keys&&Settings.#s(t,r)}}#c(e){for(let{key:t,run:n}of Array.from(this.#n.values()))(t===null||t===e)&&n(this,e)}get_boolean(e){return this.#a(e,`b`)}get_int(e){return this.#a(e,`i`)}get_uint(e){return this.#a(e,`u`)}get_double(e){return this.#a(e,`d`)}get_string(e){return this.#a(e,`s`)}get_value(t){let{type:n}=this.#r(t);return new e(n,this.#a(t,n))}set_value(t,n){if(!(n instanceof e))throw TypeError(`Expected an object of type GVariant for argument 'value' but got type ${n===null?`null`:typeof n}`);let{type:r}=this.#r(t),i=n.get_type_string();if(i!==r)throw TypeError(`Gio.Settings: key '${t}' is of type '${r}', not '${i}'`);return this.#o(t,r,n.deepUnpack())}set_boolean(e,t){return this.#o(e,`b`,t)}set_int(e,t){return this.#o(e,`i`,t)}set_uint(e,t){return this.#o(e,`u`,t)}set_double(e,t){return this.#o(e,`d`,t)}set_string(e,t){return this.#o(e,`s`,t)}connect(e,t){let n=e.indexOf(`::`);if((n===-1?e:e.slice(0,n))!==`changed`)throw Error(`No signal '${e}' on object 'GSettings'`);let r=this.#t++;return this.#n.set(r,{key:n===-1?null:e.slice(n+2),run:t}),r}disconnect(e){if(!this.#n.delete(e))throw Error(`No handler with id ${e} is connected to GSettings`)}}for(let e of t)Object.defineProperty(Settings.prototype,e,{value(){throw refuse(`${e}()`,`is not implemented`)}});for(let e of[`new`,`new_with_path`,`new_full`])Object.defineProperty(Settings,e,{value(){throw refuse(`Settings.${e}()`,`is not implemented; construct with { schema_id }`)}});return Settings}export{defineSettings,isArrayKeyType,parseArrayValue,printArrayValue};
|
|
@@ -10,17 +10,28 @@ export interface SettingsClassLike {
|
|
|
10
10
|
path?: string;
|
|
11
11
|
}): SettingsLike;
|
|
12
12
|
}
|
|
13
|
+
/** `GLib.Variant` as far as the vectors build one for `set_value` (ADR 0118 § 3). */
|
|
14
|
+
export interface VariantClassLike {
|
|
15
|
+
new (type: string, value: unknown): {
|
|
16
|
+
get_type_string(): string;
|
|
17
|
+
deepUnpack(): unknown;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
13
20
|
export interface SettingsSubject {
|
|
14
21
|
readonly name: string;
|
|
15
22
|
readonly isOracle: boolean;
|
|
16
23
|
readonly Settings: SettingsClassLike;
|
|
24
|
+
readonly Variant: VariantClassLike;
|
|
17
25
|
/** Forgets everything written, so a vector starts from the defaults. */
|
|
18
26
|
reset(): void;
|
|
19
27
|
}
|
|
20
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Learn6502's ten keys (`eu.jumplink.Learn6502.gschema.xml`, `support-prompt-years` is its `ai`),
|
|
30
|
+
* plus `u`, `d` and `as` for coverage.
|
|
31
|
+
*/
|
|
21
32
|
export declare const FIXTURE_SCHEMA: Schema;
|
|
22
33
|
/** The XML GJS compiles for the oracle; the same keys as {@link FIXTURE_SCHEMA}. */
|
|
23
|
-
export declare const FIXTURE_SCHEMA_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<schemalist>\n <schema id=\"eu.jumplink.Learn6502\" path=\"/eu/jumplink/Learn6502/\">\n <key name=\"ui-font\" type=\"s\"><default>'Sans 11'</default></key>\n <key name=\"primary-color\" type=\"s\"><default>''</default></key>\n <key name=\"accent-color\" type=\"s\"><default>''</default></key>\n <key name=\"font-name\" type=\"s\"><default>'Monospace 12'</default></key>\n <key name=\"color-scheme\" type=\"i\"><default>0</default></key>\n <key name=\"window-width\" type=\"i\"><default>1000</default></key>\n <key name=\"window-height\" type=\"i\"><default>700</default></key>\n <key name=\"is-maximized\" type=\"b\"><default>false</default></key>\n <key name=\"show-line-numbers\" type=\"b\"><default>true</default></key>\n <key name=\"auto-indent\" type=\"b\"><default>true</default></key>\n <key name=\"count\" type=\"u\"><default>7</default></key>\n <key name=\"ratio\" type=\"d\"><default>1.5</default></key>\n </schema>\n</schemalist>\n";
|
|
34
|
+
export declare const FIXTURE_SCHEMA_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<schemalist>\n <schema id=\"eu.jumplink.Learn6502\" path=\"/eu/jumplink/Learn6502/\">\n <key name=\"ui-font\" type=\"s\"><default>'Sans 11'</default></key>\n <key name=\"primary-color\" type=\"s\"><default>''</default></key>\n <key name=\"accent-color\" type=\"s\"><default>''</default></key>\n <key name=\"font-name\" type=\"s\"><default>'Monospace 12'</default></key>\n <key name=\"color-scheme\" type=\"i\"><default>0</default></key>\n <key name=\"window-width\" type=\"i\"><default>1000</default></key>\n <key name=\"window-height\" type=\"i\"><default>700</default></key>\n <key name=\"is-maximized\" type=\"b\"><default>false</default></key>\n <key name=\"show-line-numbers\" type=\"b\"><default>true</default></key>\n <key name=\"auto-indent\" type=\"b\"><default>true</default></key>\n <key name=\"count\" type=\"u\"><default>7</default></key>\n <key name=\"ratio\" type=\"d\"><default>1.5</default></key>\n <key name=\"support-prompt-years\" type=\"ai\"><default>[]</default></key>\n <key name=\"tags\" type=\"as\"><default>['a', \"b'c\"]</default></key>\n </schema>\n</schemalist>\n";
|
|
24
35
|
export interface SettingsVector {
|
|
25
36
|
readonly row: string;
|
|
26
37
|
readonly rule: string;
|
package/lib/types/settings.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
1
|
+
import { GLibVariant } from '@gjsify/adwaita-core';
|
|
2
|
+
export type BasicKeyType = 'b' | 'i' | 'u' | 'd' | 's';
|
|
3
|
+
export type ArrayKeyType = 'ab' | 'ai' | 'au' | 'ad' | 'as';
|
|
4
|
+
export type KeyType = BasicKeyType | ArrayKeyType;
|
|
5
|
+
export type BasicSettingValue = boolean | number | string;
|
|
6
|
+
export type SettingValue = BasicSettingValue | readonly BasicSettingValue[];
|
|
3
7
|
export interface SchemaKey {
|
|
4
8
|
readonly type: KeyType;
|
|
5
9
|
readonly default: SettingValue;
|
|
@@ -20,6 +24,11 @@ export interface SettingsProps {
|
|
|
20
24
|
path?: string;
|
|
21
25
|
}
|
|
22
26
|
type ChangedHandler = (settings: object, key: string) => void;
|
|
27
|
+
export declare function isArrayKeyType(type: KeyType): type is ArrayKeyType;
|
|
28
|
+
/** The text an array key is stored as: GLib's `print(false)`. */
|
|
29
|
+
export declare function printArrayValue(type: ArrayKeyType, value: SettingValue): string;
|
|
30
|
+
/** The inverse of {@link printArrayValue}; throws on text that is not a `type` value. */
|
|
31
|
+
export declare function parseArrayValue(type: ArrayKeyType, text: string): BasicSettingValue[];
|
|
23
32
|
/** The public instance surface; spelled out because declaration emit cannot carry `#private` members. */
|
|
24
33
|
export interface Settings {
|
|
25
34
|
readonly schema_id: string;
|
|
@@ -29,6 +38,8 @@ export interface Settings {
|
|
|
29
38
|
get_uint(key: string): number;
|
|
30
39
|
get_double(key: string): number;
|
|
31
40
|
get_string(key: string): string;
|
|
41
|
+
get_value(key: string): GLibVariant;
|
|
42
|
+
set_value(key: string, value: GLibVariant): boolean;
|
|
32
43
|
set_boolean(key: string, value: boolean): boolean;
|
|
33
44
|
set_int(key: string, value: number): boolean;
|
|
34
45
|
set_uint(key: string, value: number): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/app-settings",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.3-next.258",
|
|
4
4
|
"description": "Gio.Settings as a strict subset for the browser (localStorage) and NativeScript (ApplicationSettings); the native Gio.Settings on GJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -49,9 +49,12 @@
|
|
|
49
49
|
"nativescript",
|
|
50
50
|
"browser"
|
|
51
51
|
],
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@gjsify/adwaita-core": "0.64.3-next.258"
|
|
54
|
+
},
|
|
52
55
|
"devDependencies": {
|
|
53
|
-
"@gjsify/cli": "
|
|
54
|
-
"@gjsify/unit": "
|
|
56
|
+
"@gjsify/cli": "0.64.3-next.258",
|
|
57
|
+
"@gjsify/unit": "0.64.3-next.258",
|
|
55
58
|
"@types/node": "^25.9.2",
|
|
56
59
|
"typescript": "^6.0.3"
|
|
57
60
|
},
|
|
@@ -81,5 +84,6 @@
|
|
|
81
84
|
"bugs": {
|
|
82
85
|
"url": "https://github.com/gjsify/gjsify/issues"
|
|
83
86
|
},
|
|
84
|
-
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/web/app-settings#readme"
|
|
87
|
+
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/web/app-settings#readme",
|
|
88
|
+
"gitHead": "6d2fc430ffaa180a765c59d33c8fa1d5b410b364"
|
|
85
89
|
}
|