@qianxiang-ai/fu-report-embed 0.0.0-stage → 1.1.8
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.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/url.d.ts +10 -0
- package/dist/url.d.ts.map +1 -0
- package/dist/url.js +29 -0
- package/dist/url.js.map +1 -0
- package/package.json +27 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FuReportFrameMode } from '@qianxiang-ai/fu-report-contracts';
|
|
2
|
+
export { buildFuReportEmbedUrl } from './url.js';
|
|
3
|
+
export interface FuReportEmbedOptions {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
designerBaseUrl?: string;
|
|
6
|
+
viewerBaseUrl?: string;
|
|
7
|
+
reportId?: string;
|
|
8
|
+
mode?: FuReportFrameMode;
|
|
9
|
+
}
|
|
10
|
+
export interface FuReportElementHandle extends HTMLElement {
|
|
11
|
+
}
|
|
12
|
+
export declare function registerFuReportElement(tagName?: string): void;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGhD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB;AAED,MAAM,WAAW,qBAAsB,SAAQ,WAAW;CAAG;AA2C7D,wBAAgB,uBAAuB,CAAC,OAAO,SAAoB,GAAG,IAAI,CAKzE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export { buildFuReportEmbedUrl } from './url.js';
|
|
2
|
+
import { buildFuReportEmbedUrl } from './url.js';
|
|
3
|
+
function createFuReportElement() {
|
|
4
|
+
return class FuReportElement extends HTMLElement {
|
|
5
|
+
static observedAttributes = [
|
|
6
|
+
'base-url', 'designer-base-url', 'viewer-base-url', 'report-id', 'mode'
|
|
7
|
+
];
|
|
8
|
+
frame;
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.render();
|
|
11
|
+
}
|
|
12
|
+
disconnectedCallback() {
|
|
13
|
+
if (this.frame)
|
|
14
|
+
this.frame.src = 'about:blank';
|
|
15
|
+
this.replaceChildren();
|
|
16
|
+
}
|
|
17
|
+
attributeChangedCallback() {
|
|
18
|
+
if (this.isConnected)
|
|
19
|
+
this.render();
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
const frame = document.createElement('iframe');
|
|
23
|
+
frame.title = 'Fu Report';
|
|
24
|
+
frame.src = buildFuReportEmbedUrl({
|
|
25
|
+
baseUrl: this.getAttribute('base-url') || '',
|
|
26
|
+
designerBaseUrl: this.getAttribute('designer-base-url') || undefined,
|
|
27
|
+
viewerBaseUrl: this.getAttribute('viewer-base-url') || undefined,
|
|
28
|
+
reportId: this.getAttribute('report-id') || undefined,
|
|
29
|
+
mode: this.getAttribute('mode') ?? 'view'
|
|
30
|
+
});
|
|
31
|
+
frame.style.width = '100%';
|
|
32
|
+
frame.style.height = '100%';
|
|
33
|
+
frame.style.border = '0';
|
|
34
|
+
frame.sandbox.add('allow-scripts', 'allow-forms', 'allow-same-origin', 'allow-downloads');
|
|
35
|
+
frame.allow = 'clipboard-write; fullscreen';
|
|
36
|
+
frame.referrerPolicy = 'no-referrer';
|
|
37
|
+
this.frame = frame;
|
|
38
|
+
this.replaceChildren(frame);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function registerFuReportElement(tagName = 'fu-report-embed') {
|
|
43
|
+
if (typeof globalThis.customElements === 'undefined' || typeof globalThis.HTMLElement === 'undefined') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!customElements.get(tagName))
|
|
47
|
+
customElements.define(tagName, createFuReportElement());
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAYhD,SAAS,qBAAqB;IAC5B,OAAO,MAAM,eAAgB,SAAQ,WAAW;QAC9C,MAAM,CAAU,kBAAkB,GAAG;YACnC,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM;SACxE,CAAA;QACO,KAAK,CAAoB;QACjC,iBAAiB;YACf,IAAI,CAAC,MAAM,EAAE,CAAA;QACf,CAAC;QAED,oBAAoB;YAClB,IAAI,IAAI,CAAC,KAAK;gBAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,aAAa,CAAA;YAC9C,IAAI,CAAC,eAAe,EAAE,CAAA;QACxB,CAAC;QAED,wBAAwB;YACtB,IAAI,IAAI,CAAC,WAAW;gBAAE,IAAI,CAAC,MAAM,EAAE,CAAA;QACrC,CAAC;QAEO,MAAM;YACZ,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;YAC9C,KAAK,CAAC,KAAK,GAAG,WAAW,CAAA;YACzB,KAAK,CAAC,GAAG,GAAG,qBAAqB,CAAC;gBAChC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE;gBAC5C,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,IAAI,SAAS;gBACpE,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,SAAS;gBAChE,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,SAAS;gBACrD,IAAI,EAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAA8B,IAAI,MAAM;aACxE,CAAC,CAAA;YACF,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAA;YAC1B,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAA;YAC3B,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAA;YACxB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,CAAA;YACzF,KAAK,CAAC,KAAK,GAAG,6BAA6B,CAAA;YAC3C,KAAK,CAAC,cAAc,GAAG,aAAa,CAAA;YACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;YAClB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;QAC7B,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAO,GAAG,iBAAiB;IACjE,IAAI,OAAO,UAAU,CAAC,cAAc,KAAK,WAAW,IAAI,OAAO,UAAU,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;QACtG,OAAM;IACR,CAAC;IACD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,qBAAqB,EAAE,CAAC,CAAA;AAC3F,CAAC"}
|
package/dist/url.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FuReportFrameMode } from '@qianxiang-ai/fu-report-contracts';
|
|
2
|
+
export interface FuReportEmbedUrlOptions {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
designerBaseUrl?: string;
|
|
5
|
+
viewerBaseUrl?: string;
|
|
6
|
+
reportId?: string;
|
|
7
|
+
mode?: FuReportFrameMode;
|
|
8
|
+
}
|
|
9
|
+
export declare function buildFuReportEmbedUrl(options: FuReportEmbedUrlOptions): string;
|
|
10
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAE1E,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,iBAAiB,CAAA;CACzB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAa9E"}
|
package/dist/url.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function buildFuReportEmbedUrl(options) {
|
|
2
|
+
const mode = options.mode ?? 'view';
|
|
3
|
+
const id = options.reportId ? encodeURIComponent(options.reportId) : '';
|
|
4
|
+
const path = mode === 'design' ? `/reports/design/${id}`
|
|
5
|
+
: mode === 'view' ? `/reports/view/${id}`
|
|
6
|
+
: mode === 'group' ? `/report-groups/${id}/view`
|
|
7
|
+
: `/reports/${id}/print`;
|
|
8
|
+
const baseUrl = mode === 'design'
|
|
9
|
+
? options.designerBaseUrl ?? parentBaseUrl(options.baseUrl)
|
|
10
|
+
: mode === 'view'
|
|
11
|
+
? options.viewerBaseUrl ?? parentBaseUrl(options.baseUrl)
|
|
12
|
+
: options.baseUrl;
|
|
13
|
+
return `${baseUrl.replace(/\/$/, '')}${path}?embedded=1`;
|
|
14
|
+
}
|
|
15
|
+
function parentBaseUrl(value) {
|
|
16
|
+
const normalized = value.replace(/\/+$/, '');
|
|
17
|
+
try {
|
|
18
|
+
const url = new URL(normalized);
|
|
19
|
+
const segments = url.pathname.split('/').filter(Boolean);
|
|
20
|
+
segments.pop();
|
|
21
|
+
url.pathname = segments.length === 0 ? '/' : `/${segments.join('/')}`;
|
|
22
|
+
return url.toString().replace(/\/$/, '');
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
const separator = normalized.lastIndexOf('/');
|
|
26
|
+
return separator <= 0 ? '' : normalized.slice(0, separator);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=url.js.map
|
package/dist/url.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,qBAAqB,CAAC,OAAgC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAA;IACnC,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACvE,MAAM,IAAI,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,mBAAmB,EAAE,EAAE;QACtD,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,iBAAiB,EAAE,EAAE;YACvC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,kBAAkB,EAAE,OAAO;gBAC9C,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAA;IAC9B,MAAM,OAAO,GAAG,IAAI,KAAK,QAAQ;QAC/B,CAAC,CAAC,OAAO,CAAC,eAAe,IAAI,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC;QAC3D,CAAC,CAAC,IAAI,KAAK,MAAM;YACf,CAAC,CAAC,OAAO,CAAC,aAAa,IAAI,aAAa,CAAC,OAAO,CAAC,OAAO,CA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": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org/"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@qianxiang-ai/fu-report-contracts": "1.1.8"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "node ../../scripts/clean-dist.mjs && tsc -p tsconfig.json",
|
|
27
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
28
|
+
"test": "vitest run src"
|
|
29
|
+
}
|
|
6
30
|
}
|
package/README.md
DELETED