@druid-ui/plattform 1.0.0-next.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/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ // src/index.ts
2
+ import {
3
+ request as requestRaw,
4
+ loadFileFromDeployment as loadFileFromDeploymentRaw,
5
+ saveFileToDeployment as saveFileToDeploymentRaw
6
+ } from "druid:ui/plattform";
7
+ import { rawAsyncToPromise } from "@druid-ui/component";
8
+ var request = rawAsyncToPromise(requestRaw);
9
+ var loadFileFromDeployment = rawAsyncToPromise(
10
+ loadFileFromDeploymentRaw
11
+ );
12
+ var saveFileToDeployment = rawAsyncToPromise(saveFileToDeploymentRaw);
13
+ export {
14
+ loadFileFromDeployment,
15
+ request,
16
+ saveFileToDeployment
17
+ };
@@ -0,0 +1,4 @@
1
+ export declare const request: (...args: any[]) => Promise<unknown>;
2
+ export declare const loadFileFromDeployment: (...args: any[]) => Promise<unknown>;
3
+ export declare const saveFileToDeployment: (...args: any[]) => Promise<unknown>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,sCAAgC,CAAC;AAErD,eAAO,MAAM,sBAAsB,sCAElC,CAAC;AAEF,eAAO,MAAM,oBAAoB,sCAA6C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@druid-ui/plattform",
3
+ "version": "1.0.0-next.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/types/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/types/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "src",
16
+ "wit"
17
+ ],
18
+ "scripts": {
19
+ "build": "npm run build:plattform-types && npm run build:lib && npm run build:types",
20
+ "build:plattform-types": "druid-ui-gen-types druid-plattform wit/druid-plattform.wit --temp-wit-path=./wit-dist --out-dir=./src/types",
21
+ "build:lib": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=esm --external:druid:ui/ui --external:druid:ui/utils --external:druid:ui/plattform --external:@druid-ui/component",
22
+ "build:types": "tsc --emitDeclarationOnly --outDir dist/types"
23
+ },
24
+ "dependencies": {
25
+ "@druid-ui/build": "1.0.0-next.1",
26
+ "@druid-ui/component": "1.0.0-next.1"
27
+ },
28
+ "devDependencies": {
29
+ "esbuild": "^0.25.11",
30
+ "tsx": "^4.20.6",
31
+ "typescript": "~5.8.3"
32
+ }
33
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ /// <reference types="./types/druid-plattform.d.ts" />
2
+ /// <reference types="@druid-ui/component/jsx" />
3
+ import {
4
+ request as requestRaw,
5
+ loadFileFromDeployment as loadFileFromDeploymentRaw,
6
+ saveFileToDeployment as saveFileToDeploymentRaw,
7
+ } from "druid:ui/plattform";
8
+ // it is very imporant that this is external, as druid-ui/component contains
9
+ // functions that must be important and cannot just be copied in again
10
+ // otherwise promises defined here will not resolve
11
+ import { rawAsyncToPromise } from "@druid-ui/component";
12
+
13
+ export const request = rawAsyncToPromise(requestRaw);
14
+
15
+ export const loadFileFromDeployment = rawAsyncToPromise(
16
+ loadFileFromDeploymentRaw
17
+ );
18
+
19
+ export const saveFileToDeployment = rawAsyncToPromise(saveFileToDeploymentRaw);
@@ -0,0 +1,50 @@
1
+ /// <reference path="./interfaces/druid-ui-component.d.ts" />
2
+ /// <reference path="./interfaces/druid-ui-plattform.d.ts" />
3
+ /// <reference path="./interfaces/druid-ui-ui.d.ts" />
4
+ /// <reference path="./interfaces/druid-ui-utils.d.ts" />
5
+ declare module 'druid:ui/druid-plattform' {
6
+ import type * as DruidUiPlattform from 'druid:ui/plattform'; // druid:ui/plattform
7
+ import type * as DruidUiUi from 'druid:ui/ui'; // druid:ui/ui
8
+ import type * as DruidUiUtils from 'druid:ui/utils'; // druid:ui/utils
9
+ import type * as DruidUiComponent from 'druid:ui/component'; // druid:ui/component
10
+ export interface ImportObject {
11
+ 'druid:ui/plattform': typeof DruidUiPlattform,
12
+ 'druid:ui/ui': typeof DruidUiUi,
13
+ 'druid:ui/utils': typeof DruidUiUtils,
14
+ }
15
+ export interface DruidPlattform {
16
+ 'druid:ui/component': typeof DruidUiComponent,
17
+ component: typeof DruidUiComponent,
18
+ }
19
+
20
+ /**
21
+ * Instantiates this component with the provided imports and
22
+ * returns a map of all the exports of the component.
23
+ *
24
+ * This function is intended to be similar to the
25
+ * `WebAssembly.instantiate` function. The second `imports`
26
+ * argument is the "import object" for wasm, except here it
27
+ * uses component-model-layer types instead of core wasm
28
+ * integers/numbers/etc.
29
+ *
30
+ * The first argument to this function, `getCoreModule`, is
31
+ * used to compile core wasm modules within the component.
32
+ * Components are composed of core wasm modules and this callback
33
+ * will be invoked per core wasm module. The caller of this
34
+ * function is responsible for reading the core wasm module
35
+ * identified by `path` and returning its compiled
36
+ * `WebAssembly.Module` object. This would use `compileStreaming`
37
+ * on the web, for example.
38
+ */
39
+ export function instantiate(
40
+ getCoreModule: (path: string) => WebAssembly.Module,
41
+ imports: ImportObject,
42
+ instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance
43
+ ): DruidPlattform;
44
+ export function instantiate(
45
+ getCoreModule: (path: string) => WebAssembly.Module | Promise<WebAssembly.Module>,
46
+ imports: ImportObject,
47
+ instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance | Promise<WebAssembly.Instance>
48
+ ): DruidPlattform | Promise<DruidPlattform>;
49
+
50
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference path="./druid-ui-utils.d.ts" />
2
+ declare module 'druid:ui/component' {
3
+ export function init(ctx: Context): string;
4
+ export function emit(nodeid: string, event: string, e: Event): void;
5
+ export function asyncComplete(id: string, value: Result<string, void>): void;
6
+ export type Event = import('druid:ui/utils').Event;
7
+ export type Context = import('druid:ui/utils').Context;
8
+ export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
9
+ }
@@ -0,0 +1,5 @@
1
+ declare module 'druid:ui/plattform' {
2
+ export function request(url: string, method: string, body: string, header: [string, string]): string;
3
+ export function loadFileFromDeployment(path: string): string;
4
+ export function saveFileToDeployment(path: string, content: string): string;
5
+ }
@@ -0,0 +1,16 @@
1
+ declare module 'druid:ui/ui' {
2
+ export function d(element: string, props: Props, children: Children): string;
3
+ export function log(msg: string): void;
4
+ export function setHook(id: AsyncId, hook: string): void;
5
+ export function rerender(): void;
6
+ export interface Prop {
7
+ key: string,
8
+ value: string,
9
+ }
10
+ export interface Props {
11
+ prop: Array<Prop>,
12
+ on: Array<string>,
13
+ }
14
+ export type AsyncId = string;
15
+ export type Children = Array<string> | undefined;
16
+ }
@@ -0,0 +1,14 @@
1
+ declare module 'druid:ui/utils' {
2
+ export interface Context {
3
+ path: string,
4
+ }
5
+
6
+ export class Event implements Disposable {
7
+ constructor(value: string, checked: boolean)
8
+ preventDefault(): void;
9
+ stopPropagation(): void;
10
+ value(): string;
11
+ checked(): boolean;
12
+ [Symbol.dispose](): void;
13
+ }
14
+ }
@@ -0,0 +1,13 @@
1
+ package druid:ui;
2
+
3
+ interface plattform {
4
+ request: func(url: string, method: string, body: string, header: tuple<string, string>) -> string;
5
+ load-file-from-deployment: func(path: string) -> string;
6
+ save-file-to-deployment: func(path: string, content: string) -> string;
7
+ }
8
+
9
+ world druid-plattform {
10
+ import ui;
11
+ import plattform;
12
+ export component;
13
+ }