@malloydata/render 0.0.118-dev240111234914 → 0.0.118-dev240115220450
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/bundle/bundled_renderer.js +137671 -0
- package/dist/bundle/bundled_renderer.min.js +2233 -0
- package/dist/bundle/main.d.ts +6 -0
- package/dist/bundle/main.js +29 -0
- package/dist/bundle/renderer.d.ts +1 -0
- package/dist/bundle/renderer.js +71 -0
- package/package.json +5 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const renderer_1 = require("./renderer");
|
|
26
|
+
window.renderMalloyResults = async (resultStr, totalRows, preparedResultStr) => {
|
|
27
|
+
return await (0, renderer_1.renderMalloyResults)(resultStr, totalRows, preparedResultStr);
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderMalloyResults(queryResult: any, totalRows: any, preparedResult: any): Promise<HTMLElement>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.renderMalloyResults = void 0;
|
|
26
|
+
const malloy_1 = require("@malloydata/malloy");
|
|
27
|
+
const html_view_1 = require("../html/html_view");
|
|
28
|
+
async function renderMalloyResults(queryResult, totalRows, preparedResult) {
|
|
29
|
+
try {
|
|
30
|
+
let preparedResultObj;
|
|
31
|
+
if (preparedResult._modelDef !== undefined &&
|
|
32
|
+
preparedResult._rawQuery !== undefined) {
|
|
33
|
+
// prepared result is safely typecasted.
|
|
34
|
+
preparedResultObj = preparedResult;
|
|
35
|
+
}
|
|
36
|
+
else if (preparedResult.inner !== undefined &&
|
|
37
|
+
preparedResult.modelDef !== undefined) {
|
|
38
|
+
// prepared result is raw json.
|
|
39
|
+
preparedResultObj = malloy_1.PreparedResult.fromJson({
|
|
40
|
+
query: preparedResult.inner,
|
|
41
|
+
modelDef: preparedResult.modelDef,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new Error('preparedResult has missing properties.');
|
|
46
|
+
}
|
|
47
|
+
const malloyRes = {
|
|
48
|
+
queryResult: {
|
|
49
|
+
...preparedResultObj._rawQuery,
|
|
50
|
+
result: queryResult,
|
|
51
|
+
totalRows: totalRows,
|
|
52
|
+
},
|
|
53
|
+
modelDef: preparedResultObj._modelDef,
|
|
54
|
+
};
|
|
55
|
+
const result = malloy_1.Result.fromJSON(malloyRes);
|
|
56
|
+
const htmlView = new html_view_1.HTMLView(document).render(result, {
|
|
57
|
+
dataStyles: {},
|
|
58
|
+
isDrillingEnabled: false,
|
|
59
|
+
});
|
|
60
|
+
return await htmlView;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// eslint-disable-next-line no-console
|
|
64
|
+
console.error('Error rendering results:', error);
|
|
65
|
+
const span = document.createElement('span');
|
|
66
|
+
span.textContent = 'Unable to render malloy results.';
|
|
67
|
+
return span;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.renderMalloyResults = renderMalloyResults;
|
|
71
|
+
//# sourceMappingURL=renderer.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/render",
|
|
3
|
-
"version": "0.0.118-
|
|
3
|
+
"version": "0.0.118-dev240115220450",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,18 +13,19 @@
|
|
|
13
13
|
"node": ">=16"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
+
"bundle_renderer": "node src/bundle/esbuild_bundler.js",
|
|
16
17
|
"lint": "eslint '**/*.ts{,x}'",
|
|
17
18
|
"lint-fix": "eslint '**/*.ts{,x}' --fix",
|
|
18
19
|
"test": "jest --config=../../jest.config.js",
|
|
19
20
|
"build": "tsc --build",
|
|
20
21
|
"clean": "tsc --build --clean",
|
|
21
|
-
"prepublishOnly": "npm run build",
|
|
22
|
+
"prepublishOnly": "npm run build && npm run bundle_renderer",
|
|
22
23
|
"storybook": "storybook dev -p 6006",
|
|
23
24
|
"build-storybook": "storybook build"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"@lit/context": "^1.1.0",
|
|
27
|
-
"@malloydata/malloy": "^0.0.118-
|
|
28
|
+
"@malloydata/malloy": "^0.0.118-dev240115220450",
|
|
28
29
|
"@types/luxon": "^2.4.0",
|
|
29
30
|
"lit": "^3.0.2",
|
|
30
31
|
"lodash": "^4.17.20",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"@storybook/html-vite": "^7.5.0",
|
|
44
45
|
"@storybook/testing-library": "^0.2.2",
|
|
45
46
|
"@storybook/types": "^7.5.3",
|
|
47
|
+
"esbuild": "0.19.11",
|
|
46
48
|
"storybook": "^7.5.0"
|
|
47
49
|
}
|
|
48
50
|
}
|