@malloy-publisher/sdk 0.0.76 → 0.0.78
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/RenderedResult-BAZuT25g.js +117 -0
- package/dist/RenderedResult-DW6glKC-.cjs +1 -0
- package/dist/components/Model/SourcesExplorer.d.ts +1 -1
- package/dist/components/Notebook/NotebookCell.d.ts +1 -2
- package/dist/components/Package/PackageProvider.d.ts +1 -1
- package/dist/components/QueryResult/QueryResult.d.ts +11 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +3 -4
- package/dist/index.cjs.js +108 -45
- package/dist/index.es.js +26938 -8206
- package/dist/sdk.css +1 -1
- package/package.json +1 -1
- package/src/components/Model/ModelCell.tsx +9 -12
- package/src/components/Model/SourcesExplorer.tsx +89 -23
- package/src/components/MutableNotebook/MutableCell.tsx +3 -3
- package/src/components/Notebook/Notebook.tsx +0 -13
- package/src/components/Notebook/NotebookCell.tsx +9 -2
- package/src/components/Package/PackageProvider.tsx +2 -2
- package/src/components/QueryResult/QueryResult.tsx +70 -1
- package/src/components/RenderedResult/RenderedResult.tsx +124 -101
- package/dist/RenderedResult-C4b9CwSp.cjs +0 -1
- package/dist/RenderedResult-DXlUZo0k.js +0 -79
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense as w, useRef as b, useState as v, useLayoutEffect as R, useEffect as C } from "react";
|
|
3
|
+
const p = async (e) => {
|
|
4
|
+
if (typeof window > "u")
|
|
5
|
+
throw new Error("MalloyRenderer can only be used in browser environment");
|
|
6
|
+
const { MalloyRenderer: u } = await import("@malloydata/render");
|
|
7
|
+
return new u({
|
|
8
|
+
onClick: e
|
|
9
|
+
}).createViz();
|
|
10
|
+
};
|
|
11
|
+
function x({
|
|
12
|
+
result: e,
|
|
13
|
+
height: u,
|
|
14
|
+
isFillElement: s,
|
|
15
|
+
onSizeChange: a,
|
|
16
|
+
onDrill: h
|
|
17
|
+
}) {
|
|
18
|
+
const d = b(null), [y, l] = v(!1);
|
|
19
|
+
return R(() => {
|
|
20
|
+
if (!d.current || !e) return;
|
|
21
|
+
let t = !0;
|
|
22
|
+
const r = d.current;
|
|
23
|
+
for (; r.firstChild; )
|
|
24
|
+
r.removeChild(r.firstChild);
|
|
25
|
+
return p(h).then((i) => {
|
|
26
|
+
if (!t) return;
|
|
27
|
+
const n = new MutationObserver((o) => {
|
|
28
|
+
for (const f of o)
|
|
29
|
+
if (f.type === "childList" && f.addedNodes.length > 0 && Array.from(f.addedNodes).some(
|
|
30
|
+
(g) => g.nodeType === Node.ELEMENT_NODE
|
|
31
|
+
)) {
|
|
32
|
+
n.disconnect(), setTimeout(() => {
|
|
33
|
+
t && l(!0);
|
|
34
|
+
}, 50);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
n.observe(r, {
|
|
39
|
+
childList: !0,
|
|
40
|
+
subtree: !0,
|
|
41
|
+
characterData: !0
|
|
42
|
+
});
|
|
43
|
+
try {
|
|
44
|
+
i.setResult(JSON.parse(e)), i.render(r);
|
|
45
|
+
} catch (o) {
|
|
46
|
+
console.error("Error rendering visualization:", o), n.disconnect(), t && l(!0);
|
|
47
|
+
}
|
|
48
|
+
}).catch((i) => {
|
|
49
|
+
console.error("Failed to create renderer:", i), t && l(!0);
|
|
50
|
+
}), () => {
|
|
51
|
+
t = !1;
|
|
52
|
+
};
|
|
53
|
+
}, [e, h]), C(() => {
|
|
54
|
+
if (!d.current || !y) return;
|
|
55
|
+
const t = d.current, r = () => {
|
|
56
|
+
if (t) {
|
|
57
|
+
const o = t.offsetHeight;
|
|
58
|
+
o > 0 ? a && a(o) : s && t.firstChild && (t.firstChild.offsetHeight == 0 ? s(!0) : s(!1));
|
|
59
|
+
}
|
|
60
|
+
}, i = setTimeout(r, 100);
|
|
61
|
+
let n = null;
|
|
62
|
+
return n = new MutationObserver(r), n.observe(t, {
|
|
63
|
+
childList: !0,
|
|
64
|
+
subtree: !0,
|
|
65
|
+
attributes: !0
|
|
66
|
+
}), () => {
|
|
67
|
+
clearTimeout(i), n?.disconnect();
|
|
68
|
+
};
|
|
69
|
+
}, [a, e, s, y]), /* @__PURE__ */ c(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
ref: d,
|
|
73
|
+
style: {
|
|
74
|
+
width: "100%",
|
|
75
|
+
height: u ? `${u}px` : "100%"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
function N(e) {
|
|
81
|
+
return typeof window > "u" ? /* @__PURE__ */ c(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
style: {
|
|
85
|
+
width: "100%",
|
|
86
|
+
height: e.height ? `${e.height}px` : "100%",
|
|
87
|
+
display: "flex",
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
justifyContent: "center",
|
|
90
|
+
color: "#666"
|
|
91
|
+
},
|
|
92
|
+
children: "Loading..."
|
|
93
|
+
}
|
|
94
|
+
) : /* @__PURE__ */ c(
|
|
95
|
+
w,
|
|
96
|
+
{
|
|
97
|
+
fallback: /* @__PURE__ */ c(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
style: {
|
|
101
|
+
width: "100%",
|
|
102
|
+
height: e.height ? `${e.height}px` : "100%",
|
|
103
|
+
display: "flex",
|
|
104
|
+
alignItems: "center",
|
|
105
|
+
justifyContent: "center",
|
|
106
|
+
color: "#666"
|
|
107
|
+
},
|
|
108
|
+
children: "Loading visualization..."
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
children: /* @__PURE__ */ c(x, { ...e })
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
N as default
|
|
117
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var v=Object.create;var b=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var L=(e,t,r,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of x(t))!C.call(e,i)&&i!==r&&b(e,i,{get:()=>t[i],enumerable:!(d=R(t,i))||d.enumerable});return e};var M=(e,t,r)=>(r=e!=null?v(j(e)):{},L(t||!e||!e.__esModule?b(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),l=require("react"),N=async e=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:t}=await import("@malloydata/render");return new t({onClick:e}).createViz()};function T({result:e,height:t,isFillElement:r,onSizeChange:d,onDrill:i}){const a=l.useRef(null),[g,y]=l.useState(!1);return l.useLayoutEffect(()=>{if(!a.current||!e)return;let n=!0;const s=a.current;for(;s.firstChild;)s.removeChild(s.firstChild);return N(i).then(c=>{if(!n)return;const o=new MutationObserver(u=>{for(const h of u)if(h.type==="childList"&&h.addedNodes.length>0&&Array.from(h.addedNodes).some(w=>w.nodeType===Node.ELEMENT_NODE)){o.disconnect(),setTimeout(()=>{n&&y(!0)},50);break}});o.observe(s,{childList:!0,subtree:!0,characterData:!0});try{c.setResult(JSON.parse(e)),c.render(s)}catch(u){console.error("Error rendering visualization:",u),o.disconnect(),n&&y(!0)}}).catch(c=>{console.error("Failed to create renderer:",c),n&&y(!0)}),()=>{n=!1}},[e,i]),l.useEffect(()=>{if(!a.current||!g)return;const n=a.current,s=()=>{if(n){const u=n.offsetHeight;u>0?d&&d(u):r&&n.firstChild&&(n.firstChild.offsetHeight==0?r(!0):r(!1))}},c=setTimeout(s,100);let o=null;return o=new MutationObserver(s),o.observe(n,{childList:!0,subtree:!0,attributes:!0}),()=>{clearTimeout(c),o?.disconnect()}},[d,e,r,g]),f.jsx("div",{ref:a,style:{width:"100%",height:t?`${t}px`:"100%"}})}function p(e){return typeof window>"u"?f.jsx("div",{style:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#666"},children:"Loading..."}):f.jsx(l.Suspense,{fallback:f.jsx("div",{style:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#666"},children:"Loading visualization..."}),children:f.jsx(T,{...e})})}exports.default=p;
|
|
@@ -29,5 +29,5 @@ export interface QueryExplorerResult {
|
|
|
29
29
|
malloyResult: Malloy.Result | undefined;
|
|
30
30
|
}
|
|
31
31
|
export declare function emptyQueryExplorerResult(): QueryExplorerResult;
|
|
32
|
-
export declare function SourceExplorerComponent(
|
|
32
|
+
export declare function SourceExplorerComponent(props: SourceExplorerComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
33
33
|
export {};
|
|
@@ -2,11 +2,10 @@ import { NotebookCell as ClientNotebookCell } from '../../client';
|
|
|
2
2
|
interface NotebookCellProps {
|
|
3
3
|
cell: ClientNotebookCell;
|
|
4
4
|
notebookPath: string;
|
|
5
|
-
queryResultCodeSnippet: string;
|
|
6
5
|
expandCodeCell?: boolean;
|
|
7
6
|
hideCodeCellIcon?: boolean;
|
|
8
7
|
expandEmbedding?: boolean;
|
|
9
8
|
hideEmbeddingIcon?: boolean;
|
|
10
9
|
}
|
|
11
|
-
export declare function NotebookCell({ cell, notebookPath,
|
|
10
|
+
export declare function NotebookCell({ cell, notebookPath, expandCodeCell, hideCodeCellIcon, expandEmbedding, hideEmbeddingIcon, }: NotebookCellProps): import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export {};
|
|
@@ -8,5 +8,5 @@ interface PackageProviderProps extends PackageContextProps {
|
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
}
|
|
10
10
|
export declare const PackageProvider: ({ projectName, packageName, versionId, children, }: PackageProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare function usePackage(): PackageContextProps;
|
|
11
|
+
export declare function usePackage(throwOnMissing?: boolean): PackageContextProps;
|
|
12
12
|
export {};
|
|
@@ -3,6 +3,16 @@ interface QueryResultProps {
|
|
|
3
3
|
query?: string;
|
|
4
4
|
sourceName?: string;
|
|
5
5
|
queryName?: string;
|
|
6
|
+
optionalProjectName?: string;
|
|
7
|
+
optionalPackageName?: string;
|
|
8
|
+
optionalVersionId?: string;
|
|
6
9
|
}
|
|
7
|
-
export
|
|
10
|
+
export declare function createEmbeddedQueryResult(props: QueryResultProps): string;
|
|
11
|
+
/**
|
|
12
|
+
* This is a helper function to render a query result that is embedded as a string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function EmbeddedQueryResult({ embeddedQueryResult, }: {
|
|
15
|
+
embeddedQueryResult: string;
|
|
16
|
+
}): React.ReactElement;
|
|
17
|
+
export default function QueryResult({ modelPath, query, sourceName, queryName, optionalProjectName, optionalPackageName, optionalVersionId, }: QueryResultProps): import("react/jsx-runtime").JSX.Element;
|
|
8
18
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { MalloyRenderProps } from '@malloydata/render';
|
|
2
1
|
import { default as React } from 'react';
|
|
3
|
-
type MalloyRenderElement = HTMLElement &
|
|
2
|
+
type MalloyRenderElement = HTMLElement & Record<string, unknown>;
|
|
4
3
|
declare global {
|
|
5
4
|
namespace JSX {
|
|
6
5
|
interface IntrinsicElements {
|
|
@@ -13,7 +12,7 @@ interface RenderedResultProps {
|
|
|
13
12
|
height?: number;
|
|
14
13
|
isFillElement?: (boolean: any) => void;
|
|
15
14
|
onSizeChange?: (height: number) => void;
|
|
16
|
-
onDrill?: (element:
|
|
15
|
+
onDrill?: (element: unknown) => void;
|
|
17
16
|
}
|
|
18
|
-
export default function RenderedResult(
|
|
17
|
+
export default function RenderedResult(props: RenderedResultProps): import("react/jsx-runtime").JSX.Element;
|
|
19
18
|
export {};
|