@mondaydotcomorg/z2h-shared-utils 0.2.0 → 0.3.0
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/esm/mfScaffold.d.ts +24 -0
- package/dist/esm/mfScaffold.d.ts.map +1 -0
- package/dist/esm/mfScaffold.mjs +107 -0
- package/dist/mfScaffold.d.ts +24 -0
- package/dist/mfScaffold.d.ts.map +1 -0
- package/dist/mfScaffold.js +112 -0
- package/package.json +6 -1
- package/src/mfScaffold.ts +110 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const WRAPPER_TEMPLATE = "import '@vibe/core/tokens';\nimport ConsumerApp from '../../src/index';\nimport React from 'react';\nimport * as ReactDOM from 'react-dom/client';\nimport { ErrorBoundary } from 'react-error-boundary';\n\nconst roots = new Map<HTMLElement, ReactDOM.Root>();\n\nexport function init() {}\n\nexport function render(element: HTMLElement) {\n const root = ReactDOM.createRoot(element);\n root.render(\n <ErrorBoundary fallback={<div style={{ padding: 16 }}>This app crashed.</div>}>\n <ConsumerApp />\n </ErrorBoundary>,\n );\n roots.set(element, root);\n}\n\nexport function unmount({ element }: { element: HTMLElement }) {\n const root = roots.get(element);\n if (root) {\n root.unmount();\n roots.delete(element);\n }\n}\n";
|
|
2
|
+
export declare const tridentrcTemplate: (appName: string, port: number) => string;
|
|
3
|
+
export declare const dtsFileTemplate: () => string;
|
|
4
|
+
export declare const TSCONFIG_TEMPLATE: {
|
|
5
|
+
compilerOptions: {
|
|
6
|
+
target: string;
|
|
7
|
+
lib: string[];
|
|
8
|
+
allowJs: boolean;
|
|
9
|
+
skipLibCheck: boolean;
|
|
10
|
+
esModuleInterop: boolean;
|
|
11
|
+
allowSyntheticDefaultImports: boolean;
|
|
12
|
+
strict: boolean;
|
|
13
|
+
module: string;
|
|
14
|
+
moduleResolution: string;
|
|
15
|
+
resolveJsonModule: boolean;
|
|
16
|
+
noImplicitAny: boolean;
|
|
17
|
+
isolatedModules: boolean;
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
noEmit: boolean;
|
|
20
|
+
jsx: string;
|
|
21
|
+
};
|
|
22
|
+
include: string[];
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=mfScaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfScaffold.d.ts","sourceRoot":"","sources":["../../src/mfScaffold.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gBAAgB,8uBA2B5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,EAAE,MAAM,MAAM,KAAG,MAQjE,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,MA0ClC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;CAmB7B,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Shared between z2h-cli's `shadow/scaffold.ts` (long-lived per-consumer-app shadow dir) and
|
|
2
|
+
// @mondaydotcomorg/z2h-dashboard-templates' `build-templates.mjs` (ephemeral per-template-build
|
|
3
|
+
// shadow dir). Both scaffold a minimal Trident MF wrapper around a real app's `src/index`, so the
|
|
4
|
+
// wrapper/config/type-declaration content itself has no reason to differ between the two callers
|
|
5
|
+
// — only what surrounds it (package.json contents, .nvmrc, README stub) differs, because those two
|
|
6
|
+
// shadow dirs have genuinely different lifecycles. See each caller's own scaffold code for that
|
|
7
|
+
// caller-specific part.
|
|
8
|
+
const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
|
|
9
|
+
import ConsumerApp from '../../src/index';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import * as ReactDOM from 'react-dom/client';
|
|
12
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
13
|
+
|
|
14
|
+
const roots = new Map<HTMLElement, ReactDOM.Root>();
|
|
15
|
+
|
|
16
|
+
export function init() {}
|
|
17
|
+
|
|
18
|
+
export function render(element: HTMLElement) {
|
|
19
|
+
const root = ReactDOM.createRoot(element);
|
|
20
|
+
root.render(
|
|
21
|
+
<ErrorBoundary fallback={<div style={{ padding: 16 }}>This app crashed.</div>}>
|
|
22
|
+
<ConsumerApp />
|
|
23
|
+
</ErrorBoundary>,
|
|
24
|
+
);
|
|
25
|
+
roots.set(element, root);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function unmount({ element }: { element: HTMLElement }) {
|
|
29
|
+
const root = roots.get(element);
|
|
30
|
+
if (root) {
|
|
31
|
+
root.unmount();
|
|
32
|
+
roots.delete(element);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
const tridentrcTemplate = (appName, port) => `/** @type {import("@mondaydotcomorg/trident-user-config").MicroFrontendConfig} */
|
|
37
|
+
const config = {
|
|
38
|
+
appName: '${appName}',
|
|
39
|
+
port: ${port},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = config;
|
|
43
|
+
`;
|
|
44
|
+
const dtsFileTemplate = () => `
|
|
45
|
+
declare module '*.module.css' {
|
|
46
|
+
const classNames: {
|
|
47
|
+
[className: string]: string;
|
|
48
|
+
};
|
|
49
|
+
export = classNames;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare module '*.module.scss' {
|
|
53
|
+
const classNames: {
|
|
54
|
+
[className: string]: string;
|
|
55
|
+
};
|
|
56
|
+
export = classNames;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare module '*.jpg' {
|
|
60
|
+
const e: string;
|
|
61
|
+
export default e;
|
|
62
|
+
}
|
|
63
|
+
declare module '*.jpeg' {
|
|
64
|
+
const e: string;
|
|
65
|
+
export default e;
|
|
66
|
+
}
|
|
67
|
+
declare module '*.png' {
|
|
68
|
+
const e: string;
|
|
69
|
+
export default e;
|
|
70
|
+
}
|
|
71
|
+
declare module '*.riv' {
|
|
72
|
+
const e: string;
|
|
73
|
+
export default e;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare module '*.wasm' {
|
|
77
|
+
const e: string;
|
|
78
|
+
export default e;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare module '*.html?url' {
|
|
82
|
+
const src: string;
|
|
83
|
+
export default src;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
const TSCONFIG_TEMPLATE = {
|
|
87
|
+
compilerOptions: {
|
|
88
|
+
target: 'es5',
|
|
89
|
+
lib: ['dom', 'dom.iterable', 'esnext'],
|
|
90
|
+
allowJs: false,
|
|
91
|
+
skipLibCheck: true,
|
|
92
|
+
esModuleInterop: true,
|
|
93
|
+
allowSyntheticDefaultImports: true,
|
|
94
|
+
strict: false,
|
|
95
|
+
module: 'esnext',
|
|
96
|
+
moduleResolution: 'bundler',
|
|
97
|
+
resolveJsonModule: true,
|
|
98
|
+
noImplicitAny: false,
|
|
99
|
+
isolatedModules: true,
|
|
100
|
+
baseUrl: 'src',
|
|
101
|
+
noEmit: true,
|
|
102
|
+
jsx: 'react-jsx',
|
|
103
|
+
},
|
|
104
|
+
include: ['src', '../src'],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { TSCONFIG_TEMPLATE, WRAPPER_TEMPLATE, dtsFileTemplate, tridentrcTemplate };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const WRAPPER_TEMPLATE = "import '@vibe/core/tokens';\nimport ConsumerApp from '../../src/index';\nimport React from 'react';\nimport * as ReactDOM from 'react-dom/client';\nimport { ErrorBoundary } from 'react-error-boundary';\n\nconst roots = new Map<HTMLElement, ReactDOM.Root>();\n\nexport function init() {}\n\nexport function render(element: HTMLElement) {\n const root = ReactDOM.createRoot(element);\n root.render(\n <ErrorBoundary fallback={<div style={{ padding: 16 }}>This app crashed.</div>}>\n <ConsumerApp />\n </ErrorBoundary>,\n );\n roots.set(element, root);\n}\n\nexport function unmount({ element }: { element: HTMLElement }) {\n const root = roots.get(element);\n if (root) {\n root.unmount();\n roots.delete(element);\n }\n}\n";
|
|
2
|
+
export declare const tridentrcTemplate: (appName: string, port: number) => string;
|
|
3
|
+
export declare const dtsFileTemplate: () => string;
|
|
4
|
+
export declare const TSCONFIG_TEMPLATE: {
|
|
5
|
+
compilerOptions: {
|
|
6
|
+
target: string;
|
|
7
|
+
lib: string[];
|
|
8
|
+
allowJs: boolean;
|
|
9
|
+
skipLibCheck: boolean;
|
|
10
|
+
esModuleInterop: boolean;
|
|
11
|
+
allowSyntheticDefaultImports: boolean;
|
|
12
|
+
strict: boolean;
|
|
13
|
+
module: string;
|
|
14
|
+
moduleResolution: string;
|
|
15
|
+
resolveJsonModule: boolean;
|
|
16
|
+
noImplicitAny: boolean;
|
|
17
|
+
isolatedModules: boolean;
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
noEmit: boolean;
|
|
20
|
+
jsx: string;
|
|
21
|
+
};
|
|
22
|
+
include: string[];
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=mfScaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mfScaffold.d.ts","sourceRoot":"","sources":["../src/mfScaffold.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gBAAgB,8uBA2B5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,EAAE,MAAM,MAAM,KAAG,MAQjE,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,MA0ClC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;CAmB7B,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
// Shared between z2h-cli's `shadow/scaffold.ts` (long-lived per-consumer-app shadow dir) and
|
|
4
|
+
// @mondaydotcomorg/z2h-dashboard-templates' `build-templates.mjs` (ephemeral per-template-build
|
|
5
|
+
// shadow dir). Both scaffold a minimal Trident MF wrapper around a real app's `src/index`, so the
|
|
6
|
+
// wrapper/config/type-declaration content itself has no reason to differ between the two callers
|
|
7
|
+
// — only what surrounds it (package.json contents, .nvmrc, README stub) differs, because those two
|
|
8
|
+
// shadow dirs have genuinely different lifecycles. See each caller's own scaffold code for that
|
|
9
|
+
// caller-specific part.
|
|
10
|
+
const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
|
|
11
|
+
import ConsumerApp from '../../src/index';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import * as ReactDOM from 'react-dom/client';
|
|
14
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
15
|
+
|
|
16
|
+
const roots = new Map<HTMLElement, ReactDOM.Root>();
|
|
17
|
+
|
|
18
|
+
export function init() {}
|
|
19
|
+
|
|
20
|
+
export function render(element: HTMLElement) {
|
|
21
|
+
const root = ReactDOM.createRoot(element);
|
|
22
|
+
root.render(
|
|
23
|
+
<ErrorBoundary fallback={<div style={{ padding: 16 }}>This app crashed.</div>}>
|
|
24
|
+
<ConsumerApp />
|
|
25
|
+
</ErrorBoundary>,
|
|
26
|
+
);
|
|
27
|
+
roots.set(element, root);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function unmount({ element }: { element: HTMLElement }) {
|
|
31
|
+
const root = roots.get(element);
|
|
32
|
+
if (root) {
|
|
33
|
+
root.unmount();
|
|
34
|
+
roots.delete(element);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const tridentrcTemplate = (appName, port) => `/** @type {import("@mondaydotcomorg/trident-user-config").MicroFrontendConfig} */
|
|
39
|
+
const config = {
|
|
40
|
+
appName: '${appName}',
|
|
41
|
+
port: ${port},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = config;
|
|
45
|
+
`;
|
|
46
|
+
const dtsFileTemplate = () => `
|
|
47
|
+
declare module '*.module.css' {
|
|
48
|
+
const classNames: {
|
|
49
|
+
[className: string]: string;
|
|
50
|
+
};
|
|
51
|
+
export = classNames;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare module '*.module.scss' {
|
|
55
|
+
const classNames: {
|
|
56
|
+
[className: string]: string;
|
|
57
|
+
};
|
|
58
|
+
export = classNames;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare module '*.jpg' {
|
|
62
|
+
const e: string;
|
|
63
|
+
export default e;
|
|
64
|
+
}
|
|
65
|
+
declare module '*.jpeg' {
|
|
66
|
+
const e: string;
|
|
67
|
+
export default e;
|
|
68
|
+
}
|
|
69
|
+
declare module '*.png' {
|
|
70
|
+
const e: string;
|
|
71
|
+
export default e;
|
|
72
|
+
}
|
|
73
|
+
declare module '*.riv' {
|
|
74
|
+
const e: string;
|
|
75
|
+
export default e;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare module '*.wasm' {
|
|
79
|
+
const e: string;
|
|
80
|
+
export default e;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare module '*.html?url' {
|
|
84
|
+
const src: string;
|
|
85
|
+
export default src;
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
const TSCONFIG_TEMPLATE = {
|
|
89
|
+
compilerOptions: {
|
|
90
|
+
target: 'es5',
|
|
91
|
+
lib: ['dom', 'dom.iterable', 'esnext'],
|
|
92
|
+
allowJs: false,
|
|
93
|
+
skipLibCheck: true,
|
|
94
|
+
esModuleInterop: true,
|
|
95
|
+
allowSyntheticDefaultImports: true,
|
|
96
|
+
strict: false,
|
|
97
|
+
module: 'esnext',
|
|
98
|
+
moduleResolution: 'bundler',
|
|
99
|
+
resolveJsonModule: true,
|
|
100
|
+
noImplicitAny: false,
|
|
101
|
+
isolatedModules: true,
|
|
102
|
+
baseUrl: 'src',
|
|
103
|
+
noEmit: true,
|
|
104
|
+
jsx: 'react-jsx',
|
|
105
|
+
},
|
|
106
|
+
include: ['src', '../src'],
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
exports.TSCONFIG_TEMPLATE = TSCONFIG_TEMPLATE;
|
|
110
|
+
exports.WRAPPER_TEMPLATE = WRAPPER_TEMPLATE;
|
|
111
|
+
exports.dtsFileTemplate = dtsFileTemplate;
|
|
112
|
+
exports.tridentrcTemplate = tridentrcTemplate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/z2h-shared-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"require": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts"
|
|
11
11
|
},
|
|
12
|
+
"./mf-scaffold": {
|
|
13
|
+
"import": "./dist/esm/mfScaffold.mjs",
|
|
14
|
+
"require": "./dist/mfScaffold.js",
|
|
15
|
+
"types": "./dist/mfScaffold.d.ts"
|
|
16
|
+
},
|
|
12
17
|
"./package.json": "./package.json"
|
|
13
18
|
},
|
|
14
19
|
"nx": {
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Shared between z2h-cli's `shadow/scaffold.ts` (long-lived per-consumer-app shadow dir) and
|
|
2
|
+
// @mondaydotcomorg/z2h-dashboard-templates' `build-templates.mjs` (ephemeral per-template-build
|
|
3
|
+
// shadow dir). Both scaffold a minimal Trident MF wrapper around a real app's `src/index`, so the
|
|
4
|
+
// wrapper/config/type-declaration content itself has no reason to differ between the two callers
|
|
5
|
+
// — only what surrounds it (package.json contents, .nvmrc, README stub) differs, because those two
|
|
6
|
+
// shadow dirs have genuinely different lifecycles. See each caller's own scaffold code for that
|
|
7
|
+
// caller-specific part.
|
|
8
|
+
export const WRAPPER_TEMPLATE = `import '@vibe/core/tokens';
|
|
9
|
+
import ConsumerApp from '../../src/index';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import * as ReactDOM from 'react-dom/client';
|
|
12
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
13
|
+
|
|
14
|
+
const roots = new Map<HTMLElement, ReactDOM.Root>();
|
|
15
|
+
|
|
16
|
+
export function init() {}
|
|
17
|
+
|
|
18
|
+
export function render(element: HTMLElement) {
|
|
19
|
+
const root = ReactDOM.createRoot(element);
|
|
20
|
+
root.render(
|
|
21
|
+
<ErrorBoundary fallback={<div style={{ padding: 16 }}>This app crashed.</div>}>
|
|
22
|
+
<ConsumerApp />
|
|
23
|
+
</ErrorBoundary>,
|
|
24
|
+
);
|
|
25
|
+
roots.set(element, root);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function unmount({ element }: { element: HTMLElement }) {
|
|
29
|
+
const root = roots.get(element);
|
|
30
|
+
if (root) {
|
|
31
|
+
root.unmount();
|
|
32
|
+
roots.delete(element);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
export const tridentrcTemplate = (appName: string, port: number): string =>
|
|
38
|
+
`/** @type {import("@mondaydotcomorg/trident-user-config").MicroFrontendConfig} */
|
|
39
|
+
const config = {
|
|
40
|
+
appName: '${appName}',
|
|
41
|
+
port: ${port},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = config;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export const dtsFileTemplate = (): string =>
|
|
48
|
+
`
|
|
49
|
+
declare module '*.module.css' {
|
|
50
|
+
const classNames: {
|
|
51
|
+
[className: string]: string;
|
|
52
|
+
};
|
|
53
|
+
export = classNames;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare module '*.module.scss' {
|
|
57
|
+
const classNames: {
|
|
58
|
+
[className: string]: string;
|
|
59
|
+
};
|
|
60
|
+
export = classNames;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare module '*.jpg' {
|
|
64
|
+
const e: string;
|
|
65
|
+
export default e;
|
|
66
|
+
}
|
|
67
|
+
declare module '*.jpeg' {
|
|
68
|
+
const e: string;
|
|
69
|
+
export default e;
|
|
70
|
+
}
|
|
71
|
+
declare module '*.png' {
|
|
72
|
+
const e: string;
|
|
73
|
+
export default e;
|
|
74
|
+
}
|
|
75
|
+
declare module '*.riv' {
|
|
76
|
+
const e: string;
|
|
77
|
+
export default e;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare module '*.wasm' {
|
|
81
|
+
const e: string;
|
|
82
|
+
export default e;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare module '*.html?url' {
|
|
86
|
+
const src: string;
|
|
87
|
+
export default src;
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
export const TSCONFIG_TEMPLATE = {
|
|
92
|
+
compilerOptions: {
|
|
93
|
+
target: 'es5',
|
|
94
|
+
lib: ['dom', 'dom.iterable', 'esnext'],
|
|
95
|
+
allowJs: false,
|
|
96
|
+
skipLibCheck: true,
|
|
97
|
+
esModuleInterop: true,
|
|
98
|
+
allowSyntheticDefaultImports: true,
|
|
99
|
+
strict: false,
|
|
100
|
+
module: 'esnext',
|
|
101
|
+
moduleResolution: 'bundler',
|
|
102
|
+
resolveJsonModule: true,
|
|
103
|
+
noImplicitAny: false,
|
|
104
|
+
isolatedModules: true,
|
|
105
|
+
baseUrl: 'src',
|
|
106
|
+
noEmit: true,
|
|
107
|
+
jsx: 'react-jsx',
|
|
108
|
+
},
|
|
109
|
+
include: ['src', '../src'],
|
|
110
|
+
};
|