@druid-ui/component 1.0.11 → 1.0.12
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/jsx-runtime.js +3 -74
- package/package.json +3 -9
- package/dist/raw.js +0 -109
- package/dist/types/raw.d.ts +0 -13
- package/dist/types/raw.d.ts.map +0 -1
- package/src/raw.ts +0 -14
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,82 +1,11 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import { d as dfunc } from "druid:ui/ui";
|
|
3
|
-
|
|
4
|
-
// src/utils.ts
|
|
5
|
-
import { log, rerender, setHook } from "druid:ui/ui";
|
|
6
|
-
var callbackMap = {};
|
|
7
|
-
var registerHooks = (id, fnresult) => {
|
|
8
|
-
switch (true) {
|
|
9
|
-
case !!fnresult.init:
|
|
10
|
-
setHook(id, "init");
|
|
11
|
-
callbackMap[id] = {
|
|
12
|
-
...callbackMap[id],
|
|
13
|
-
init: fnresult.init
|
|
14
|
-
};
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
var createDFunc = (dfunc2) => {
|
|
19
|
-
return (tag, props, ...children) => {
|
|
20
|
-
children = children.flat();
|
|
21
|
-
if (typeof tag !== "string") {
|
|
22
|
-
if (typeof tag === "function") {
|
|
23
|
-
const fnresult = tag(props);
|
|
24
|
-
if (fnresult?.view) {
|
|
25
|
-
const id3 = fnresult.view(props);
|
|
26
|
-
registerHooks(id3, fnresult);
|
|
27
|
-
return id3;
|
|
28
|
-
} else {
|
|
29
|
-
return tag(props);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const id2 = tag.view(props);
|
|
33
|
-
registerHooks(id2, tag);
|
|
34
|
-
return id2;
|
|
35
|
-
}
|
|
36
|
-
const ps = { prop: [], on: [] };
|
|
37
|
-
const cbObj = {};
|
|
38
|
-
if (props) {
|
|
39
|
-
for (const [key, value] of Object.entries(props)) {
|
|
40
|
-
if (value instanceof Function) {
|
|
41
|
-
const eventKey = key.startsWith("on") ? key.slice(2).toLowerCase() : key;
|
|
42
|
-
cbObj[eventKey] = value;
|
|
43
|
-
ps.on.push(eventKey);
|
|
44
|
-
} else {
|
|
45
|
-
if (typeof value === "boolean") {
|
|
46
|
-
if (value) {
|
|
47
|
-
ps.prop.push({ key, value: "true" });
|
|
48
|
-
}
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
ps.prop.push({ key, value });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const id = dfunc2(
|
|
56
|
-
tag,
|
|
57
|
-
ps,
|
|
58
|
-
children.filter((c) => typeof c !== "boolean").map((c) => c?.toString())
|
|
59
|
-
);
|
|
60
|
-
callbackMap[id] = {
|
|
61
|
-
...callbackMap[id],
|
|
62
|
-
...cbObj
|
|
63
|
-
};
|
|
64
|
-
return id;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// src/index.ts
|
|
69
|
-
import { Event } from "druid:ui/utils";
|
|
70
|
-
import { log as log2 } from "druid:ui/ui";
|
|
71
|
-
var d2 = createDFunc(dfunc);
|
|
72
|
-
|
|
73
1
|
// src/jsx-runtime.ts
|
|
2
|
+
import { d } from "./index";
|
|
74
3
|
function jsx(type, props) {
|
|
75
4
|
const { children, ...rest } = props || {};
|
|
76
5
|
if (children !== void 0) {
|
|
77
|
-
return
|
|
6
|
+
return d(type, rest, children);
|
|
78
7
|
}
|
|
79
|
-
return
|
|
8
|
+
return d(type, rest);
|
|
80
9
|
}
|
|
81
10
|
var jsxs = jsx;
|
|
82
11
|
var jsxDEV = jsx;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@druid-ui/component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -10,11 +10,6 @@
|
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./raw": {
|
|
14
|
-
"types": "./dist/types/raw.d.ts",
|
|
15
|
-
"import": "./dist/raw.js",
|
|
16
|
-
"default": "./dist/raw.js"
|
|
17
|
-
},
|
|
18
13
|
"./jsx": {
|
|
19
14
|
"types": "./src/jsx.d.ts"
|
|
20
15
|
},
|
|
@@ -32,10 +27,9 @@
|
|
|
32
27
|
"src"
|
|
33
28
|
],
|
|
34
29
|
"scripts": {
|
|
35
|
-
"build": "npm run build:types-ui && npm run build:lib && npm run build:
|
|
30
|
+
"build": "npm run build:types-ui && npm run build:lib && npm run build:jsx-runtime && npm run build:types",
|
|
36
31
|
"build:lib": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=esm --external:druid:ui/ui --external:druid:ui/utils --external:druid:ui/component --external:@druid-ui/host",
|
|
37
|
-
"build:
|
|
38
|
-
"build:jsx-runtime": "esbuild src/jsx-runtime.ts --bundle --outfile=dist/jsx-runtime.js --format=esm --external:druid:ui/ui --external:druid:ui/utils --external:druid:ui/component --external:@druid-ui/host",
|
|
32
|
+
"build:jsx-runtime": "esbuild src/jsx-runtime.ts --bundle --outfile=dist/jsx-runtime.js --format=esm --external:druid:ui/ui --external:druid:ui/utils --external:druid:ui/component --external:@druid-ui/host --external:./index",
|
|
39
33
|
"build:types": "tsc --emitDeclarationOnly --outDir dist/types",
|
|
40
34
|
"build:types-ui": "druid-ui-gen-types druid-ui --out-dir=dist/types"
|
|
41
35
|
},
|
package/dist/raw.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// src/utils.ts
|
|
2
|
-
import { log, rerender, setHook } from "druid:ui/ui";
|
|
3
|
-
var callbackMap = {};
|
|
4
|
-
function emit(nodeid, event, e) {
|
|
5
|
-
log(`Emit called for nodeid: ${nodeid}, event: ${event}`);
|
|
6
|
-
const callbacks = callbackMap[nodeid];
|
|
7
|
-
const result = callbacks?.[event]?.(e);
|
|
8
|
-
if (result instanceof Promise) {
|
|
9
|
-
result.then(() => rerender());
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
var registerHooks = (id, fnresult) => {
|
|
13
|
-
switch (true) {
|
|
14
|
-
case !!fnresult.init:
|
|
15
|
-
setHook(id, "init");
|
|
16
|
-
callbackMap[id] = {
|
|
17
|
-
...callbackMap[id],
|
|
18
|
-
init: fnresult.init
|
|
19
|
-
};
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
var createDFunc = (dfunc2) => {
|
|
24
|
-
return (tag, props, ...children) => {
|
|
25
|
-
children = children.flat();
|
|
26
|
-
if (typeof tag !== "string") {
|
|
27
|
-
if (typeof tag === "function") {
|
|
28
|
-
const fnresult = tag(props);
|
|
29
|
-
if (fnresult?.view) {
|
|
30
|
-
const id3 = fnresult.view(props);
|
|
31
|
-
registerHooks(id3, fnresult);
|
|
32
|
-
return id3;
|
|
33
|
-
} else {
|
|
34
|
-
return tag(props);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const id2 = tag.view(props);
|
|
38
|
-
registerHooks(id2, tag);
|
|
39
|
-
return id2;
|
|
40
|
-
}
|
|
41
|
-
const ps = { prop: [], on: [] };
|
|
42
|
-
const cbObj = {};
|
|
43
|
-
if (props) {
|
|
44
|
-
for (const [key, value] of Object.entries(props)) {
|
|
45
|
-
if (value instanceof Function) {
|
|
46
|
-
const eventKey = key.startsWith("on") ? key.slice(2).toLowerCase() : key;
|
|
47
|
-
cbObj[eventKey] = value;
|
|
48
|
-
ps.on.push(eventKey);
|
|
49
|
-
} else {
|
|
50
|
-
if (typeof value === "boolean") {
|
|
51
|
-
if (value) {
|
|
52
|
-
ps.prop.push({ key, value: "true" });
|
|
53
|
-
}
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
ps.prop.push({ key, value });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const id = dfunc2(
|
|
61
|
-
tag,
|
|
62
|
-
ps,
|
|
63
|
-
children.filter((c) => typeof c !== "boolean").map((c) => c?.toString())
|
|
64
|
-
);
|
|
65
|
-
callbackMap[id] = {
|
|
66
|
-
...callbackMap[id],
|
|
67
|
-
...cbObj
|
|
68
|
-
};
|
|
69
|
-
return id;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
var pendingOperations = /* @__PURE__ */ new Map();
|
|
73
|
-
var asyncCallback = (id, result) => {
|
|
74
|
-
log(`Async callback received for id: ${id} with result: ${result.tag}`);
|
|
75
|
-
const pending = pendingOperations.get(id);
|
|
76
|
-
if (pending) {
|
|
77
|
-
if (result.tag === "ok") {
|
|
78
|
-
pending.resolve(result.val);
|
|
79
|
-
} else {
|
|
80
|
-
pending.reject(new Error(result.val));
|
|
81
|
-
}
|
|
82
|
-
pendingOperations.delete(id);
|
|
83
|
-
rerender();
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var rawAsyncToPromise = (fn) => (...args) => {
|
|
87
|
-
return new Promise((resolve, reject) => {
|
|
88
|
-
const asyncId = fn(...args);
|
|
89
|
-
pendingOperations.set(asyncId, { resolve, reject });
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
var createComponent = (j) => ({
|
|
93
|
-
init: (ctx) => j(ctx),
|
|
94
|
-
emit,
|
|
95
|
-
asyncComplete: asyncCallback
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// src/raw.ts
|
|
99
|
-
var dfunc = window["druid-ui"]?.d || (() => {
|
|
100
|
-
throw new Error("druid.d function not defined");
|
|
101
|
-
});
|
|
102
|
-
var d2 = createDFunc(dfunc);
|
|
103
|
-
var log2 = (msg) => console.log("UI LOG:", msg);
|
|
104
|
-
export {
|
|
105
|
-
createComponent,
|
|
106
|
-
d2 as d,
|
|
107
|
-
log2 as log,
|
|
108
|
-
rawAsyncToPromise
|
|
109
|
-
};
|
package/dist/types/raw.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const d: (tag: string | {
|
|
2
|
-
view: (props?: any) => string;
|
|
3
|
-
init?: () => void;
|
|
4
|
-
} | ((props?: any) => void) | ((props?: any) => {
|
|
5
|
-
view: (props?: any) => string;
|
|
6
|
-
init?: () => void;
|
|
7
|
-
}), props?: Record<string, any>, ...children: string[] | Array<string[]>) => string | void | {
|
|
8
|
-
view: (props?: any) => string;
|
|
9
|
-
init?: () => void;
|
|
10
|
-
};
|
|
11
|
-
export declare const log: (msg: string) => void;
|
|
12
|
-
export { createComponent, rawAsyncToPromise } from "./utils";
|
|
13
|
-
//# sourceMappingURL=raw.d.ts.map
|
package/dist/types/raw.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../src/raw.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,CAAC;gBAK8mB,CAAC;QAAsB,CAAC;WAA8B,CAAC,yBAA+B,CAAC;gBAAwB,CAAC;QAAsB,CAAC;;gBAAxB,CAAC;;CALzsB,CAAC;AAEpC,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,SAAgC,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
|
package/src/raw.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//this file fully works in the browser, this hopefully can be remvoved in the future and unified with
|
|
2
|
-
import { createDFunc } from "./utils";
|
|
3
|
-
|
|
4
|
-
const dfunc =
|
|
5
|
-
window["druid-ui"]?.d ||
|
|
6
|
-
(() => {
|
|
7
|
-
throw new Error("druid.d function not defined");
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export const d = createDFunc(dfunc);
|
|
11
|
-
|
|
12
|
-
export const log = (msg: string) => console.log("UI LOG:", msg);
|
|
13
|
-
|
|
14
|
-
export { createComponent, rawAsyncToPromise } from "./utils";
|