@harborclient/sdk 0.7.0 → 1.0.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/dist/build/index.d.ts +59 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +116 -0
- package/dist/client.d.ts +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/portalToBody.d.ts +11 -0
- package/dist/components/portalToBody.d.ts.map +1 -0
- package/dist/components/portalToBody.js +15 -0
- package/dist/eslint/index.d.ts +9 -0
- package/dist/eslint/index.d.ts.map +1 -0
- package/dist/eslint/index.js +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/jsx-dev-runtime.d.ts +1 -1
- package/dist/runtime/jsx-runtime-host.d.ts +44 -0
- package/dist/runtime/jsx-runtime-host.js +42 -0
- package/dist/runtime/react-dom.d.ts +1 -0
- package/dist/runtime/react-dom.js +16 -0
- package/dist/runtime/react.d.ts +6 -0
- package/dist/runtime/react.js +70 -2
- package/dist/runtime/reactHost.js +52 -0
- package/dist/runtime/store.d.ts +106 -0
- package/dist/runtime/store.d.ts.map +1 -1
- package/dist/runtime/store.js +100 -0
- package/dist/runtime/store.ts +211 -0
- package/dist/runtime/viewHost.js +2 -1
- package/dist/runtime-utils.d.ts +59 -0
- package/dist/runtime-utils.d.ts.map +1 -1
- package/dist/runtime-utils.js +66 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -0
- package/dist/storage/validate.d.ts +71 -0
- package/dist/storage/validate.d.ts.map +1 -0
- package/dist/storage/validate.js +111 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +37 -8
- package/tsconfig.base.json +15 -0
- package/dist/components/enhanceControl.test.d.ts +0 -2
- package/dist/components/enhanceControl.test.d.ts.map +0 -1
- package/dist/components/enhanceControl.test.js +0 -83
- package/dist/components/utils.test.d.ts +0 -2
- package/dist/components/utils.test.d.ts.map +0 -1
- package/dist/components/utils.test.js +0 -44
- package/dist/http/resolveRequest.test.d.ts +0 -2
- package/dist/http/resolveRequest.test.d.ts.map +0 -1
- package/dist/http/resolveRequest.test.js +0 -40
- package/dist/http/substitute.test.d.ts +0 -2
- package/dist/http/substitute.test.d.ts.map +0 -1
- package/dist/http/substitute.test.js +0 -93
- package/dist/pluginDatabaseApi.test.d.ts +0 -2
- package/dist/pluginDatabaseApi.test.d.ts.map +0 -1
- package/dist/pluginDatabaseApi.test.js +0 -65
- package/dist/runtime/index.test.d.ts +0 -2
- package/dist/runtime/index.test.d.ts.map +0 -1
- package/dist/runtime/index.test.js +0 -41
- package/dist/runtime/index.test.ts +0 -53
- package/dist/runtime-utils.test.d.ts +0 -2
- package/dist/runtime-utils.test.d.ts.map +0 -1
- package/dist/runtime-utils.test.js +0 -104
- package/dist/signing/signing.test.d.ts +0 -2
- package/dist/signing/signing.test.d.ts.map +0 -1
- package/dist/signing/signing.test.js +0 -100
- package/dist/storage/cappedList.test.d.ts +0 -2
- package/dist/storage/cappedList.test.d.ts.map +0 -1
- package/dist/storage/cappedList.test.js +0 -11
- package/dist/utilities.test.d.ts +0 -2
- package/dist/utilities.test.d.ts.map +0 -1
- package/dist/utilities.test.js +0 -16
- package/dist/variables/dynamic.test.d.ts +0 -2
- package/dist/variables/dynamic.test.d.ts.map +0 -1
- package/dist/variables/dynamic.test.js +0 -60
- package/dist/variables/tokens.test.d.ts +0 -2
- package/dist/variables/tokens.test.d.ts.map +0 -1
- package/dist/variables/tokens.test.js +0 -160
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { BuildOptions, Plugin } from 'esbuild';
|
|
2
|
+
/**
|
|
3
|
+
* Which JSX runtime alias (if any) the renderer bundle should use.
|
|
4
|
+
*
|
|
5
|
+
* - `host` — bind `react/jsx-runtime` to `@harborclient/sdk/jsx-runtime-host` for
|
|
6
|
+
* bundled third-party React libraries that import jsx-runtime at module load.
|
|
7
|
+
* - `runtime` — route through the SDK runtime shims that forward to `hc.react`.
|
|
8
|
+
* - `automatic` — automatic JSX with `@harborclient/sdk` import source, no alias.
|
|
9
|
+
* - `none` — no JSX options (theme plugins that only register colors).
|
|
10
|
+
*/
|
|
11
|
+
export type JsxRuntimeMode = 'host' | 'runtime' | 'automatic' | 'none';
|
|
12
|
+
/**
|
|
13
|
+
* Options for {@link buildRenderer}.
|
|
14
|
+
*/
|
|
15
|
+
export interface BuildRendererOptions {
|
|
16
|
+
/** Renderer entry file. Defaults to `src/renderer.tsx`. */
|
|
17
|
+
entry?: string;
|
|
18
|
+
/** Output bundle path. Defaults to `dist/renderer.js`. */
|
|
19
|
+
outfile?: string;
|
|
20
|
+
/** When true, watch for changes instead of a one-shot build. */
|
|
21
|
+
watch?: boolean;
|
|
22
|
+
/** JSX runtime wiring for the bundle. Defaults to `runtime`. */
|
|
23
|
+
jsxRuntime?: JsxRuntimeMode;
|
|
24
|
+
/** Modules left external (provided by the HarborClient host). */
|
|
25
|
+
external?: string[];
|
|
26
|
+
/** esbuild `define` replacements merged into the build. */
|
|
27
|
+
define?: Record<string, string>;
|
|
28
|
+
/** Extra esbuild plugins appended after built-in plugins. */
|
|
29
|
+
plugins?: Plugin[];
|
|
30
|
+
/**
|
|
31
|
+
* When set, alias `react` to this path instead of externalizing it (e.g. aws-sigv
|
|
32
|
+
* proxy shim). Implies `external: []` unless `external` is explicitly provided.
|
|
33
|
+
*/
|
|
34
|
+
aliasReactTo?: string;
|
|
35
|
+
/** esbuild log level. Defaults to `info`. */
|
|
36
|
+
logLevel?: BuildOptions['logLevel'];
|
|
37
|
+
/**
|
|
38
|
+
* Files to copy after a successful build, e.g. theme stylesheets.
|
|
39
|
+
* Each pair is `[source, destination]`.
|
|
40
|
+
*/
|
|
41
|
+
copy?: ReadonlyArray<readonly [string, string]>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Bundles a HarborClient plugin renderer entry with canonical esbuild options.
|
|
45
|
+
*
|
|
46
|
+
* @param options - Build configuration.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildRenderer(options?: BuildRendererOptions): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* esbuild plugin that stubs Node built-in modules with empty exports.
|
|
51
|
+
*
|
|
52
|
+
* Use when a dependency imports Node modules that are unused at runtime in the
|
|
53
|
+
* renderer (e.g. `dotenv` importing `fs`/`path`).
|
|
54
|
+
*
|
|
55
|
+
* @param moduleNames - Built-in module names to stub (e.g. `path`, `fs`).
|
|
56
|
+
* @returns esbuild plugin.
|
|
57
|
+
*/
|
|
58
|
+
export declare function nodeBuiltinStubsPlugin(moduleNames: readonly string[]): Plugin;
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gEAAgE;IAChE,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACpC;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAwCD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDrF;AAYD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAiB7E"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { cpSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import * as esbuild from 'esbuild';
|
|
4
|
+
const JSX_RUNTIME_HOST = '@harborclient/sdk/jsx-runtime-host';
|
|
5
|
+
const JSX_RUNTIME = '@harborclient/sdk/jsx-runtime';
|
|
6
|
+
const JSX_DEV_RUNTIME = '@harborclient/sdk/jsx-dev-runtime';
|
|
7
|
+
/**
|
|
8
|
+
* Builds the jsx-runtime alias map for the given mode.
|
|
9
|
+
*
|
|
10
|
+
* @param mode - JSX runtime wiring mode.
|
|
11
|
+
* @returns Alias entries to merge into esbuild options, or undefined when none apply.
|
|
12
|
+
*/
|
|
13
|
+
function jsxRuntimeAliases(mode) {
|
|
14
|
+
if (mode === 'host') {
|
|
15
|
+
return {
|
|
16
|
+
'react/jsx-runtime': JSX_RUNTIME_HOST,
|
|
17
|
+
'react/jsx-dev-runtime': JSX_RUNTIME_HOST
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (mode === 'runtime') {
|
|
21
|
+
return {
|
|
22
|
+
'react/jsx-runtime': JSX_RUNTIME,
|
|
23
|
+
'react/jsx-dev-runtime': JSX_DEV_RUNTIME
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Copies asset files after a successful renderer build.
|
|
30
|
+
*
|
|
31
|
+
* @param pairs - Source/destination path pairs.
|
|
32
|
+
*/
|
|
33
|
+
function copyAssets(pairs) {
|
|
34
|
+
for (const [source, destination] of pairs) {
|
|
35
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
36
|
+
cpSync(source, destination);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Bundles a HarborClient plugin renderer entry with canonical esbuild options.
|
|
41
|
+
*
|
|
42
|
+
* @param options - Build configuration.
|
|
43
|
+
*/
|
|
44
|
+
export async function buildRenderer(options = {}) {
|
|
45
|
+
const { entry = 'src/renderer.tsx', outfile = 'dist/renderer.js', watch = false, jsxRuntime = 'runtime', define, plugins = [], aliasReactTo, logLevel = 'info', copy = [] } = options;
|
|
46
|
+
const external = options.external ?? (aliasReactTo ? [] : ['react', 'react-dom']);
|
|
47
|
+
const alias = {
|
|
48
|
+
...jsxRuntimeAliases(jsxRuntime),
|
|
49
|
+
...(aliasReactTo ? { react: aliasReactTo } : {})
|
|
50
|
+
};
|
|
51
|
+
const shared = {
|
|
52
|
+
entryPoints: [entry],
|
|
53
|
+
outfile,
|
|
54
|
+
bundle: true,
|
|
55
|
+
format: 'esm',
|
|
56
|
+
platform: 'browser',
|
|
57
|
+
logLevel,
|
|
58
|
+
external,
|
|
59
|
+
define,
|
|
60
|
+
plugins,
|
|
61
|
+
...(Object.keys(alias).length > 0 ? { alias } : {}),
|
|
62
|
+
...(jsxRuntime === 'none'
|
|
63
|
+
? {}
|
|
64
|
+
: {
|
|
65
|
+
jsx: 'automatic',
|
|
66
|
+
jsxImportSource: '@harborclient/sdk'
|
|
67
|
+
})
|
|
68
|
+
};
|
|
69
|
+
if (watch) {
|
|
70
|
+
const context = await esbuild.context(shared);
|
|
71
|
+
await context.watch();
|
|
72
|
+
console.log('Watching for changes…');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const context = await esbuild.context(shared);
|
|
76
|
+
await context.rebuild();
|
|
77
|
+
await context.dispose();
|
|
78
|
+
if (copy.length > 0) {
|
|
79
|
+
copyAssets(copy);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Escapes a string for use as a literal in a RegExp.
|
|
84
|
+
*
|
|
85
|
+
* @param value - Raw string to escape.
|
|
86
|
+
* @returns Regex-safe literal.
|
|
87
|
+
*/
|
|
88
|
+
function escapeRegExp(value) {
|
|
89
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* esbuild plugin that stubs Node built-in modules with empty exports.
|
|
93
|
+
*
|
|
94
|
+
* Use when a dependency imports Node modules that are unused at runtime in the
|
|
95
|
+
* renderer (e.g. `dotenv` importing `fs`/`path`).
|
|
96
|
+
*
|
|
97
|
+
* @param moduleNames - Built-in module names to stub (e.g. `path`, `fs`).
|
|
98
|
+
* @returns esbuild plugin.
|
|
99
|
+
*/
|
|
100
|
+
export function nodeBuiltinStubsPlugin(moduleNames) {
|
|
101
|
+
return {
|
|
102
|
+
name: 'node-builtins-stub',
|
|
103
|
+
setup(build) {
|
|
104
|
+
for (const moduleName of moduleNames) {
|
|
105
|
+
build.onResolve({ filter: new RegExp(`^${escapeRegExp(moduleName)}$`) }, () => ({
|
|
106
|
+
path: moduleName,
|
|
107
|
+
namespace: 'node-stub'
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
build.onLoad({ filter: /.*/, namespace: 'node-stub' }, () => ({
|
|
111
|
+
contents: 'export default {};',
|
|
112
|
+
loader: 'js'
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './index';
|
|
2
|
-
export * from './runtime/index';
|
|
1
|
+
export * from './index.js';
|
|
2
|
+
export * from './runtime/index.js';
|
|
@@ -24,6 +24,7 @@ export type { Props as KeyValueEditorProps } from './KeyValueEditor/index.js';
|
|
|
24
24
|
export { MethodSelect } from './MethodSelect/index.js';
|
|
25
25
|
export { Modal, ModalFooter, ModalFormLayout } from './Modal/index.js';
|
|
26
26
|
export { ModalHeader } from './Modal/ModalHeader.js';
|
|
27
|
+
export { portalToBody } from './portalToBody.js';
|
|
27
28
|
export { OverlayCloseButton } from './OverlayCloseButton/index.js';
|
|
28
29
|
export { Page } from './Page/index.js';
|
|
29
30
|
export { PageHeader } from './PageHeader/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EAAE,KAAK,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,KAAK,IAAI,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC1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AO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { KeyValueEditor } from './KeyValueEditor/index.js';
|
|
|
17
17
|
export { MethodSelect } from './MethodSelect/index.js';
|
|
18
18
|
export { Modal, ModalFooter, ModalFormLayout } from './Modal/index.js';
|
|
19
19
|
export { ModalHeader } from './Modal/ModalHeader.js';
|
|
20
|
+
export { portalToBody } from './portalToBody.js';
|
|
20
21
|
export { OverlayCloseButton } from './OverlayCloseButton/index.js';
|
|
21
22
|
export { Page } from './Page/index.js';
|
|
22
23
|
export { PageHeader } from './PageHeader/index.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode, ReactPortal } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Portals modal content to document.body so fixed positioning is not clipped by
|
|
4
|
+
* the sidebar or other overflow-hidden plugin webview containers.
|
|
5
|
+
*
|
|
6
|
+
* @param node - Modal element to render.
|
|
7
|
+
* @returns Portal into document.body.
|
|
8
|
+
* @throws When `document` is unavailable (SSR, tests, or misconfigured host).
|
|
9
|
+
*/
|
|
10
|
+
export declare function portalToBody(node: ReactNode): ReactPortal;
|
|
11
|
+
//# sourceMappingURL=portalToBody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portalToBody.d.ts","sourceRoot":"","sources":["../../src/components/portalToBody.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAKzD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createPortal } from '@harborclient/sdk/react-dom';
|
|
2
|
+
/**
|
|
3
|
+
* Portals modal content to document.body so fixed positioning is not clipped by
|
|
4
|
+
* the sidebar or other overflow-hidden plugin webview containers.
|
|
5
|
+
*
|
|
6
|
+
* @param node - Modal element to render.
|
|
7
|
+
* @returns Portal into document.body.
|
|
8
|
+
* @throws When `document` is unavailable (SSR, tests, or misconfigured host).
|
|
9
|
+
*/
|
|
10
|
+
export function portalToBody(node) {
|
|
11
|
+
if (typeof document === 'undefined') {
|
|
12
|
+
throw new Error('portalToBody requires a DOM document');
|
|
13
|
+
}
|
|
14
|
+
return createPortal(node, document.body);
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared flat ESLint config for HarborClient plugins (ESLint 10 compatible).
|
|
3
|
+
*
|
|
4
|
+
* Plugins re-export this from `eslint.config.mjs`:
|
|
5
|
+
* `export { default } from '@harborclient/sdk/eslint';`
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: import("typescript-eslint").FlatConfig.ConfigArray;
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eslint/index.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;;AACH,wBAaE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
3
|
+
import globals from 'globals';
|
|
4
|
+
import tseslint from 'typescript-eslint';
|
|
5
|
+
/**
|
|
6
|
+
* Shared flat ESLint config for HarborClient plugins (ESLint 10 compatible).
|
|
7
|
+
*
|
|
8
|
+
* Plugins re-export this from `eslint.config.mjs`:
|
|
9
|
+
* `export { default } from '@harborclient/sdk/eslint';`
|
|
10
|
+
*/
|
|
11
|
+
export default tseslint.config({
|
|
12
|
+
ignores: ['**/node_modules', '**/dist', 'pnpm-lock.yaml']
|
|
13
|
+
}, eslint.configs.recommended, tseslint.configs.recommended, {
|
|
14
|
+
files: ['**/*.mjs'],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: globals.node
|
|
17
|
+
}
|
|
18
|
+
}, eslintConfigPrettier);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type * from './types';
|
|
1
|
+
export type * from './types.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC"}
|
package/dist/main.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { CodeEditorSetup, CodeEditorTheme, Disposable, EchoServerIncomingRequest, EchoServerStartResult, EchoServerStatus, MainPluginContext, PluginHttp, PluginHttpRequest, PluginHttpResponse, PluginIpc, PluginScriptCollectionInit, PluginScriptContext, PluginScriptContextInit, PluginScriptEnvironmentInit, PluginScriptKeyValue, PluginScriptRequestInit, PluginScriptResponseInit, PluginScriptRunResult, PluginScripts, PluginScriptTestResult, PluginServer, PluginStorage, ScriptPhase } from './types';
|
|
1
|
+
export type { CodeEditorSetup, CodeEditorTheme, Disposable, EchoServerIncomingRequest, EchoServerStartResult, EchoServerStatus, MainPluginContext, PluginHttp, PluginHttpRequest, PluginHttpResponse, PluginIpc, PluginScriptCollectionInit, PluginScriptContext, PluginScriptContextInit, PluginScriptEnvironmentInit, PluginScriptKeyValue, PluginScriptRequestInit, PluginScriptResponseInit, PluginScriptRunResult, PluginScripts, PluginScriptTestResult, PluginServer, PluginStorage, ScriptPhase } from './types.js';
|
|
2
2
|
//# sourceMappingURL=main.d.ts.map
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,eAAe,EACf,UAAU,EACV,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,WAAW,EACZ,MAAM,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,eAAe,EACf,UAAU,EACV,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,WAAW,EACZ,MAAM,YAAY,CAAC"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
|
-
import type { Disposable, PluginContext, ThemeContribution } from '../types';
|
|
2
|
+
import type { Disposable, PluginContext, ThemeContribution } from '../types.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Installs the HarborClient renderer React instance for plugin JSX and hooks.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Host React fragment, resolved from the externalized `react` module at runtime.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Fragment: React.ExoticComponent<{ children?: React.ReactNode }>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Automatic JSX runtime entry for third-party deps aliased to this module.
|
|
10
|
+
*/
|
|
11
|
+
export function jsx(
|
|
12
|
+
type: React.ElementType,
|
|
13
|
+
props: Record<string, unknown> | null | undefined,
|
|
14
|
+
key?: string | number
|
|
15
|
+
): React.ReactElement;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Automatic JSX runtime entry for elements with multiple children.
|
|
19
|
+
*/
|
|
20
|
+
export function jsxs(
|
|
21
|
+
type: React.ElementType,
|
|
22
|
+
props: Record<string, unknown> | null | undefined,
|
|
23
|
+
key?: string | number
|
|
24
|
+
): React.ReactElement;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Development JSX transform entry; delegates to {@link jsx}.
|
|
28
|
+
*/
|
|
29
|
+
export function jsxDEV(
|
|
30
|
+
type: React.ElementType,
|
|
31
|
+
props: Record<string, unknown> | null | undefined,
|
|
32
|
+
key?: string | number
|
|
33
|
+
): React.ReactElement;
|
|
34
|
+
|
|
35
|
+
export namespace JSX {
|
|
36
|
+
interface Element extends React.JSX.Element {}
|
|
37
|
+
interface ElementClass extends React.JSX.ElementClass {}
|
|
38
|
+
interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {}
|
|
39
|
+
interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {}
|
|
40
|
+
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>;
|
|
41
|
+
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
|
|
42
|
+
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
|
|
43
|
+
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
|
|
44
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export const Fragment = React.Fragment;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Builds a React element using the externalized host React directly.
|
|
7
|
+
*
|
|
8
|
+
* Used when bundling third-party deps (e.g. @uiw/react-codemirror,
|
|
9
|
+
* @fortawesome/react-fontawesome) that import `react/jsx-runtime`. Aliasing
|
|
10
|
+
* those imports to this module keeps them on the same host React instance as
|
|
11
|
+
* the plugin shell without requiring installReact() to have run first.
|
|
12
|
+
*
|
|
13
|
+
* @param {import('react').ElementType} type - Element type or Fragment.
|
|
14
|
+
* @param {Record<string, unknown> | null | undefined} props - Element props.
|
|
15
|
+
* @param {string | number | undefined} key - React key when provided by the compiler.
|
|
16
|
+
* @returns {import('react').ReactElement}
|
|
17
|
+
*/
|
|
18
|
+
function build(type, props, key) {
|
|
19
|
+
const { children, ...rest } = props ?? {};
|
|
20
|
+
if (key !== undefined) {
|
|
21
|
+
rest.key = key;
|
|
22
|
+
}
|
|
23
|
+
return React.createElement(type, props === null ? props : rest, children);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @type {typeof import('react/jsx-runtime').jsx} */
|
|
27
|
+
export const jsx = build;
|
|
28
|
+
|
|
29
|
+
/** @type {typeof import('react/jsx-runtime').jsxs} */
|
|
30
|
+
export const jsxs = build;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Development JSX transform entry; delegates to the production jsx helper.
|
|
34
|
+
*
|
|
35
|
+
* @param {import('react').ElementType} type - Element type or Fragment.
|
|
36
|
+
* @param {Record<string, unknown> | null | undefined} props - Element props.
|
|
37
|
+
* @param {string | number | undefined} key - React key when provided by the compiler.
|
|
38
|
+
* @returns {import('react').ReactElement}
|
|
39
|
+
*/
|
|
40
|
+
export function jsxDEV(type, props, key) {
|
|
41
|
+
return build(type, props, key);
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createPortal } from 'react-dom';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { requireHostReactDom } from './reactHost.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a React portal into the host DOM tree.
|
|
5
|
+
*
|
|
6
|
+
* Delegates to the installed host React DOM instance so portals reconcile with
|
|
7
|
+
* the same React copy as {@link @harborclient/sdk/react} hooks.
|
|
8
|
+
*
|
|
9
|
+
* @param {import('react').ReactNode} children - Portal content.
|
|
10
|
+
* @param {Element | DocumentFragment} container - DOM mount target.
|
|
11
|
+
* @param {string | null} [key] - Optional React key for the portal.
|
|
12
|
+
* @returns {import('react').ReactPortal} Portal element.
|
|
13
|
+
*/
|
|
14
|
+
export function createPortal(children, container, key) {
|
|
15
|
+
return requireHostReactDom().createPortal(children, container, key);
|
|
16
|
+
}
|
package/dist/runtime/react.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
useRef,
|
|
7
7
|
useSyncExternalStore,
|
|
8
8
|
forwardRef,
|
|
9
|
+
useImperativeHandle,
|
|
9
10
|
cloneElement,
|
|
10
11
|
isValidElement,
|
|
11
12
|
createContext,
|
|
@@ -14,3 +15,8 @@ export {
|
|
|
14
15
|
useLayoutEffect,
|
|
15
16
|
createElement
|
|
16
17
|
} from 'react';
|
|
18
|
+
|
|
19
|
+
import type * as React from 'react';
|
|
20
|
+
|
|
21
|
+
declare const _default: typeof React;
|
|
22
|
+
export default _default;
|
package/dist/runtime/react.js
CHANGED
|
@@ -45,9 +45,40 @@ export function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)
|
|
|
45
45
|
return hook('useSyncExternalStore')(subscribe, getSnapshot, getServerSnapshot);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Defers host React lookup until render so module-level `React.forwardRef(...)`
|
|
50
|
+
* calls (e.g. from @fortawesome/react-fontawesome) work before activate().
|
|
51
|
+
*
|
|
52
|
+
* @type {typeof import('react').forwardRef}
|
|
53
|
+
*/
|
|
49
54
|
export function forwardRef(render) {
|
|
50
|
-
|
|
55
|
+
/** @type {ReturnType<typeof import('react').forwardRef> | null} */
|
|
56
|
+
let forwarded = null;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Lazily wraps the render function with host React.forwardRef on first render.
|
|
60
|
+
*
|
|
61
|
+
* @param {Record<string, unknown>} props - Component props.
|
|
62
|
+
* @param {import('react').Ref<unknown>} ref - Ref forwarded from the parent.
|
|
63
|
+
* @returns {import('react').ReactElement}
|
|
64
|
+
*/
|
|
65
|
+
function LazyForwardRef(props, ref) {
|
|
66
|
+
const react = requireHostReact();
|
|
67
|
+
if (forwarded === null) {
|
|
68
|
+
forwarded = react.forwardRef(render);
|
|
69
|
+
}
|
|
70
|
+
return react.createElement(forwarded, { ...props, ref });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const displayName = render.displayName ?? render.name ?? 'Component';
|
|
74
|
+
LazyForwardRef.displayName = `ForwardRef(${displayName})`;
|
|
75
|
+
|
|
76
|
+
return LazyForwardRef;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @type {typeof import('react').useImperativeHandle} */
|
|
80
|
+
export function useImperativeHandle(ref, create, deps) {
|
|
81
|
+
return hook('useImperativeHandle')(ref, create, deps);
|
|
51
82
|
}
|
|
52
83
|
|
|
53
84
|
/** @type {typeof import('react').cloneElement} */
|
|
@@ -84,3 +115,40 @@ export function useLayoutEffect(effect, deps) {
|
|
|
84
115
|
export function createElement(type, props, ...children) {
|
|
85
116
|
return hook('createElement')(type, props, ...children);
|
|
86
117
|
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Named SDK React exports used as the Proxy target for the default export.
|
|
121
|
+
*/
|
|
122
|
+
const reactNamespace = {
|
|
123
|
+
useState,
|
|
124
|
+
useEffect,
|
|
125
|
+
useCallback,
|
|
126
|
+
useMemo,
|
|
127
|
+
useRef,
|
|
128
|
+
useSyncExternalStore,
|
|
129
|
+
forwardRef,
|
|
130
|
+
useImperativeHandle,
|
|
131
|
+
cloneElement,
|
|
132
|
+
isValidElement,
|
|
133
|
+
createContext,
|
|
134
|
+
useContext,
|
|
135
|
+
useId,
|
|
136
|
+
useLayoutEffect,
|
|
137
|
+
createElement
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Default React namespace for `import React from 'react'` when aliasing bare
|
|
142
|
+
* `react` to `@harborclient/sdk/react`. Named exports are served from the SDK;
|
|
143
|
+
* other properties fall back to the installed host React instance.
|
|
144
|
+
*/
|
|
145
|
+
const defaultExport = new Proxy(reactNamespace, {
|
|
146
|
+
get(target, prop, receiver) {
|
|
147
|
+
if (prop in target) {
|
|
148
|
+
return Reflect.get(target, prop, receiver);
|
|
149
|
+
}
|
|
150
|
+
return requireHostReact()[prop];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export default defaultExport;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/** Global key shared across bundled plugin copies of this module and the view host. */
|
|
2
2
|
const HOST_REACT_GLOBAL_KEY = '__HARBORCLIENT_HOST_REACT__';
|
|
3
3
|
|
|
4
|
+
/** Global key for the host React DOM instance (createPortal, etc.). */
|
|
5
|
+
const HOST_REACT_DOM_GLOBAL_KEY = '__HARBORCLIENT_HOST_REACT_DOM__';
|
|
6
|
+
|
|
4
7
|
/** @type {typeof import('react') | null} */
|
|
5
8
|
let hostReact = null;
|
|
6
9
|
|
|
10
|
+
/** @type {typeof import('react-dom') | null} */
|
|
11
|
+
let hostReactDom = null;
|
|
12
|
+
|
|
7
13
|
/**
|
|
8
14
|
* Reads the host React instance published on globalThis by the view host bootstrap.
|
|
9
15
|
*
|
|
@@ -52,3 +58,49 @@ export function requireHostReact() {
|
|
|
52
58
|
}
|
|
53
59
|
return hostReact;
|
|
54
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Reads the host React DOM instance published on globalThis by the view host bootstrap.
|
|
64
|
+
*
|
|
65
|
+
* @returns {typeof import('react-dom') | null} Host React DOM when available.
|
|
66
|
+
*/
|
|
67
|
+
function readGlobalHostReactDom() {
|
|
68
|
+
if (typeof globalThis === 'undefined') {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const candidate = globalThis[HOST_REACT_DOM_GLOBAL_KEY];
|
|
72
|
+
return candidate ?? null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Installs the HarborClient renderer React DOM instance for plugin portals.
|
|
77
|
+
*
|
|
78
|
+
* @param {typeof import('react-dom')} reactDom - React DOM namespace from the host shim.
|
|
79
|
+
*/
|
|
80
|
+
export function setHostReactDom(reactDom) {
|
|
81
|
+
hostReactDom = reactDom;
|
|
82
|
+
if (typeof globalThis !== 'undefined') {
|
|
83
|
+
globalThis[HOST_REACT_DOM_GLOBAL_KEY] = reactDom;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Returns the installed host React DOM instance.
|
|
89
|
+
*
|
|
90
|
+
* @returns {typeof import('react-dom')} Host React DOM namespace.
|
|
91
|
+
* @throws {Error} When {@link setHostReactDom} has not been called yet.
|
|
92
|
+
*/
|
|
93
|
+
export function requireHostReactDom() {
|
|
94
|
+
if (hostReactDom == null) {
|
|
95
|
+
const globalReactDom = readGlobalHostReactDom();
|
|
96
|
+
if (globalReactDom != null) {
|
|
97
|
+
hostReactDom = globalReactDom;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (hostReactDom == null) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
'Plugin React DOM host is not installed. The view host must call setHostReactDom() before activate().'
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return hostReactDom;
|
|
106
|
+
}
|