@yahoo/uds-create-sidecar 3.0.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,36 @@
1
+ //#region src/registry.d.ts
2
+ type UDSCreateSidecarModules = Readonly<{
3
+ '@json-render/react': unknown;
4
+ react: unknown;
5
+ 'react/jsx-runtime': unknown;
6
+ 'react-native': unknown;
7
+ } & Record<string, unknown>>;
8
+ interface UDSCreateSidecarRegistryOptions {
9
+ /** A human-readable app name shown by Create when this host connects. */
10
+ readonly hostName: string;
11
+ /** Optional app version shown alongside the connected host name. */
12
+ readonly hostVersion?: string;
13
+ /** Statically imported modules that downloaded preview bundles may resolve. */
14
+ readonly modules: UDSCreateSidecarModules;
15
+ /** Exact installed versions keyed by package root, not module subpath. */
16
+ readonly packageVersions: Readonly<Record<string, string>>;
17
+ }
18
+ interface UDSCreateSidecarRegistry {
19
+ readonly hostName: string;
20
+ readonly hostVersion?: string;
21
+ readonly modules: UDSCreateSidecarModules;
22
+ readonly packageVersions: Readonly<Record<string, string>>;
23
+ }
24
+ /**
25
+ * Define the complete module boundary available to downloaded Create previews.
26
+ * Every module must have an exact installed package version so the connected
27
+ * host can advertise its real capabilities before any bundle is evaluated.
28
+ */
29
+ declare function createUDSCreateSidecarRegistry({
30
+ hostName,
31
+ hostVersion,
32
+ modules,
33
+ packageVersions
34
+ }: UDSCreateSidecarRegistryOptions): UDSCreateSidecarRegistry;
35
+ //#endregion
36
+ export { UDSCreateSidecarModules, UDSCreateSidecarRegistry, UDSCreateSidecarRegistryOptions, createUDSCreateSidecarRegistry };
@@ -0,0 +1,38 @@
1
+ //#region src/registry.ts
2
+ const REQUIRED_MODULES = [
3
+ "@json-render/react",
4
+ "react",
5
+ "react/jsx-runtime",
6
+ "react-native"
7
+ ];
8
+ /**
9
+ * Define the complete module boundary available to downloaded Create previews.
10
+ * Every module must have an exact installed package version so the connected
11
+ * host can advertise its real capabilities before any bundle is evaluated.
12
+ */
13
+ function createUDSCreateSidecarRegistry({ hostName, hostVersion, modules, packageVersions }) {
14
+ if (hostName.trim() === "") throw new Error("The Sidecar registry requires a hostName.");
15
+ for (const required of REQUIRED_MODULES) if (!(required in modules)) throw new Error(`The Sidecar registry must expose ${required}.`);
16
+ const versions = {};
17
+ for (const specifier of Object.keys(modules)) {
18
+ const name = packageRoot(specifier);
19
+ const version = packageVersions[name];
20
+ if (!version || !isExactVersion(version)) throw new Error(`The Sidecar registry exposes ${name} without an exact installed version.`);
21
+ versions[name] = version;
22
+ }
23
+ return Object.freeze({
24
+ hostName,
25
+ ...hostVersion ? { hostVersion } : {},
26
+ modules: Object.freeze({ ...modules }),
27
+ packageVersions: Object.freeze(versions)
28
+ });
29
+ }
30
+ function isExactVersion(version) {
31
+ return /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(version);
32
+ }
33
+ function packageRoot(moduleName) {
34
+ const parts = moduleName.split("/");
35
+ return moduleName.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? moduleName;
36
+ }
37
+ //#endregion
38
+ export { createUDSCreateSidecarRegistry };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@yahoo/uds-create-sidecar",
3
+ "version": "3.0.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./registry": {
21
+ "types": "./dist/registry.d.ts",
22
+ "default": "./dist/registry.js"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "scripts": {
27
+ "build": "tsdown",
28
+ "clean": "internal-cli tools clean",
29
+ "dev": "tsdown --watch --no-clean",
30
+ "fix": "internal-cli tools fix",
31
+ "lint": "internal-cli tools lint",
32
+ "test": "bun run build && bun test src/",
33
+ "typecheck": "tsc -b"
34
+ },
35
+ "dependencies": {
36
+ "@noble/hashes": "2.2.0"
37
+ },
38
+ "peerDependencies": {
39
+ "@json-render/react": ">=0.19.0",
40
+ "expo": "^57.0.0",
41
+ "react": "^19.0.0",
42
+ "react-native": ">=0.86.0",
43
+ "react-native-safe-area-context": ">=5.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "@hocuspocus/provider": "^3.4.4",
47
+ "@types/bun": "^1.3.14",
48
+ "@types/react": "19.2.14",
49
+ "esbuild": "^0.27.4",
50
+ "expo": "~57.0.18",
51
+ "react": "19.2.3",
52
+ "react-native": "0.86.3",
53
+ "react-native-safe-area-context": "5.7.0",
54
+ "tsdown": "^0.21.0",
55
+ "typescript": "~6.0.3",
56
+ "yjs": "^13.6.29"
57
+ },
58
+ "udsSchemaVersion": 20260910212453
59
+ }