@haklex/rich-dynamic-protocol 0.25.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.
@@ -0,0 +1,16 @@
1
+ export interface DynamicHostContext {
2
+ theme: 'light' | 'dark';
3
+ }
4
+ export interface DynamicMountInput {
5
+ host: DynamicHostContext;
6
+ props: Record<string, unknown>;
7
+ }
8
+ export interface DynamicMountHandle {
9
+ unmount: () => void;
10
+ update?: (input: DynamicMountInput) => void;
11
+ }
12
+ export interface DynamicComponentModule {
13
+ mount: (container: HTMLElement, input: DynamicMountInput) => DynamicMountHandle;
14
+ }
15
+ export declare function isDynamicComponentModule(value: unknown): value is DynamicComponentModule;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,KAAK,kBAAkB,CAAC;CACjF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAMxF"}
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ //#region src/index.ts
2
+ function isDynamicComponentModule(value) {
3
+ return typeof value === "object" && value !== null && typeof value.mount === "function";
4
+ }
5
+ //#endregion
6
+ export { isDynamicComponentModule };
@@ -0,0 +1,4 @@
1
+ import { ReactElement } from 'react';
2
+ import { DynamicComponentModule, DynamicHostContext } from './index';
3
+ export declare function defineDynamicComponent(render: (props: Record<string, unknown>, host: DynamicHostContext) => ReactElement): DynamicComponentModule;
4
+ //# sourceMappingURL=react-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-entry.d.ts","sourceRoot":"","sources":["../src/react-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAqB,MAAM,SAAS,CAAC;AAE7F,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,kBAAkB,KAAK,YAAY,GACjF,sBAAsB,CAexB"}
package/dist/react.mjs ADDED
@@ -0,0 +1,18 @@
1
+ import { createRoot } from "react-dom/client";
2
+ //#region src/react-entry.ts
3
+ function defineDynamicComponent(render) {
4
+ return { mount(container, input) {
5
+ const root = createRoot(container);
6
+ root.render(render(input.props, input.host));
7
+ return {
8
+ update(next) {
9
+ root.render(render(next.props, next.host));
10
+ },
11
+ unmount() {
12
+ root.unmount();
13
+ }
14
+ };
15
+ } };
16
+ }
17
+ //#endregion
18
+ export { defineDynamicComponent };
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@haklex/rich-dynamic-protocol",
3
+ "version": "0.25.0",
4
+ "description": "Mount protocol and authoring helpers for haklex dynamic external components",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/Innei/haklex.git",
8
+ "directory": "packages/rich-dynamic-protocol"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.mjs",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./react": {
18
+ "import": "./dist/react.mjs",
19
+ "types": "./dist/react-entry.d.ts"
20
+ }
21
+ },
22
+ "main": "./dist/index.mjs",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "devDependencies": {
27
+ "@types/react": "^19.2.15",
28
+ "@types/react-dom": "^19.2.3",
29
+ "react": "19.2.6",
30
+ "react-dom": "19.2.6",
31
+ "typescript": "^5.9.3",
32
+ "unplugin-dts": "^1.0.1",
33
+ "vite": "^8.0.14"
34
+ },
35
+ "peerDependencies": {
36
+ "react": ">=18",
37
+ "react-dom": ">=18"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "react": {
41
+ "optional": true
42
+ },
43
+ "react-dom": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "scripts": {
51
+ "build": "vite build",
52
+ "dev:build": "vite build --watch"
53
+ },
54
+ "types": "./dist/index.d.ts"
55
+ }