@sdcorejs/angular 20.1.6 → 20.2.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/README.md +10 -0
- package/assets/scss/core/menu.scss +18 -0
- package/assets/scss/core/utilities/_misc.scss +15 -0
- package/assets/scss/sd-core.scss +1 -0
- package/components/anchor/index.d.ts +3 -1
- package/components/api-contract-builder/index.d.ts +694 -0
- package/components/badge/index.d.ts +2 -0
- package/components/ckeditor-styles/index.d.ts +1 -1
- package/components/form-generic/index.d.ts +44 -33
- package/components/import-excel/index.d.ts +1 -0
- package/components/index.d.ts +7 -1
- package/components/mini-editor/index.d.ts +1 -1
- package/components/modal/index.d.ts +3 -2
- package/components/modal-resizable/index.d.ts +92 -0
- package/components/org-chart/index.d.ts +6 -0
- package/components/preview/index.d.ts +1 -0
- package/components/query-bar/index.d.ts +55 -17
- package/components/query-builder/index.d.ts +150 -98
- package/components/section/index.d.ts +5 -0
- package/components/tab-router/index.d.ts +19 -19
- package/components/table/index.d.ts +251 -109
- package/components/tree/index.d.ts +48 -30
- package/components/upload-file/index.d.ts +6 -3
- package/configurations/index.d.ts +1 -2
- package/fesm2022/sdcorejs-angular-components-anchor.mjs +37 -13
- package/fesm2022/sdcorejs-angular-components-anchor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs +3417 -0
- package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-badge.mjs +27 -2
- package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-button.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-button.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs +1 -1
- package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-code-editor.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-code-editor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-data-state.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-data-state.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-editor.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-editor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs +324 -192
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-history.mjs +4 -4
- package/fesm2022/sdcorejs-angular-components-history.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-import-excel.mjs +13 -5
- package/fesm2022/sdcorejs-angular-components-import-excel.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-inform.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-inform.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs +164 -8
- package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-modal.mjs +30 -18
- package/fesm2022/sdcorejs-angular-components-modal.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-operator.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-operator.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-org-chart.mjs +60 -13
- package/fesm2022/sdcorejs-angular-components-org-chart.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-preview.mjs +27 -17
- package/fesm2022/sdcorejs-angular-components-preview.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-query-bar.mjs +192 -30
- package/fesm2022/sdcorejs-angular-components-query-bar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-query-builder.mjs +187 -127
- package/fesm2022/sdcorejs-angular-components-query-builder.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-section.mjs +33 -2
- package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +83 -24
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-splitter.mjs +57 -21
- package/fesm2022/sdcorejs-angular-components-splitter.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-stepper.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-stepper.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs +68 -20
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tab.mjs +3 -2
- package/fesm2022/sdcorejs-angular-components-tab.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-table.mjs +556 -268
- package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tree.mjs +80 -17
- package/fesm2022/sdcorejs-angular-components-tree.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs +48 -13
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components.mjs +7 -1
- package/fesm2022/sdcorejs-angular-components.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-configurations.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-directives.mjs +45 -8
- package/fesm2022/sdcorejs-angular-directives.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +40 -29
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-checkbox.mjs +5 -5
- package/fesm2022/sdcorejs-angular-forms-checkbox.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +67 -50
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip.mjs +57 -43
- package/fesm2022/sdcorejs-angular-forms-chip.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs +232 -61
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date.mjs +96 -24
- package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs +131 -27
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs +40 -16
- package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input-color.mjs +16 -5
- package/fesm2022/sdcorejs-angular-forms-input-color.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs +24 -9
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input.mjs +58 -10
- package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-models.mjs +227 -6
- package/fesm2022/sdcorejs-angular-forms-models.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-radio.mjs +4 -4
- package/fesm2022/sdcorejs-angular-forms-radio.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-select.mjs +136 -38
- package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-switch.mjs +18 -3
- package/fesm2022/sdcorejs-angular-forms-switch.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs +51 -62
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-time-range.mjs +57 -12
- package/fesm2022/sdcorejs-angular-forms-time-range.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-time.mjs +16 -5
- package/fesm2022/sdcorejs-angular-forms-time.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-tree-select.mjs +100 -9
- package/fesm2022/sdcorejs-angular-forms-tree-select.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms.mjs +91 -46
- package/fesm2022/sdcorejs-angular-forms.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-handlers.mjs +18 -3
- package/fesm2022/sdcorejs-angular-handlers.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-i18n.mjs +895 -68
- package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-interceptors.mjs +87 -29
- package/fesm2022/sdcorejs-angular-interceptors.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-auth.mjs +25 -15
- package/fesm2022/sdcorejs-angular-modules-auth.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-icon.mjs +2 -2
- package/fesm2022/sdcorejs-angular-modules-icon.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-keycloak.mjs +32 -3
- package/fesm2022/sdcorejs-angular-modules-keycloak.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-layout.mjs +342 -111
- package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-permission.mjs +177 -40
- package/fesm2022/sdcorejs-angular-modules-permission.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-pipes.mjs +62 -28
- package/fesm2022/sdcorejs-angular-pipes.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-api.mjs +123 -13
- package/fesm2022/sdcorejs-angular-services-api.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-cache.mjs +53 -3
- package/fesm2022/sdcorejs-angular-services-cache.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-confirm.mjs +25 -73
- package/fesm2022/sdcorejs-angular-services-confirm.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-excel.mjs +12 -10
- package/fesm2022/sdcorejs-angular-services-excel.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-loading.mjs +75 -84
- package/fesm2022/sdcorejs-angular-services-loading.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-notify.mjs +46 -5
- package/fesm2022/sdcorejs-angular-services-notify.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-storage.mjs +4 -0
- package/fesm2022/sdcorejs-angular-services-storage.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services.mjs +0 -1
- package/fesm2022/sdcorejs-angular-services.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-utilities-extensions.mjs +225 -80
- package/fesm2022/sdcorejs-angular-utilities-extensions.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-utilities-models.mjs +1 -63
- package/fesm2022/sdcorejs-angular-utilities-models.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular.mjs +17 -10
- package/fesm2022/sdcorejs-angular.mjs.map +1 -1
- package/forms/autocomplete/index.d.ts +5 -2
- package/forms/chip-calendar/index.d.ts +10 -0
- package/forms/date/index.d.ts +13 -2
- package/forms/date-range/index.d.ts +14 -2
- package/forms/datetime/index.d.ts +13 -2
- package/forms/entity-picker/index.d.ts +9 -3
- package/forms/index.d.ts +22 -13
- package/forms/input/index.d.ts +3 -0
- package/forms/input-color/index.d.ts +4 -0
- package/forms/input-number/index.d.ts +3 -0
- package/forms/models/index.d.ts +119 -4
- package/forms/select/index.d.ts +27 -4
- package/forms/switch/index.d.ts +7 -1
- package/forms/textarea/index.d.ts +5 -3
- package/forms/time-range/index.d.ts +22 -1
- package/forms/tree-select/index.d.ts +36 -5
- package/i18n/index.d.ts +175 -16
- package/index.d.ts +11 -2
- package/interceptors/index.d.ts +13 -3
- package/modules/auth/index.d.ts +1 -1
- package/modules/keycloak/index.d.ts +1 -0
- package/modules/layout/index.d.ts +94 -28
- package/modules/permission/index.d.ts +66 -4
- package/package.json +36 -25
- package/pipes/index.d.ts +27 -5
- package/services/api/index.d.ts +21 -1
- package/services/cache/index.d.ts +11 -1
- package/services/index.d.ts +0 -1
- package/services/notify/index.d.ts +1 -1
- package/utilities/extensions/index.d.ts +83 -61
- package/utilities/models/index.d.ts +2 -76
- package/components/base/index.d.ts +0 -11
- package/components/document-builder/index.d.ts +0 -252
- package/fesm2022/sdcorejs-angular-components-base.mjs +0 -23
- package/fesm2022/sdcorejs-angular-components-base.mjs.map +0 -1
- package/fesm2022/sdcorejs-angular-components-document-builder.mjs +0 -5038
- package/fesm2022/sdcorejs-angular-components-document-builder.mjs.map +0 -1
- package/fesm2022/sdcorejs-angular-models.mjs +0 -6
- package/fesm2022/sdcorejs-angular-models.mjs.map +0 -1
- package/fesm2022/sdcorejs-angular-services-docx.mjs +0 -291
- package/fesm2022/sdcorejs-angular-services-docx.mjs.map +0 -1
- package/fesm2022/sdcorejs-angular-services-license.mjs +0 -97
- package/fesm2022/sdcorejs-angular-services-license.mjs.map +0 -1
- package/models/index.d.ts +0 -2
- package/services/docx/index.d.ts +0 -27
- package/services/license/index.d.ts +0 -12
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdcorejs-angular-models.mjs","sources":["../../../projects/sdcorejs-angular/models/sdcorejs-angular-models.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;;AAEG"}
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, Injectable } from '@angular/core';
|
|
3
|
-
import { SdNotifyService } from '@sdcorejs/angular/services/notify';
|
|
4
|
-
import { SdLoadingService } from '@sdcorejs/angular/services/loading';
|
|
5
|
-
import { I18nService } from '@sdcorejs/angular/i18n';
|
|
6
|
-
import { OpenFile, PreopenDirectory, File as File$1, ConsoleStdout, WASI } from '@bjorn3/browser_wasi_shim';
|
|
7
|
-
|
|
8
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
9
|
-
/* Pandoc WASM core logic — adapted from pandoc-wasm/src/core.js
|
|
10
|
-
*
|
|
11
|
-
* This file is a local copy of the environment-agnostic pandoc core.
|
|
12
|
-
* It imports @bjorn3/browser_wasi_shim directly, avoiding the pandoc-wasm
|
|
13
|
-
* package entry points which use top-level await (incompatible with
|
|
14
|
-
* Angular's esbuild/Vite build pipeline).
|
|
15
|
-
*
|
|
16
|
-
* Source: https://github.com/pandoc/pandoc-wasm (GPL-2.0-or-later)
|
|
17
|
-
*/
|
|
18
|
-
// @ts-nocheck
|
|
19
|
-
function createPandocInstance(wasmBinary) {
|
|
20
|
-
const args = ['pandoc.wasm', '+RTS', '-H64m', '-RTS'];
|
|
21
|
-
const env = [];
|
|
22
|
-
const fileSystem = new Map();
|
|
23
|
-
const fds = [
|
|
24
|
-
new OpenFile(new File$1(new Uint8Array(), { readonly: true })),
|
|
25
|
-
ConsoleStdout.lineBuffered(() => undefined),
|
|
26
|
-
ConsoleStdout.lineBuffered((msg) => console.warn(`[WASI stderr] ${msg}`)),
|
|
27
|
-
new PreopenDirectory('/', fileSystem),
|
|
28
|
-
];
|
|
29
|
-
const options = { debug: false };
|
|
30
|
-
const wasi = new WASI(args, env, fds, options);
|
|
31
|
-
return WebAssembly.instantiate(wasmBinary, {
|
|
32
|
-
wasi_snapshot_preview1: wasi.wasiImport,
|
|
33
|
-
}).then(({ instance }) => {
|
|
34
|
-
wasi.initialize(instance);
|
|
35
|
-
instance.exports.__wasm_call_ctors();
|
|
36
|
-
function memory_data_view() {
|
|
37
|
-
return new DataView(instance.exports.memory.buffer);
|
|
38
|
-
}
|
|
39
|
-
const argc_ptr = instance.exports.malloc(4);
|
|
40
|
-
memory_data_view().setUint32(argc_ptr, args.length, true);
|
|
41
|
-
const argv = instance.exports.malloc(4 * (args.length + 1));
|
|
42
|
-
for (let i = 0; i < args.length; ++i) {
|
|
43
|
-
const arg = instance.exports.malloc(args[i].length + 1);
|
|
44
|
-
new TextEncoder().encodeInto(args[i], new Uint8Array(instance.exports.memory.buffer, arg, args[i].length));
|
|
45
|
-
memory_data_view().setUint8(arg + args[i].length, 0);
|
|
46
|
-
memory_data_view().setUint32(argv + 4 * i, arg, true);
|
|
47
|
-
}
|
|
48
|
-
memory_data_view().setUint32(argv + 4 * args.length, 0, true);
|
|
49
|
-
const argv_ptr = instance.exports.malloc(4);
|
|
50
|
-
memory_data_view().setUint32(argv_ptr, argv, true);
|
|
51
|
-
instance.exports.hs_init_with_rtsopts(argc_ptr, argv_ptr);
|
|
52
|
-
async function addFile(filename, data, readonly) {
|
|
53
|
-
let uint8Array;
|
|
54
|
-
if (typeof data === 'string') {
|
|
55
|
-
uint8Array = new TextEncoder().encode(data);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
const buffer = await data.arrayBuffer();
|
|
59
|
-
uint8Array = new Uint8Array(buffer);
|
|
60
|
-
}
|
|
61
|
-
const file = new File$1(uint8Array, { readonly });
|
|
62
|
-
fileSystem.set(filename, file);
|
|
63
|
-
}
|
|
64
|
-
async function convert(options, stdin, files) {
|
|
65
|
-
const opts_str = JSON.stringify(options);
|
|
66
|
-
const encoded = new TextEncoder().encode(opts_str);
|
|
67
|
-
const opts_ptr = instance.exports.malloc(encoded.length);
|
|
68
|
-
new TextEncoder().encodeInto(opts_str, new Uint8Array(instance.exports.memory.buffer, opts_ptr, encoded.length));
|
|
69
|
-
files = { ...files };
|
|
70
|
-
fileSystem.clear();
|
|
71
|
-
const in_file = new File$1(new Uint8Array(), { readonly: true });
|
|
72
|
-
const out_file = new File$1(new Uint8Array(), { readonly: false });
|
|
73
|
-
const err_file = new File$1(new Uint8Array(), { readonly: false });
|
|
74
|
-
const warnings_file = new File$1(new Uint8Array(), { readonly: false });
|
|
75
|
-
fileSystem.set('stdin', in_file);
|
|
76
|
-
fileSystem.set('stdout', out_file);
|
|
77
|
-
fileSystem.set('stderr', err_file);
|
|
78
|
-
fileSystem.set('warnings', warnings_file);
|
|
79
|
-
const knownFiles = new Set(['stdin', 'stdout', 'stderr', 'warnings']);
|
|
80
|
-
for (const filename in files) {
|
|
81
|
-
await addFile(filename, files[filename], true);
|
|
82
|
-
knownFiles.add(filename);
|
|
83
|
-
}
|
|
84
|
-
const outputFileName = options['output-file'] || null;
|
|
85
|
-
const extractMediaPath = options['extract-media'] || null;
|
|
86
|
-
if (outputFileName) {
|
|
87
|
-
await addFile(outputFileName, new Blob(), false);
|
|
88
|
-
knownFiles.add(outputFileName);
|
|
89
|
-
}
|
|
90
|
-
if (extractMediaPath) {
|
|
91
|
-
await addFile(extractMediaPath, new Blob(), false);
|
|
92
|
-
if (extractMediaPath.endsWith('.zip')) {
|
|
93
|
-
knownFiles.add(extractMediaPath);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (stdin) {
|
|
97
|
-
in_file.data = new TextEncoder().encode(stdin);
|
|
98
|
-
}
|
|
99
|
-
instance.exports.convert(opts_ptr, encoded.length);
|
|
100
|
-
if (options['output-file']) {
|
|
101
|
-
const outputFile = fileSystem.get(options['output-file']);
|
|
102
|
-
if (outputFile && outputFile.data && outputFile.data.length > 0) {
|
|
103
|
-
files[options['output-file']] = new Blob([outputFile.data]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (options['extract-media']) {
|
|
107
|
-
const mediaFile = fileSystem.get(options['extract-media']);
|
|
108
|
-
if (mediaFile && mediaFile.data && mediaFile.data.length > 0) {
|
|
109
|
-
files[options['extract-media']] = new Blob([mediaFile.data], { type: 'application/zip' });
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const mediaFiles = {};
|
|
113
|
-
for (const [name, fileData] of fileSystem.entries()) {
|
|
114
|
-
if (!knownFiles.has(name) && fileData && fileData.data && fileData.data.length > 0) {
|
|
115
|
-
const blob = new Blob([fileData.data]);
|
|
116
|
-
files[name] = blob;
|
|
117
|
-
if (name !== outputFileName && name !== extractMediaPath) {
|
|
118
|
-
mediaFiles[name] = blob;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const rawWarnings = new TextDecoder('utf-8', { fatal: true }).decode(warnings_file.data);
|
|
123
|
-
let warnings = [];
|
|
124
|
-
if (rawWarnings) {
|
|
125
|
-
try {
|
|
126
|
-
warnings = JSON.parse(rawWarnings);
|
|
127
|
-
}
|
|
128
|
-
catch (e) {
|
|
129
|
-
console.warn('Failed to parse warnings:', e);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
stdout: new TextDecoder('utf-8', { fatal: true }).decode(out_file.data),
|
|
134
|
-
stderr: new TextDecoder('utf-8', { fatal: true }).decode(err_file.data),
|
|
135
|
-
warnings,
|
|
136
|
-
files,
|
|
137
|
-
mediaFiles,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
return { convert };
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
class SdDocxService {
|
|
145
|
-
notifyService = inject(SdNotifyService);
|
|
146
|
-
loadingService = inject(SdLoadingService);
|
|
147
|
-
#i18n = inject(I18nService);
|
|
148
|
-
#DEFAULT_MAX_SIZE_MB = 50;
|
|
149
|
-
#VALID_EXTENSIONS = ['.doc', '.docx'];
|
|
150
|
-
#PANDOC_WASM_URL = 'https://pandoc.github.io/pandoc-wasm/pandoc.wasm';
|
|
151
|
-
#fileInput = null;
|
|
152
|
-
#pandocInstance = null;
|
|
153
|
-
constructor() { }
|
|
154
|
-
async open(options) {
|
|
155
|
-
return new Promise(resolve => {
|
|
156
|
-
this.#createFileInput();
|
|
157
|
-
if (!this.#fileInput) {
|
|
158
|
-
resolve(null);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const handleChange = async (event) => {
|
|
162
|
-
const input = event.target;
|
|
163
|
-
const file = input.files?.[0];
|
|
164
|
-
if (!file) {
|
|
165
|
-
resolve(null);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
this.loadingService.start();
|
|
169
|
-
try {
|
|
170
|
-
const result = await this.convertToHtml(file, options);
|
|
171
|
-
resolve(result);
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
console.error('[SdDocxService] DocX conversion error:', error);
|
|
175
|
-
this.notifyService.error(this.#i18n.t('core.docx.convert-error'));
|
|
176
|
-
resolve(null);
|
|
177
|
-
}
|
|
178
|
-
finally {
|
|
179
|
-
input.value = '';
|
|
180
|
-
input.removeEventListener('change', handleChange);
|
|
181
|
-
this.loadingService.stop();
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
this.#fileInput.addEventListener('change', handleChange, { once: true });
|
|
185
|
-
this.#fileInput.click();
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
#createFileInput() {
|
|
189
|
-
if (this.#fileInput) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
this.#fileInput = document.createElement('input');
|
|
193
|
-
this.#fileInput.type = 'file';
|
|
194
|
-
this.#fileInput.accept = '.doc,.docx';
|
|
195
|
-
this.#fileInput.style.display = 'none';
|
|
196
|
-
document.body.appendChild(this.#fileInput);
|
|
197
|
-
}
|
|
198
|
-
async #getPandocInstance() {
|
|
199
|
-
if (this.#pandocInstance) {
|
|
200
|
-
return this.#pandocInstance;
|
|
201
|
-
}
|
|
202
|
-
const wasmResponse = await fetch(this.#PANDOC_WASM_URL);
|
|
203
|
-
if (!wasmResponse.ok) {
|
|
204
|
-
throw new Error(`Failed to fetch pandoc.wasm: ${wasmResponse.status} ${wasmResponse.statusText}`);
|
|
205
|
-
}
|
|
206
|
-
const wasmBinary = await wasmResponse.arrayBuffer();
|
|
207
|
-
this.#pandocInstance = await createPandocInstance(wasmBinary);
|
|
208
|
-
return this.#pandocInstance;
|
|
209
|
-
}
|
|
210
|
-
async convertToHtml(input, options) {
|
|
211
|
-
const opts = {
|
|
212
|
-
validateFormat: true,
|
|
213
|
-
validateSize: true,
|
|
214
|
-
maxSizeInMb: this.#DEFAULT_MAX_SIZE_MB,
|
|
215
|
-
...options,
|
|
216
|
-
};
|
|
217
|
-
try {
|
|
218
|
-
let fileName;
|
|
219
|
-
let fileSize;
|
|
220
|
-
let blob;
|
|
221
|
-
if (input instanceof File) {
|
|
222
|
-
fileName = input.name;
|
|
223
|
-
fileSize = input.size;
|
|
224
|
-
blob = input;
|
|
225
|
-
}
|
|
226
|
-
else if (input instanceof Blob) {
|
|
227
|
-
fileSize = input.size;
|
|
228
|
-
blob = input;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
blob = new Blob([input], {
|
|
232
|
-
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
if (opts.validateFormat && fileName) {
|
|
236
|
-
if (!this.#isValidFormat(fileName)) {
|
|
237
|
-
this.notifyService.error(this.#i18n.t('core.docx.invalid-format'));
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (opts.validateSize && fileSize !== undefined) {
|
|
242
|
-
const maxSizeInBytes = opts.maxSizeInMb * 1024 * 1024;
|
|
243
|
-
if (fileSize > maxSizeInBytes) {
|
|
244
|
-
this.notifyService.error(this.#i18n.t('core.docx.size-exceeded'));
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
const pandoc = await this.#getPandocInstance();
|
|
249
|
-
const pandocOpts = {
|
|
250
|
-
from: 'docx',
|
|
251
|
-
to: 'html',
|
|
252
|
-
'input-files': ['document.docx'],
|
|
253
|
-
standalone: true,
|
|
254
|
-
'embed-resources': true,
|
|
255
|
-
};
|
|
256
|
-
const result = await pandoc.convert(pandocOpts, null, { 'document.docx': blob });
|
|
257
|
-
return {
|
|
258
|
-
html: result.stdout,
|
|
259
|
-
messages: result.warnings.map((w) => String(w)),
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
catch (error) {
|
|
263
|
-
console.error('[SdDocxService] DocX conversion error:', error);
|
|
264
|
-
this.notifyService.error(this.#i18n.t('core.docx.convert-error'));
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
async convertToHtmlString(input, options) {
|
|
269
|
-
const result = await this.convertToHtml(input, options);
|
|
270
|
-
return result?.html ?? null;
|
|
271
|
-
}
|
|
272
|
-
#isValidFormat(fileName) {
|
|
273
|
-
const lowerCaseName = fileName.toLowerCase();
|
|
274
|
-
return this.#VALID_EXTENSIONS.some(ext => lowerCaseName.endsWith(ext));
|
|
275
|
-
}
|
|
276
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdDocxService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
277
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdDocxService, providedIn: 'root' });
|
|
278
|
-
}
|
|
279
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdDocxService, decorators: [{
|
|
280
|
-
type: Injectable,
|
|
281
|
-
args: [{
|
|
282
|
-
providedIn: 'root',
|
|
283
|
-
}]
|
|
284
|
-
}], ctorParameters: () => [] });
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Generated bundle index. Do not edit.
|
|
288
|
-
*/
|
|
289
|
-
|
|
290
|
-
export { SdDocxService };
|
|
291
|
-
//# sourceMappingURL=sdcorejs-angular-services-docx.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdcorejs-angular-services-docx.mjs","sources":["../../../projects/sdcorejs-angular/services/docx/src/lib/pandoc-core.ts","../../../projects/sdcorejs-angular/services/docx/src/lib/docx.service.ts","../../../projects/sdcorejs-angular/services/docx/sdcorejs-angular-services-docx.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* Pandoc WASM core logic — adapted from pandoc-wasm/src/core.js\n *\n * This file is a local copy of the environment-agnostic pandoc core.\n * It imports @bjorn3/browser_wasi_shim directly, avoiding the pandoc-wasm\n * package entry points which use top-level await (incompatible with\n * Angular's esbuild/Vite build pipeline).\n *\n * Source: https://github.com/pandoc/pandoc-wasm (GPL-2.0-or-later)\n */\n\n// @ts-nocheck\nimport { ConsoleStdout, File, OpenFile, PreopenDirectory, WASI } from '@bjorn3/browser_wasi_shim';\n\nexport interface PandocConvertResult {\n stdout: string;\n stderr: string;\n warnings: any[];\n files: Record<string, any>;\n mediaFiles: Record<string, any>;\n}\n\nexport interface PandocInstance {\n convert(options: Record<string, any>, stdin: string | null, files: Record<string, Blob | string>): Promise<PandocConvertResult>;\n}\n\nexport function createPandocInstance(wasmBinary: ArrayBuffer): Promise<PandocInstance> {\n const args = ['pandoc.wasm', '+RTS', '-H64m', '-RTS'];\n const env: string[] = [];\n const fileSystem = new Map();\n const fds = [\n new OpenFile(new File(new Uint8Array(), { readonly: true })),\n ConsoleStdout.lineBuffered(() => undefined),\n ConsoleStdout.lineBuffered((msg: string) => console.warn(`[WASI stderr] ${msg}`)),\n new PreopenDirectory('/', fileSystem),\n ];\n const options = { debug: false };\n const wasi = new WASI(args, env, fds, options);\n\n return WebAssembly.instantiate(wasmBinary, {\n wasi_snapshot_preview1: wasi.wasiImport,\n }).then(({ instance }: any) => {\n wasi.initialize(instance);\n instance.exports.__wasm_call_ctors();\n\n function memory_data_view() {\n return new DataView(instance.exports.memory.buffer);\n }\n\n const argc_ptr = instance.exports.malloc(4);\n memory_data_view().setUint32(argc_ptr, args.length, true);\n const argv = instance.exports.malloc(4 * (args.length + 1));\n for (let i = 0; i < args.length; ++i) {\n const arg = instance.exports.malloc(args[i].length + 1);\n new TextEncoder().encodeInto(args[i], new Uint8Array(instance.exports.memory.buffer, arg, args[i].length));\n memory_data_view().setUint8(arg + args[i].length, 0);\n memory_data_view().setUint32(argv + 4 * i, arg, true);\n }\n memory_data_view().setUint32(argv + 4 * args.length, 0, true);\n const argv_ptr = instance.exports.malloc(4);\n memory_data_view().setUint32(argv_ptr, argv, true);\n\n instance.exports.hs_init_with_rtsopts(argc_ptr, argv_ptr);\n\n async function addFile(filename: string, data: Blob | string, readonly: boolean) {\n let uint8Array: Uint8Array;\n if (typeof data === 'string') {\n uint8Array = new TextEncoder().encode(data);\n } else {\n const buffer = await data.arrayBuffer();\n uint8Array = new Uint8Array(buffer);\n }\n const file = new File(uint8Array, { readonly });\n fileSystem.set(filename, file);\n }\n\n async function convert(\n options: Record<string, any>,\n stdin: string | null,\n files: Record<string, Blob | string>\n ): Promise<PandocConvertResult> {\n const opts_str = JSON.stringify(options);\n const encoded = new TextEncoder().encode(opts_str);\n const opts_ptr = instance.exports.malloc(encoded.length);\n new TextEncoder().encodeInto(opts_str, new Uint8Array(instance.exports.memory.buffer, opts_ptr, encoded.length));\n\n files = { ...files };\n\n fileSystem.clear();\n const in_file = new File(new Uint8Array(), { readonly: true });\n const out_file = new File(new Uint8Array(), { readonly: false });\n const err_file = new File(new Uint8Array(), { readonly: false });\n const warnings_file = new File(new Uint8Array(), { readonly: false });\n fileSystem.set('stdin', in_file);\n fileSystem.set('stdout', out_file);\n fileSystem.set('stderr', err_file);\n fileSystem.set('warnings', warnings_file);\n\n const knownFiles = new Set(['stdin', 'stdout', 'stderr', 'warnings']);\n\n for (const filename in files) {\n await addFile(filename, files[filename], true);\n knownFiles.add(filename);\n }\n\n const outputFileName = options['output-file'] || null;\n const extractMediaPath = options['extract-media'] || null;\n\n if (outputFileName) {\n await addFile(outputFileName, new Blob(), false);\n knownFiles.add(outputFileName);\n }\n\n if (extractMediaPath) {\n await addFile(extractMediaPath, new Blob(), false);\n if (extractMediaPath.endsWith('.zip')) {\n knownFiles.add(extractMediaPath);\n }\n }\n\n if (stdin) {\n in_file.data = new TextEncoder().encode(stdin);\n }\n\n instance.exports.convert(opts_ptr, encoded.length);\n\n if (options['output-file']) {\n const outputFile = fileSystem.get(options['output-file']);\n if (outputFile && outputFile.data && outputFile.data.length > 0) {\n files[options['output-file']] = new Blob([outputFile.data]);\n }\n }\n\n if (options['extract-media']) {\n const mediaFile = fileSystem.get(options['extract-media']);\n if (mediaFile && mediaFile.data && mediaFile.data.length > 0) {\n files[options['extract-media']] = new Blob([mediaFile.data], { type: 'application/zip' });\n }\n }\n\n const mediaFiles: Record<string, Blob> = {};\n for (const [name, fileData] of fileSystem.entries()) {\n if (!knownFiles.has(name) && fileData && fileData.data && fileData.data.length > 0) {\n const blob = new Blob([fileData.data]);\n files[name] = blob;\n if (name !== outputFileName && name !== extractMediaPath) {\n mediaFiles[name] = blob;\n }\n }\n }\n\n const rawWarnings = new TextDecoder('utf-8', { fatal: true }).decode(warnings_file.data);\n let warnings: any[] = [];\n if (rawWarnings) {\n try {\n warnings = JSON.parse(rawWarnings);\n } catch (e) {\n console.warn('Failed to parse warnings:', e);\n }\n }\n\n return {\n stdout: new TextDecoder('utf-8', { fatal: true }).decode(out_file.data),\n stderr: new TextDecoder('utf-8', { fatal: true }).decode(err_file.data),\n warnings,\n files,\n mediaFiles,\n };\n }\n\n return { convert } as PandocInstance;\n });\n}\n","import { inject, Injectable } from '@angular/core';\nimport { SdNotifyService } from '@sdcorejs/angular/services/notify';\nimport { SdLoadingService } from '@sdcorejs/angular/services/loading';\nimport { I18nService } from '@sdcorejs/angular/i18n';\n\nimport { SdDocxConvertOptions, SdDocxConvertResult } from './docx.model';\nimport { createPandocInstance, PandocInstance } from './pandoc-core';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SdDocxService {\n private notifyService = inject(SdNotifyService);\n private loadingService = inject(SdLoadingService);\n\n readonly #i18n = inject(I18nService);\n\n readonly #DEFAULT_MAX_SIZE_MB = 50;\n readonly #VALID_EXTENSIONS = ['.doc', '.docx'];\n\n readonly #PANDOC_WASM_URL = 'https://pandoc.github.io/pandoc-wasm/pandoc.wasm';\n\n #fileInput: HTMLInputElement | null = null;\n #pandocInstance: PandocInstance | null = null;\n\n /** Inserted by Angular inject() migration for backwards compatibility */\n constructor(...args: unknown[]);\n\n constructor() {}\n\n async open(options?: SdDocxConvertOptions): Promise<SdDocxConvertResult | null> {\n return new Promise(resolve => {\n this.#createFileInput();\n if (!this.#fileInput) {\n resolve(null);\n return;\n }\n\n const handleChange = async (event: Event) => {\n const input = event.target as HTMLInputElement;\n const file = input.files?.[0];\n\n if (!file) {\n resolve(null);\n return;\n }\n\n this.loadingService.start();\n try {\n const result = await this.convertToHtml(file, options);\n resolve(result);\n } catch (error) {\n console.error('[SdDocxService] DocX conversion error:', error);\n this.notifyService.error(this.#i18n.t('core.docx.convert-error'));\n resolve(null);\n } finally {\n input.value = '';\n input.removeEventListener('change', handleChange);\n this.loadingService.stop();\n }\n };\n\n this.#fileInput.addEventListener('change', handleChange, { once: true });\n this.#fileInput.click();\n });\n }\n\n #createFileInput(): void {\n if (this.#fileInput) {\n return;\n }\n\n this.#fileInput = document.createElement('input');\n this.#fileInput.type = 'file';\n this.#fileInput.accept = '.doc,.docx';\n this.#fileInput.style.display = 'none';\n document.body.appendChild(this.#fileInput);\n }\n\n async #getPandocInstance(): Promise<PandocInstance> {\n if (this.#pandocInstance) {\n return this.#pandocInstance;\n }\n\n const wasmResponse = await fetch(this.#PANDOC_WASM_URL);\n if (!wasmResponse.ok) {\n throw new Error(`Failed to fetch pandoc.wasm: ${wasmResponse.status} ${wasmResponse.statusText}`);\n }\n const wasmBinary = await wasmResponse.arrayBuffer();\n this.#pandocInstance = await createPandocInstance(wasmBinary);\n return this.#pandocInstance;\n }\n\n async convertToHtml(input: File | Blob | ArrayBuffer, options?: SdDocxConvertOptions): Promise<SdDocxConvertResult | null> {\n const opts = {\n validateFormat: true,\n validateSize: true,\n maxSizeInMb: this.#DEFAULT_MAX_SIZE_MB,\n ...options,\n };\n\n try {\n let fileName: string | undefined;\n let fileSize: number | undefined;\n let blob: Blob;\n\n if (input instanceof File) {\n fileName = input.name;\n fileSize = input.size;\n blob = input;\n } else if (input instanceof Blob) {\n fileSize = input.size;\n blob = input;\n } else {\n blob = new Blob([input], {\n type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n });\n }\n\n if (opts.validateFormat && fileName) {\n if (!this.#isValidFormat(fileName)) {\n this.notifyService.error(this.#i18n.t('core.docx.invalid-format'));\n return null;\n }\n }\n\n if (opts.validateSize && fileSize !== undefined) {\n const maxSizeInBytes = opts.maxSizeInMb! * 1024 * 1024;\n if (fileSize > maxSizeInBytes) {\n this.notifyService.error(this.#i18n.t('core.docx.size-exceeded'));\n return null;\n }\n }\n\n const pandoc = await this.#getPandocInstance();\n\n const pandocOpts: Record<string, any> = {\n from: 'docx',\n to: 'html',\n 'input-files': ['document.docx'],\n standalone: true,\n 'embed-resources': true,\n };\n\n const result = await pandoc.convert(pandocOpts, null, { 'document.docx': blob });\n\n return {\n html: result.stdout,\n messages: result.warnings.map((w: any) => String(w)),\n };\n } catch (error) {\n console.error('[SdDocxService] DocX conversion error:', error);\n this.notifyService.error(this.#i18n.t('core.docx.convert-error'));\n return null;\n }\n }\n\n async convertToHtmlString(input: File | Blob | ArrayBuffer, options?: SdDocxConvertOptions): Promise<string | null> {\n const result = await this.convertToHtml(input, options);\n return result?.html ?? null;\n }\n\n #isValidFormat(fileName: string): boolean {\n const lowerCaseName = fileName.toLowerCase();\n return this.#VALID_EXTENSIONS.some(ext => lowerCaseName.endsWith(ext));\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["File"],"mappings":";;;;;;;AAAA;AACA;;;;;;;;AAQG;AAEH;AAeM,SAAU,oBAAoB,CAAC,UAAuB,EAAA;IAC1D,MAAM,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;IACrD,MAAM,GAAG,GAAa,EAAE;AACxB,IAAA,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE;AAC5B,IAAA,MAAM,GAAG,GAAG;AACV,QAAA,IAAI,QAAQ,CAAC,IAAIA,MAAI,CAAC,IAAI,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5D,QAAA,aAAa,CAAC,YAA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{ inject, Injectable } from '@angular/core';
|
|
3
|
-
import { SD_CORE_CONFIGURATION } from '@sdcorejs/angular/configurations';
|
|
4
|
-
|
|
5
|
-
class SdLicenseService {
|
|
6
|
-
#SALT = 'angular-core-976e2fa6f8b44dadbc63f87b057a331f';
|
|
7
|
-
#isValid = false;
|
|
8
|
-
coreConfiguration = inject(SD_CORE_CONFIGURATION, { optional: true });
|
|
9
|
-
constructor() {
|
|
10
|
-
this.#verify();
|
|
11
|
-
}
|
|
12
|
-
enforceLicense = () => {
|
|
13
|
-
if (!this.#isValid) {
|
|
14
|
-
this.#throwSecurityError();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
#verify = () => {
|
|
18
|
-
const hostname = window.location.hostname; // Ví dụ: store.uat.nexa.mobi
|
|
19
|
-
// 1. Bypass Localhost
|
|
20
|
-
if (this.#isLocalhost(hostname)) {
|
|
21
|
-
this.#isValid = true;
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const configKeys = this.#getConfiguredKeys();
|
|
25
|
-
if (configKeys.length === 0) {
|
|
26
|
-
this.#isValid = false;
|
|
27
|
-
this.#throwSecurityError();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
// 2. CHECK EXACT MATCH (Ưu tiên khớp chính xác 100%)
|
|
31
|
-
// Hash chuỗi: "store.uat.nexa.mobi" + SALT
|
|
32
|
-
if (this.#checkMatch(hostname, configKeys)) {
|
|
33
|
-
this.#isValid = true;
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
// 3. CHECK WILDCARD MATCH (Thử các trường hợp có dấu *)
|
|
37
|
-
const parts = hostname.split('.'); // ["store", "uat", "nexa", "mobi"]
|
|
38
|
-
// Lặp để cắt dần subdomain bên trái và thêm "*." vào
|
|
39
|
-
// Điều kiện > 2 để đảm bảo không check các case vô nghĩa như *.mobi hay *.com
|
|
40
|
-
while (parts.length > 2) {
|
|
41
|
-
parts.shift(); // Bỏ phần đầu: ["uat", "nexa", "mobi"]
|
|
42
|
-
// Tạo domain wildcard: "*.uat.nexa.mobi"
|
|
43
|
-
const wildcardDomain = '*.' + parts.join('.');
|
|
44
|
-
// Hash chuỗi: "*.uat.nexa.mobi" + SALT
|
|
45
|
-
if (this.#checkMatch(wildcardDomain, configKeys)) {
|
|
46
|
-
this.#isValid = true;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Nếu chạy hết vòng lặp mà không khớp cái nào
|
|
51
|
-
this.#isValid = false;
|
|
52
|
-
this.#throwSecurityError();
|
|
53
|
-
};
|
|
54
|
-
// Helper để check xem hash của input có nằm trong list key không
|
|
55
|
-
#checkMatch = (inputString, validKeys) => {
|
|
56
|
-
const hash = this.#generateHash(inputString + this.#SALT);
|
|
57
|
-
return validKeys.includes(hash);
|
|
58
|
-
};
|
|
59
|
-
#getConfiguredKeys = () => {
|
|
60
|
-
const keyOrKeys = this.coreConfiguration?.licenseKey;
|
|
61
|
-
if (!keyOrKeys)
|
|
62
|
-
return [];
|
|
63
|
-
return Array.isArray(keyOrKeys) ? keyOrKeys : [keyOrKeys];
|
|
64
|
-
};
|
|
65
|
-
#isLocalhost = (domain) => {
|
|
66
|
-
return domain === 'localhost' || domain === '127.0.0.1' || domain.includes('localhost');
|
|
67
|
-
};
|
|
68
|
-
#generateHash = (input) => {
|
|
69
|
-
let hash = 0;
|
|
70
|
-
if (input.length === 0)
|
|
71
|
-
return hash.toString();
|
|
72
|
-
for (let i = 0; i < input.length; i++) {
|
|
73
|
-
const char = input.charCodeAt(i);
|
|
74
|
-
hash = (hash << 5) - hash + char;
|
|
75
|
-
hash = hash & hash;
|
|
76
|
-
}
|
|
77
|
-
return btoa(hash.toString() + 'signed');
|
|
78
|
-
};
|
|
79
|
-
#throwSecurityError = () => {
|
|
80
|
-
throw new Error(`[Security] Unauthorized usage of UI Lib on domain: ${window.location.hostname}`);
|
|
81
|
-
};
|
|
82
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdLicenseService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
83
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdLicenseService, providedIn: 'root' });
|
|
84
|
-
}
|
|
85
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdLicenseService, decorators: [{
|
|
86
|
-
type: Injectable,
|
|
87
|
-
args: [{
|
|
88
|
-
providedIn: 'root',
|
|
89
|
-
}]
|
|
90
|
-
}], ctorParameters: () => [] });
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Generated bundle index. Do not edit.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
export { SdLicenseService };
|
|
97
|
-
//# sourceMappingURL=sdcorejs-angular-services-license.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdcorejs-angular-services-license.mjs","sources":["../../../projects/sdcorejs-angular/services/license/src/license.service.ts","../../../projects/sdcorejs-angular/services/license/sdcorejs-angular-services-license.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { ISdCoreConfiguration, SD_CORE_CONFIGURATION } from '@sdcorejs/angular/configurations';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SdLicenseService {\n readonly #SALT = 'angular-core-976e2fa6f8b44dadbc63f87b057a331f';\n #isValid = false;\n private readonly coreConfiguration: ISdCoreConfiguration | null = inject(SD_CORE_CONFIGURATION, { optional: true });\n\n constructor() {\n this.#verify();\n }\n\n enforceLicense = () => {\n if (!this.#isValid) {\n this.#throwSecurityError();\n }\n };\n\n #verify = () => {\n const hostname = window.location.hostname; // Ví dụ: store.uat.nexa.mobi\n\n // 1. Bypass Localhost\n if (this.#isLocalhost(hostname)) {\n this.#isValid = true;\n return;\n }\n\n const configKeys = this.#getConfiguredKeys();\n if (configKeys.length === 0) {\n this.#isValid = false;\n this.#throwSecurityError();\n return;\n }\n\n // 2. CHECK EXACT MATCH (Ưu tiên khớp chính xác 100%)\n // Hash chuỗi: \"store.uat.nexa.mobi\" + SALT\n if (this.#checkMatch(hostname, configKeys)) {\n this.#isValid = true;\n return;\n }\n\n // 3. CHECK WILDCARD MATCH (Thử các trường hợp có dấu *)\n const parts = hostname.split('.'); // [\"store\", \"uat\", \"nexa\", \"mobi\"]\n\n // Lặp để cắt dần subdomain bên trái và thêm \"*.\" vào\n // Điều kiện > 2 để đảm bảo không check các case vô nghĩa như *.mobi hay *.com\n while (parts.length > 2) {\n parts.shift(); // Bỏ phần đầu: [\"uat\", \"nexa\", \"mobi\"]\n\n // Tạo domain wildcard: \"*.uat.nexa.mobi\"\n const wildcardDomain = '*.' + parts.join('.');\n\n // Hash chuỗi: \"*.uat.nexa.mobi\" + SALT\n if (this.#checkMatch(wildcardDomain, configKeys)) {\n this.#isValid = true;\n return;\n }\n }\n\n // Nếu chạy hết vòng lặp mà không khớp cái nào\n this.#isValid = false;\n this.#throwSecurityError();\n };\n\n // Helper để check xem hash của input có nằm trong list key không\n #checkMatch = (inputString: string, validKeys: string[]): boolean => {\n const hash = this.#generateHash(inputString + this.#SALT);\n return validKeys.includes(hash);\n };\n\n #getConfiguredKeys = (): string[] => {\n const keyOrKeys = this.coreConfiguration?.licenseKey;\n if (!keyOrKeys) return [];\n return Array.isArray(keyOrKeys) ? keyOrKeys : [keyOrKeys];\n };\n\n #isLocalhost = (domain: string) => {\n return domain === 'localhost' || domain === '127.0.0.1' || domain.includes('localhost');\n };\n\n #generateHash = (input: string): string => {\n let hash = 0;\n if (input.length === 0) return hash.toString();\n for (let i = 0; i < input.length; i++) {\n const char = input.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return btoa(hash.toString() + 'signed');\n };\n\n #throwSecurityError = () => {\n throw new Error(`[Security] Unauthorized usage of UI Lib on domain: ${window.location.hostname}`);\n };\n}\n","/**\n * Generated bundle index. Do not edit.\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AAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,QAAQ,CAAC;AACzC,IAAA,CAAC;IAED,mBAAmB,GAAG,MAAK;QACzB,MAAM,IAAI,KAAK,CAAC,CAAA,mDAAA,EAAsD,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAA,CAAE,CAAC;AACnG,IAAA,CAAC;wGA1FU,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAhB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,cAFf,MAAM,EAAA,CAAA;;4FAEP,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAH5B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACLD;;AAEG;;;;"}
|
package/models/index.d.ts
DELETED
package/services/docx/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
|
|
3
|
-
interface SdDocxConvertOptions {
|
|
4
|
-
validateFormat?: boolean;
|
|
5
|
-
validateSize?: boolean;
|
|
6
|
-
maxSizeInMb?: number;
|
|
7
|
-
}
|
|
8
|
-
interface SdDocxConvertResult {
|
|
9
|
-
html: string;
|
|
10
|
-
messages: string[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare class SdDocxService {
|
|
14
|
-
#private;
|
|
15
|
-
private notifyService;
|
|
16
|
-
private loadingService;
|
|
17
|
-
/** Inserted by Angular inject() migration for backwards compatibility */
|
|
18
|
-
constructor(...args: unknown[]);
|
|
19
|
-
open(options?: SdDocxConvertOptions): Promise<SdDocxConvertResult | null>;
|
|
20
|
-
convertToHtml(input: File | Blob | ArrayBuffer, options?: SdDocxConvertOptions): Promise<SdDocxConvertResult | null>;
|
|
21
|
-
convertToHtmlString(input: File | Blob | ArrayBuffer, options?: SdDocxConvertOptions): Promise<string | null>;
|
|
22
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<SdDocxService, never>;
|
|
23
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<SdDocxService>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { SdDocxService };
|
|
27
|
-
export type { SdDocxConvertOptions, SdDocxConvertResult };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
|
|
3
|
-
declare class SdLicenseService {
|
|
4
|
-
#private;
|
|
5
|
-
private readonly coreConfiguration;
|
|
6
|
-
constructor();
|
|
7
|
-
enforceLicense: () => void;
|
|
8
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<SdLicenseService, never>;
|
|
9
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<SdLicenseService>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { SdLicenseService };
|