@gjsify/adwaita-app 0.64.1-next.241 → 0.64.1-next.244

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.
@@ -1,2 +1,2 @@
1
- import"./_virtual/_rolldown/runtime.js";import{scanXml as e}from"./appdata-xml.js";const t={applicationId:null,applicationName:null,developerName:null,version:null,website:null,supportUrl:null,issueUrl:null,license:null,releaseNotes:null};function localeScore(e,t){let n=0;for(let r=0;;r++){let i=r<e.length?e.charAt(r):`\0`,a=r<t.length?t.charAt(r):`\0`;if((i===`-`||i===`\0`)&&(a===`-`||a===`\0`)&&n++,i===`\0`||a===`\0`)break;if(i!==a)return 0}return n}function appdataLocale(e,t={}){let n,r=e[0];r!==void 0&&!r.includes(`_`)&&t.LANG!==void 0&&t.LANG.includes(`_`)&&(n=t.LANG),n=n??r??`C`,n.endsWith(`.UTF-8`)&&(n=n.slice(0,-6));let i=``,a=n.indexOf(`@`);if(a>=0){let e=n.slice(a);e.startsWith(`@cyrillic`)?i=`-Cyrl`:e.startsWith(`@devanagari`)?i=`-Deva`:e.startsWith(`@latin`)?i=`-Latn`:e.startsWith(`@shaw`)?i=`-Shaw`:e.startsWith(`@euro`)||(i=`-euro`),n=n.slice(0,a)}return n.replace(/_/g,`-`)+i}function childElements(e,t,n){let r=[],i=t;for(;i<n;){let t=e[i];if(t.kind!==`open`){i+=1;continue}let a=t;if(a.selfClosing){r.push({name:a.name,attributes:a.attributes,start:i+1,end:i+1}),i+=1;continue}let o=1,s=i+1;for(;s<n&&o>0;){let t=e[s];t.kind===`open`?t.selfClosing||(o+=1):t.kind===`close`&&--o,s+=1}let c=o===0?s-1:n;r.push({name:a.name,attributes:a.attributes,start:i+1,end:c}),i=o===0?s:n}return r}function elementText(e,t){let n=0,r=``;for(let i=t.start;i<t.end;i++){let t=e[i];t.kind===`open`?t.selfClosing||(n+=1):t.kind===`close`?--n:n===0&&(r+=t.text)}return r.trim()}const lang=e=>e.attributes[`xml:lang`]??`C`;function considerTranslatable(e,t,n,r){(e.value===null&&lang(t)===`C`||r>e.score)&&(e.score=r,e.value=n)}function escapeMarkup(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/'/g,`&#39;`).replace(/"/g,`&quot;`)}function inlineMarkup(e,t){let n=``,r=!0,i=0,a=0;for(let o=t.start;o<t.end;o++){let t=e[o];if(t.kind===`open`){let e=t,r=!e.selfClosing;if(r&&(a+=1),i>0)continue;e.name===`em`||e.name===`code`?n+=`<${e.name}>`:r&&(i=a)}else if(t.kind===`close`)i>0&&a===i?i=0:i===0&&(t.name===`em`||t.name===`code`)&&(n+=`</${t.name}>`),--a;else if(i===0){let e=``;for(let n of t.text){if(n===`
1
+ import"./_virtual/_rolldown/runtime.js";import{scanXml as e}from"@gjsify/utils/core";const t={applicationId:null,applicationName:null,developerName:null,version:null,website:null,supportUrl:null,issueUrl:null,license:null,releaseNotes:null};function localeScore(e,t){let n=0;for(let r=0;;r++){let i=r<e.length?e.charAt(r):`\0`,a=r<t.length?t.charAt(r):`\0`;if((i===`-`||i===`\0`)&&(a===`-`||a===`\0`)&&n++,i===`\0`||a===`\0`)break;if(i!==a)return 0}return n}function appdataLocale(e,t={}){let n,r=e[0];r!==void 0&&!r.includes(`_`)&&t.LANG!==void 0&&t.LANG.includes(`_`)&&(n=t.LANG),n=n??r??`C`,n.endsWith(`.UTF-8`)&&(n=n.slice(0,-6));let i=``,a=n.indexOf(`@`);if(a>=0){let e=n.slice(a);e.startsWith(`@cyrillic`)?i=`-Cyrl`:e.startsWith(`@devanagari`)?i=`-Deva`:e.startsWith(`@latin`)?i=`-Latn`:e.startsWith(`@shaw`)?i=`-Shaw`:e.startsWith(`@euro`)||(i=`-euro`),n=n.slice(0,a)}return n.replace(/_/g,`-`)+i}function childElements(e,t,n){let r=[],i=t;for(;i<n;){let t=e[i];if(t.kind!==`open`){i+=1;continue}let a=t;if(a.selfClosing){r.push({name:a.name,attributes:a.attributes,start:i+1,end:i+1}),i+=1;continue}let o=1,s=i+1;for(;s<n&&o>0;){let t=e[s];t.kind===`open`?t.selfClosing||(o+=1):t.kind===`close`&&--o,s+=1}let c=o===0?s-1:n;r.push({name:a.name,attributes:a.attributes,start:i+1,end:c}),i=o===0?s:n}return r}function elementText(e,t){let n=0,r=``;for(let i=t.start;i<t.end;i++){let t=e[i];t.kind===`open`?t.selfClosing||(n+=1):t.kind===`close`?--n:n===0&&(r+=t.text)}return r.trim()}const lang=e=>e.attributes[`xml:lang`]??`C`;function considerTranslatable(e,t,n,r){(e.value===null&&lang(t)===`C`||r>e.score)&&(e.score=r,e.value=n)}function escapeMarkup(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/'/g,`&#39;`).replace(/"/g,`&quot;`)}function inlineMarkup(e,t){let n=``,r=!0,i=0,a=0;for(let o=t.start;o<t.end;o++){let t=e[o];if(t.kind===`open`){let e=t,r=!e.selfClosing;if(r&&(a+=1),i>0)continue;e.name===`em`||e.name===`code`?n+=`<${e.name}>`:r&&(i=a)}else if(t.kind===`close`)i>0&&a===i?i=0:i===0&&(t.name===`em`||t.name===`code`)&&(n+=`</${t.name}>`),--a;else if(i===0){let e=``;for(let n of t.text){if(n===`
2
2
  `||n===` `||n===` `){if(r)continue;e+=` `,r=!0;continue}e+=n,r=!1}n+=escapeMarkup(e)}}return n}function parseDescription(e,t,n){let r=new Map,bucketFor=(e,t)=>{if(localeScore(n,e)===0&&e!==`C`)return null;let i=r.get(e);return i===void 0&&(i=[],r.set(e,i),t!==void 0&&i.push(`<${t}>\n`)),i};for(let n of childElements(e,t.start,t.end))if(n.name===`p`)bucketFor(lang(n))?.push(`<p>${inlineMarkup(e,n)}</p>\n`);else if(n.name===`ul`||n.name===`ol`){for(let e of r.values())e.push(`<${n.name}>\n`);for(let t of childElements(e,n.start,n.end))t.name===`li`&&bucketFor(lang(t),n.name)?.push(`<li>${inlineMarkup(e,t)}</li>\n`);for(let e of r.values())e.push(`</${n.name}>\n`)}let i=r.get(`C`),a=0;for(let[e,t]of r){let r=localeScore(n,e);r>a&&(a=r,i=t)}return i===void 0?null:i.join(``)}function parseAppdata(n,r={}){let i=r.locale??`C`,a=e(n),o=childElements(a,0,a.length).find(e=>e.name===`component`||e.name===`application`);if(o===void 0)return{...t};let s={...t},c={value:null,score:0},l={value:null,score:0},u=[],d=null;for(let e of childElements(a,o.start,o.end))switch(e.name){case`id`:s.applicationId===null&&(s.applicationId=elementText(a,e));break;case`name`:considerTranslatable(c,e,elementText(a,e),localeScore(i,lang(e)));break;case`developer`:for(let t of childElements(a,e.start,e.end)){if(t.name!==`name`)continue;let e=localeScore(i,lang(t))+1024;e>l.score&&(lang(t)===`C`||e>1024)&&(l.score=e,l.value=elementText(a,t))}break;case`developer_name`:considerTranslatable(l,e,elementText(a,e),localeScore(i,lang(e)));break;case`url`:{let t=elementText(a,e);e.attributes.type===`homepage`?s.website=t:e.attributes.type===`bugtracker`?s.issueUrl=t:e.attributes.type===`help`&&(s.supportUrl=t);break}case`launchable`:e.attributes.type===`desktop-id`&&u.push(elementText(a,e));break;case`project_license`:s.license===null&&(s.license=elementText(a,e));break;case`releases`:d===null&&(d=e);break;default:break}if(s.applicationName=c.value,s.developerName=l.value,d!==null){let e=childElements(a,d.start,d.end).filter(e=>e.name===`release`);s.version=e[0]?.attributes.version??null;let t=r.releaseNotesVersion;if(t!==void 0&&t!==``){let n=e.find(e=>e.attributes.version===t),r=n&&childElements(a,n.start,n.end).find(e=>e.name===`description`);r&&(s.releaseNotes=parseDescription(a,r,i))}}s.applicationId!==null&&s.applicationId.endsWith(`.desktop`)&&(u.includes(`${s.applicationId}.desktop`)||(s.applicationId=s.applicationId.slice(0,-8)));for(let e of Object.keys(s))s[e]===``&&(s[e]=null);return s}export{appdataLocale,localeScore,parseAppdata};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{appdataLocale as e,parseAppdata as t}from"./appdata.js";import{applyAppdataFields as n,buildAboutDialogFromAppdata as r,createAboutDialog as i,hasAppdataConstructor as a,licenseTypeFor as o}from"./about-dialog.js";import{BUNDLED_ICON_COUNT as s,BUNDLED_ICON_RESOURCE_PATH as c}from"./icons.generated.js";import{BUNDLED_ICON_THEME_NAME as l,addBundledIconsToTheme as u,installBundledIconTheme as d,registerBundledIconResource as f}from"./icon-theme.js";import{AdwaitaApp as p,runAdwaitaApp as m,runApplication as h}from"./application.js";import{readAppDevHooks as g}from"./dev-hooks.js";import{confirmDialog as _,errorDialog as v}from"./dialogs.js";import{pickFile as y,saveFile as b}from"./file-dialog.js";import{createNavShell as x}from"./nav-shell.js";import{LoadToken as S,loadIntoStack as C}from"./view-loader.js";import{LoadingStack as w}from"./loading-stack.js";import{registerToastOverlay as T,showToast as E}from"./toast.js";import{SYSTEM_LOCALE_DIR as D,resolveLocaleDir as O,systemLocaleDir as k}from"./locale-dir.js";import{initLocale as A}from"./locale.js";import{APPLE_ACCENT_COLOR_ARGV as j,MACOS_ACCENT_POLL_SECONDS as M,onMacosAccentColorChanged as N,readMacosAccentColor as P}from"./system-accent.js";import{findNavItem as F,resolveInitialNavIndex as I}from"./nav-model.js";export{j as APPLE_ACCENT_COLOR_ARGV,p as AdwaitaApp,s as BUNDLED_ICON_COUNT,c as BUNDLED_ICON_RESOURCE_PATH,l as BUNDLED_ICON_THEME_NAME,S as LoadToken,w as LoadingStack,M as MACOS_ACCENT_POLL_SECONDS,D as SYSTEM_LOCALE_DIR,u as addBundledIconsToTheme,e as appdataLocale,n as applyAppdataFields,r as buildAboutDialogFromAppdata,_ as confirmDialog,i as createAboutDialog,x as createNavShell,v as errorDialog,F as findNavItem,a as hasAppdataConstructor,A as initLocale,d as installBundledIconTheme,o as licenseTypeFor,C as loadIntoStack,N as onMacosAccentColorChanged,t as parseAppdata,y as pickFile,g as readAppDevHooks,P as readMacosAccentColor,f as registerBundledIconResource,T as registerToastOverlay,I as resolveInitialNavIndex,O as resolveLocaleDir,m as runAdwaitaApp,h as runApplication,b as saveFile,E as showToast,k as systemLocaleDir};
1
+ import{appdataLocale as e,parseAppdata as t}from"./appdata.js";import{applyAppdataFields as n,buildAboutDialogFromAppdata as r,createAboutDialog as i,hasAppdataConstructor as a,licenseTypeFor as o}from"./about-dialog.js";import{BUNDLED_ICON_COUNT as s,BUNDLED_ICON_RESOURCE_PATH as c}from"./icons.generated.js";import{BUNDLED_ICON_THEME_NAME as l,addBundledIconsToTheme as u,installBundledIconTheme as d,registerBundledIconResource as f}from"./icon-theme.js";import{AdwaitaApp as p,runAdwaitaApp as m,runApplication as h}from"./application.js";import{readAppDevHooks as g}from"./dev-hooks.js";import{confirmDialog as _,errorDialog as v}from"./dialogs.js";import{pickFile as y,saveFile as b}from"./file-dialog.js";import{createNavShell as x}from"./nav-shell.js";import{LoadToken as S,loadIntoStack as C}from"./view-loader.js";import{LoadingStack as w}from"./loading-stack.js";import{registerToastOverlay as T,showToast as E}from"./toast.js";import{SYSTEM_LOCALE_DIR as D,resolveLocaleDir as O,systemLocaleDir as k}from"./locale-dir.js";import{LOCALE_ENV_VARS as A,localeEnvToSet as j,posixLocale as M}from"./locale-env.js";import{initLocale as N}from"./locale.js";import{APPLE_ACCENT_COLOR_ARGV as P,MACOS_ACCENT_POLL_SECONDS as F,onMacosAccentColorChanged as I,readMacosAccentColor as L}from"./system-accent.js";import{findNavItem as R,resolveInitialNavIndex as z}from"./nav-model.js";export{P as APPLE_ACCENT_COLOR_ARGV,p as AdwaitaApp,s as BUNDLED_ICON_COUNT,c as BUNDLED_ICON_RESOURCE_PATH,l as BUNDLED_ICON_THEME_NAME,A as LOCALE_ENV_VARS,S as LoadToken,w as LoadingStack,F as MACOS_ACCENT_POLL_SECONDS,D as SYSTEM_LOCALE_DIR,u as addBundledIconsToTheme,e as appdataLocale,n as applyAppdataFields,r as buildAboutDialogFromAppdata,_ as confirmDialog,i as createAboutDialog,x as createNavShell,v as errorDialog,R as findNavItem,a as hasAppdataConstructor,N as initLocale,d as installBundledIconTheme,o as licenseTypeFor,C as loadIntoStack,j as localeEnvToSet,I as onMacosAccentColorChanged,t as parseAppdata,y as pickFile,M as posixLocale,g as readAppDevHooks,L as readMacosAccentColor,f as registerBundledIconResource,T as registerToastOverlay,z as resolveInitialNavIndex,O as resolveLocaleDir,m as runAdwaitaApp,h as runApplication,b as saveFile,E as showToast,k as systemLocaleDir};
@@ -0,0 +1 @@
1
+ import"./_virtual/_rolldown/runtime.js";const e=[`LANGUAGE`,`LC_ALL`,`LC_MESSAGES`,`LANG`];function posixLocale(e){if(e===void 0)return;let[t,...n]=e.trim().split(/[.@]/)[0].split(/-u-|-x-/i)[0].split(/[-_]/);if(!/^[A-Za-z]{2,3}$/.test(t??``)||/^(c|posix)$/i.test(t))return;let r=n.find(e=>/^[A-Za-z]{2}$/.test(e));return r===void 0?t.toLowerCase():`${t.toLowerCase()}_${r.toUpperCase()}`}function localeEnvToSet(t){if(t.platform===`win32`&&!e.some(e=>(t.env[e]??``).trim()!==``))for(let e of t.userLocales){let t=posixLocale(e);if(t!==void 0)return t}}export{e as LOCALE_ENV_VARS,localeEnvToSet,posixLocale};
package/lib/esm/locale.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{resolveLocaleDir as e}from"./locale-dir.js";import t from"gi://GLib?version=2.0";import n from"gettext";function initLocale(r,i={}){let a=e({...i,env:{GJSIFY_LOCALE_DIR:t.getenv(`GJSIFY_LOCALE_DIR`)??void 0},platform:typeof process>`u`?void 0:process.platform});return n.setlocale(n.LocaleCategory.ALL,``),a!==void 0&&n.bindtextdomain(r,a),n.textdomain(r),Object.assign(e=>n.dgettext(r,e),{plural:(e,t,i)=>n.dngettext(r,e,t,i),context:(e,t)=>n.dpgettext(r,e,t),localeDir:a,domain:r})}export{initLocale};
1
+ import"./_virtual/_rolldown/runtime.js";import{resolveLocaleDir as e}from"./locale-dir.js";import{LOCALE_ENV_VARS as t,localeEnvToSet as n}from"./locale-env.js";import r from"gi://GLib?version=2.0";import i from"gettext";function adoptUserLocaleOnWindows(e){if(e!==`win32`)return;let i={};for(let e of t)i[e]=r.getenv(e)??process.env[e];let a=n({platform:e,env:i,userLocales:[typeof Intl>`u`?void 0:Intl.DateTimeFormat().resolvedOptions().locale,r.get_language_names()[0]]});a!==void 0&&(r.setenv(`LANG`,a,!1),process.env.LANG=a)}function initLocale(t,n={}){let a=typeof process>`u`?void 0:process.platform,o=e({...n,env:{GJSIFY_LOCALE_DIR:r.getenv(`GJSIFY_LOCALE_DIR`)??void 0},platform:a});return adoptUserLocaleOnWindows(a),i.setlocale(i.LocaleCategory.ALL,``),o!==void 0&&i.bindtextdomain(t,o),i.textdomain(t),Object.assign(e=>i.dgettext(t,e),{plural:(e,n,r)=>i.dngettext(t,e,n,r),context:(e,n)=>i.dpgettext(t,e,n),localeDir:o,domain:t})}export{initLocale};
@@ -20,6 +20,8 @@ export { initLocale } from './locale.js';
20
20
  export type { InitLocaleOptions, Translator } from './locale.js';
21
21
  export { SYSTEM_LOCALE_DIR, resolveLocaleDir, systemLocaleDir } from './locale-dir.js';
22
22
  export type { ResolveLocaleDirOptions } from './locale-dir.js';
23
+ export { LOCALE_ENV_VARS, localeEnvToSet, posixLocale } from './locale-env.js';
24
+ export type { LocaleEnvOptions } from './locale-env.js';
23
25
  export { APPLE_ACCENT_COLOR_ARGV, MACOS_ACCENT_POLL_SECONDS, onMacosAccentColorChanged, readMacosAccentColor, } from './system-accent.js';
24
26
  export type { OnMacosAccentColorChangedOptions, ReadMacosAccentColorOptions } from './system-accent.js';
25
27
  export { readAppDevHooks } from './dev-hooks.js';
@@ -0,0 +1,25 @@
1
+ /** The variables gettext consults, in its own precedence order. */
2
+ export declare const LOCALE_ENV_VARS: readonly string[];
3
+ /**
4
+ * A BCP 47 tag (`de-DE`, `zh-Hans-CN`) or a POSIX locale (`de_DE.UTF-8`) as `ll[_CC]`, or
5
+ * `undefined` for "C"/"POSIX"/garbage — a value that must not be written into `LANG`.
6
+ *
7
+ * The script subtag and any extension (`-u-ca-…`) are dropped: gettext catalogues are named
8
+ * `ll_CC`, so `zh-Hant-TW` must become `zh_TW`.
9
+ */
10
+ export declare function posixLocale(tag: string | undefined): string | undefined;
11
+ export interface LocaleEnvOptions {
12
+ /** `process.platform`. Anything but `win32` answers `undefined`. */
13
+ platform?: string;
14
+ /** The current values of {@link LOCALE_ENV_VARS}. */
15
+ env: Record<string, string | undefined>;
16
+ /** The user's locale, best source first — a BCP 47 tag or a POSIX name. */
17
+ userLocales: readonly (string | undefined)[];
18
+ }
19
+ /**
20
+ * The value to export as `LANG`, or `undefined` for "leave the environment alone".
21
+ *
22
+ * Only on win32, and only when all four variables are unset or empty: a user who set any of
23
+ * them chose a locale, and this must never override it.
24
+ */
25
+ export declare function localeEnvToSet(options: LocaleEnvOptions): string | undefined;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/adwaita-app",
3
- "version": "0.64.1-next.241",
3
+ "version": "0.64.1-next.244",
4
4
  "description": "Native Adwaita application shell for GJS/GTK apps — Adw.Application lifecycle (runAsync + devtools + CSS), a data-driven NavigationSplitView nav shell, an async-view mounter, promise dialog/toast/file helpers, and a display-less reader of the desktop accent and colour scheme (`./appearance`)",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -57,13 +57,14 @@
57
57
  "@girs/glib-2.0": "5.4.0",
58
58
  "@girs/gobject-2.0": "5.4.0",
59
59
  "@girs/gtk-4.0": "5.4.0",
60
- "@gjsify/adwaita-core": "0.64.1-next.241",
61
- "@gjsify/devtools": "0.64.1-next.241"
60
+ "@gjsify/adwaita-core": "0.64.1-next.244",
61
+ "@gjsify/devtools": "0.64.1-next.244",
62
+ "@gjsify/utils": "0.64.1-next.244"
62
63
  },
63
64
  "devDependencies": {
64
- "@gjsify/cli": "0.64.1-next.241",
65
- "@gjsify/storybook": "0.64.1-next.241",
66
- "@gjsify/unit": "0.64.1-next.241",
65
+ "@gjsify/cli": "0.64.1-next.244",
66
+ "@gjsify/storybook": "0.64.1-next.244",
67
+ "@gjsify/unit": "0.64.1-next.244",
67
68
  "@types/node": "^25.9.2",
68
69
  "typescript": "^6.0.3"
69
70
  },
@@ -101,5 +102,5 @@
101
102
  "url": "https://github.com/gjsify/gjsify/issues"
102
103
  },
103
104
  "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/framework/adwaita-app#readme",
104
- "gitHead": "9937e8d27d18d159e35471b6669bdca6dff0cd05"
105
+ "gitHead": "9a6ca179c1a74477f23791c5b8f6d5a7bffaee61"
105
106
  }
@@ -1 +0,0 @@
1
- import"./_virtual/_rolldown/runtime.js";const e={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`};function decodeXmlEntities(t){return t.includes(`&`)?t.replace(/&(#[Xx][0-9A-Fa-f]+|#[0-9]+|[A-Za-z][A-Za-z0-9]*);/g,(t,n)=>{if(n.charAt(0)!==`#`)return e[n]??t;let r=n.charAt(1)===`x`||n.charAt(1)===`X`,i=Number.parseInt(r?n.slice(2):n.slice(1),r?16:10);return!Number.isFinite(i)||i<1||i>1114111||i>=55296&&i<=57343?t:String.fromCodePoint(i)}):t}function findTagEnd(e,t){let n=``;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if(n)t===n&&(n=``);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return r}return-1}const t=/([^\s=/<>]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function parseAttributes(e){let n={};t.lastIndex=0;let r=t.exec(e);for(;r!==null;)r[1]in n||(n[r[1]]=decodeXmlEntities(r[2]??r[3]??``)),r=t.exec(e);return n}function scanXml(e){let t=[],pushText=e=>{t.push({kind:`text`,text:decodeXmlEntities(e)})},n=0;for(;n<e.length;){let r=e.indexOf(`<`,n);if(r<0){pushText(e.slice(n));break}if(r>n&&pushText(e.slice(n,r)),e.startsWith(`<!--`,r)){let t=e.indexOf(`-->`,r+4);n=t<0?e.length:t+3;continue}if(e.startsWith(`<![CDATA[`,r)){let i=e.indexOf(`]]>`,r+9);t.push({kind:`text`,text:e.slice(r+9,i<0?e.length:i)}),n=i<0?e.length:i+3;continue}if(e.startsWith(`<?`,r)){let t=e.indexOf(`?>`,r+2);n=t<0?e.length:t+2;continue}if(e.startsWith(`<!`,r)){let t=e.indexOf(`>`,r+2);n=t<0?e.length:t+1;continue}let i=findTagEnd(e,r);if(i<0){pushText(e.slice(r));break}let a=e.slice(r+1,i);if(n=i+1,a.charAt(0)===`/`){let e=a.slice(1).trim();e!==``&&t.push({kind:`close`,name:e});continue}let o=a,s=!1;o.endsWith(`/`)&&(s=!0,o=o.slice(0,-1));let c=/^([^\s/<>]+)/.exec(o);if(c===null)continue;let l=c[1];t.push({kind:`open`,name:l,attributes:parseAttributes(o.slice(l.length)),selfClosing:s})}return t}export{decodeXmlEntities,scanXml};
@@ -1,38 +0,0 @@
1
- /** An opening (or self-closing) element. */
2
- export interface XmlOpenTag {
3
- kind: 'open';
4
- /** Element name exactly as written, prefix included (`xml:lang` is an attribute, not this). */
5
- name: string;
6
- /** Attribute values with entities already decoded. */
7
- attributes: Record<string, string>;
8
- /** `true` for `<foo/>`, which emits no matching {@link XmlCloseTag}. */
9
- selfClosing: boolean;
10
- }
11
- /** A closing element. */
12
- export interface XmlCloseTag {
13
- kind: 'close';
14
- name: string;
15
- }
16
- /** Character data between elements, with entities already decoded. */
17
- export interface XmlText {
18
- kind: 'text';
19
- text: string;
20
- }
21
- export type XmlToken = XmlOpenTag | XmlCloseTag | XmlText;
22
- /**
23
- * Resolve the entity references a metainfo file may contain.
24
- *
25
- * An UNKNOWN reference is returned verbatim rather than dropped. A metainfo file is
26
- * hand-written and `&` is the character most often left unescaped in one; turning
27
- * `Tom & Jerry` into `Tom ` would silently truncate a developer name, which is exactly
28
- * the kind of Windows-only difference this module exists to prevent.
29
- */
30
- export declare function decodeXmlEntities(text: string): string;
31
- /**
32
- * Tokenise an XML document.
33
- *
34
- * Returns an array rather than a generator on purpose: a metainfo file is a few kilobytes,
35
- * three bundler targets (`gjs`, `node`, library) have to agree on the output, and an array
36
- * is the form that needs no iteration-protocol support from any of them.
37
- */
38
- export declare function scanXml(xml: string): XmlToken[];