qmlbox 0.0.0-stage → 0.1.1
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/LICENSE +232 -0
- package/README.md +166 -2
- package/dist/index.cjs +794 -0
- package/dist/index.d.cts +109 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +758 -0
- package/package.json +58 -4
- package/wasm/qml_engine.js +18 -0
- package/wasm/qml_engine.wasm +0 -0
- package/wasm/qtloader.js +309 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** File names are relative to the theme root and use forward slashes. */
|
|
2
|
+
type ThemeFileMap = Record<string, Uint8Array>;
|
|
3
|
+
type ThemeFiles = Record<string, Uint8Array | string>;
|
|
4
|
+
type ThemeConfigValue = string | number | boolean;
|
|
5
|
+
type QmlVersion = "auto" | "6.8" | "6" | "2.15" | "2.12" | "2.0" | (string & {});
|
|
6
|
+
interface RenderThemeOptions {
|
|
7
|
+
entryFile?: string;
|
|
8
|
+
qmlVersion?: QmlVersion;
|
|
9
|
+
}
|
|
10
|
+
interface SddmUser {
|
|
11
|
+
name: string;
|
|
12
|
+
realName?: string;
|
|
13
|
+
homeDir?: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
uid?: number;
|
|
16
|
+
needsPassword?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface SddmSession {
|
|
19
|
+
name: string;
|
|
20
|
+
file?: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
exec?: string;
|
|
23
|
+
comment?: string;
|
|
24
|
+
}
|
|
25
|
+
interface SddmMockConfig {
|
|
26
|
+
hostName?: string;
|
|
27
|
+
canPowerOff?: boolean;
|
|
28
|
+
canReboot?: boolean;
|
|
29
|
+
canSuspend?: boolean;
|
|
30
|
+
canHibernate?: boolean;
|
|
31
|
+
canHybridSleep?: boolean;
|
|
32
|
+
canSwitchUser?: boolean;
|
|
33
|
+
loginSucceeds?: boolean;
|
|
34
|
+
users?: readonly SddmUser[];
|
|
35
|
+
sessions?: readonly SddmSession[];
|
|
36
|
+
lastUserIndex?: number;
|
|
37
|
+
lastSessionIndex?: number;
|
|
38
|
+
/** Values here override the theme's INI files. */
|
|
39
|
+
config?: Record<string, ThemeConfigValue>;
|
|
40
|
+
}
|
|
41
|
+
interface QmlViewerOptions {
|
|
42
|
+
container: HTMLElement;
|
|
43
|
+
/** Directory containing qtloader.js, qml_engine.js and qml_engine.wasm. Defaults to ./wasm/. */
|
|
44
|
+
wasmBaseUrl?: string;
|
|
45
|
+
sddmConfig?: SddmMockConfig;
|
|
46
|
+
/** Target QML version for standard Qt imports ("auto" preserves source imports). */
|
|
47
|
+
qmlVersion?: QmlVersion;
|
|
48
|
+
/** Positive upper bound for the viewer's device pixel ratio. Defaults to 2. */
|
|
49
|
+
maxPixelRatio?: number;
|
|
50
|
+
onProgress?: (percent: number) => void;
|
|
51
|
+
onError?: (msg: string) => void;
|
|
52
|
+
}
|
|
53
|
+
interface GitHubRepoOptions {
|
|
54
|
+
/** Use this when a /tree/ URL has an ambiguous branch name, or to override the default branch. */
|
|
55
|
+
ref?: string;
|
|
56
|
+
subdirectory?: string;
|
|
57
|
+
/** Optional GitHub API token supplied by the caller. */
|
|
58
|
+
token?: string;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare function fromCodeString(source: string): ThemeFileMap;
|
|
63
|
+
declare function fromSingleFile(file: File): Promise<ThemeFileMap>;
|
|
64
|
+
declare function fromFolderInput(input: FileList | Iterable<File>): Promise<ThemeFileMap>;
|
|
65
|
+
declare function fromZipFile(file: Blob): Promise<ThemeFileMap>;
|
|
66
|
+
declare function fromGitHubRepo(url: string, options?: GitHubRepoOptions): Promise<ThemeFileMap>;
|
|
67
|
+
|
|
68
|
+
type IniSection = Record<string, string>;
|
|
69
|
+
type IniFile = Record<string, IniSection>;
|
|
70
|
+
declare function parseIni(source: string): IniFile;
|
|
71
|
+
declare function parseThemeConfig(source: string): Record<string, string>;
|
|
72
|
+
|
|
73
|
+
declare const SUPPORTED_QML_VERSIONS: readonly ["auto", "6.8", "2.15", "2.12", "2.0"];
|
|
74
|
+
declare function transformQmlImports(source: string, version: QmlVersion): string;
|
|
75
|
+
|
|
76
|
+
declare class QmlViewer {
|
|
77
|
+
private readonly options;
|
|
78
|
+
private readonly maxPixelRatio;
|
|
79
|
+
private readonly document;
|
|
80
|
+
private frame?;
|
|
81
|
+
private runtime?;
|
|
82
|
+
private initializing?;
|
|
83
|
+
private controller?;
|
|
84
|
+
private observer?;
|
|
85
|
+
private sddmConfig?;
|
|
86
|
+
private themeConfig?;
|
|
87
|
+
private qmlVersion;
|
|
88
|
+
private generation;
|
|
89
|
+
private destroyed;
|
|
90
|
+
private inViewport;
|
|
91
|
+
constructor(options: QmlViewerOptions);
|
|
92
|
+
init(): Promise<void>;
|
|
93
|
+
private start;
|
|
94
|
+
renderThemeFiles(input: ThemeFiles, entryOrOptions?: string | RenderThemeOptions): Promise<void>;
|
|
95
|
+
renderCode(qmlSource: string, qmlVersion?: QmlVersion): Promise<void>;
|
|
96
|
+
/** Return the active default QML target version used when rendering. */
|
|
97
|
+
getQmlVersion(): QmlVersion;
|
|
98
|
+
/** Set the default QML target version for subsequent renders. */
|
|
99
|
+
setQmlVersion(version: QmlVersion): void;
|
|
100
|
+
/** Update the mock environment used by the current and subsequent previews. */
|
|
101
|
+
setSddmConfig(config: SddmMockConfig): void;
|
|
102
|
+
destroy(): void;
|
|
103
|
+
private mockJson;
|
|
104
|
+
private readonly syncVisibility;
|
|
105
|
+
private readonly reportError;
|
|
106
|
+
private stop;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { type GitHubRepoOptions, type IniFile, type QmlVersion, QmlViewer, type QmlViewerOptions, type RenderThemeOptions, SUPPORTED_QML_VERSIONS, type SddmMockConfig, type SddmSession, type SddmUser, type ThemeConfigValue, type ThemeFileMap, type ThemeFiles, fromCodeString, fromFolderInput, fromGitHubRepo, fromSingleFile, fromZipFile, parseIni, parseThemeConfig, transformQmlImports };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** File names are relative to the theme root and use forward slashes. */
|
|
2
|
+
type ThemeFileMap = Record<string, Uint8Array>;
|
|
3
|
+
type ThemeFiles = Record<string, Uint8Array | string>;
|
|
4
|
+
type ThemeConfigValue = string | number | boolean;
|
|
5
|
+
type QmlVersion = "auto" | "6.8" | "6" | "2.15" | "2.12" | "2.0" | (string & {});
|
|
6
|
+
interface RenderThemeOptions {
|
|
7
|
+
entryFile?: string;
|
|
8
|
+
qmlVersion?: QmlVersion;
|
|
9
|
+
}
|
|
10
|
+
interface SddmUser {
|
|
11
|
+
name: string;
|
|
12
|
+
realName?: string;
|
|
13
|
+
homeDir?: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
uid?: number;
|
|
16
|
+
needsPassword?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface SddmSession {
|
|
19
|
+
name: string;
|
|
20
|
+
file?: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
exec?: string;
|
|
23
|
+
comment?: string;
|
|
24
|
+
}
|
|
25
|
+
interface SddmMockConfig {
|
|
26
|
+
hostName?: string;
|
|
27
|
+
canPowerOff?: boolean;
|
|
28
|
+
canReboot?: boolean;
|
|
29
|
+
canSuspend?: boolean;
|
|
30
|
+
canHibernate?: boolean;
|
|
31
|
+
canHybridSleep?: boolean;
|
|
32
|
+
canSwitchUser?: boolean;
|
|
33
|
+
loginSucceeds?: boolean;
|
|
34
|
+
users?: readonly SddmUser[];
|
|
35
|
+
sessions?: readonly SddmSession[];
|
|
36
|
+
lastUserIndex?: number;
|
|
37
|
+
lastSessionIndex?: number;
|
|
38
|
+
/** Values here override the theme's INI files. */
|
|
39
|
+
config?: Record<string, ThemeConfigValue>;
|
|
40
|
+
}
|
|
41
|
+
interface QmlViewerOptions {
|
|
42
|
+
container: HTMLElement;
|
|
43
|
+
/** Directory containing qtloader.js, qml_engine.js and qml_engine.wasm. Defaults to ./wasm/. */
|
|
44
|
+
wasmBaseUrl?: string;
|
|
45
|
+
sddmConfig?: SddmMockConfig;
|
|
46
|
+
/** Target QML version for standard Qt imports ("auto" preserves source imports). */
|
|
47
|
+
qmlVersion?: QmlVersion;
|
|
48
|
+
/** Positive upper bound for the viewer's device pixel ratio. Defaults to 2. */
|
|
49
|
+
maxPixelRatio?: number;
|
|
50
|
+
onProgress?: (percent: number) => void;
|
|
51
|
+
onError?: (msg: string) => void;
|
|
52
|
+
}
|
|
53
|
+
interface GitHubRepoOptions {
|
|
54
|
+
/** Use this when a /tree/ URL has an ambiguous branch name, or to override the default branch. */
|
|
55
|
+
ref?: string;
|
|
56
|
+
subdirectory?: string;
|
|
57
|
+
/** Optional GitHub API token supplied by the caller. */
|
|
58
|
+
token?: string;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare function fromCodeString(source: string): ThemeFileMap;
|
|
63
|
+
declare function fromSingleFile(file: File): Promise<ThemeFileMap>;
|
|
64
|
+
declare function fromFolderInput(input: FileList | Iterable<File>): Promise<ThemeFileMap>;
|
|
65
|
+
declare function fromZipFile(file: Blob): Promise<ThemeFileMap>;
|
|
66
|
+
declare function fromGitHubRepo(url: string, options?: GitHubRepoOptions): Promise<ThemeFileMap>;
|
|
67
|
+
|
|
68
|
+
type IniSection = Record<string, string>;
|
|
69
|
+
type IniFile = Record<string, IniSection>;
|
|
70
|
+
declare function parseIni(source: string): IniFile;
|
|
71
|
+
declare function parseThemeConfig(source: string): Record<string, string>;
|
|
72
|
+
|
|
73
|
+
declare const SUPPORTED_QML_VERSIONS: readonly ["auto", "6.8", "2.15", "2.12", "2.0"];
|
|
74
|
+
declare function transformQmlImports(source: string, version: QmlVersion): string;
|
|
75
|
+
|
|
76
|
+
declare class QmlViewer {
|
|
77
|
+
private readonly options;
|
|
78
|
+
private readonly maxPixelRatio;
|
|
79
|
+
private readonly document;
|
|
80
|
+
private frame?;
|
|
81
|
+
private runtime?;
|
|
82
|
+
private initializing?;
|
|
83
|
+
private controller?;
|
|
84
|
+
private observer?;
|
|
85
|
+
private sddmConfig?;
|
|
86
|
+
private themeConfig?;
|
|
87
|
+
private qmlVersion;
|
|
88
|
+
private generation;
|
|
89
|
+
private destroyed;
|
|
90
|
+
private inViewport;
|
|
91
|
+
constructor(options: QmlViewerOptions);
|
|
92
|
+
init(): Promise<void>;
|
|
93
|
+
private start;
|
|
94
|
+
renderThemeFiles(input: ThemeFiles, entryOrOptions?: string | RenderThemeOptions): Promise<void>;
|
|
95
|
+
renderCode(qmlSource: string, qmlVersion?: QmlVersion): Promise<void>;
|
|
96
|
+
/** Return the active default QML target version used when rendering. */
|
|
97
|
+
getQmlVersion(): QmlVersion;
|
|
98
|
+
/** Set the default QML target version for subsequent renders. */
|
|
99
|
+
setQmlVersion(version: QmlVersion): void;
|
|
100
|
+
/** Update the mock environment used by the current and subsequent previews. */
|
|
101
|
+
setSddmConfig(config: SddmMockConfig): void;
|
|
102
|
+
destroy(): void;
|
|
103
|
+
private mockJson;
|
|
104
|
+
private readonly syncVisibility;
|
|
105
|
+
private readonly reportError;
|
|
106
|
+
private stop;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { type GitHubRepoOptions, type IniFile, type QmlVersion, QmlViewer, type QmlViewerOptions, type RenderThemeOptions, SUPPORTED_QML_VERSIONS, type SddmMockConfig, type SddmSession, type SddmUser, type ThemeConfigValue, type ThemeFileMap, type ThemeFiles, fromCodeString, fromFolderInput, fromGitHubRepo, fromSingleFile, fromZipFile, parseIni, parseThemeConfig, transformQmlImports };
|