@hewel/zgui-build 0.1.0 → 0.1.2
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 +3 -1
- package/package.json +1 -1
- package/sdk/Cargo.lock +5 -4
- package/sdk/bun.lock +7 -7
- package/sdk/package.json +1 -1
- package/src/build.ts +158 -24
- package/src/public-api.d.ts +7 -0
package/README.md
CHANGED
|
@@ -75,7 +75,9 @@ zgui-js build ./my-app --watch --capabilities-file ./generated/plugin-capabiliti
|
|
|
75
75
|
|
|
76
76
|
Install or link the build package and SDK dependencies in the consumer repository. Declare `@hewel/zgui` and, if used, `@hewel/zgui-services` in the app. The app owns `src/main.tsx`, `tsconfig.json` (which can extend `@hewel/zgui/tsconfig.native.json`), `package.json`, and optional assets. Pass `appDirectory` or use `resolveApplication` to select it. No workspace-wide `node_modules` link is needed.
|
|
77
77
|
|
|
78
|
-
`root` selects the SDK's default preview inputs and `bun.lock`/`Cargo.lock` provenance, not the app's working directory. The default is the SDK checkout for a linked build package or the shipped SDK resources for an installed tarball.
|
|
78
|
+
`root` selects the SDK's default preview inputs and `bun.lock`/`Cargo.lock` provenance, not the app's working directory. The default is the SDK checkout for a linked build package or the shipped SDK resources for an installed tarball.
|
|
79
|
+
|
|
80
|
+
On Linux `x86_64` (`glibc >= 2.39`), installing `@hewel/zgui-cli` automatically pulls the matching prebuilt `@hewel/zgui-host-linux-x64` binary via `optionalDependencies`, so `dev`, `preview`, and `package` resolve `zgui-host` with no Rust toolchain or explicit host flags. For custom host builds or platforms without a prebuilt host package, pass a matching checkout as `hostRoot` (or `--host-root <dir>`) to compile via Cargo, or pass a prebuilt binary as `hostExecutable` (or `--host-executable <path>`). The checkout and binary must match the package's host API and `lightningcss-v1` style profile.
|
|
79
81
|
|
|
80
82
|
For either CLI command, `--host-root <dir>` selects the checkout used to build the host and the working directory used to run it. `--host-executable <path>` skips Cargo and runs a prebuilt host; it can be combined with `--host-root` to set the host's working directory. Relative flag values resolve from the caller's current directory.
|
|
81
83
|
|
package/package.json
CHANGED
package/sdk/Cargo.lock
CHANGED
|
@@ -1646,7 +1646,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
|
|
1646
1646
|
|
|
1647
1647
|
[[package]]
|
|
1648
1648
|
name = "host-services"
|
|
1649
|
-
version = "0.1.
|
|
1649
|
+
version = "0.1.2"
|
|
1650
1650
|
dependencies = [
|
|
1651
1651
|
"bytes",
|
|
1652
1652
|
"flate2",
|
|
@@ -2060,7 +2060,7 @@ dependencies = [
|
|
|
2060
2060
|
|
|
2061
2061
|
[[package]]
|
|
2062
2062
|
name = "js-runtime"
|
|
2063
|
-
version = "0.1.
|
|
2063
|
+
version = "0.1.2"
|
|
2064
2064
|
dependencies = [
|
|
2065
2065
|
"rquickjs",
|
|
2066
2066
|
]
|
|
@@ -4623,7 +4623,7 @@ dependencies = [
|
|
|
4623
4623
|
|
|
4624
4624
|
[[package]]
|
|
4625
4625
|
name = "ui-bridge"
|
|
4626
|
-
version = "0.1.
|
|
4626
|
+
version = "0.1.2"
|
|
4627
4627
|
dependencies = [
|
|
4628
4628
|
"js-runtime",
|
|
4629
4629
|
"roxmltree 0.21.2",
|
|
@@ -6119,7 +6119,7 @@ dependencies = [
|
|
|
6119
6119
|
|
|
6120
6120
|
[[package]]
|
|
6121
6121
|
name = "zgui-host"
|
|
6122
|
-
version = "0.1.
|
|
6122
|
+
version = "0.1.2"
|
|
6123
6123
|
dependencies = [
|
|
6124
6124
|
"accesskit",
|
|
6125
6125
|
"accesskit_consumer",
|
|
@@ -6278,6 +6278,7 @@ dependencies = [
|
|
|
6278
6278
|
"wayland-scanner",
|
|
6279
6279
|
"zbus",
|
|
6280
6280
|
"zgui-geom",
|
|
6281
|
+
"zgui-layout",
|
|
6281
6282
|
"zgui-platform",
|
|
6282
6283
|
"zgui-profile",
|
|
6283
6284
|
"zgui-vocab",
|
package/sdk/bun.lock
CHANGED
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
},
|
|
161
161
|
"packages/build": {
|
|
162
162
|
"name": "@hewel/zgui-build",
|
|
163
|
-
"version": "0.1.
|
|
163
|
+
"version": "0.1.2",
|
|
164
164
|
"dependencies": {
|
|
165
165
|
"@solidjs/compiler": "2.0.1",
|
|
166
166
|
"lightningcss": "1.33.0",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
},
|
|
176
176
|
"packages/cli": {
|
|
177
177
|
"name": "@hewel/zgui-cli",
|
|
178
|
-
"version": "0.1.
|
|
178
|
+
"version": "0.1.2",
|
|
179
179
|
"bin": {
|
|
180
180
|
"zgui-js": "./src/cli.ts",
|
|
181
181
|
},
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
},
|
|
192
192
|
"packages/create-zgui-js": {
|
|
193
193
|
"name": "create-zgui-js",
|
|
194
|
-
"version": "0.1.
|
|
194
|
+
"version": "0.1.2",
|
|
195
195
|
"bin": {
|
|
196
196
|
"create-zgui-js": "./src/cli.ts",
|
|
197
197
|
},
|
|
@@ -204,22 +204,22 @@
|
|
|
204
204
|
},
|
|
205
205
|
"packages/host-linux-arm64": {
|
|
206
206
|
"name": "@hewel/zgui-host-linux-arm64",
|
|
207
|
-
"version": "0.1.
|
|
207
|
+
"version": "0.1.2",
|
|
208
208
|
},
|
|
209
209
|
"packages/host-linux-x64": {
|
|
210
210
|
"name": "@hewel/zgui-host-linux-x64",
|
|
211
|
-
"version": "0.1.
|
|
211
|
+
"version": "0.1.2",
|
|
212
212
|
},
|
|
213
213
|
"packages/services": {
|
|
214
214
|
"name": "@hewel/zgui-services",
|
|
215
|
-
"version": "0.1.
|
|
215
|
+
"version": "0.1.2",
|
|
216
216
|
"dependencies": {
|
|
217
217
|
"solid-js": "2.0.1",
|
|
218
218
|
},
|
|
219
219
|
},
|
|
220
220
|
"packages/ui": {
|
|
221
221
|
"name": "@hewel/zgui",
|
|
222
|
-
"version": "0.1.
|
|
222
|
+
"version": "0.1.2",
|
|
223
223
|
"dependencies": {
|
|
224
224
|
"@solidjs/signals": "2.0.1",
|
|
225
225
|
"@solidjs/universal": "2.0.1",
|
package/sdk/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -542,21 +542,87 @@ function parseCapabilities(input: unknown, source: string): Capabilities {
|
|
|
542
542
|
throw new Error(`${field} must be an object`);
|
|
543
543
|
const network: {
|
|
544
544
|
origins?: string[];
|
|
545
|
+
originRules?: {
|
|
546
|
+
origin: string;
|
|
547
|
+
allowInsecureHttp?: boolean;
|
|
548
|
+
allowPrivateNetworks?: boolean;
|
|
549
|
+
}[];
|
|
545
550
|
allowInsecureHttp?: boolean;
|
|
546
551
|
allowPrivateNetworks?: boolean;
|
|
547
552
|
} = {};
|
|
553
|
+
const originSet = new Set<string>();
|
|
554
|
+
const ruleSet = new Set<string>();
|
|
548
555
|
for (const [subKey, subVal] of Object.entries(value as Record<string, unknown>)) {
|
|
549
556
|
switch (subKey) {
|
|
550
557
|
case "origins": {
|
|
551
558
|
if (!Array.isArray(subVal)) throw new Error(`${field}.origins must be an array`);
|
|
552
|
-
const origins = new Set<string>();
|
|
553
559
|
for (const item of subVal as unknown[]) {
|
|
554
560
|
const parsed = parseNetworkOrigin(item, `${field}.origins`);
|
|
555
|
-
if (
|
|
561
|
+
if (originSet.has(parsed.canonical))
|
|
556
562
|
throw new Error(`${field}.origins contains duplicate origin ${parsed.canonical}`);
|
|
557
|
-
|
|
563
|
+
originSet.add(parsed.canonical);
|
|
558
564
|
}
|
|
559
|
-
if (
|
|
565
|
+
if (originSet.size) network.origins = [...originSet];
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
case "originRules": {
|
|
569
|
+
if (!Array.isArray(subVal)) throw new Error(`${field}.originRules must be an array`);
|
|
570
|
+
const rules: {
|
|
571
|
+
origin: string;
|
|
572
|
+
allowInsecureHttp?: boolean;
|
|
573
|
+
allowPrivateNetworks?: boolean;
|
|
574
|
+
}[] = [];
|
|
575
|
+
for (const item of subVal as unknown[]) {
|
|
576
|
+
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
577
|
+
throw new Error(`${field}.originRules entries must be objects`);
|
|
578
|
+
const record = item as Record<string, unknown>;
|
|
579
|
+
for (const ruleKey of Object.keys(record)) {
|
|
580
|
+
if (
|
|
581
|
+
ruleKey !== "origin" &&
|
|
582
|
+
ruleKey !== "allowInsecureHttp" &&
|
|
583
|
+
ruleKey !== "allowPrivateNetworks"
|
|
584
|
+
) {
|
|
585
|
+
throw new Error(`${field}.originRules entry contains unknown key: ${ruleKey}`);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const parsed = parseNetworkOrigin(record.origin, `${field}.originRules`);
|
|
589
|
+
if (
|
|
590
|
+
record.allowInsecureHttp !== undefined &&
|
|
591
|
+
typeof record.allowInsecureHttp !== "boolean"
|
|
592
|
+
) {
|
|
593
|
+
throw new Error(`${field}.originRules allowInsecureHttp must be a boolean`);
|
|
594
|
+
}
|
|
595
|
+
if (
|
|
596
|
+
record.allowPrivateNetworks !== undefined &&
|
|
597
|
+
typeof record.allowPrivateNetworks !== "boolean"
|
|
598
|
+
) {
|
|
599
|
+
throw new Error(`${field}.originRules allowPrivateNetworks must be a boolean`);
|
|
600
|
+
}
|
|
601
|
+
const allowInsecureHttp = record.allowInsecureHttp === true;
|
|
602
|
+
const allowPrivateNetworks = record.allowPrivateNetworks === true;
|
|
603
|
+
if (parsed.insecure && !allowInsecureHttp) {
|
|
604
|
+
throw new Error(
|
|
605
|
+
`${field}.originRules contains insecure origin ${parsed.canonical} without allowInsecureHttp: true`,
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
if (isPrivateHost(parsed.host) && !allowPrivateNetworks) {
|
|
609
|
+
throw new Error(
|
|
610
|
+
`${field}.originRules contains private/loopback origin ${parsed.canonical} without allowPrivateNetworks: true`,
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
if (ruleSet.has(parsed.canonical)) {
|
|
614
|
+
throw new Error(
|
|
615
|
+
`${field}.originRules contains duplicate origin ${parsed.canonical}`,
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
ruleSet.add(parsed.canonical);
|
|
619
|
+
rules.push({
|
|
620
|
+
origin: parsed.canonical,
|
|
621
|
+
...(allowInsecureHttp ? { allowInsecureHttp: true } : {}),
|
|
622
|
+
...(allowPrivateNetworks ? { allowPrivateNetworks: true } : {}),
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
if (rules.length) network.originRules = rules;
|
|
560
626
|
break;
|
|
561
627
|
}
|
|
562
628
|
case "allowInsecureHttp":
|
|
@@ -570,6 +636,13 @@ function parseCapabilities(input: unknown, source: string): Capabilities {
|
|
|
570
636
|
throw new Error(`Unknown capability: ${field}.${subKey}`);
|
|
571
637
|
}
|
|
572
638
|
}
|
|
639
|
+
for (const origin of ruleSet) {
|
|
640
|
+
if (originSet.has(origin)) {
|
|
641
|
+
throw new Error(
|
|
642
|
+
`${field} declares duplicate origin in origins and originRules: ${origin}`,
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
573
646
|
if (Object.keys(network).length) capabilities.network = network;
|
|
574
647
|
break;
|
|
575
648
|
}
|
|
@@ -654,28 +727,89 @@ async function mergeCapabilities(
|
|
|
654
727
|
.map(([dirPath, mode]) => ({ path: dirPath, mode })),
|
|
655
728
|
};
|
|
656
729
|
}
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
730
|
+
const networkSources = sources
|
|
731
|
+
.map(source => source.network)
|
|
732
|
+
.filter((net): net is NonNullable<Capabilities["network"]> => net !== undefined);
|
|
733
|
+
const usesLegacySingleSource =
|
|
734
|
+
networkSources.length === 1 &&
|
|
735
|
+
(networkSources[0]!.originRules === undefined || networkSources[0]!.originRules.length === 0);
|
|
736
|
+
if (usesLegacySingleSource) {
|
|
737
|
+
const only = networkSources[0]!;
|
|
738
|
+
const allowInsecureHttp = Boolean(only.allowInsecureHttp);
|
|
739
|
+
const allowPrivateNetworks = Boolean(only.allowPrivateNetworks);
|
|
740
|
+
const networkOrigins = [...new Set(only.origins ?? [])].sort();
|
|
741
|
+
for (const origin of networkOrigins) {
|
|
742
|
+
const parsed = parseNetworkOrigin(origin, "capabilities.network.origins");
|
|
743
|
+
if (parsed.insecure && !allowInsecureHttp) {
|
|
744
|
+
throw new Error(
|
|
745
|
+
`capabilities.network.origins contains insecure origin ${origin} without allowInsecureHttp: true`,
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
if (isPrivateHost(parsed.host) && !allowPrivateNetworks) {
|
|
749
|
+
throw new Error(
|
|
750
|
+
`capabilities.network.origins contains private/loopback origin ${origin} without allowPrivateNetworks: true`,
|
|
751
|
+
);
|
|
752
|
+
}
|
|
666
753
|
}
|
|
667
|
-
if (
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
754
|
+
if (networkOrigins.length || allowInsecureHttp || allowPrivateNetworks) {
|
|
755
|
+
merged.network = {
|
|
756
|
+
...(networkOrigins.length ? { origins: networkOrigins } : {}),
|
|
757
|
+
...(allowInsecureHttp ? { allowInsecureHttp: true } : {}),
|
|
758
|
+
...(allowPrivateNetworks ? { allowPrivateNetworks: true } : {}),
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
} else if (networkSources.length > 0) {
|
|
762
|
+
const byOrigin = new Map<
|
|
763
|
+
string,
|
|
764
|
+
{ allowInsecureHttp: boolean; allowPrivateNetworks: boolean }
|
|
765
|
+
>();
|
|
766
|
+
for (const net of networkSources) {
|
|
767
|
+
const sourceInsecure = Boolean(net.allowInsecureHttp);
|
|
768
|
+
const sourcePrivate = Boolean(net.allowPrivateNetworks);
|
|
769
|
+
for (const origin of net.origins ?? []) {
|
|
770
|
+
const parsed = parseNetworkOrigin(origin, "capabilities.network.origins");
|
|
771
|
+
if (parsed.insecure && !sourceInsecure) {
|
|
772
|
+
throw new Error(
|
|
773
|
+
`capabilities.network.origins contains insecure origin ${origin} without allowInsecureHttp: true`,
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
if (isPrivateHost(parsed.host) && !sourcePrivate) {
|
|
777
|
+
throw new Error(
|
|
778
|
+
`capabilities.network.origins contains private/loopback origin ${origin} without allowPrivateNetworks: true`,
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
const prev = byOrigin.get(parsed.canonical) ?? {
|
|
782
|
+
allowInsecureHttp: false,
|
|
783
|
+
allowPrivateNetworks: false,
|
|
784
|
+
};
|
|
785
|
+
byOrigin.set(parsed.canonical, {
|
|
786
|
+
allowInsecureHttp: prev.allowInsecureHttp || sourceInsecure,
|
|
787
|
+
allowPrivateNetworks: prev.allowPrivateNetworks || sourcePrivate,
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
for (const rule of net.originRules ?? []) {
|
|
791
|
+
const parsed = parseNetworkOrigin(rule.origin, "capabilities.network.originRules");
|
|
792
|
+
const prev = byOrigin.get(parsed.canonical) ?? {
|
|
793
|
+
allowInsecureHttp: false,
|
|
794
|
+
allowPrivateNetworks: false,
|
|
795
|
+
};
|
|
796
|
+
byOrigin.set(parsed.canonical, {
|
|
797
|
+
allowInsecureHttp: prev.allowInsecureHttp || Boolean(rule.allowInsecureHttp),
|
|
798
|
+
allowPrivateNetworks: prev.allowPrivateNetworks || Boolean(rule.allowPrivateNetworks),
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
if (byOrigin.size > 0) {
|
|
803
|
+
merged.network = {
|
|
804
|
+
originRules: [...byOrigin.entries()]
|
|
805
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
806
|
+
.map(([origin, flags]) => ({
|
|
807
|
+
origin,
|
|
808
|
+
...(flags.allowInsecureHttp ? { allowInsecureHttp: true } : {}),
|
|
809
|
+
...(flags.allowPrivateNetworks ? { allowPrivateNetworks: true } : {}),
|
|
810
|
+
})),
|
|
811
|
+
};
|
|
671
812
|
}
|
|
672
|
-
}
|
|
673
|
-
if (networkOrigins.size || allowInsecureHttp || allowPrivateNetworks) {
|
|
674
|
-
merged.network = {
|
|
675
|
-
...(networkOrigins.size ? { origins: [...networkOrigins].sort() } : {}),
|
|
676
|
-
...(allowInsecureHttp ? { allowInsecureHttp: true } : {}),
|
|
677
|
-
...(allowPrivateNetworks ? { allowPrivateNetworks: true } : {}),
|
|
678
|
-
};
|
|
679
813
|
}
|
|
680
814
|
return Object.keys(merged).length ? merged : undefined;
|
|
681
815
|
}
|
package/src/public-api.d.ts
CHANGED
|
@@ -15,8 +15,15 @@ export type FilesCapabilities = {
|
|
|
15
15
|
directories?: FileDirectoryGrant[];
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export type NetworkOriginRule = {
|
|
19
|
+
origin: string;
|
|
20
|
+
allowInsecureHttp?: boolean;
|
|
21
|
+
allowPrivateNetworks?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
18
24
|
export type NetworkCapabilities = {
|
|
19
25
|
origins?: string[];
|
|
26
|
+
originRules?: NetworkOriginRule[];
|
|
20
27
|
allowInsecureHttp?: boolean;
|
|
21
28
|
allowPrivateNetworks?: boolean;
|
|
22
29
|
};
|