@powerhousedao/reactor-api 6.2.3-dev.5 → 6.2.3-dev.50
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 +7 -2
- package/dist/{adapter-gateway-apollo-CxJNBVyD.mjs → adapter-gateway-apollo-B54G_cXT.mjs} +15 -13
- package/dist/{adapter-gateway-apollo-CxJNBVyD.mjs.map → adapter-gateway-apollo-B54G_cXT.mjs.map} +1 -1
- package/dist/{adapter-gateway-apollo-DowrX6E_.mjs → adapter-gateway-apollo-D2DNlPY0.mjs} +3 -3
- package/dist/{adapter-gateway-mercurius-CZVy88Za.mjs → adapter-gateway-mercurius-rbKlwF9m.mjs} +4 -4
- package/dist/{adapter-gateway-mercurius-CZVy88Za.mjs.map → adapter-gateway-mercurius-rbKlwF9m.mjs.map} +1 -1
- package/dist/{adapter-gateway-stitching-CaZjvRzx.mjs → adapter-gateway-stitching-Dzv10u8D.mjs} +15 -10
- package/dist/{adapter-gateway-stitching-CaZjvRzx.mjs.map → adapter-gateway-stitching-Dzv10u8D.mjs.map} +1 -1
- package/dist/{adapter-http-express-B39rPhqH.mjs → adapter-http-express-P0t-mdMV.mjs} +10 -10
- package/dist/adapter-http-express-P0t-mdMV.mjs.map +1 -0
- package/dist/{adapter-http-fastify-BwXO6rqE.mjs → adapter-http-fastify-D0OP5q9K.mjs} +13 -12
- package/dist/adapter-http-fastify-D0OP5q9K.mjs.map +1 -0
- package/dist/index.d.mts +1621 -604
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2622 -617
- package/dist/index.mjs.map +1 -1
- package/dist/pglite-node-Ow9i5Rb4.mjs +573 -0
- package/dist/pglite-node-Ow9i5Rb4.mjs.map +1 -0
- package/dist/rolldown-runtime-8H4AJuhK.mjs +16 -0
- package/dist/run-node-handler-CQjyjOuN.mjs +52 -0
- package/dist/run-node-handler-CQjyjOuN.mjs.map +1 -0
- package/dist/src/packages/https-hooks.d.mts +4 -4
- package/dist/src/packages/https-hooks.d.mts.map +1 -1
- package/dist/src/packages/https-hooks.mjs +2 -2
- package/dist/src/packages/https-hooks.mjs.map +1 -1
- package/dist/src/packages/vite-loader.d.mts +19 -9
- package/dist/src/packages/vite-loader.d.mts.map +1 -1
- package/dist/src/packages/vite-loader.mjs +114 -50
- package/dist/src/packages/vite-loader.mjs.map +1 -1
- package/dist/src/pglite/pglite-node.d.mts +130 -0
- package/dist/src/pglite/pglite-node.d.mts.map +1 -0
- package/dist/src/pglite/pglite-node.mjs +4 -0
- package/dist/{utils-XWVecaNn.mjs → subgraph-extraction-DTFoN_bS.mjs} +266 -11
- package/dist/subgraph-extraction-DTFoN_bS.mjs.map +1 -0
- package/dist/{types-DcYyNcHJ.d.mts → types-DlTiz6AA.d.mts} +27 -4
- package/dist/types-DlTiz6AA.d.mts.map +1 -0
- package/dist/{websocket-DncAB9XK.mjs → websocket-_SH5aBcy.mjs} +3 -3
- package/dist/{websocket-DncAB9XK.mjs.map → websocket-_SH5aBcy.mjs.map} +1 -1
- package/package.json +24 -19
- package/dist/adapter-http-express-B39rPhqH.mjs.map +0 -1
- package/dist/adapter-http-fastify-BwXO6rqE.mjs.map +0 -1
- package/dist/path-normalize-BOQwY9wR.mjs +0 -23
- package/dist/path-normalize-BOQwY9wR.mjs.map +0 -1
- package/dist/types-DcYyNcHJ.d.mts.map +0 -1
- package/dist/utils-XWVecaNn.mjs.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { __exportAll as t };
|
|
15
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e3b80eba-208e-51a9-b437-5ac76accf5d0")}catch(e){}}();
|
|
16
|
+
//# debugId=e3b80eba-208e-51a9-b437-5ac76accf5d0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b96f00d4-5192-57bc-b435-7cc0f7c0f5c8")}catch(e){}}();
|
|
3
|
+
import { childLogger } from "document-model";
|
|
4
|
+
//#region src/graphql/gateway/path-normalize.ts
|
|
5
|
+
/**
|
|
6
|
+
* Normalises a route path for path-to-regexp v8:
|
|
7
|
+
* - Collapses duplicate slashes (e.g. "//explorer" → "/explorer")
|
|
8
|
+
* - Converts legacy optional-param syntax "/:param?" → "{/:param}". The
|
|
9
|
+
* slash must move inside the group: in p-r v8 a group whose content
|
|
10
|
+
* begins with "/" is what makes the slash and the parameter optional
|
|
11
|
+
* together, while a literal "/" left in front of the group compiles to
|
|
12
|
+
* a pattern that matches nothing (and v8 rejects a bare ":param?").
|
|
13
|
+
*
|
|
14
|
+
* Shared by both http adapters so registry dispatch matches the same path
|
|
15
|
+
* shapes regardless of which framework is in use.
|
|
16
|
+
*/
|
|
17
|
+
function normalizePath(path) {
|
|
18
|
+
return path.replace(/\/+/g, "/").replace(/\/:(\w+)\?/g, "{/:$1}");
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/graphql/gateway/run-node-handler.ts
|
|
22
|
+
const logger = childLogger(["reactor-api", "node-route"]);
|
|
23
|
+
/**
|
|
24
|
+
* Runs a node route handler without awaiting it. A throw or rejection is
|
|
25
|
+
* logged and answered with a 500, or ends the socket if headers already went
|
|
26
|
+
* out; it never reaches the process as an unhandled rejection.
|
|
27
|
+
*/
|
|
28
|
+
function runNodeHandler(handler, req, res, body) {
|
|
29
|
+
const fail = (err) => {
|
|
30
|
+
logger.error("Node route handler failed for @method @url: @error", req.method, req.url, err);
|
|
31
|
+
if (res.headersSent) {
|
|
32
|
+
res.destroy();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
res.statusCode = 500;
|
|
36
|
+
res.setHeader("Content-Type", "application/json");
|
|
37
|
+
res.end(JSON.stringify({ error: "Internal error" }));
|
|
38
|
+
};
|
|
39
|
+
let result;
|
|
40
|
+
try {
|
|
41
|
+
result = handler(req, res, body);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
fail(err);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (result) result.catch(fail);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { normalizePath as n, runNodeHandler as t };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=run-node-handler-CQjyjOuN.mjs.map
|
|
52
|
+
//# debugId=b96f00d4-5192-57bc-b435-7cc0f7c0f5c8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-node-handler-CQjyjOuN.mjs","sources":["../src/graphql/gateway/path-normalize.ts","../src/graphql/gateway/run-node-handler.ts"],"sourcesContent":["/**\n * Normalises a route path for path-to-regexp v8:\n * - Collapses duplicate slashes (e.g. \"//explorer\" → \"/explorer\")\n * - Converts legacy optional-param syntax \"/:param?\" → \"{/:param}\". The\n * slash must move inside the group: in p-r v8 a group whose content\n * begins with \"/\" is what makes the slash and the parameter optional\n * together, while a literal \"/\" left in front of the group compiles to\n * a pattern that matches nothing (and v8 rejects a bare \":param?\").\n *\n * Shared by both http adapters so registry dispatch matches the same path\n * shapes regardless of which framework is in use.\n */\nexport function normalizePath(path: string): string {\n return path.replace(/\\/+/g, \"/\").replace(/\\/:(\\w+)\\?/g, \"{/:$1}\");\n}\n","import { childLogger } from \"document-model\";\nimport type http from \"node:http\";\n\nconst logger = childLogger([\"reactor-api\", \"node-route\"]);\n\nexport type NodeHandler = (\n req: http.IncomingMessage,\n res: http.ServerResponse,\n body?: unknown,\n) => void | Promise<void>;\n\n/**\n * Runs a node route handler without awaiting it. A throw or rejection is\n * logged and answered with a 500, or ends the socket if headers already went\n * out; it never reaches the process as an unhandled rejection.\n */\nexport function runNodeHandler(\n handler: NodeHandler,\n req: http.IncomingMessage,\n res: http.ServerResponse,\n body: unknown,\n): void {\n const fail = (err: unknown): void => {\n logger.error(\n \"Node route handler failed for @method @url: @error\",\n req.method,\n req.url,\n err,\n );\n if (res.headersSent) {\n res.destroy();\n return;\n }\n res.statusCode = 500;\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(JSON.stringify({ error: \"Internal error\" }));\n };\n\n let result: void | Promise<void>;\n try {\n result = handler(req, res, body);\n } catch (err) {\n fail(err);\n return;\n }\n if (result) {\n result.catch(fail);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,SAAgB,cAAc,MAAsB;CAClD,OAAO,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,QAAQ,eAAe,QAAQ;AAClE;;;ACXA,MAAM,SAAS,YAAY,CAAC,eAAe,YAAY,CAAC;;;;;;AAaxD,SAAgB,eACd,SACA,KACA,KACA,MACM;CACN,MAAM,QAAQ,QAAuB;EACnC,OAAO,MACL,sDACA,IAAI,QACJ,IAAI,KACJ,GACF;EACA,IAAI,IAAI,aAAa;GACnB,IAAI,QAAQ;GACZ;EACF;EACA,IAAI,aAAa;EACjB,IAAI,UAAU,gBAAgB,kBAAkB;EAChD,IAAI,IAAI,KAAK,UAAU,EAAE,OAAO,iBAAiB,CAAC,CAAC;CACrD;CAEA,IAAI;CACJ,IAAI;EACF,SAAS,QAAQ,KAAK,KAAK,IAAI;CACjC,SAAS,KAAK;EACZ,KAAK,GAAG;EACR;CACF;CACA,IAAI,QACF,OAAO,MAAM,IAAI;AAErB","debug_id":"b96f00d4-5192-57bc-b435-7cc0f7c0f5c8"}
|
|
@@ -25,15 +25,15 @@ type NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;
|
|
|
25
25
|
/**
|
|
26
26
|
* Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.
|
|
27
27
|
*/
|
|
28
|
-
declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
|
|
28
|
+
export declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
|
|
29
29
|
/**
|
|
30
30
|
* Load hook: fetches module source from HTTP/HTTPS URLs.
|
|
31
31
|
*/
|
|
32
|
-
declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
|
|
32
|
+
export declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
|
|
33
33
|
/**
|
|
34
34
|
* Path to this hooks file for use with node:module register()
|
|
35
35
|
*/
|
|
36
|
-
declare const httpsHooksPath: string;
|
|
36
|
+
export declare const httpsHooksPath: string;
|
|
37
37
|
//#endregion
|
|
38
|
-
export {
|
|
38
|
+
export {};
|
|
39
39
|
//# sourceMappingURL=https-hooks.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"https-hooks.d.mts","names":[],"sources":["../../../src/packages/https-hooks.mts"],"mappings":";;;;;KASK
|
|
1
|
+
{"version":3,"file":"https-hooks.d.mts","names":[],"sources":["../../../src/packages/https-hooks.mts"],"mappings":";;;;;KASK;EAAmB;EAAoB;;KACvC;EACH;EACA;EACA;;KAEG,eACH,mBACA,SAAS,mBACN,QAAQ;KAER;EAAgB;;KAChB;EAAe;EAAgB;EAAwB;;KACvD,YAAY,aAAa,SAAS,gBAAgB,QAAQ;;;;wBAKzC,QACpB,mBACA,SAAS,gBACT,aAAa,cACZ,QAAQ;;;;wBAgEW,KACpB,aACA,SAAS,aACT,UAAU,WACT,QAAQ;;;;qBAoFE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8149a6c4-bab0-57e3-a471-cfc77d529bbf")}catch(e){}}();
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { get } from "node:http";
|
|
5
5
|
import { get as get$1 } from "node:https";
|
|
@@ -99,4 +99,4 @@ const httpsHooksPath = import.meta.url;
|
|
|
99
99
|
export { httpsHooksPath, load, resolve };
|
|
100
100
|
|
|
101
101
|
//# sourceMappingURL=https-hooks.mjs.map
|
|
102
|
-
//# debugId=
|
|
102
|
+
//# debugId=8149a6c4-bab0-57e3-a471-cfc77d529bbf
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"https-hooks.mjs","sources":["../../../src/packages/https-hooks.mts"],"sourcesContent":["import { get as httpGet } from \"node:http\";\nimport { get } from \"node:https\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Node.js module loader hooks that enable importing from HTTP/HTTPS URLs.\n * See: https://nodejs.org/docs/latest-v24.x/api/module.html#import-from-https\n */\n\ntype ResolveContext = { parentURL?: string; conditions?: string[] };\ntype ResolveResult = {\n url: string;\n shortCircuit?: boolean;\n format?: string;\n};\ntype NextResolve = (\n specifier: string,\n context: ResolveContext,\n) => Promise<ResolveResult>;\n\ntype LoadContext = { format?: string };\ntype LoadResult = { format: string; shortCircuit?: boolean; source: string };\ntype NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;\n\n/**\n * Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.\n */\nexport async function resolve(\n specifier: string,\n context: ResolveContext,\n nextResolve: NextResolve,\n): Promise<ResolveResult> {\n const { parentURL } = context;\n\n // If the specifier is already an HTTP(S) URL, resolve it directly\n if (specifier.startsWith(\"https://\") || specifier.startsWith(\"http://\")) {\n return { url: specifier, shortCircuit: true, format: \"module\" };\n }\n\n // If the parent is an HTTP(S) URL and specifier is relative, resolve against it.\n // Only handle relative specifiers (./ or ../), not bare package specifiers.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\")) &&\n (specifier.startsWith(\"./\") || specifier.startsWith(\"../\"))\n ) {\n const resolved = new URL(specifier, parentURL).href;\n return { url: resolved, shortCircuit: true, format: \"module\" };\n }\n\n // Bare specifiers from HTTP modules need a node_modules root to resolve\n // against. Under pnpm's strict isolation the deps a registry-built bundle\n // needs split into two classes:\n // - Peer deps the *consumer* declared (react, react-dom, graphql, …) —\n // live at the consumer project root.\n // - Things reactor-api keeps external by design (the reactor-api package\n // itself, for class identity; internal helpers) — live in reactor-api's\n // own tree.\n // Neither root sees the other under strict mode, so try the consumer first\n // (its declared peers win on version) and fall back to reactor-api's tree.\n //\n // At this point: specifier is not an http(s):// URL (branch 1) and not\n // relative (branch 2). Only redirect bare package specifiers; let absolute\n // paths and other URL schemes (e.g. \"node:fs\", \"file://…\") fall through.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\"))\n ) {\n const isBareSpecifier =\n !specifier.startsWith(\"/\") && !/^[a-z][a-z0-9+.-]*:/i.test(specifier);\n if (isBareSpecifier) {\n const consumerRoot = pathToFileURL(process.cwd() + \"/\").href;\n try {\n return await nextResolve(specifier, {\n ...context,\n parentURL: consumerRoot,\n });\n } catch (e) {\n const code = (e as NodeJS.ErrnoException | undefined)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\") throw e;\n return nextResolve(specifier, {\n ...context,\n parentURL: import.meta.url,\n });\n }\n }\n }\n\n // Let Node.js handle all other specifiers\n return nextResolve(specifier, context);\n}\n\n/**\n * Load hook: fetches module source from HTTP/HTTPS URLs.\n */\nexport async function load(\n url: string,\n context: LoadContext,\n nextLoad: NextLoad,\n): Promise<LoadResult> {\n // Handle HTTPS URLs\n if (url.startsWith(\"https://\")) {\n const source = await fetchModule(url, get);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Handle HTTP URLs (for local development)\n if (url.startsWith(\"http://\")) {\n const source = await fetchModule(url, httpGet);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Let Node.js handle all other URLs\n return nextLoad(url, context);\n}\n\n/**\n * Rewrite `createRequire(import.meta.url)` in HTTP-loaded modules so that\n * `createRequire` receives a local file URL instead of an HTTP URL it cannot handle.\n *\n * The base is baked in at hook time as a string literal. Injecting a live\n * `process.cwd()` call into the module source (the previous approach) crashes\n * with \"process.cwd is not a function\": HTTP-loaded modules execute in the\n * module-customization realm, which has no full `process`. This hook itself\n * runs where `process.cwd()` works, so we resolve the base here and embed the\n * resulting file URL as a literal — no runtime `process` access in the loaded\n * module. Any package whose bundle contains `createRequire(import.meta.url)`\n * (common CJS interop) failed to load before this.\n */\nfunction patchCreateRequire(source: string): string {\n const requireBase = pathToFileURL(process.cwd() + \"/\").href;\n return source.replace(\n /createRequire\\(import\\.meta\\.url\\)/g,\n `createRequire(${JSON.stringify(requireBase)})`,\n );\n}\n\nfunction fetchModule(\n url: string,\n getter: typeof get | typeof httpGet,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n getter(url, (res) => {\n // Handle redirects\n if (\n res.statusCode &&\n res.statusCode >= 300 &&\n res.statusCode < 400 &&\n res.headers.location\n ) {\n const redirectUrl = res.headers.location;\n const redirectGetter = redirectUrl.startsWith(\"https://\")\n ? get\n : httpGet;\n fetchModule(redirectUrl, redirectGetter).then(resolve).catch(reject);\n return;\n }\n\n if (res.statusCode && res.statusCode >= 400) {\n reject(new Error(`Failed to fetch ${url}: ${res.statusCode}`));\n return;\n }\n\n let data = \"\";\n res.setEncoding(\"utf8\");\n res.on(\"data\", (chunk) => (data += chunk));\n res.on(\"end\", () => resolve(data));\n res.on(\"error\", reject);\n }).on(\"error\", reject);\n });\n}\n\n/**\n * Path to this hooks file for use with node:module register()\n */\nexport const httpsHooksPath: string = import.meta.url;\n"],"names":["get","httpGet"],"mappings":";;;;;;;;;AA2BA,eAAsB,QACpB,WACA,SACA,aACwB;CACxB,MAAM,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"https-hooks.mjs","sources":["../../../src/packages/https-hooks.mts"],"sourcesContent":["import { get as httpGet } from \"node:http\";\nimport { get } from \"node:https\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Node.js module loader hooks that enable importing from HTTP/HTTPS URLs.\n * See: https://nodejs.org/docs/latest-v24.x/api/module.html#import-from-https\n */\n\ntype ResolveContext = { parentURL?: string; conditions?: string[] };\ntype ResolveResult = {\n url: string;\n shortCircuit?: boolean;\n format?: string;\n};\ntype NextResolve = (\n specifier: string,\n context: ResolveContext,\n) => Promise<ResolveResult>;\n\ntype LoadContext = { format?: string };\ntype LoadResult = { format: string; shortCircuit?: boolean; source: string };\ntype NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;\n\n/**\n * Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.\n */\nexport async function resolve(\n specifier: string,\n context: ResolveContext,\n nextResolve: NextResolve,\n): Promise<ResolveResult> {\n const { parentURL } = context;\n\n // If the specifier is already an HTTP(S) URL, resolve it directly\n if (specifier.startsWith(\"https://\") || specifier.startsWith(\"http://\")) {\n return { url: specifier, shortCircuit: true, format: \"module\" };\n }\n\n // If the parent is an HTTP(S) URL and specifier is relative, resolve against it.\n // Only handle relative specifiers (./ or ../), not bare package specifiers.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\")) &&\n (specifier.startsWith(\"./\") || specifier.startsWith(\"../\"))\n ) {\n const resolved = new URL(specifier, parentURL).href;\n return { url: resolved, shortCircuit: true, format: \"module\" };\n }\n\n // Bare specifiers from HTTP modules need a node_modules root to resolve\n // against. Under pnpm's strict isolation the deps a registry-built bundle\n // needs split into two classes:\n // - Peer deps the *consumer* declared (react, react-dom, graphql, …) —\n // live at the consumer project root.\n // - Things reactor-api keeps external by design (the reactor-api package\n // itself, for class identity; internal helpers) — live in reactor-api's\n // own tree.\n // Neither root sees the other under strict mode, so try the consumer first\n // (its declared peers win on version) and fall back to reactor-api's tree.\n //\n // At this point: specifier is not an http(s):// URL (branch 1) and not\n // relative (branch 2). Only redirect bare package specifiers; let absolute\n // paths and other URL schemes (e.g. \"node:fs\", \"file://…\") fall through.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\"))\n ) {\n const isBareSpecifier =\n !specifier.startsWith(\"/\") && !/^[a-z][a-z0-9+.-]*:/i.test(specifier);\n if (isBareSpecifier) {\n const consumerRoot = pathToFileURL(process.cwd() + \"/\").href;\n try {\n return await nextResolve(specifier, {\n ...context,\n parentURL: consumerRoot,\n });\n } catch (e) {\n const code = (e as NodeJS.ErrnoException | undefined)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\") throw e;\n return nextResolve(specifier, {\n ...context,\n parentURL: import.meta.url,\n });\n }\n }\n }\n\n // Let Node.js handle all other specifiers\n return nextResolve(specifier, context);\n}\n\n/**\n * Load hook: fetches module source from HTTP/HTTPS URLs.\n */\nexport async function load(\n url: string,\n context: LoadContext,\n nextLoad: NextLoad,\n): Promise<LoadResult> {\n // Handle HTTPS URLs\n if (url.startsWith(\"https://\")) {\n const source = await fetchModule(url, get);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Handle HTTP URLs (for local development)\n if (url.startsWith(\"http://\")) {\n const source = await fetchModule(url, httpGet);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Let Node.js handle all other URLs\n return nextLoad(url, context);\n}\n\n/**\n * Rewrite `createRequire(import.meta.url)` in HTTP-loaded modules so that\n * `createRequire` receives a local file URL instead of an HTTP URL it cannot handle.\n *\n * The base is baked in at hook time as a string literal. Injecting a live\n * `process.cwd()` call into the module source (the previous approach) crashes\n * with \"process.cwd is not a function\": HTTP-loaded modules execute in the\n * module-customization realm, which has no full `process`. This hook itself\n * runs where `process.cwd()` works, so we resolve the base here and embed the\n * resulting file URL as a literal — no runtime `process` access in the loaded\n * module. Any package whose bundle contains `createRequire(import.meta.url)`\n * (common CJS interop) failed to load before this.\n */\nfunction patchCreateRequire(source: string): string {\n const requireBase = pathToFileURL(process.cwd() + \"/\").href;\n return source.replace(\n /createRequire\\(import\\.meta\\.url\\)/g,\n `createRequire(${JSON.stringify(requireBase)})`,\n );\n}\n\nfunction fetchModule(\n url: string,\n getter: typeof get | typeof httpGet,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n getter(url, (res) => {\n // Handle redirects\n if (\n res.statusCode &&\n res.statusCode >= 300 &&\n res.statusCode < 400 &&\n res.headers.location\n ) {\n const redirectUrl = res.headers.location;\n const redirectGetter = redirectUrl.startsWith(\"https://\")\n ? get\n : httpGet;\n fetchModule(redirectUrl, redirectGetter).then(resolve).catch(reject);\n return;\n }\n\n if (res.statusCode && res.statusCode >= 400) {\n reject(new Error(`Failed to fetch ${url}: ${res.statusCode}`));\n return;\n }\n\n let data = \"\";\n res.setEncoding(\"utf8\");\n res.on(\"data\", (chunk) => (data += chunk));\n res.on(\"end\", () => resolve(data));\n res.on(\"error\", reject);\n }).on(\"error\", reject);\n });\n}\n\n/**\n * Path to this hooks file for use with node:module register()\n */\nexport const httpsHooksPath: string = import.meta.url;\n"],"names":["get","httpGet"],"mappings":";;;;;;;;;AA2BA,eAAsB,QACpB,WACA,SACA,aACwB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CACA,iBAAiB,KAAK,UAAU,WAAW,EAAE,EAC/C;AACF;AAEA,SAAS,YACP,KACA,QACiB;CACjB,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,OAAO,MAAM,QAAQ;GAEnB,IACE,IAAI,cACJ,IAAI,cAAc,OAClB,IAAI,aAAa,OACjB,IAAI,QAAQ,UACZ;IACA,MAAM,cAAc,IAAI,QAAQ;IAIhC,YAAY,aAHW,YAAY,WAAW,UAAU,IACpDD,QACAC,GACmC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,MAAM,MAAM;IACnE;GACF;GAEA,IAAI,IAAI,cAAc,IAAI,cAAc,KAAK;IAC3C,uBAAO,IAAI,MAAM,mBAAmB,IAAI,IAAI,IAAI,YAAY,CAAC;IAC7D;GACF;GAEA,IAAI,OAAO;GACX,IAAI,YAAY,MAAM;GACtB,IAAI,GAAG,SAAS,UAAW,QAAQ,KAAM;GACzC,IAAI,GAAG,aAAa,QAAQ,IAAI,CAAC;GACjC,IAAI,GAAG,SAAS,MAAM;EACxB,CAAC,CAAC,CAAC,GAAG,SAAS,MAAM;CACvB,CAAC;AACH;;;;AAKA,MAAa,iBAAyB,YAAY","debug_id":"8149a6c4-bab0-57e3-a471-cfc77d529bbf"}
|
|
@@ -1,30 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ILogger } from "document-model";
|
|
1
|
+
import { o as ISubscribablePackageLoader, s as ISubscriptionOptions, u as PackagePieceEntry } from "../../types-DlTiz6AA.mjs";
|
|
3
2
|
import { DocumentModelModule, UpgradeManifest } from "@powerhousedao/shared/document-model";
|
|
3
|
+
import { ILogger } from "document-model";
|
|
4
4
|
import { Logger, ViteDevServer } from "vite";
|
|
5
5
|
import { ProcessorFactoryBuilder, SubgraphClass } from "@powerhousedao/reactor-api";
|
|
6
|
-
|
|
7
6
|
//#region src/packages/vite-loader.d.mts
|
|
8
|
-
declare function createViteLogger(logger: ILogger, prefix?: string): Logger;
|
|
9
|
-
|
|
7
|
+
export declare function createViteLogger(logger: ILogger, prefix?: string): Logger;
|
|
8
|
+
export interface VitePackageLoaderOptions {
|
|
9
|
+
/** Modules, as paths or file URLs, whose dependencies a package the project
|
|
10
|
+
* does not install may resolve from. This loader's own module always is. */
|
|
11
|
+
resolveFrom?: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare class VitePackageLoader implements ISubscribablePackageLoader {
|
|
10
14
|
#private;
|
|
11
15
|
private readonly logger;
|
|
12
16
|
private readonly vite;
|
|
17
|
+
private readonly importers;
|
|
13
18
|
readonly name = "VitePackageLoader";
|
|
14
|
-
static build(vite: ViteDevServer): VitePackageLoader;
|
|
15
|
-
constructor(vite: ViteDevServer);
|
|
19
|
+
static build(vite: ViteDevServer, options?: VitePackageLoaderOptions): VitePackageLoader;
|
|
20
|
+
constructor(vite: ViteDevServer, options?: VitePackageLoaderOptions);
|
|
16
21
|
private getDocumentModelsPath;
|
|
17
22
|
private getSubgraphsPath;
|
|
18
23
|
private getProcessorsPath;
|
|
24
|
+
private getPiecesPath;
|
|
25
|
+
private aliasedRoot;
|
|
26
|
+
private pieceRoot;
|
|
19
27
|
loadDocumentModels(identifier: string, immediate?: boolean): Promise<DocumentModelModule[]>;
|
|
20
28
|
loadUpgradeManifests(identifier: string): Promise<UpgradeManifest<readonly number[]>[]>;
|
|
21
29
|
loadSubgraphs(identifier: string): Promise<SubgraphClass[]>;
|
|
22
30
|
loadProcessors(identifier: string): Promise<ProcessorFactoryBuilder | null>;
|
|
31
|
+
loadPieces(identifier: string): Promise<PackagePieceEntry[]>;
|
|
23
32
|
onDocumentModelsChange(identifier: string, handler: (documentModels: DocumentModelModule[]) => void, options?: ISubscriptionOptions): () => void;
|
|
24
33
|
onSubgraphsChange(identifier: string, handler: (subgraphs: SubgraphClass[]) => void, options?: ISubscriptionOptions): () => void;
|
|
25
34
|
onProcessorsChange(identifier: string, handler: (processors: ProcessorFactoryBuilder | null) => void, options?: ISubscriptionOptions): () => void;
|
|
35
|
+
onPiecesChange(identifier: string, handler: (pieces: PackagePieceEntry[]) => void, options?: ISubscriptionOptions): () => void;
|
|
26
36
|
}
|
|
27
|
-
declare function startViteServer(root: string, logger?: Logger): Promise<ViteDevServer>;
|
|
37
|
+
export declare function startViteServer(root: string, logger?: Logger): Promise<ViteDevServer>;
|
|
28
38
|
//#endregion
|
|
29
|
-
export {
|
|
39
|
+
export {};
|
|
30
40
|
//# sourceMappingURL=vite-loader.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-loader.d.mts","names":[],"sources":["../../../src/packages/vite-loader.mts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-loader.d.mts","names":[],"sources":["../../../src/packages/vite-loader.mts"],"mappings":";;;;;;wBA+BgB,iBAAiB,QAAQ,SAAS,kBAAW;iBA2B5C;;;EAGf;;qBAQW,6BAA6B;;mBACvB;mBAEA;mBAEA;WAER;SAEF,MAAM,MAAM,eAAe,UAAU,2BAAwB;EAIpE,YAAY,MAAM,eAAe,UAAS;UAyDlC;UAIA;UAIA;UAIA;UAMA;UASA;EAcD,mBAAmB,oBAAoB,sBAAiB,QAAA;EA0BzD,qBACJ,qBACC,QAAQ;EAoBL,cAAc,qBAAqB,QAAQ;EAiB3C,eACJ,qBACC,QAAQ;EAkBL,WAAW,qBAAqB,QAAQ;EAsB9C,uBACE,oBACA,UAAU,gBAAgB,gCAC1B,UAAU;EAwBZ,kBACE,oBACA,UAAU,WAAW,0BACrB,UAAU;EAuBZ,mBACE,oBACA,UAAU,YAAY,yCACtB,UAAU;EAuBZ,eACE,oBACA,UAAU,QAAQ,8BAClB,UAAU;;wBA2BQ,gBAAgB,cAAc,SAAS,SAAM,QAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { a as
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="647a32d0-3e32-5241-8c60-6c1d9d1e7ec5")}catch(e){}}();
|
|
3
|
+
import { _ as isSubpath, a as packageRootOf, c as piecesFromListModule, g as extractUpgradeManifests, h as debounce, l as extractDocumentModels, n as BUILT_PIECE_LIST, o as pieceListLocation, r as PIECES_SUBPATH, t as extractSubgraphs } from "../../subgraph-extraction-DTFoN_bS.mjs";
|
|
4
4
|
import { childLogger } from "document-model";
|
|
5
5
|
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
|
|
7
8
|
import { readPackage } from "read-pkg";
|
|
8
9
|
import { createLogger, createServer } from "vite";
|
|
@@ -17,12 +18,42 @@ function createViteLogger(logger, prefix = "") {
|
|
|
17
18
|
var VitePackageLoader = class VitePackageLoader {
|
|
18
19
|
logger = childLogger(["reactor-api", "vite-loader"]);
|
|
19
20
|
vite;
|
|
21
|
+
importers;
|
|
20
22
|
name = "VitePackageLoader";
|
|
21
|
-
static build(vite) {
|
|
22
|
-
return new VitePackageLoader(vite);
|
|
23
|
+
static build(vite, options) {
|
|
24
|
+
return new VitePackageLoader(vite, options);
|
|
23
25
|
}
|
|
24
|
-
constructor(vite) {
|
|
26
|
+
constructor(vite, options = {}) {
|
|
25
27
|
this.vite = vite;
|
|
28
|
+
this.importers = [...options.resolveFrom ?? [], import.meta.url].map((from) => from.startsWith("file:") ? fileURLToPath(from) : from);
|
|
29
|
+
}
|
|
30
|
+
async #resolve(identifier, subpath) {
|
|
31
|
+
const aliased = path.isAbsolute(identifier) ? void 0 : this.aliasedRoot(identifier);
|
|
32
|
+
const specifier = path.posix.join(aliased ?? identifier, subpath);
|
|
33
|
+
const importers = !aliased && !path.isAbsolute(identifier) ? [void 0, ...this.importers] : [void 0];
|
|
34
|
+
const container = this.vite.environments.ssr.pluginContainer;
|
|
35
|
+
for (const importer of importers) try {
|
|
36
|
+
const resolved = await container.resolveId(specifier, importer);
|
|
37
|
+
if (resolved && !resolved.external) return resolved.id;
|
|
38
|
+
} catch (e) {
|
|
39
|
+
this.logger.debug("Could not resolve @specifier: @error", specifier, e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async #load(identifier, subpath) {
|
|
43
|
+
const id = await this.#resolve(identifier, subpath);
|
|
44
|
+
if (id === void 0) {
|
|
45
|
+
this.logger.debug("No @subpath module in @pkg", subpath, identifier);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
return {
|
|
50
|
+
id,
|
|
51
|
+
namespace: await this.vite.ssrLoadModule(id)
|
|
52
|
+
};
|
|
53
|
+
} catch (e) {
|
|
54
|
+
this.logger.error("Failed to load @subpath of @pkg from @id: @error", subpath, identifier, id, e instanceof Error ? e.message : e);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
26
57
|
}
|
|
27
58
|
getDocumentModelsPath(identifier) {
|
|
28
59
|
return path.posix.join(identifier, "./document-models");
|
|
@@ -33,74 +64,89 @@ var VitePackageLoader = class VitePackageLoader {
|
|
|
33
64
|
getProcessorsPath(identifier) {
|
|
34
65
|
return path.posix.join(identifier, "./processors");
|
|
35
66
|
}
|
|
67
|
+
getPiecesPath(identifier) {
|
|
68
|
+
return path.posix.join(identifier, `./${PIECES_SUBPATH}`);
|
|
69
|
+
}
|
|
70
|
+
aliasedRoot(identifier) {
|
|
71
|
+
const alias = this.vite.config.resolve.alias;
|
|
72
|
+
const hit = (Array.isArray(alias) ? alias : []).find((entry) => entry.find === identifier);
|
|
73
|
+
return typeof hit?.replacement === "string" ? hit.replacement : void 0;
|
|
74
|
+
}
|
|
75
|
+
pieceRoot(identifier, listId) {
|
|
76
|
+
if (!path.isAbsolute(identifier)) {
|
|
77
|
+
const aliased = this.aliasedRoot(identifier);
|
|
78
|
+
if (aliased) return aliased;
|
|
79
|
+
if (listId) return packageRootOf(path.dirname(listId));
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
return pieceListLocation(identifier).root;
|
|
83
|
+
} catch {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
36
87
|
loadDocumentModels(identifier, immediate = false) {
|
|
37
88
|
return this.#loadDocumentModelsWithDebounce(immediate, identifier);
|
|
38
89
|
}
|
|
39
90
|
#loadDocumentModelsWithDebounce = debounce(this.#loadDocumentModels.bind(this), 500);
|
|
40
91
|
async #loadDocumentModels(identifier) {
|
|
41
|
-
|
|
42
|
-
this
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
for (const dm of exports) if (dm.documentModel) documentModels.push(dm);
|
|
48
|
-
this.logger.verbose(` ➜ Loaded ${documentModels.length} Document Models from: ${identifier}`);
|
|
49
|
-
return documentModels;
|
|
50
|
-
} catch (e) {
|
|
51
|
-
this.logger.debug(` ➜ No Document Models found for: ${identifier}`, e);
|
|
52
|
-
}
|
|
53
|
-
return [];
|
|
92
|
+
this.logger.debug("Loading document models from", this.getDocumentModelsPath(identifier));
|
|
93
|
+
const loaded = await this.#load(identifier, "document-models");
|
|
94
|
+
if (!loaded) return [];
|
|
95
|
+
const documentModels = extractDocumentModels(loaded.namespace);
|
|
96
|
+
this.logger.verbose(` ➜ Loaded ${documentModels.length} Document Models from: ${identifier}`);
|
|
97
|
+
return documentModels;
|
|
54
98
|
}
|
|
55
99
|
async loadUpgradeManifests(identifier) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
100
|
+
for (const subpath of ["document-models", "document-models/upgrade-manifests"]) {
|
|
101
|
+
const loaded = await this.#load(identifier, subpath);
|
|
102
|
+
if (!loaded) continue;
|
|
103
|
+
const manifests = extractUpgradeManifests(loaded.namespace);
|
|
59
104
|
if (manifests.length > 0) {
|
|
60
105
|
this.logger.verbose(` ➜ Loaded ${manifests.length} Upgrade Manifests from: ${identifier}`);
|
|
61
106
|
return manifests;
|
|
62
107
|
}
|
|
63
|
-
} catch (e) {
|
|
64
|
-
this.logger.debug(` ➜ No Upgrade Manifests found at ${fullPath} for: ${identifier}`, e);
|
|
65
108
|
}
|
|
66
109
|
return [];
|
|
67
110
|
}
|
|
68
111
|
async loadSubgraphs(identifier) {
|
|
69
|
-
|
|
70
|
-
this
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
localSubgraphs = await this.vite.ssrLoadModule(fullPath);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
this.logger.debug(` ➜ No Subgraphs found for: ${identifier}`, e);
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
const subgraphs = [];
|
|
79
|
-
for (const [name, subgraph] of Object.entries(localSubgraphs)) {
|
|
80
|
-
const SubgraphClass = subgraph[name];
|
|
81
|
-
if (isSubgraphClass(SubgraphClass)) subgraphs.push(SubgraphClass);
|
|
82
|
-
}
|
|
112
|
+
this.logger.verbose("Loading subgraphs from", this.getSubgraphsPath(identifier));
|
|
113
|
+
const loaded = await this.#load(identifier, "subgraphs");
|
|
114
|
+
if (!loaded) return [];
|
|
115
|
+
const subgraphs = extractSubgraphs(loaded.namespace);
|
|
83
116
|
this.logger.debug(` ➜ Loaded ${subgraphs.length} Subgraphs from: ${identifier}`);
|
|
84
117
|
return subgraphs;
|
|
85
118
|
}
|
|
86
119
|
async loadProcessors(identifier) {
|
|
87
|
-
|
|
88
|
-
this
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.logger.verbose(` ➜ Loaded Processor Factory from: ${identifier}`);
|
|
93
|
-
return factory;
|
|
94
|
-
}
|
|
95
|
-
} catch (e) {
|
|
96
|
-
this.logger.debug(` ➜ No Processor Factory found for: ${identifier}`, e);
|
|
120
|
+
this.logger.verbose("Loading processors from", this.getProcessorsPath(identifier));
|
|
121
|
+
const factory = (await this.#load(identifier, "processors"))?.namespace.processorFactory;
|
|
122
|
+
if (typeof factory === "function") {
|
|
123
|
+
this.logger.verbose(` ➜ Loaded Processor Factory from: ${identifier}`);
|
|
124
|
+
return factory;
|
|
97
125
|
}
|
|
98
126
|
this.logger.verbose(` ➜ No Processor Factory found for: ${identifier}`);
|
|
99
127
|
return null;
|
|
100
128
|
}
|
|
129
|
+
async loadPieces(identifier) {
|
|
130
|
+
this.logger.verbose("Loading pieces from", this.getPiecesPath(identifier));
|
|
131
|
+
const loaded = await this.#load(identifier, PIECES_SUBPATH);
|
|
132
|
+
if (!loaded) return [];
|
|
133
|
+
const root = this.pieceRoot(identifier, loaded.id);
|
|
134
|
+
if (root === void 0) {
|
|
135
|
+
this.logger.debug(` ➜ No package root found for: ${identifier}`);
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
const pieces = piecesFromListModule(loaded.namespace, {
|
|
139
|
+
root,
|
|
140
|
+
identifier,
|
|
141
|
+
logger: this.logger
|
|
142
|
+
});
|
|
143
|
+
this.logger.debug(` ➜ Loaded ${pieces.length} Pieces from: ${identifier}`);
|
|
144
|
+
return pieces;
|
|
145
|
+
}
|
|
101
146
|
onDocumentModelsChange(identifier, handler, options) {
|
|
102
147
|
const listener = async (changedPath) => {
|
|
103
|
-
|
|
148
|
+
const documentModelsPath = this.getDocumentModelsPath(identifier);
|
|
149
|
+
if (isSubpath(documentModelsPath, changedPath)) handler(await this.loadDocumentModels(identifier));
|
|
104
150
|
};
|
|
105
151
|
this.vite.watcher.on("change", listener);
|
|
106
152
|
this.vite.watcher.on("add", listener);
|
|
@@ -139,8 +185,26 @@ var VitePackageLoader = class VitePackageLoader {
|
|
|
139
185
|
this.vite.watcher.off("unlink", listener);
|
|
140
186
|
};
|
|
141
187
|
}
|
|
188
|
+
onPiecesChange(identifier, handler, options) {
|
|
189
|
+
const watched = [this.getPiecesPath(identifier)];
|
|
190
|
+
const root = this.pieceRoot(identifier);
|
|
191
|
+
if (root !== void 0) watched.push(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));
|
|
192
|
+
const listener = async (changedPath) => {
|
|
193
|
+
if (!watched.some((dir) => isSubpath(dir, changedPath))) return;
|
|
194
|
+
handler(await this.loadPieces(identifier));
|
|
195
|
+
};
|
|
196
|
+
this.vite.watcher.on("change", listener);
|
|
197
|
+
this.vite.watcher.on("add", listener);
|
|
198
|
+
this.vite.watcher.on("unlink", listener);
|
|
199
|
+
return () => {
|
|
200
|
+
this.vite.watcher.off("change", listener);
|
|
201
|
+
this.vite.watcher.off("add", listener);
|
|
202
|
+
this.vite.watcher.off("unlink", listener);
|
|
203
|
+
};
|
|
204
|
+
}
|
|
142
205
|
};
|
|
143
206
|
async function startViteServer(root, logger) {
|
|
207
|
+
const packageJson = await readPackage({ cwd: root });
|
|
144
208
|
return await createServer({
|
|
145
209
|
root,
|
|
146
210
|
configFile: false,
|
|
@@ -153,7 +217,7 @@ async function startViteServer(root, logger) {
|
|
|
153
217
|
build: { rollupOptions: { input: [] } },
|
|
154
218
|
resolve: {
|
|
155
219
|
tsconfigPaths: true,
|
|
156
|
-
alias: { [
|
|
220
|
+
alias: { [packageJson.name]: root }
|
|
157
221
|
},
|
|
158
222
|
plugins: [viteCommonjs(), {
|
|
159
223
|
name: "suppress-hmr",
|
|
@@ -167,4 +231,4 @@ async function startViteServer(root, logger) {
|
|
|
167
231
|
export { VitePackageLoader, createViteLogger, startViteServer };
|
|
168
232
|
|
|
169
233
|
//# sourceMappingURL=vite-loader.mjs.map
|
|
170
|
-
//# debugId=
|
|
234
|
+
//# debugId=647a32d0-3e32-5241-8c60-6c1d9d1e7ec5
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-loader.mjs","sources":["../../../src/packages/vite-loader.mts"],"sourcesContent":["import { viteCommonjs } from \"@originjs/vite-plugin-commonjs\";\nimport type {\n ProcessorFactoryBuilder,\n SubgraphClass,\n} from \"@powerhousedao/reactor-api\";\nimport type {\n DocumentModelModule,\n UpgradeManifest,\n} from \"@powerhousedao/shared/document-model\";\nimport { childLogger, type ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport { readPackage } from \"read-pkg\";\nimport type { Logger, PluginOption, ViteDevServer } from \"vite\";\nimport { createLogger, createServer } from \"vite\";\nimport { isSubgraphClass } from \"../graphql/utils.js\";\nimport type {\n ISubscribablePackageLoader,\n ISubscriptionOptions,\n} from \"./types.js\";\nimport { debounce, extractUpgradeManifests, isSubpath } from \"./util.js\";\n\nexport function createViteLogger(logger: ILogger, prefix = \"\") {\n const customLogger = createLogger(\"info\", {\n prefix,\n });\n // Wrapped rather than assigned: the logger methods are bound to their own\n // instance, and re-homing them onto Vite's logger object made every Vite\n // log line throw.\n //\n // Vite's text goes through as a replacement, never as the format string: it\n // is somebody else's prose, not a template. `ILogger` substitutes `@token`,\n // and Vite log lines are full of npm scopes, so `pre-transforming\n // @powerhousedao/design-system` came out as `pre-transforming\n // null/design-system`. Substituting into `@line` instead emits it verbatim.\n //\n // Vite's second argument is dropped for the same reason. It is `LogOptions`\n // -- `{ clear, timestamp }` -- and forwarding it made it the replacement for\n // whatever `@token` the line happened to contain, or got appended as JSON.\n // Only `error` keeps it, where it carries the error itself.\n customLogger.info = (msg) => logger.info(\"@line\", msg);\n customLogger.warn = (msg) => logger.warn(\"@line\", msg);\n customLogger.error = (msg, options) =>\n options?.error\n ? logger.error(\"@line\", msg, options.error)\n : logger.error(\"@line\", msg);\n return customLogger;\n}\n\nexport class VitePackageLoader implements ISubscribablePackageLoader {\n private readonly logger = childLogger([\"reactor-api\", \"vite-loader\"]);\n\n private readonly vite: ViteDevServer;\n\n readonly name = \"VitePackageLoader\";\n\n static build(vite: ViteDevServer) {\n return new VitePackageLoader(vite);\n }\n\n constructor(vite: ViteDevServer) {\n this.vite = vite;\n }\n\n private getDocumentModelsPath(identifier: string): string {\n return path.posix.join(identifier, \"./document-models\");\n }\n\n private getSubgraphsPath(identifier: string): string {\n return path.posix.join(identifier, \"./subgraphs\");\n }\n\n private getProcessorsPath(identifier: string): string {\n return path.posix.join(identifier, \"./processors\");\n }\n\n public loadDocumentModels(identifier: string, immediate = false) {\n return this.#loadDocumentModelsWithDebounce(immediate, identifier);\n }\n\n #loadDocumentModelsWithDebounce = debounce(\n this.#loadDocumentModels.bind(this),\n 500,\n );\n\n async #loadDocumentModels(\n identifier: string,\n ): Promise<DocumentModelModule[]> {\n const fullPath = this.getDocumentModelsPath(identifier);\n this.logger.debug(\"Loading document models from\", fullPath);\n\n try {\n const localDMs = (await this.vite.ssrLoadModule(fullPath)) as Record<\n string,\n DocumentModelModule\n >;\n\n const exports = Object.values(localDMs);\n\n // duck type\n const documentModels: DocumentModelModule[] = [];\n for (const dm of exports) {\n if (dm.documentModel) {\n documentModels.push(dm);\n }\n }\n\n this.logger.verbose(\n ` ➜ Loaded ${documentModels.length} Document Models from: ${identifier}`,\n );\n\n return documentModels;\n } catch (e) {\n this.logger.debug(` ➜ No Document Models found for: ${identifier}`, e);\n }\n\n return [];\n }\n\n async loadUpgradeManifests(\n identifier: string,\n ): Promise<UpgradeManifest<readonly number[]>[]> {\n // Projects generated before the aggregate index re-exported the\n // manifests only expose them at document-models/upgrade-manifests, so\n // try both without requiring a regeneration.\n const candidatePaths = [\n this.getDocumentModelsPath(identifier),\n path.posix.join(this.getDocumentModelsPath(identifier), \"upgrade-manifests\"),\n ];\n for (const fullPath of candidatePaths) {\n try {\n const namespace = (await this.vite.ssrLoadModule(fullPath)) as Record<\n string,\n unknown\n >;\n const manifests = extractUpgradeManifests(namespace);\n if (manifests.length > 0) {\n this.logger.verbose(\n ` ➜ Loaded ${manifests.length} Upgrade Manifests from: ${identifier}`,\n );\n return manifests;\n }\n } catch (e) {\n this.logger.debug(\n ` ➜ No Upgrade Manifests found at ${fullPath} for: ${identifier}`,\n e,\n );\n }\n }\n return [];\n }\n\n async loadSubgraphs(identifier: string): Promise<SubgraphClass[]> {\n const fullPath = this.getSubgraphsPath(identifier);\n\n this.logger.verbose(\"Loading subgraphs from\", fullPath);\n\n let localSubgraphs: Record<string, Record<string, SubgraphClass>> = {};\n try {\n localSubgraphs = await this.vite.ssrLoadModule(fullPath);\n } catch (e) {\n this.logger.debug(` ➜ No Subgraphs found for: ${identifier}`, e);\n return [];\n }\n\n const subgraphs: SubgraphClass[] = [];\n for (const [name, subgraph] of Object.entries(localSubgraphs)) {\n const SubgraphClass = subgraph[name];\n if (isSubgraphClass(SubgraphClass)) {\n subgraphs.push(SubgraphClass);\n }\n }\n\n this.logger.debug(\n ` ➜ Loaded ${subgraphs.length} Subgraphs from: ${identifier}`,\n );\n\n return subgraphs;\n }\n\n async loadProcessors(\n identifier: string,\n ): Promise<ProcessorFactoryBuilder | null> {\n const fullPath = this.getProcessorsPath(identifier);\n\n this.logger.verbose(\"Loading processors from\", fullPath);\n\n try {\n const pkgModule = await this.vite.ssrLoadModule(fullPath);\n\n const factory = (\n pkgModule as Record<string, ProcessorFactoryBuilder | undefined>\n )?.processorFactory;\n\n if (factory && typeof factory === \"function\") {\n this.logger.verbose(\n ` ➜ Loaded Processor Factory from: ${identifier}`,\n );\n return factory;\n }\n } catch (e) {\n this.logger.debug(\n ` ➜ No Processor Factory found for: ${identifier}`,\n e,\n );\n }\n\n this.logger.verbose(` ➜ No Processor Factory found for: ${identifier}`);\n\n // return empty processor factory\n return null;\n }\n\n onDocumentModelsChange(\n identifier: string,\n handler: (documentModels: DocumentModelModule[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const listener = async (changedPath: string) => {\n const documentModelsPath = this.getDocumentModelsPath(identifier);\n if (isSubpath(documentModelsPath, changedPath)) {\n const documentModels = await this.loadDocumentModels(identifier);\n handler(documentModels);\n }\n };\n\n // \"change\" alone misses files that are created or deleted: a removed\n // document-models/ entry would never report an empty result, and the\n // package's registered models would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n\n onSubgraphsChange(\n identifier: string,\n handler: (subgraphs: SubgraphClass[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const subgraphsPath = this.getSubgraphsPath(identifier);\n const listener = async (changedPath: string) => {\n if (isSubpath(subgraphsPath, changedPath)) {\n const subgraphs = await this.loadSubgraphs(identifier);\n handler(subgraphs);\n }\n };\n // \"change\" alone misses files that are created or deleted: a removed\n // subgraphs/ entry would never report an empty result, and the\n // package's registered subgraphs would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n\n onProcessorsChange(\n identifier: string,\n handler: (processors: ProcessorFactoryBuilder | null) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const processorsPath = this.getProcessorsPath(identifier);\n const listener = async (changedPath: string) => {\n if (isSubpath(processorsPath, changedPath)) {\n const processors = await this.loadProcessors(identifier);\n handler(processors);\n }\n };\n // \"change\" alone misses files that are created or deleted: a removed\n // processors/ entry would never report an empty result, and the\n // package's registered processor factories would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n}\n\nexport async function startViteServer(root: string, logger?: Logger) {\n const packageJson = await readPackage({ cwd: root });\n\n const vite = await createServer({\n root,\n configFile: false,\n logger,\n server: { middlewareMode: true, watch: { ignored: [\"**/.ph/**\"] } },\n appType: \"custom\",\n build: {\n rollupOptions: {\n input: [],\n },\n },\n resolve: {\n tsconfigPaths: true,\n alias: {\n [packageJson.name]: root,\n },\n },\n plugins: [\n // cast: the plugin ships types built against an older vite, and the\n // mismatched Plugin type crashes tsc 6 during assignability checking\n viteCommonjs() as PluginOption,\n {\n name: \"suppress-hmr\",\n handleHotUpdate() {\n return []; // return empty array to suppress server refresh\n },\n },\n ],\n });\n\n return vite;\n}\n"],"names":["#loadDocumentModelsWithDebounce","#loadDocumentModels"],"mappings":";;;;;;;;;AAqBA,SAAgB,iBAAiB,QAAiB,SAAS,IAAI;CAC7D,MAAM,eAAe,aAAa,QAAQ,EACxC,QACD,CAAC;AAeF,cAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,IAAI;AACtD,cAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,IAAI;AACtD,cAAa,SAAS,KAAK,YACzB,SAAS,QACL,OAAO,MAAM,SAAS,KAAK,QAAQ,MAAM,GACzC,OAAO,MAAM,SAAS,IAAI;AAChC,QAAO;;AAGT,IAAa,oBAAb,MAAa,kBAAwD;CACnE,SAA0B,YAAY,CAAC,eAAe,cAAc,CAAC;CAErE;CAEA,OAAgB;CAEhB,OAAO,MAAM,MAAqB;AAChC,SAAO,IAAI,kBAAkB,KAAK;;CAGpC,YAAY,MAAqB;AAC/B,OAAK,OAAO;;CAGd,sBAA8B,YAA4B;AACxD,SAAO,KAAK,MAAM,KAAK,YAAY,oBAAoB;;CAGzD,iBAAyB,YAA4B;AACnD,SAAO,KAAK,MAAM,KAAK,YAAY,cAAc;;CAGnD,kBAA0B,YAA4B;AACpD,SAAO,KAAK,MAAM,KAAK,YAAY,eAAe;;CAGpD,mBAA0B,YAAoB,YAAY,OAAO;AAC/D,SAAO,MAAA,+BAAqC,WAAW,WAAW;;CAGpE,kCAAkC,SAChC,MAAA,mBAAyB,KAAK,KAAK,EACnC,IACD;CAED,OAAA,mBACE,YACgC;EAChC,MAAM,WAAW,KAAK,sBAAsB,WAAW;AACvD,OAAK,OAAO,MAAM,gCAAgC,SAAS;AAE3D,MAAI;GACF,MAAM,WAAY,MAAM,KAAK,KAAK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BACE,YACA,SACA,SACY;EACZ,MAAM,iBAAiB,KAAK,kBAAkB,WAAW;EACzD,MAAM,WAAW,OAAO,gBAAwB;AAC9C,OAAI,UAAU,gBAAgB,YAAY,CAExC,SADmB,MAAM,KAAK,eAAe,WAAW,CACrC;;AAMvB,OAAK,KAAK,QAAQ,GAAG,UAAU,SAAS;AACxC,OAAK,KAAK,QAAQ,GAAG,OAAO,SAAS;AACrC,OAAK,KAAK,QAAQ,GAAG,UAAU,SAAS;AAExC,eAAa;AACX,QAAK,KAAK,QAAQ,IAAI,UAAU,SAAS;AACzC,QAAK,KAAK,QAAQ,IAAI,OAAO,SAAS;AACtC,QAAK,KAAK,QAAQ,IAAI,UAAU,SAAS;;;;AAK/C,eAAsB,gBAAgB,MAAc,QAAiB;AAiCnE,QA9Ba,MAAM,aAAa;EAC9B;EACA,YAAY;EACZ;EACA,QAAQ;GAAE,gBAAgB;GAAM,OAAO,EAAE,SAAS,CAAC,YAAY,EAAE;GAAE;EACnE,SAAS;EACT,OAAO,EACL,eAAe,EACb,OAAO,EAAE,EACV,EACF;EACD,SAAS;GACP,eAAe;GACf,OAAO,IAfS,MAAM,YAAY,EAAE,KAAK,MAAM,CAAC,EAgBjC,OAAO,MACrB;GACF;EACD,SAAS,CAGP,cAAc,EACd;GACE,MAAM;GACN,kBAAkB;AAChB,WAAO,EAAE;;GAEZ,CACF;EACF,CAAC","debug_id":"9da64ff1-d15d-5b85-94b1-f1b0dad67551"}
|
|
1
|
+
{"version":3,"file":"vite-loader.mjs","sources":["../../../src/packages/vite-loader.mts"],"sourcesContent":["import { viteCommonjs } from \"@originjs/vite-plugin-commonjs\";\nimport type {\n ProcessorFactoryBuilder,\n SubgraphClass,\n} from \"@powerhousedao/reactor-api\";\nimport type {\n DocumentModelModule,\n UpgradeManifest,\n} from \"@powerhousedao/shared/document-model\";\nimport { childLogger, type ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { readPackage } from \"read-pkg\";\nimport type { Logger, PluginOption, ViteDevServer } from \"vite\";\nimport { createLogger, createServer } from \"vite\";\nimport { extractDocumentModels } from \"./document-model-detection.js\";\nimport { extractSubgraphs } from \"./subgraph-extraction.js\";\nimport {\n BUILT_PIECE_LIST,\n PIECES_SUBPATH,\n packageRootOf,\n pieceListLocation,\n piecesFromListModule,\n} from \"./pieces.js\";\nimport type {\n ISubscribablePackageLoader,\n ISubscriptionOptions,\n PackagePieceEntry,\n} from \"./types.js\";\nimport { debounce, extractUpgradeManifests, isSubpath } from \"./util.js\";\n\nexport function createViteLogger(logger: ILogger, prefix = \"\") {\n const customLogger = createLogger(\"info\", {\n prefix,\n });\n // Wrapped rather than assigned: the logger methods are bound to their own\n // instance, and re-homing them onto Vite's logger object made every Vite\n // log line throw.\n //\n // Vite's text goes through as a replacement, never as the format string: it\n // is somebody else's prose, not a template. `ILogger` substitutes `@token`,\n // and Vite log lines are full of npm scopes, so `pre-transforming\n // @powerhousedao/design-system` came out as `pre-transforming\n // null/design-system`. Substituting into `@line` instead emits it verbatim.\n //\n // Vite's second argument is dropped for the same reason. It is `LogOptions`\n // -- `{ clear, timestamp }` -- and forwarding it made it the replacement for\n // whatever `@token` the line happened to contain, or got appended as JSON.\n // Only `error` keeps it, where it carries the error itself.\n customLogger.info = (msg) => logger.info(\"@line\", msg);\n customLogger.warn = (msg) => logger.warn(\"@line\", msg);\n customLogger.error = (msg, options) =>\n options?.error\n ? logger.error(\"@line\", msg, options.error)\n : logger.error(\"@line\", msg);\n return customLogger;\n}\n\nexport interface VitePackageLoaderOptions {\n /** Modules, as paths or file URLs, whose dependencies a package the project\n * does not install may resolve from. This loader's own module always is. */\n resolveFrom?: string[];\n}\n\ninterface LoadedModule {\n id: string;\n namespace: Record<string, unknown>;\n}\n\nexport class VitePackageLoader implements ISubscribablePackageLoader {\n private readonly logger = childLogger([\"reactor-api\", \"vite-loader\"]);\n\n private readonly vite: ViteDevServer;\n\n private readonly importers: string[];\n\n readonly name = \"VitePackageLoader\";\n\n static build(vite: ViteDevServer, options?: VitePackageLoaderOptions) {\n return new VitePackageLoader(vite, options);\n }\n\n constructor(vite: ViteDevServer, options: VitePackageLoaderOptions = {}) {\n this.vite = vite;\n this.importers = [...(options.resolveFrom ?? []), import.meta.url].map(\n (from) => (from.startsWith(\"file:\") ? fileURLToPath(from) : from),\n );\n }\n\n // The project first, then the host's own dependencies. A bare name or a path\n // Vite cannot resolve is a package without that module, not an error.\n async #resolve(identifier: string, subpath: string) {\n const aliased = path.isAbsolute(identifier)\n ? undefined\n : this.aliasedRoot(identifier);\n const specifier = path.posix.join(aliased ?? identifier, subpath);\n const bare = !aliased && !path.isAbsolute(identifier);\n const importers = bare ? [undefined, ...this.importers] : [undefined];\n const container = this.vite.environments.ssr.pluginContainer;\n for (const importer of importers) {\n try {\n const resolved = await container.resolveId(specifier, importer);\n if (resolved && !resolved.external) return resolved.id;\n } catch (e) {\n this.logger.debug(\"Could not resolve @specifier: @error\", specifier, e);\n }\n }\n return undefined;\n }\n\n // Resolved before it is loaded, so only a module that exists and fails is\n // reported; one a package does not have is a debug-level miss.\n async #load(\n identifier: string,\n subpath: string,\n ): Promise<LoadedModule | undefined> {\n const id = await this.#resolve(identifier, subpath);\n if (id === undefined) {\n this.logger.debug(\"No @subpath module in @pkg\", subpath, identifier);\n return undefined;\n }\n try {\n const namespace = (await this.vite.ssrLoadModule(id)) as Record<\n string,\n unknown\n >;\n return { id, namespace };\n } catch (e) {\n this.logger.error(\n \"Failed to load @subpath of @pkg from @id: @error\",\n subpath,\n identifier,\n id,\n e instanceof Error ? e.message : e,\n );\n return undefined;\n }\n }\n\n private getDocumentModelsPath(identifier: string): string {\n return path.posix.join(identifier, \"./document-models\");\n }\n\n private getSubgraphsPath(identifier: string): string {\n return path.posix.join(identifier, \"./subgraphs\");\n }\n\n private getProcessorsPath(identifier: string): string {\n return path.posix.join(identifier, \"./processors\");\n }\n\n private getPiecesPath(identifier: string): string {\n return path.posix.join(identifier, `./${PIECES_SUBPATH}`);\n }\n\n // The dev server aliases the local project by its own package name, so a\n // package that is this project is rooted at the source tree vite serves.\n private aliasedRoot(identifier: string): string | undefined {\n const alias = this.vite.config.resolve.alias;\n const entries = Array.isArray(alias) ? alias : [];\n const hit = entries.find((entry) => entry.find === identifier);\n return typeof hit?.replacement === \"string\" ? hit.replacement : undefined;\n }\n\n // What a declared piece path is relative to. Not the module vite loaded: a\n // list read from source still points at the built output beside it.\n private pieceRoot(identifier: string, listId?: string): string | undefined {\n if (!path.isAbsolute(identifier)) {\n const aliased = this.aliasedRoot(identifier);\n if (aliased) return aliased;\n // A built list resolved from wherever the package is installed.\n if (listId) return packageRootOf(path.dirname(listId));\n }\n try {\n return pieceListLocation(identifier).root;\n } catch {\n return undefined;\n }\n }\n\n public loadDocumentModels(identifier: string, immediate = false) {\n return this.#loadDocumentModelsWithDebounce(immediate, identifier);\n }\n\n #loadDocumentModelsWithDebounce = debounce(\n this.#loadDocumentModels.bind(this),\n 500,\n );\n\n async #loadDocumentModels(\n identifier: string,\n ): Promise<DocumentModelModule[]> {\n this.logger.debug(\n \"Loading document models from\",\n this.getDocumentModelsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"document-models\");\n if (!loaded) return [];\n\n const documentModels = extractDocumentModels(loaded.namespace);\n this.logger.verbose(\n ` ➜ Loaded ${documentModels.length} Document Models from: ${identifier}`,\n );\n return documentModels;\n }\n\n async loadUpgradeManifests(\n identifier: string,\n ): Promise<UpgradeManifest<readonly number[]>[]> {\n // Projects generated before the aggregate index re-exported the\n // manifests only expose them at document-models/upgrade-manifests.\n for (const subpath of [\n \"document-models\",\n \"document-models/upgrade-manifests\",\n ]) {\n const loaded = await this.#load(identifier, subpath);\n if (!loaded) continue;\n const manifests = extractUpgradeManifests(loaded.namespace);\n if (manifests.length > 0) {\n this.logger.verbose(\n ` ➜ Loaded ${manifests.length} Upgrade Manifests from: ${identifier}`,\n );\n return manifests;\n }\n }\n return [];\n }\n\n async loadSubgraphs(identifier: string): Promise<SubgraphClass[]> {\n this.logger.verbose(\n \"Loading subgraphs from\",\n this.getSubgraphsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"subgraphs\");\n if (!loaded) return [];\n\n const subgraphs = extractSubgraphs(loaded.namespace);\n\n this.logger.debug(\n ` ➜ Loaded ${subgraphs.length} Subgraphs from: ${identifier}`,\n );\n\n return subgraphs;\n }\n\n async loadProcessors(\n identifier: string,\n ): Promise<ProcessorFactoryBuilder | null> {\n this.logger.verbose(\n \"Loading processors from\",\n this.getProcessorsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"processors\");\n const factory = loaded?.namespace.processorFactory;\n if (typeof factory === \"function\") {\n this.logger.verbose(` ➜ Loaded Processor Factory from: ${identifier}`);\n return factory as ProcessorFactoryBuilder;\n }\n\n this.logger.verbose(` ➜ No Processor Factory found for: ${identifier}`);\n return null;\n }\n\n // The list only, never a piece: in dev it is usually the TypeScript source,\n // and what it names is still the built bundle a worker will load.\n async loadPieces(identifier: string): Promise<PackagePieceEntry[]> {\n this.logger.verbose(\"Loading pieces from\", this.getPiecesPath(identifier));\n const loaded = await this.#load(identifier, PIECES_SUBPATH);\n if (!loaded) return [];\n\n const root = this.pieceRoot(identifier, loaded.id);\n if (root === undefined) {\n this.logger.debug(` ➜ No package root found for: ${identifier}`);\n return [];\n }\n\n const pieces = piecesFromListModule(loaded.namespace, {\n root,\n identifier,\n logger: this.logger,\n });\n this.logger.debug(\n ` ➜ Loaded ${pieces.length} Pieces from: ${identifier}`,\n );\n return pieces;\n }\n\n onDocumentModelsChange(\n identifier: string,\n handler: (documentModels: DocumentModelModule[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const listener = async (changedPath: string) => {\n const documentModelsPath = this.getDocumentModelsPath(identifier);\n if (isSubpath(documentModelsPath, changedPath)) {\n const documentModels = await this.loadDocumentModels(identifier);\n handler(documentModels);\n }\n };\n\n // \"change\" alone misses files that are created or deleted: a removed\n // document-models/ entry would never report an empty result, and the\n // package's registered models would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n\n onSubgraphsChange(\n identifier: string,\n handler: (subgraphs: SubgraphClass[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const subgraphsPath = this.getSubgraphsPath(identifier);\n const listener = async (changedPath: string) => {\n if (isSubpath(subgraphsPath, changedPath)) {\n const subgraphs = await this.loadSubgraphs(identifier);\n handler(subgraphs);\n }\n };\n // \"change\" alone misses files that are created or deleted: a removed\n // subgraphs/ entry would never report an empty result, and the\n // package's registered subgraphs would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n\n onProcessorsChange(\n identifier: string,\n handler: (processors: ProcessorFactoryBuilder | null) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const processorsPath = this.getProcessorsPath(identifier);\n const listener = async (changedPath: string) => {\n if (isSubpath(processorsPath, changedPath)) {\n const processors = await this.loadProcessors(identifier);\n handler(processors);\n }\n };\n // \"change\" alone misses files that are created or deleted: a removed\n // processors/ entry would never report an empty result, and the\n // package's registered processor factories would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n\n onPiecesChange(\n identifier: string,\n handler: (pieces: PackagePieceEntry[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n // Both the source list and the build output: the list says which pieces a\n // package ships, and only the build decides whether one is there to run.\n const watched = [this.getPiecesPath(identifier)];\n const root = this.pieceRoot(identifier);\n if (root !== undefined) {\n watched.push(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));\n }\n const listener = async (changedPath: string) => {\n if (!watched.some((dir) => isSubpath(dir, changedPath))) return;\n handler(await this.loadPieces(identifier));\n };\n // \"change\" alone misses files that are created or deleted, and a piece\n // appearing for the first time is exactly the build this watches for.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n}\n\nexport async function startViteServer(root: string, logger?: Logger) {\n const packageJson = await readPackage({ cwd: root });\n\n const vite = await createServer({\n root,\n configFile: false,\n logger,\n server: { middlewareMode: true, watch: { ignored: [\"**/.ph/**\"] } },\n appType: \"custom\",\n build: {\n rollupOptions: {\n input: [],\n },\n },\n resolve: {\n tsconfigPaths: true,\n alias: {\n [packageJson.name]: root,\n },\n },\n plugins: [\n // cast: the plugin ships types built against an older vite, and the\n // mismatched Plugin type crashes tsc 6 during assignability checking\n viteCommonjs() as PluginOption,\n {\n name: \"suppress-hmr\",\n handleHotUpdate() {\n return []; // return empty array to suppress server refresh\n },\n },\n ],\n });\n\n return vite;\n}\n"],"names":[],"mappings":";;;;;;;;;;AA+BA,SAAgB,iBAAiB,QAAiB,SAAS,IAAI;CAC7D,MAAM,eAAe,aAAa,QAAQ,EACxC,OACF,CAAC;CAeD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,SAAS,KAAK,YACzB,SAAS,QACL,OAAO,MAAM,SAAS,KAAK,QAAQ,KAAK,IACxC,OAAO,MAAM,SAAS,GAAG;CAC/B,OAAO;AACT;AAaA,IAAa,oBAAb,MAAa,kBAAwD;CACnE,SAA0B,YAAY,CAAC,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