@gjsify/rolldown-plugin-gjsify 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.
@@ -1,8 +1,10 @@
1
1
  import type { Plugin } from 'rolldown';
2
2
  export declare const GSCHEMA_PLUGIN = "gjsify-gschema";
3
+ type BasicType = 'b' | 'i' | 'u' | 'd' | 's';
4
+ type BasicValue = boolean | number | string;
3
5
  export interface GschemaKey {
4
- type: 'b' | 'i' | 'u' | 'd' | 's';
5
- default: boolean | number | string;
6
+ type: BasicType | `a${BasicType}`;
7
+ default: BasicValue | BasicValue[];
6
8
  }
7
9
  export interface GschemaOut {
8
10
  id: string;
@@ -15,3 +17,4 @@ export interface GschemaPluginOptions {
15
17
  mode: 'emit' | 'ignore';
16
18
  }
17
19
  export declare function gschemaPlugin({ mode }: GschemaPluginOptions): Plugin;
20
+ export {};
@@ -7,12 +7,12 @@
7
7
  // the no-op `Settings.register`.
8
8
  //
9
9
  // What the subset cannot honour is refused HERE, naming the key and the line, rather than
10
- // compiled into a schema that behaves differently from GNOME's: a key type outside `b i u d s`,
11
- // `<range>`, `<choices>`, `<enum>`, `<flags>`, `<child>`, `<override>`, and a schema without
10
+ // compiled into a schema that behaves differently from GNOME's: a key type outside `b i u d s`
11
+ // and the arrays of them (`ab ai au ad as`, ADR 0118 § 3), `<range>`, `<choices>`, `<enum>`, `<flags>`, `<child>`, `<override>`, and a schema without
12
12
  // `path` (the storage key is `<path><key>`).
13
13
  import { readFile } from 'node:fs/promises';
14
14
  export const GSCHEMA_PLUGIN = 'gjsify-gschema';
15
- const KEY_TYPES = new Set(['b', 'i', 'u', 'd', 's']);
15
+ const KEY_TYPES = new Set(['b', 'i', 'u', 'd', 's', 'ab', 'ai', 'au', 'ad', 'as']);
16
16
  const REFUSED_TAGS = ['range', 'choices', 'enum', 'flags', 'child', 'override'];
17
17
  function lineOf(xml, index) {
18
18
  return xml.slice(0, index).split('\n').length;
@@ -31,9 +31,54 @@ function unescapeXml(s) {
31
31
  .replace(/&apos;/g, "'")
32
32
  .replace(/&amp;/g, '&');
33
33
  }
34
- /** GVariant text format for the five supported types. */
34
+ /**
35
+ * The elements of an array default: `[]`, `@ai []` or `[a, b, …]`. Restricted to what a schema
36
+ * default of `ab ai au ad as` holds; the runtime reads stored values with adwaita-core's
37
+ * `GLibVariant.parseText`, which this build step cannot depend on.
38
+ */
39
+ function splitArray(text, type) {
40
+ const body = text.replace(new RegExp(`^@${type}\\s+`), '');
41
+ if (!body.startsWith('[') || !body.endsWith(']'))
42
+ return undefined;
43
+ const inner = body.slice(1, -1).trim();
44
+ if (inner === '')
45
+ return [];
46
+ const items = [];
47
+ let start = 0;
48
+ let quote = '';
49
+ for (let i = 0; i < inner.length; i++) {
50
+ const c = inner[i];
51
+ if (quote) {
52
+ if (c === '\\')
53
+ i++;
54
+ else if (c === quote)
55
+ quote = '';
56
+ }
57
+ else if (c === "'" || c === '"')
58
+ quote = c;
59
+ else if (c === ',') {
60
+ items.push(inner.slice(start, i).trim());
61
+ start = i + 1;
62
+ }
63
+ }
64
+ if (quote)
65
+ return undefined;
66
+ items.push(inner.slice(start).trim());
67
+ return items.includes('') ? undefined : items;
68
+ }
69
+ /** GVariant text format for the supported types. */
35
70
  function parseDefault(raw, type, where) {
36
71
  const text = unescapeXml(raw.trim());
72
+ if (type.length === 2) {
73
+ const items = splitArray(text, type);
74
+ const element = type[1];
75
+ if (items)
76
+ return items.map((item) => parseBasic(item, element, where));
77
+ throw new Error(`${where}: default '${text}' is not a valid '${type}' value`);
78
+ }
79
+ return parseBasic(text, type, where);
80
+ }
81
+ function parseBasic(text, type, where) {
37
82
  if (type === 'b') {
38
83
  if (text === 'true' || text === 'false')
39
84
  return text === 'true';
@@ -79,7 +124,7 @@ export function parseGschema(xml, file) {
79
124
  if (!name)
80
125
  throw new Error(`${where}: <key> has no name`);
81
126
  if (!type || !KEY_TYPES.has(type)) {
82
- throw new Error(`${where}: key '${name}' has type '${type}'; the subset supports b, i, u, d, s`);
127
+ throw new Error(`${where}: key '${name}' has type '${type}'; the subset supports b, i, u, d, s and arrays of them`);
83
128
  }
84
129
  const def = /<default\b[^>]*>([\s\S]*?)<\/default>/.exec(m[2]);
85
130
  if (!def)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-gjsify",
3
- "version": "0.64.2",
3
+ "version": "0.64.3-next.258",
4
4
  "description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -67,12 +67,12 @@
67
67
  ],
68
68
  "license": "MIT",
69
69
  "dependencies": {
70
- "@gjsify/console": "^0.64.2",
71
- "@gjsify/resolve-npm": "^0.64.2",
72
- "@gjsify/rolldown-plugin-deepkit": "^0.64.2",
73
- "@gjsify/rolldown-plugin-pnp": "^0.64.2",
74
- "@gjsify/utils": "^0.64.2",
75
- "@gjsify/vite-plugin-blueprint": "^0.64.2",
70
+ "@gjsify/console": "0.64.3-next.258",
71
+ "@gjsify/resolve-npm": "0.64.3-next.258",
72
+ "@gjsify/rolldown-plugin-deepkit": "0.64.3-next.258",
73
+ "@gjsify/rolldown-plugin-pnp": "0.64.3-next.258",
74
+ "@gjsify/utils": "0.64.3-next.258",
75
+ "@gjsify/vite-plugin-blueprint": "0.64.3-next.258",
76
76
  "@rollup/pluginutils": "^5.4.0",
77
77
  "acorn": "^8.17.0",
78
78
  "acorn-typescript": "^1.4.13",
@@ -82,7 +82,7 @@
82
82
  "sass": "^1.101.0"
83
83
  },
84
84
  "peerDependencies": {
85
- "@gjsify/lightningcss-native": "^0.64.2",
85
+ "@gjsify/lightningcss-native": "0.64.3-next.258",
86
86
  "rolldown": "^1.1.4"
87
87
  },
88
88
  "peerDependenciesMeta": {
@@ -94,8 +94,8 @@
94
94
  }
95
95
  },
96
96
  "devDependencies": {
97
- "@gjsify/cli": "^0.64.2",
98
- "@gjsify/unit": "^0.64.2",
97
+ "@gjsify/cli": "0.64.3-next.258",
98
+ "@gjsify/unit": "0.64.3-next.258",
99
99
  "@types/node": "^25.9.2",
100
100
  "rolldown": "^1.1.4",
101
101
  "typescript": "^6.0.3"
@@ -107,5 +107,6 @@
107
107
  "darwin": "supported",
108
108
  "win32": "supported"
109
109
  }
110
- }
110
+ },
111
+ "gitHead": "6d2fc430ffaa180a765c59d33c8fa1d5b410b364"
111
112
  }