@lunora/config 1.0.0-alpha.43 → 1.0.0-alpha.44
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,72 @@
|
|
|
1
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { normalize, join, relative, isAbsolute, dirname } from 'node:path';
|
|
4
|
+
|
|
5
|
+
const loadStudioAssets = (logger, resolveFrom = import.meta.url) => {
|
|
6
|
+
try {
|
|
7
|
+
const require = createRequire(resolveFrom);
|
|
8
|
+
return {
|
|
9
|
+
script: readFileSync(require.resolve("@lunora/studio/standalone/studio.js")),
|
|
10
|
+
styles: readFileSync(require.resolve("@lunora/studio/styles.css"))
|
|
11
|
+
};
|
|
12
|
+
} catch (error) {
|
|
13
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
14
|
+
logger?.warnOnce?.(`[lunora] studio assets unavailable (build @lunora/studio?): ${message}`);
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const studioAssetsStamp = (resolveFrom = import.meta.url) => {
|
|
19
|
+
try {
|
|
20
|
+
const require = createRequire(resolveFrom);
|
|
21
|
+
const scriptMtime = statSync(require.resolve("@lunora/studio/standalone/studio.js")).mtimeMs;
|
|
22
|
+
const stylesMtime = statSync(require.resolve("@lunora/studio/styles.css")).mtimeMs;
|
|
23
|
+
return Math.max(scriptMtime, stylesMtime);
|
|
24
|
+
} catch {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const resolveStandaloneDirectory = (resolveFrom = import.meta.url) => {
|
|
29
|
+
try {
|
|
30
|
+
return dirname(createRequire(resolveFrom).resolve("@lunora/studio/standalone/studio.js"));
|
|
31
|
+
} catch {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const resolveContainedFile = (directory, fileName) => {
|
|
36
|
+
if (fileName === "" || fileName === "." || fileName === ".." || fileName.includes("/") || fileName.includes("\\") || fileName.includes("\0")) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
const resolved = normalize(join(directory, fileName));
|
|
40
|
+
const relativePath = relative(directory, resolved);
|
|
41
|
+
if (relativePath === "" || relativePath.startsWith("..") || isAbsolute(relativePath) || relativePath.includes("/") || relativePath.includes("\\")) {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
return resolved;
|
|
45
|
+
};
|
|
46
|
+
const readStandaloneAsset = (fileName, resolveFrom = import.meta.url) => {
|
|
47
|
+
const directory = resolveStandaloneDirectory(resolveFrom);
|
|
48
|
+
if (directory === void 0) {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
const resolved = resolveContainedFile(directory, fileName);
|
|
52
|
+
if (resolved === void 0) {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
return readFileSync(resolved);
|
|
57
|
+
} catch {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const isStandaloneModulePath = (pathname) => pathname.endsWith(".js") || pathname.endsWith(".js.map");
|
|
62
|
+
const assetContentType = (fileName) => {
|
|
63
|
+
if (fileName.endsWith(".css")) {
|
|
64
|
+
return "text/css; charset=utf-8";
|
|
65
|
+
}
|
|
66
|
+
if (fileName.endsWith(".map")) {
|
|
67
|
+
return "application/json; charset=utf-8";
|
|
68
|
+
}
|
|
69
|
+
return "text/javascript; charset=utf-8";
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { assetContentType, isStandaloneModulePath, loadStudioAssets, readStandaloneAsset, resolveContainedFile, resolveStandaloneDirectory, studioAssetsStamp };
|
|
@@ -81,6 +81,38 @@ declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => S
|
|
|
81
81
|
*/
|
|
82
82
|
declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
|
|
83
83
|
/**
|
|
84
|
+
* Absolute path of the built standalone directory — `@lunora/studio`'s
|
|
85
|
+
* `dist/standalone`, where the `studio.js` entry and its code-split `chunk-*.js`
|
|
86
|
+
* siblings live — or `undefined` when the studio isn't installed/built. The
|
|
87
|
+
* standalone bundle is emitted with esbuild `splitting`, so the hosts must serve
|
|
88
|
+
* the whole directory (not two fixed paths); this resolves its root.
|
|
89
|
+
*/
|
|
90
|
+
declare const resolveStandaloneDirectory: (resolveFrom?: string) => string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Read a single file from the standalone directory by its plain filename (the
|
|
93
|
+
* `studio.js` entry, a `chunk-*.js`, or a `.map`). **Path-traversal-safe** via
|
|
94
|
+
* {@link resolveContainedFile}: only a lone filename resolving to a direct child
|
|
95
|
+
* of the standalone directory is served — any separator, `..`, NUL, or absolute
|
|
96
|
+
* path is rejected — so a request like `../../etc/passwd` can never escape it.
|
|
97
|
+
* Returns the bytes, or `undefined` when the studio isn't built or the name
|
|
98
|
+
* doesn't resolve to a file inside the directory (the host answers that 404).
|
|
99
|
+
*/
|
|
100
|
+
declare const readStandaloneAsset: (fileName: string, resolveFrom?: string) => Buffer | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* True when `pathname` addresses a standalone JS module — the `studio.js` entry
|
|
103
|
+
* or one of its code-split `chunk-*.js` siblings (and their `.map`s). Shared by
|
|
104
|
+
* the CLI and Vite hosts so both route the same request shapes to the directory
|
|
105
|
+
* server; the stylesheet is matched separately at each host's own style path.
|
|
106
|
+
*/
|
|
107
|
+
declare const isStandaloneModulePath: (pathname: string) => boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Content-Type for a served standalone asset, by extension: `.css` → CSS,
|
|
110
|
+
* `.map` → JSON (a source map), everything else (the `.js` entry + chunks) →
|
|
111
|
+
* JavaScript. Shared by the CLI and Vite hosts so the MIME decision lives in one
|
|
112
|
+
* place.
|
|
113
|
+
*/
|
|
114
|
+
declare const assetContentType: (fileName: string) => string;
|
|
115
|
+
/**
|
|
84
116
|
* Endpoint path both dev hosts mount the handler at. A sibling of the schema
|
|
85
117
|
* editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
|
|
86
118
|
* CLI's `/_lunora/*` worker proxy (single underscore).
|
|
@@ -224,4 +256,4 @@ type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResp
|
|
|
224
256
|
* `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
|
|
225
257
|
*/
|
|
226
258
|
declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string) => void;
|
|
227
|
-
export { type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type WarnLogger, type WirePolicyEdit, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, loadStudioAssets, parseDevVariable, renderStudioHtml, resolveAdminToken, serveJsonHandler, studioAssetsStamp };
|
|
259
|
+
export { type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type WarnLogger, type WirePolicyEdit, assetContentType, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, isStandaloneModulePath, loadStudioAssets, parseDevVariable, readStandaloneAsset, renderStudioHtml, resolveAdminToken, resolveStandaloneDirectory, serveJsonHandler, studioAssetsStamp };
|
|
@@ -81,6 +81,38 @@ declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => S
|
|
|
81
81
|
*/
|
|
82
82
|
declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
|
|
83
83
|
/**
|
|
84
|
+
* Absolute path of the built standalone directory — `@lunora/studio`'s
|
|
85
|
+
* `dist/standalone`, where the `studio.js` entry and its code-split `chunk-*.js`
|
|
86
|
+
* siblings live — or `undefined` when the studio isn't installed/built. The
|
|
87
|
+
* standalone bundle is emitted with esbuild `splitting`, so the hosts must serve
|
|
88
|
+
* the whole directory (not two fixed paths); this resolves its root.
|
|
89
|
+
*/
|
|
90
|
+
declare const resolveStandaloneDirectory: (resolveFrom?: string) => string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Read a single file from the standalone directory by its plain filename (the
|
|
93
|
+
* `studio.js` entry, a `chunk-*.js`, or a `.map`). **Path-traversal-safe** via
|
|
94
|
+
* {@link resolveContainedFile}: only a lone filename resolving to a direct child
|
|
95
|
+
* of the standalone directory is served — any separator, `..`, NUL, or absolute
|
|
96
|
+
* path is rejected — so a request like `../../etc/passwd` can never escape it.
|
|
97
|
+
* Returns the bytes, or `undefined` when the studio isn't built or the name
|
|
98
|
+
* doesn't resolve to a file inside the directory (the host answers that 404).
|
|
99
|
+
*/
|
|
100
|
+
declare const readStandaloneAsset: (fileName: string, resolveFrom?: string) => Buffer | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* True when `pathname` addresses a standalone JS module — the `studio.js` entry
|
|
103
|
+
* or one of its code-split `chunk-*.js` siblings (and their `.map`s). Shared by
|
|
104
|
+
* the CLI and Vite hosts so both route the same request shapes to the directory
|
|
105
|
+
* server; the stylesheet is matched separately at each host's own style path.
|
|
106
|
+
*/
|
|
107
|
+
declare const isStandaloneModulePath: (pathname: string) => boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Content-Type for a served standalone asset, by extension: `.css` → CSS,
|
|
110
|
+
* `.map` → JSON (a source map), everything else (the `.js` entry + chunks) →
|
|
111
|
+
* JavaScript. Shared by the CLI and Vite hosts so the MIME decision lives in one
|
|
112
|
+
* place.
|
|
113
|
+
*/
|
|
114
|
+
declare const assetContentType: (fileName: string) => string;
|
|
115
|
+
/**
|
|
84
116
|
* Endpoint path both dev hosts mount the handler at. A sibling of the schema
|
|
85
117
|
* editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
|
|
86
118
|
* CLI's `/_lunora/*` worker proxy (single underscore).
|
|
@@ -224,4 +256,4 @@ type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResp
|
|
|
224
256
|
* `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
|
|
225
257
|
*/
|
|
226
258
|
declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string) => void;
|
|
227
|
-
export { type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type WarnLogger, type WirePolicyEdit, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, loadStudioAssets, parseDevVariable, renderStudioHtml, resolveAdminToken, serveJsonHandler, studioAssetsStamp };
|
|
259
|
+
export { type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type WarnLogger, type WirePolicyEdit, assetContentType, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, isStandaloneModulePath, loadStudioAssets, parseDevVariable, readStandaloneAsset, renderStudioHtml, resolveAdminToken, resolveStandaloneDirectory, serveJsonHandler, studioAssetsStamp };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { parseDevVariable, resolveAdminToken } from '../packem_shared/parseDevVariable-CJiq2IwE.mjs';
|
|
2
|
-
export {
|
|
2
|
+
export { assetContentType, isStandaloneModulePath, loadStudioAssets, readStandaloneAsset, resolveStandaloneDirectory, studioAssetsStamp } from '../packem_shared/assetContentType-ByZjeV3D.mjs';
|
|
3
3
|
export { POLICY_SCAFFOLD_ENDPOINT, handlePolicyScaffoldRequest } from '../packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs';
|
|
4
4
|
export { default as renderStudioHtml } from '../packem_shared/renderStudioHtml-449Ysn75.mjs';
|
|
5
5
|
export { SCHEMA_EDIT_ENDPOINT, handleSchemaEditRequest } from '../packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.44",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"ts-morph": "^28.0.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@lunora/studio": "1.0.0-alpha.
|
|
63
|
+
"@lunora/studio": "1.0.0-alpha.30"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|
|
66
66
|
"@lunora/studio": {
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
|
|
4
|
-
const loadStudioAssets = (logger, resolveFrom = import.meta.url) => {
|
|
5
|
-
try {
|
|
6
|
-
const require = createRequire(resolveFrom);
|
|
7
|
-
return {
|
|
8
|
-
script: readFileSync(require.resolve("@lunora/studio/standalone/studio.js")),
|
|
9
|
-
styles: readFileSync(require.resolve("@lunora/studio/styles.css"))
|
|
10
|
-
};
|
|
11
|
-
} catch (error) {
|
|
12
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
13
|
-
logger?.warnOnce?.(`[lunora] studio assets unavailable (build @lunora/studio?): ${message}`);
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const studioAssetsStamp = (resolveFrom = import.meta.url) => {
|
|
18
|
-
try {
|
|
19
|
-
const require = createRequire(resolveFrom);
|
|
20
|
-
const scriptMtime = statSync(require.resolve("@lunora/studio/standalone/studio.js")).mtimeMs;
|
|
21
|
-
const stylesMtime = statSync(require.resolve("@lunora/studio/styles.css")).mtimeMs;
|
|
22
|
-
return Math.max(scriptMtime, stylesMtime);
|
|
23
|
-
} catch {
|
|
24
|
-
return void 0;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { loadStudioAssets as default, studioAssetsStamp };
|