@monimesl/dot-dash 0.1.0-alpha.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 ADDED
@@ -0,0 +1 @@
1
+ # @monimesl/dot-dash
@@ -0,0 +1,72 @@
1
+ import { HostCallOptions, HostError, HostErrorCode, HostRequest } from "@monimesl/dot-core";
2
+ //#region src/ui/dialogs.d.ts
3
+ interface AlertAction {
4
+ id: string;
5
+ label: string;
6
+ role?: 'default' | 'cancel' | 'destructive' | undefined;
7
+ }
8
+ interface AlertOptions {
9
+ title: string;
10
+ message?: string | undefined;
11
+ actions?: AlertAction[] | undefined;
12
+ }
13
+ interface AlertResult {
14
+ action: string;
15
+ }
16
+ interface DialogMethods {
17
+ 'dash.ui.alert': {
18
+ params: AlertOptions;
19
+ result: AlertResult;
20
+ };
21
+ }
22
+ declare function alert(options: AlertOptions, callOptions?: CallOptions): DashRequest<AlertResult>;
23
+ declare namespace index_d_exports$1 {
24
+ export { AlertAction, AlertOptions, AlertResult, UIMethods, alert };
25
+ }
26
+ type UIMethods = DialogMethods;
27
+ //#endregion
28
+ //#region src/methods.d.ts
29
+ type DashMethods = UIMethods & SystemMethods;
30
+ type DashMethod = keyof DashMethods;
31
+ //#endregion
32
+ //#region src/call.d.ts
33
+ type CallOptions = HostCallOptions;
34
+ type DashRequest<Result> = HostRequest<Result>;
35
+ //#endregion
36
+ //#region src/system/haptics.d.ts
37
+ type VibrationStyle = 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error';
38
+ interface VibrateOptions {
39
+ style?: VibrationStyle | undefined;
40
+ }
41
+ interface HapticsMethods {
42
+ 'dash.system.vibrate': {
43
+ params: VibrateOptions;
44
+ result: void;
45
+ };
46
+ }
47
+ declare function vibrate(options?: VibrateOptions, callOptions?: CallOptions): DashRequest<void>;
48
+ //#endregion
49
+ //#region src/system/torch.d.ts
50
+ type TorchState = 'on' | 'off';
51
+ interface TorchMethods {
52
+ 'dash.system.torch': {
53
+ params: {
54
+ state: TorchState;
55
+ };
56
+ result: void;
57
+ };
58
+ }
59
+ declare function torch(state: TorchState, callOptions?: CallOptions): DashRequest<void>;
60
+ declare namespace index_d_exports {
61
+ export { SystemMethods, TorchState, VibrateOptions, VibrationStyle, torch, vibrate };
62
+ }
63
+ type SystemMethods = HapticsMethods & TorchMethods;
64
+ //#endregion
65
+ //#region src/index.d.ts
66
+ export declare const dash: {
67
+ ui: typeof index_d_exports$1;
68
+ system: typeof index_d_exports;
69
+ };
70
+ //#endregion
71
+ export { type AlertAction, type AlertOptions, type AlertResult, type CallOptions, type DashMethod, type DashMethods, type DashRequest, HostError, type HostErrorCode, type SystemMethods, type TorchState, type UIMethods, type VibrateOptions, type VibrationStyle };
72
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/ui/dialogs.ts","../src/ui/index.ts","../src/methods.ts","../src/call.ts","../src/system/haptics.ts","../src/system/torch.ts","../src/system/index.ts","../src/index.ts"],"mappings":";;UAGiB;EACf;EACA;EAEA;;UAGe;EACf;EACA;EAEA,UAAU;;UAGK;EAEf;;UAGe;EACf;IAAmB,QAAQ;IAAc,QAAQ;;;iBAInC,MAAM,SAAS,cAAc,cAAc,cAAc,YAAY;;;;KCtBzE,YAAY;;;KCAZ,cAAc,YAAY;KAE1B,mBAAmB;;;KCFnB,cAAc;KAGd,YAAY,UAAU,YAAY;;;KCLlC;UAEK;EAEf,QAAQ;;UAGO;EACf;IAAyB,QAAQ;IAAgB;;;iBAInC,QACd,UAAS,gBACT,cAAc,cACb;;;KCfS;UAEK;EACf;IAAuB;MAAU,OAAO;;IAAc;;;iBAIxC,MAAM,OAAO,YAAY,cAAc,cAAc;;;;KCFzD,gBAAgB,iBAAiB;;;qBCJhC;aAAA;iBAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { HostError, callHost } from "@monimesl/dot-core";
3
+ //#region src/call.ts
4
+ function call(method, params, options = {}) {
5
+ return callHost(method, params, options);
6
+ }
7
+ //#endregion
8
+ //#region src/system/haptics.ts
9
+ function vibrate(options = {}, callOptions) {
10
+ return call("dash.system.vibrate", { style: options.style ?? "medium" }, callOptions);
11
+ }
12
+ //#endregion
13
+ //#region src/system/torch.ts
14
+ function torch(state, callOptions) {
15
+ return call("dash.system.torch", { state }, callOptions);
16
+ }
17
+ //#endregion
18
+ //#region src/system/index.ts
19
+ var system_exports = /* @__PURE__ */ __exportAll({
20
+ torch: () => torch,
21
+ vibrate: () => vibrate
22
+ });
23
+ //#endregion
24
+ //#region src/ui/dialogs.ts
25
+ function alert(options, callOptions) {
26
+ const actions = options.actions ?? [{
27
+ id: "ok",
28
+ label: "OK"
29
+ }];
30
+ return call("dash.ui.alert", {
31
+ ...options,
32
+ actions
33
+ }, callOptions);
34
+ }
35
+ //#endregion
36
+ //#region src/index.ts
37
+ const dash = {
38
+ ui: /* @__PURE__ */ __exportAll({ alert: () => alert }),
39
+ system: system_exports
40
+ };
41
+ //#endregion
42
+ export { HostError, dash };
43
+
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/call.ts","../src/system/haptics.ts","../src/system/torch.ts","../src/system/index.ts","../src/ui/dialogs.ts","../src/ui/index.ts","../src/index.ts"],"sourcesContent":["import type { HostCallOptions, HostRequest } from '@monimesl/dot-core';\nimport { callHost } from '@monimesl/dot-core';\n\nimport type { DashMethod, DashMethods } from './methods';\n\nexport type CallOptions = HostCallOptions;\n\n// A Dash call in flight: await it for the result, or cancel it.\nexport type DashRequest<Result> = HostRequest<Result>;\n\nexport function call<Method extends DashMethod>(\n method: Method,\n params: DashMethods[Method]['params'],\n options: CallOptions = {},\n): DashRequest<DashMethods[Method]['result']> {\n return callHost(method, params, options);\n}\n","import type { CallOptions, DashRequest } from '../call';\nimport { call } from '../call';\n\nexport type VibrationStyle = 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error';\n\nexport interface VibrateOptions {\n // Defaults to `medium`.\n style?: VibrationStyle | undefined;\n}\n\nexport interface HapticsMethods {\n 'dash.system.vibrate': { params: VibrateOptions; result: void };\n}\n\n// Plays a short vibration, and resolves once it has.\nexport function vibrate(\n options: VibrateOptions = {},\n callOptions?: CallOptions,\n): DashRequest<void> {\n return call('dash.system.vibrate', { style: options.style ?? 'medium' }, callOptions);\n}\n","import type { CallOptions, DashRequest } from '../call';\nimport { call } from '../call';\n\nexport type TorchState = 'on' | 'off';\n\nexport interface TorchMethods {\n 'dash.system.torch': { params: { state: TorchState }; result: void };\n}\n\n// Turns the torch on or off. Rejects with `unsupported` on a device without one.\nexport function torch(state: TorchState, callOptions?: CallOptions): DashRequest<void> {\n return call('dash.system.torch', { state }, callOptions);\n}\n","import type { HapticsMethods } from './haptics';\nimport type { TorchMethods } from './torch';\n\nexport { vibrate } from './haptics';\nexport { torch } from './torch';\nexport type { VibrateOptions, VibrationStyle } from './haptics';\nexport type { TorchState } from './torch';\n\nexport type SystemMethods = HapticsMethods & TorchMethods;\n","import type { CallOptions, DashRequest } from '../call';\nimport { call } from '../call';\n\nexport interface AlertAction {\n id: string;\n label: string;\n // `cancel` dismisses the alert; `destructive` marks something that cannot be undone.\n role?: 'default' | 'cancel' | 'destructive' | undefined;\n}\n\nexport interface AlertOptions {\n title: string;\n message?: string | undefined;\n // Defaults to a single OK.\n actions?: AlertAction[] | undefined;\n}\n\nexport interface AlertResult {\n // The `id` of the action the user chose.\n action: string;\n}\n\nexport interface DialogMethods {\n 'dash.ui.alert': { params: AlertOptions; result: AlertResult };\n}\n\n// Shows a native alert, and resolves with the action the user chose.\nexport function alert(options: AlertOptions, callOptions?: CallOptions): DashRequest<AlertResult> {\n const actions = options.actions ?? [{ id: 'ok', label: 'OK' }];\n return call('dash.ui.alert', { ...options, actions }, callOptions);\n}\n","import type { DialogMethods } from './dialogs';\n\nexport { alert } from './dialogs';\nexport type { AlertAction, AlertOptions, AlertResult } from './dialogs';\n\nexport type UIMethods = DialogMethods;\n","import * as system from './system';\nimport * as ui from './ui';\n\n// Dash's features for a dot's service, grouped by use: `dash.ui.alert(...)`, `dash.system.torch(...)`.\nexport const dash = { ui, system };\n\nexport { HostError } from '@monimesl/dot-core';\nexport type { HostErrorCode } from '@monimesl/dot-core';\nexport type { CallOptions, DashRequest } from './call';\nexport type { DashMethod, DashMethods } from './methods';\nexport type { SystemMethods, TorchState, VibrateOptions, VibrationStyle } from './system';\nexport type { AlertAction, AlertOptions, AlertResult, UIMethods } from './ui';\n"],"mappings":";;;AAUA,SAAgB,KACd,QACA,QACA,UAAuB,CAAC,GACoB;CAC5C,OAAO,SAAS,QAAQ,QAAQ,OAAO;AACzC;;;ACDA,SAAgB,QACd,UAA0B,CAAC,GAC3B,aACmB;CACnB,OAAO,KAAK,uBAAuB,EAAE,OAAO,QAAQ,SAAS,SAAS,GAAG,WAAW;AACtF;;;ACVA,SAAgB,MAAM,OAAmB,aAA8C;CACrF,OAAO,KAAK,qBAAqB,EAAE,MAAM,GAAG,WAAW;AACzD;;;;;;;;;AEeA,SAAgB,MAAM,SAAuB,aAAqD;CAChG,MAAM,UAAU,QAAQ,WAAW,CAAC;EAAE,IAAI;EAAM,OAAO;CAAK,CAAC;CAC7D,OAAO,KAAK,iBAAiB;EAAE,GAAG;EAAS;CAAQ,GAAG,WAAW;AACnE;;;AE1BA,MAAa,OAAO;CAAE,IAAA,kDAAA;CAAI,QAAA;AAAO"}
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@monimesl/dot-dash",
3
+ "version": "0.1.0-alpha.2",
4
+ "description": "Dash features for dots: native UI, system and more, called from the service",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/monime-lab/dot.git",
9
+ "directory": "packages/dash"
10
+ },
11
+ "sideEffects": false,
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "@monimesl/dot-source": "./src/index.ts",
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "dependencies": {
27
+ "@monimesl/dot-core": "0.1.0-alpha.2"
28
+ },
29
+ "devDependencies": {
30
+ "publint": "^0.3.24",
31
+ "rimraf": "^6.1.3",
32
+ "tsdown": "^0.23.0",
33
+ "typescript": "^5.9.3",
34
+ "vitest": "^5.0.1"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "scripts": {
40
+ "build": "tsdown",
41
+ "dev": "tsdown --watch",
42
+ "typecheck": "tsc --noEmit -p tsconfig.json",
43
+ "test": "vitest run",
44
+ "clean": "rimraf dist *.tsbuildinfo"
45
+ }
46
+ }