resuxjs 0.4.0-beta.7 → 0.4.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.
- package/README.md +4 -2
- package/dist/_virtual/_rolldown/runtime.js +4 -0
- package/dist/build/index.d.ts +1 -2
- package/dist/cli.d.ts +3 -3
- package/dist/cli.js +125 -31
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +2 -3
- package/dist/compiler/adapter.js +2 -2
- package/dist/compiler/dev-warnings.d.ts +1 -2
- package/dist/compiler/directives.d.ts +1 -2
- package/dist/compiler/directives.js +7 -3
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +4 -2
- package/dist/compiler/implementation.js +101 -43
- package/dist/compiler/index.d.ts +2 -3
- package/dist/compiler/index.js +2 -2
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +1 -2
- package/dist/core/hooks.d.ts +10 -2
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/module-container.d.ts +1 -2
- package/dist/core/module-container.js +2 -1
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +1 -2
- package/dist/create.d.ts +1 -2
- package/dist/create.js +110 -33
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +1 -2
- package/dist/deploy/common.d.ts +1 -2
- package/dist/deploy/common.js +19 -3
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +1 -2
- package/dist/deploy/index.d.ts +1 -2
- package/dist/deploy/netlify.d.ts +1 -2
- package/dist/deploy/node.d.ts +1 -2
- package/dist/deploy/production-report.d.ts +1 -2
- package/dist/deploy/runtime-dependencies.d.ts +1 -2
- package/dist/deploy/static.d.ts +1 -2
- package/dist/deploy/types.d.ts +1 -2
- package/dist/deploy/vercel.d.ts +1 -2
- package/dist/deploy/vercel.js +3 -3
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +1 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +1 -2
- package/dist/halal-core/ai/classifyProject.d.ts +1 -2
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +1 -2
- package/dist/halal-core/ai/createProjectSummary.d.ts +1 -2
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +1 -2
- package/dist/halal-core/ai/redactSensitiveData.d.ts +1 -2
- package/dist/halal-core/ai/validateAiResponse.d.ts +1 -2
- package/dist/halal-core/cli/check.d.ts +1 -2
- package/dist/halal-core/cli/explain.d.ts +1 -2
- package/dist/halal-core/cli/report.d.ts +1 -2
- package/dist/halal-core/cli/submitReview.d.ts +1 -2
- package/dist/halal-core/cli/verifyReview.d.ts +1 -2
- package/dist/halal-core/config.d.ts +2 -2
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +1 -2
- package/dist/halal-core/crypto/integrity.js +1 -1
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +4 -3
- package/dist/halal-core/enforce.js +31 -4
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/lifecycle.d.ts +1 -2
- package/dist/halal-core/policy.d.ts +1 -2
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +1 -2
- package/dist/halal-core/report/formatTerminalReport.d.ts +1 -2
- package/dist/halal-core/report/generateHalalReport.d.ts +1 -2
- package/dist/halal-core/report/signReport.d.ts +1 -2
- package/dist/halal-core/report/verifyReport.d.ts +1 -2
- package/dist/halal-core/review/createReviewRequest.d.ts +1 -2
- package/dist/halal-core/review/reviewPolicy.d.ts +1 -2
- package/dist/halal-core/review/signedReviewFile.d.ts +1 -2
- package/dist/halal-core/review/verifyReviewApproval.d.ts +1 -2
- package/dist/halal-core/rules/adultContentRules.d.ts +1 -2
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +1 -2
- package/dist/halal-core/rules/childSafetyRules.d.ts +1 -2
- package/dist/halal-core/rules/coreCategories.d.ts +1 -2
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +1 -2
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +1 -2
- package/dist/halal-core/rules/dependencyRules.d.ts +1 -2
- package/dist/halal-core/rules/endpointRules.d.ts +1 -2
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/financeRibaRules.d.ts +1 -2
- package/dist/halal-core/rules/gamblingRules.d.ts +1 -2
- package/dist/halal-core/rules/generalHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/healthHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/keywordRules.d.ts +1 -2
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +1 -2
- package/dist/halal-core/rules/scamFraudRules.d.ts +1 -2
- package/dist/halal-core/rules/selfHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +1 -2
- package/dist/halal-core/runtime/guard.d.ts +1 -2
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/reviewedMemory.d.ts +1 -2
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +1 -2
- package/dist/halal-core/runtime/types.d.ts +1 -2
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +1 -2
- package/dist/halal-core/scanner/scanComponents.d.ts +1 -2
- package/dist/halal-core/scanner/scanContent.d.ts +1 -2
- package/dist/halal-core/scanner/scanDependencies.d.ts +1 -2
- package/dist/halal-core/scanner/scanDomains.d.ts +1 -2
- package/dist/halal-core/scanner/scanEnvNames.d.ts +1 -2
- package/dist/halal-core/scanner/scanMetadata.d.ts +1 -2
- package/dist/halal-core/scanner/scanPages.d.ts +1 -2
- package/dist/halal-core/scanner/scanProject.d.ts +1 -2
- package/dist/halal-core/scanner/scanRoutes.d.ts +1 -2
- package/dist/halal-core/scanner/scanTranslations.d.ts +1 -2
- package/dist/halal-core/status.d.ts +1 -2
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +1 -2
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +1 -2
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +1 -2
- package/dist/head/utils.d.ts +15 -0
- package/dist/head/utils.js +52 -0
- package/dist/head/utils.js.map +1 -0
- package/dist/i18n/index.d.ts +1 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +1 -2
- package/dist/icons/api-fetcher.d.ts +1 -2
- package/dist/icons/cache.d.ts +1 -2
- package/dist/icons/cache.js.map +1 -1
- package/dist/icons/component.d.ts +7 -8
- package/dist/icons/constants.d.ts +1 -2
- package/dist/icons/css-mode.d.ts +1 -2
- package/dist/icons/index.d.ts +1 -2
- package/dist/icons/index.js.map +1 -1
- package/dist/icons/local-svg.d.ts +1 -2
- package/dist/icons/normalize.d.ts +1 -2
- package/dist/icons/offline-loader.d.ts +1 -2
- package/dist/icons/parser.d.ts +1 -2
- package/dist/icons/registry.d.ts +1 -2
- package/dist/icons/resolver.d.ts +1 -2
- package/dist/icons/svg-mode.d.ts +1 -2
- package/dist/icons/transform.d.ts +1 -2
- package/dist/icons/types.d.ts +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kit/index.d.ts +1 -2
- package/dist/nitro-server/index.d.ts +1 -2
- package/dist/node.d.ts +1 -2
- package/dist/reactivity/computed.d.ts +1 -2
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +3 -3
- package/dist/reactivity/effect.js +8 -3
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/reactive.d.ts +1 -2
- package/dist/reactivity/reactive.js +221 -11
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/ref.d.ts +1 -2
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +1 -2
- package/dist/reactivity/scheduler.js +2 -0
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +1 -2
- package/dist/reactivity/utils.d.ts +1 -2
- package/dist/reactivity/watch.d.ts +1 -2
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +1 -2
- package/dist/runtime/core.js.map +1 -1
- package/dist/runtime/index.d.ts +19 -2
- package/dist/runtime/index.js +921 -170
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/resume.d.ts +1 -2
- package/dist/runtime/resume.js.map +1 -1
- package/dist/runtime/router.d.ts +1 -2
- package/dist/runtime/router.js.map +1 -1
- package/dist/runtime/streaming.d.ts +1 -2
- package/dist/runtime/streaming.js.map +1 -1
- package/dist/runtime/view-transitions/detect.d.ts +1 -2
- package/dist/runtime/view-transitions/transition.d.ts +1 -2
- package/dist/runtime/view-transitions/types.d.ts +1 -2
- package/dist/security/media-fetch.d.ts +1 -2
- package/dist/security/media-fetch.js.map +1 -1
- package/dist/security/path-boundary.d.ts +1 -2
- package/dist/security/path-boundary.js +10 -4
- package/dist/security/path-boundary.js.map +1 -1
- package/dist/ui/index.d.ts +41 -42
- package/dist/ui/verification-code.d.ts +9 -10
- package/dist/ui/verification-code.js.map +1 -1
- package/dist/vite-builder/index.d.ts +1 -2
- package/package.json +2 -2
- package/templates/default/.env.example +3 -0
- package/templates/default/nitro.config.ts +16 -4
package/dist/core/config.d.ts
CHANGED
|
@@ -18,5 +18,4 @@ export declare function normalizeResuxGeneratedPath(value: string): string;
|
|
|
18
18
|
* Resolves user configuration into the complete framework configuration with
|
|
19
19
|
* safe defaults for builders, generated paths, and compatibility behavior.
|
|
20
20
|
*/
|
|
21
|
-
export declare function resolveResuxConfig(input: Record<string, unknown>): ResuxResolvedConfig;
|
|
22
|
-
//# sourceMappingURL=config.d.ts.map
|
|
21
|
+
export declare function resolveResuxConfig(input: Record<string, unknown>): ResuxResolvedConfig;
|
package/dist/core/hooks.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
export interface RenderHtmlContext {
|
|
2
|
+
htmlAttrs: string[];
|
|
3
|
+
head: string[];
|
|
4
|
+
bodyPrepend: string[];
|
|
5
|
+
body: string[];
|
|
6
|
+
bodyAppend: string[];
|
|
7
|
+
bodyAttrs: string[];
|
|
8
|
+
}
|
|
1
9
|
export interface ResuxHookPayloads {
|
|
10
|
+
"render:html": RenderHtmlContext;
|
|
2
11
|
"config:resolved": {
|
|
3
12
|
rootDir: string;
|
|
4
13
|
buildDir: string;
|
|
@@ -128,5 +137,4 @@ export declare class ResuxHooks {
|
|
|
128
137
|
callHook<K extends ResuxHookName>(name: K, payload: ResuxHookPayloads[K]): Promise<void>;
|
|
129
138
|
private remove;
|
|
130
139
|
}
|
|
131
|
-
export declare function createResuxHooks(): ResuxHooks;
|
|
132
|
-
//# sourceMappingURL=hooks.d.ts.map
|
|
140
|
+
export declare function createResuxHooks(): ResuxHooks;
|
package/dist/core/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":[],"sources":["../../src/core/hooks.ts"],"sourcesContent":["export interface ResuxHookPayloads {\n \"config:resolved\": { rootDir: string; buildDir: string; config: Record<string, unknown> };\n \"app:resolve\": { appRoot: string; outDir: string };\n \"app:templates\": { outDir: string; templatesDir: string };\n \"app:templatesGenerated\": { outDir: string; files: string[] };\n \"pages:extend\": { pages: Array<Record<string, unknown>> };\n \"pages:resolved\": { pages: Array<Record<string, unknown>> };\n \"imports:dirs\": { dirs: string[] };\n \"imports:extend\": { imports: Array<Record<string, unknown>> };\n \"components:dirs\": { dirs: string[] };\n \"components:extend\": { components: Array<Record<string, unknown>> };\n \"plugins:dirs\": { dirs: string[] };\n \"plugins:extend\": { plugins: Array<Record<string, unknown>> };\n \"middleware:dirs\": { dirs: string[] };\n \"middleware:extend\": { middleware: Array<Record<string, unknown>> };\n \"vite:extendConfig\": { config: Record<string, unknown>; dev: boolean };\n \"vite:serverCreated\": { server: unknown };\n \"vite:compiled\": { outDir: string; dev: boolean };\n \"build:before\": { appRoot: string; outDir: string; mode: \"dev\" | \"build\" };\n \"build:manifest\": { manifest: Record<string, unknown>; outDir: string };\n \"build:done\": { appRoot: string; outDir: string; mode: \"dev\" | \"build\" };\n \"build:error\": { appRoot: string; outDir: string; mode: \"dev\" | \"build\"; error: unknown };\n \"nitro:config\": { config: Record<string, unknown> };\n \"nitro:init\": { appRoot: string };\n \"nitro:build:before\": { appRoot: string; preset?: string };\n \"nitro:build:public-assets\": { appRoot: string; publicDir: string };\n \"prepare:types\": { outDir: string; files: string[] };\n \"dev:reload\": { appRoot: string; changedPath: string };\n \"dev:error\": { appRoot: string; error: unknown };\n \"page:loading:start\": { path?: string };\n \"page:loading:end\": { path?: string };\n \"page:finish\": { path?: string };\n \"app:error\": { error: unknown };\n \"app:error:cleared\": { path?: string };\n}\n\nexport type ResuxHookName = keyof ResuxHookPayloads;\nexport type ResuxHookHandler<T = unknown> = (payload: T) => void | Promise<void>;\ntype HookMap = { [K in ResuxHookName]?: ResuxHookHandler<ResuxHookPayloads[K]>[] };\n\nexport class ResuxHooks {\n private readonly map: HookMap = {};\n\n hook<K extends ResuxHookName>(name: K, handler: ResuxHookHandler<ResuxHookPayloads[K]>): () => void {\n const handlers = (this.map[name] ?? []) as ResuxHookHandler<ResuxHookPayloads[K]>[];\n handlers.push(handler);\n this.map[name] = handlers as HookMap[K];\n return () => this.remove(name, handler);\n }\n\n addHooks(handlers: Partial<{ [K in ResuxHookName]: ResuxHookHandler<ResuxHookPayloads[K]> | ResuxHookHandler<ResuxHookPayloads[K]>[] }>): void {\n for (const [key, value] of Object.entries(handlers) as Array<[ResuxHookName, unknown]>) {\n if (!value) {\n continue;\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n this.hook(key, item as ResuxHookHandler<ResuxHookPayloads[typeof key]>);\n }\n continue;\n }\n this.hook(key, value as ResuxHookHandler<ResuxHookPayloads[typeof key]>);\n }\n }\n\n async callHook<K extends ResuxHookName>(name: K, payload: ResuxHookPayloads[K]): Promise<void> {\n const handlers = this.map[name];\n if (!handlers || handlers.length === 0) {\n return;\n }\n\n // Dispatch a stable snapshot. A hook is allowed to register or remove hooks,\n // but those mutations must affect the next dispatch rather than extending or\n // shrinking the loop that is currently running.\n for (const handler of [...handlers]) {\n try {\n await handler(payload);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Resux hook \"${name}\" failed: ${message}`);\n }\n }\n }\n\n private remove<K extends ResuxHookName>(name: K, target: ResuxHookHandler<ResuxHookPayloads[K]>): void {\n const handlers = this.map[name];\n if (!handlers?.length) {\n return;\n }\n const next = handlers.filter((handler) => handler !== target);\n if (next.length === 0) {\n delete this.map[name];\n return;\n }\n this.map[name] = next as HookMap[K];\n }\n}\n\nexport function createResuxHooks(): ResuxHooks {\n return new ResuxHooks();\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"hooks.js","names":[],"sources":["../../src/core/hooks.ts"],"sourcesContent":["export interface RenderHtmlContext {\n htmlAttrs: string[];\n head: string[];\n bodyPrepend: string[];\n body: string[];\n bodyAppend: string[];\n bodyAttrs: string[];\n}\n\nexport interface ResuxHookPayloads {\n \"render:html\": RenderHtmlContext;\n \"config:resolved\": { rootDir: string; buildDir: string; config: Record<string, unknown> };\n \"app:resolve\": { appRoot: string; outDir: string };\n \"app:templates\": { outDir: string; templatesDir: string };\n \"app:templatesGenerated\": { outDir: string; files: string[] };\n \"pages:extend\": { pages: Array<Record<string, unknown>> };\n \"pages:resolved\": { pages: Array<Record<string, unknown>> };\n \"imports:dirs\": { dirs: string[] };\n \"imports:extend\": { imports: Array<Record<string, unknown>> };\n \"components:dirs\": { dirs: string[] };\n \"components:extend\": { components: Array<Record<string, unknown>> };\n \"plugins:dirs\": { dirs: string[] };\n \"plugins:extend\": { plugins: Array<Record<string, unknown>> };\n \"middleware:dirs\": { dirs: string[] };\n \"middleware:extend\": { middleware: Array<Record<string, unknown>> };\n \"vite:extendConfig\": { config: Record<string, unknown>; dev: boolean };\n \"vite:serverCreated\": { server: unknown };\n \"vite:compiled\": { outDir: string; dev: boolean };\n \"build:before\": { appRoot: string; outDir: string; mode: \"dev\" | \"build\" };\n \"build:manifest\": { manifest: Record<string, unknown>; outDir: string };\n \"build:done\": { appRoot: string; outDir: string; mode: \"dev\" | \"build\" };\n \"build:error\": { appRoot: string; outDir: string; mode: \"dev\" | \"build\"; error: unknown };\n \"nitro:config\": { config: Record<string, unknown> };\n \"nitro:init\": { appRoot: string };\n \"nitro:build:before\": { appRoot: string; preset?: string };\n \"nitro:build:public-assets\": { appRoot: string; publicDir: string };\n \"prepare:types\": { outDir: string; files: string[] };\n \"dev:reload\": { appRoot: string; changedPath: string };\n \"dev:error\": { appRoot: string; error: unknown };\n \"page:loading:start\": { path?: string };\n \"page:loading:end\": { path?: string };\n \"page:finish\": { path?: string };\n \"app:error\": { error: unknown };\n \"app:error:cleared\": { path?: string };\n}\n\nexport type ResuxHookName = keyof ResuxHookPayloads;\nexport type ResuxHookHandler<T = unknown> = (payload: T) => void | Promise<void>;\ntype HookMap = { [K in ResuxHookName]?: ResuxHookHandler<ResuxHookPayloads[K]>[] };\n\nexport class ResuxHooks {\n private readonly map: HookMap = {};\n\n hook<K extends ResuxHookName>(name: K, handler: ResuxHookHandler<ResuxHookPayloads[K]>): () => void {\n const handlers = (this.map[name] ?? []) as ResuxHookHandler<ResuxHookPayloads[K]>[];\n handlers.push(handler);\n this.map[name] = handlers as HookMap[K];\n return () => this.remove(name, handler);\n }\n\n addHooks(handlers: Partial<{ [K in ResuxHookName]: ResuxHookHandler<ResuxHookPayloads[K]> | ResuxHookHandler<ResuxHookPayloads[K]>[] }>): void {\n for (const [key, value] of Object.entries(handlers) as Array<[ResuxHookName, unknown]>) {\n if (!value) {\n continue;\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n this.hook(key, item as ResuxHookHandler<ResuxHookPayloads[typeof key]>);\n }\n continue;\n }\n this.hook(key, value as ResuxHookHandler<ResuxHookPayloads[typeof key]>);\n }\n }\n\n async callHook<K extends ResuxHookName>(name: K, payload: ResuxHookPayloads[K]): Promise<void> {\n const handlers = this.map[name];\n if (!handlers || handlers.length === 0) {\n return;\n }\n\n // Dispatch a stable snapshot. A hook is allowed to register or remove hooks,\n // but those mutations must affect the next dispatch rather than extending or\n // shrinking the loop that is currently running.\n for (const handler of [...handlers]) {\n try {\n await handler(payload);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Resux hook \"${name}\" failed: ${message}`);\n }\n }\n }\n\n private remove<K extends ResuxHookName>(name: K, target: ResuxHookHandler<ResuxHookPayloads[K]>): void {\n const handlers = this.map[name];\n if (!handlers?.length) {\n return;\n }\n const next = handlers.filter((handler) => handler !== target);\n if (next.length === 0) {\n delete this.map[name];\n return;\n }\n this.map[name] = next as HookMap[K];\n }\n}\n\nexport function createResuxHooks(): ResuxHooks {\n return new ResuxHooks();\n}\n"],"mappings":";AAkDA,IAAa,aAAb,MAAwB;CACL,MAAe,CAAC;CAEjC,KAA8B,MAAS,SAA6D;EAClG,MAAM,WAAY,KAAK,IAAI,SAAS,CAAC;EACrC,SAAS,KAAK,OAAO;EACrB,KAAK,IAAI,QAAQ;EACjB,aAAa,KAAK,OAAO,MAAM,OAAO;CACxC;CAEA,SAAS,UAAsI;EAC7I,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,GAAsC;GACtF,IAAI,CAAC,OACH;GAEF,IAAI,MAAM,QAAQ,KAAK,GAAG;IACxB,KAAK,MAAM,QAAQ,OACjB,KAAK,KAAK,KAAK,IAAuD;IAExE;GACF;GACA,KAAK,KAAK,KAAK,KAAwD;EACzE;CACF;CAEA,MAAM,SAAkC,MAAS,SAA8C;EAC7F,MAAM,WAAW,KAAK,IAAI;EAC1B,IAAI,CAAC,YAAY,SAAS,WAAW,GACnC;EAMF,KAAK,MAAM,WAAW,CAAC,GAAG,QAAQ,GAChC,IAAI;GACF,MAAM,QAAQ,OAAO;EACvB,SAAS,OAAO;GACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GACrE,MAAM,IAAI,MAAM,eAAe,KAAK,YAAY,SAAS;EAC3D;CAEJ;CAEQ,OAAgC,MAAS,QAAsD;EACrG,MAAM,WAAW,KAAK,IAAI;EAC1B,IAAI,CAAC,UAAU,QACb;EAEF,MAAM,OAAO,SAAS,QAAQ,YAAY,YAAY,MAAM;EAC5D,IAAI,KAAK,WAAW,GAAG;GACrB,OAAO,KAAK,IAAI;GAChB;EACF;EACA,KAAK,IAAI,QAAQ;CACnB;AACF;AAEA,SAAgB,mBAA+B;CAC7C,OAAO,IAAI,WAAW;AACxB"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_RESUX_BUILD_DIR, RESUX_CLIENT_ASSET_DIR, ResuxResolvedConfig, normalizeResuxGeneratedPath, resolveResuxConfig } from "./config.js";
|
|
2
|
-
import { ResuxHookHandler, ResuxHookName, ResuxHookPayloads, ResuxHooks, createResuxHooks } from "./hooks.js";
|
|
2
|
+
import { RenderHtmlContext, ResuxHookHandler, ResuxHookName, ResuxHookPayloads, ResuxHooks, createResuxHooks } from "./hooks.js";
|
|
3
3
|
import { NitroConfigExtender, PagesExtender, RESUX_HANDLER_MODULES_PATH, RESUX_RUNTIME_CLIENT_CACHE_CONTROL, RESUX_RUNTIME_CLIENT_PATH, RESUX_VUE_ISLAND_MODULES_PATH, ResuxComponentInput, ResuxComponentsDirInput, ResuxImportInput, ResuxModuleContainer, ResuxModuleContext, ResuxModuleContributions, ResuxPluginInput, ResuxPrerenderRouteInput, ResuxRouteMiddlewareInput, ResuxServerHandlerInput, ResuxSupportMode, ResuxTemplateInput, ResuxTypeTemplateInput, ViteConfigExtender } from "./module-container.js";
|
|
4
4
|
import { ResuxCoreApp, ResuxCoreOptions, createResux } from "./resux.js";
|
|
5
|
-
export { DEFAULT_RESUX_BUILD_DIR, NitroConfigExtender, PagesExtender, RESUX_CLIENT_ASSET_DIR, RESUX_HANDLER_MODULES_PATH, RESUX_RUNTIME_CLIENT_CACHE_CONTROL, RESUX_RUNTIME_CLIENT_PATH, RESUX_VUE_ISLAND_MODULES_PATH, ResuxComponentInput, ResuxComponentsDirInput, ResuxCoreApp, ResuxCoreOptions, ResuxHookHandler, ResuxHookName, ResuxHookPayloads, ResuxHooks, ResuxImportInput, ResuxModuleContainer, ResuxModuleContext, ResuxModuleContributions, ResuxPluginInput, ResuxPrerenderRouteInput, ResuxResolvedConfig, ResuxRouteMiddlewareInput, ResuxServerHandlerInput, ResuxSupportMode, ResuxTemplateInput, ResuxTypeTemplateInput, ViteConfigExtender, createResux, createResuxHooks, normalizeResuxGeneratedPath, resolveResuxConfig };
|
|
5
|
+
export { DEFAULT_RESUX_BUILD_DIR, NitroConfigExtender, PagesExtender, RESUX_CLIENT_ASSET_DIR, RESUX_HANDLER_MODULES_PATH, RESUX_RUNTIME_CLIENT_CACHE_CONTROL, RESUX_RUNTIME_CLIENT_PATH, RESUX_VUE_ISLAND_MODULES_PATH, RenderHtmlContext, ResuxComponentInput, ResuxComponentsDirInput, ResuxCoreApp, ResuxCoreOptions, ResuxHookHandler, ResuxHookName, ResuxHookPayloads, ResuxHooks, ResuxImportInput, ResuxModuleContainer, ResuxModuleContext, ResuxModuleContributions, ResuxPluginInput, ResuxPrerenderRouteInput, ResuxResolvedConfig, ResuxRouteMiddlewareInput, ResuxServerHandlerInput, ResuxSupportMode, ResuxTemplateInput, ResuxTypeTemplateInput, ViteConfigExtender, createResux, createResuxHooks, normalizeResuxGeneratedPath, resolveResuxConfig };
|
|
@@ -100,5 +100,4 @@ export interface ResuxModuleContext {
|
|
|
100
100
|
export declare class ResuxModuleContainer {
|
|
101
101
|
readonly contributions: ResuxModuleContributions;
|
|
102
102
|
createContext(config: Record<string, unknown>, rootDir: string, buildDir: string, hooks: ResuxHooks): ResuxModuleContext;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=module-container.d.ts.map
|
|
103
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dedupeHeadScripts } from "../head/utils.js";
|
|
1
2
|
// src/core/module-container.ts
|
|
2
3
|
const RESUX_RUNTIME_CLIENT_PATH = "/__resux/runtime-client.mjs";
|
|
3
4
|
const RESUX_HANDLER_MODULES_PATH = "/__resux/handlers/**";
|
|
@@ -155,7 +156,7 @@ function mergeHead(current, next) {
|
|
|
155
156
|
meta: mergeHeadArray(current.meta, next.meta),
|
|
156
157
|
link: mergeHeadArray(current.link, next.link),
|
|
157
158
|
style: mergeHeadArray(current.style, next.style),
|
|
158
|
-
script: mergeHeadArray(current.script, next.script),
|
|
159
|
+
script: dedupeHeadScripts(mergeHeadArray(current.script, next.script)),
|
|
159
160
|
noscript: mergeHeadArray(current.noscript, next.noscript),
|
|
160
161
|
htmlAttrs: {
|
|
161
162
|
...isObject(current.htmlAttrs) ? current.htmlAttrs : {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-container.js","names":[],"sources":["../../src/core/module-container.ts"],"sourcesContent":["import type { ResuxHooks, ResuxHookName, ResuxHookPayloads } from \"./hooks.js\";\n\nexport type ResuxSupportMode = \"all\" | \"server\" | \"client\";\n\nexport const RESUX_RUNTIME_CLIENT_PATH = \"/__resux/runtime-client.mjs\";\nexport const RESUX_HANDLER_MODULES_PATH = \"/__resux/handlers/**\";\nexport const RESUX_VUE_ISLAND_MODULES_PATH = \"/__resux/vue-islands/**\";\nexport const RESUX_RUNTIME_CLIENT_CACHE_CONTROL = \"no-cache, no-store, must-revalidate\";\n\nconst RESUX_STABLE_RESUMABILITY_ASSET_PATHS = new Set([\n RESUX_RUNTIME_CLIENT_PATH,\n RESUX_HANDLER_MODULES_PATH,\n RESUX_VUE_ISLAND_MODULES_PATH,\n]);\n\nexport interface ResuxTemplateInput {\n filename: string;\n getContents: () => string | Promise<string>;\n write?: boolean;\n}\n\nexport interface ResuxTypeTemplateInput extends ResuxTemplateInput {}\n\nexport interface ResuxComponentInput {\n file: string;\n name?: string;\n global?: boolean;\n mode?: ResuxSupportMode;\n lazy?: boolean;\n}\n\nexport interface ResuxComponentsDirInput {\n path: string;\n global?: boolean;\n mode?: ResuxSupportMode;\n pathPrefix?: boolean;\n}\n\nexport interface ResuxImportInput {\n from: string;\n name: string;\n as?: string;\n}\n\nexport interface ResuxPluginInput {\n src: string;\n mode?: ResuxSupportMode;\n}\n\nexport interface ResuxRouteMiddlewareInput {\n name: string;\n src: string;\n global?: boolean;\n mode?: ResuxSupportMode;\n}\n\nexport interface ResuxServerHandlerInput {\n route: string;\n handler: string;\n middleware?: boolean;\n method?: string;\n}\n\nexport interface ResuxPrerenderRouteInput {\n route: string;\n}\n\nexport type PagesExtender = (pages: Array<Record<string, unknown>>) => void | Promise<void>;\nexport type ViteConfigExtender = (config: Record<string, unknown>) => void | Promise<void>;\nexport type NitroConfigExtender = (config: Record<string, unknown>) => void | Promise<void>;\n\nexport interface ResuxModuleContributions {\n components: ResuxComponentInput[];\n componentDirs: ResuxComponentsDirInput[];\n imports: ResuxImportInput[];\n importDirs: string[];\n plugins: ResuxPluginInput[];\n middleware: ResuxRouteMiddlewareInput[];\n serverHandlers: ResuxServerHandlerInput[];\n serverPlugins: string[];\n templates: ResuxTemplateInput[];\n typeTemplates: ResuxTypeTemplateInput[];\n pagesExtenders: PagesExtender[];\n runtimeConfigExtends: Record<string, unknown>[];\n viteConfigExtenders: ViteConfigExtender[];\n nitroConfigExtenders: NitroConfigExtender[];\n vitePlugins: unknown[];\n routeRules: Array<{ path: string; rule: Record<string, unknown> }>;\n prerenderRoutes: ResuxPrerenderRouteInput[];\n}\n\nexport interface ResuxModuleContext {\n rootDir: string;\n buildDir: string;\n options: Record<string, unknown>;\n addCss(href: string): void;\n addHead(head: Record<string, unknown>): void;\n addRouteRule(path: string, rule: Record<string, unknown>): void;\n extendRuntimeConfig(config: Record<string, unknown>): void;\n hook<K extends ResuxHookName>(name: K, handler: (payload: ResuxHookPayloads[K]) => void | Promise<void>): () => void;\n addComponent(component: ResuxComponentInput | string): void;\n addComponentsDir(dir: ResuxComponentsDirInput | string): void;\n addImports(imports: ResuxImportInput | ResuxImportInput[]): void;\n addImportsDir(dir: string): void;\n addPlugin(plugin: ResuxPluginInput | string): void;\n addRouteMiddleware(middleware: ResuxRouteMiddlewareInput): void;\n addServerHandler(handler: ResuxServerHandlerInput): void;\n addServerPlugin(plugin: string): void;\n addTemplate(template: ResuxTemplateInput): void;\n addTypeTemplate(template: ResuxTypeTemplateInput): void;\n extendPages(extender: PagesExtender): void;\n extendViteConfig(extender: ViteConfigExtender): void;\n extendNitroConfig(extender: NitroConfigExtender): void;\n addVitePlugin(plugin: unknown): void;\n addPrerenderRoutes(route: string | string[]): void;\n}\n\nexport class ResuxModuleContainer {\n readonly contributions: ResuxModuleContributions = {\n components: [],\n componentDirs: [],\n imports: [],\n importDirs: [],\n plugins: [],\n middleware: [],\n serverHandlers: [],\n serverPlugins: [],\n templates: [],\n typeTemplates: [],\n pagesExtenders: [],\n runtimeConfigExtends: [],\n viteConfigExtenders: [],\n nitroConfigExtenders: [],\n vitePlugins: [],\n routeRules: [],\n prerenderRoutes: []\n };\n\n createContext(\n config: Record<string, unknown>,\n rootDir: string,\n buildDir: string,\n hooks: ResuxHooks\n ): ResuxModuleContext {\n return {\n rootDir,\n buildDir,\n options: config,\n addCss: (href) => {\n const css = Array.isArray(config.css) ? config.css : [];\n if (!css.includes(href)) {\n css.push(href);\n }\n config.css = css;\n },\n addHead: (head) => {\n const app = isObject(config.app) ? config.app : {};\n const current = isObject(app.head) ? app.head : {};\n app.head = mergeHead(current, head);\n config.app = app;\n },\n addRouteRule: (path, rule) => {\n if (!path.startsWith(\"/\")) {\n throw new Error(`Route rules need an absolute path. Received \"${path}\".`);\n }\n const routeRules = isObject(config.routeRules) ? config.routeRules : {};\n const current = isObject(routeRules[path]) ? routeRules[path] : {};\n const merged = mergeRouteRule(path, current, rule);\n routeRules[path] = merged;\n config.routeRules = routeRules;\n this.contributions.routeRules.push({ path, rule: merged });\n },\n extendRuntimeConfig: (runtimeConfig) => {\n this.contributions.runtimeConfigExtends.push(runtimeConfig);\n const current = isObject(config.runtimeConfig) ? config.runtimeConfig : {};\n config.runtimeConfig = deepMergeObjects(current, runtimeConfig);\n },\n hook: (name, handler) => hooks.hook(name, handler),\n addComponent: (component) => {\n if (typeof component === \"string\") {\n this.contributions.components.push({ file: component });\n return;\n }\n this.contributions.components.push(component);\n },\n addComponentsDir: (dir) => {\n if (typeof dir === \"string\") {\n this.contributions.componentDirs.push({ path: dir });\n return;\n }\n this.contributions.componentDirs.push(dir);\n },\n addImports: (imports) => {\n const list = Array.isArray(imports) ? imports : [imports];\n this.contributions.imports.push(...list);\n },\n addImportsDir: (dir) => {\n this.contributions.importDirs.push(dir);\n },\n addPlugin: (plugin) => {\n if (typeof plugin === \"string\") {\n this.contributions.plugins.push({ src: plugin, mode: \"all\" });\n return;\n }\n this.contributions.plugins.push({ mode: \"all\", ...plugin });\n },\n addRouteMiddleware: (middleware) => {\n this.contributions.middleware.push(middleware);\n },\n addServerHandler: (handler) => {\n this.contributions.serverHandlers.push(handler);\n },\n addServerPlugin: (plugin) => {\n this.contributions.serverPlugins.push(plugin);\n },\n addTemplate: (template) => {\n this.contributions.templates.push(template);\n },\n addTypeTemplate: (template) => {\n this.contributions.typeTemplates.push(template);\n },\n extendPages: (extender) => {\n this.contributions.pagesExtenders.push(extender);\n },\n extendViteConfig: (extender) => {\n this.contributions.viteConfigExtenders.push(extender);\n },\n extendNitroConfig: (extender) => {\n this.contributions.nitroConfigExtenders.push(extender);\n },\n addVitePlugin: (plugin) => {\n this.contributions.vitePlugins.push(plugin);\n },\n addPrerenderRoutes: (route) => {\n const list = Array.isArray(route) ? route : [route];\n for (const item of list) {\n this.contributions.prerenderRoutes.push({ route: item });\n }\n }\n };\n }\n}\n\nfunction mergeRouteRule(\n routePath: string,\n current: Record<string, unknown>,\n next: Record<string, unknown>,\n): Record<string, unknown> {\n const headers: Record<string, unknown> = {\n ...(isObject(current.headers) ? current.headers : {}),\n ...(isObject(next.headers) ? next.headers : {}),\n };\n\n if (RESUX_STABLE_RESUMABILITY_ASSET_PATHS.has(routePath)) {\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === \"cache-control\") {\n delete headers[key];\n }\n }\n headers[\"cache-control\"] = RESUX_RUNTIME_CLIENT_CACHE_CONTROL;\n return {\n ...current,\n ...next,\n cache: false,\n headers,\n };\n }\n\n return {\n ...current,\n ...next,\n headers,\n };\n}\n\nfunction mergeHead(current: Record<string, unknown>, next: Record<string, unknown>): Record<string, unknown> {\n return {\n ...current,\n ...next,\n meta: mergeHeadArray(current.meta, next.meta),\n link: mergeHeadArray(current.link, next.link),\n style: mergeHeadArray(current.style, next.style),\n script: mergeHeadArray(current.script, next.script),\n noscript: mergeHeadArray(current.noscript, next.noscript),\n htmlAttrs: {\n ...(isObject(current.htmlAttrs) ? current.htmlAttrs : {}),\n ...(isObject(next.htmlAttrs) ? next.htmlAttrs : {}),\n },\n bodyAttrs: {\n ...(isObject(current.bodyAttrs) ? current.bodyAttrs : {}),\n ...(isObject(next.bodyAttrs) ? next.bodyAttrs : {}),\n },\n };\n}\n\nfunction mergeHeadArray(current: unknown, next: unknown): unknown[] {\n return [\n ...(Array.isArray(current) ? current : []),\n ...(Array.isArray(next) ? next : []),\n ];\n}\n\nfunction isObject(value: unknown): value is Record<string, any> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nconst FORBIDDEN_OBJECT_KEYS = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\n\nfunction deepMergeObjects(base: Record<string, unknown>, next: Record<string, unknown>): Record<string, unknown> {\n const output: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(next)) {\n if (FORBIDDEN_OBJECT_KEYS.has(key)) {\n throw new Error(`Runtime config contains unsafe key \"${key}\".`);\n }\n const current = Object.hasOwn(output, key)\n ? output[key]\n : undefined;\n output[key] = isObject(current) && isObject(value)\n ? deepMergeObjects(current, value)\n : value;\n }\n return output;\n}\n"],"mappings":";A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AI,QAAQ,YAAY,CAAC;GACvD,GAAI,SAAS,KAAK,SAAS,IAAI,KAAK,YAAY,CAAC;EACnD;EACA,WAAW;GACT,GAAI,SAAS,QAAQ,SAAS,IAAI,QAAQ,YAAY,CAAC;GACvD,GAAI,SAAS,KAAK,SAAS,IAAI,KAAK,YAAY,CAAC;EACnD;CACF;AACF;AAEA,SAAS,eAAe,SAAkB,MAA0B;CAClE,OAAO,CACL,GAAI,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,GACxC,GAAI,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,CACpC;AACF;AAEA,SAAS,SAAS,OAA8C;CAC9D,OAAO,QAAQ,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,CAAC;AAC5E;AAEA,MAAM,wCAAwB,IAAI,IAAI;CAAC;CAAa;CAAa;AAAa,CAAC;AAE/E,SAAS,iBAAiB,MAA+B,MAAwD;CAC/G,MAAM,SAAkC,EAAE,GAAG,KAAK;CAClD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAAG;EAC/C,IAAI,sBAAsB,IAAI,GAAG,GAC/B,MAAM,IAAI,MAAM,uCAAuC,IAAI,GAAG;EAEhE,MAAM,UAAU,OAAO,OAAO,QAAQ,GAAG,IACrC,OAAO,OACP,KAAA;EACJ,OAAO,OAAO,SAAS,OAAO,KAAK,SAAS,KAAK,IAC7C,iBAAiB,SAAS,KAAK,IAC/B;CACN;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"module-container.js","names":[],"sources":["../../src/core/module-container.ts"],"sourcesContent":["import type { ResuxHooks, ResuxHookName, ResuxHookPayloads } from \"./hooks.js\";\nimport { dedupeHeadScripts } from \"../head/utils.js\";\n\nexport type ResuxSupportMode = \"all\" | \"server\" | \"client\";\n\nexport const RESUX_RUNTIME_CLIENT_PATH = \"/__resux/runtime-client.mjs\";\nexport const RESUX_HANDLER_MODULES_PATH = \"/__resux/handlers/**\";\nexport const RESUX_VUE_ISLAND_MODULES_PATH = \"/__resux/vue-islands/**\";\nexport const RESUX_RUNTIME_CLIENT_CACHE_CONTROL = \"no-cache, no-store, must-revalidate\";\n\nconst RESUX_STABLE_RESUMABILITY_ASSET_PATHS = new Set([\n RESUX_RUNTIME_CLIENT_PATH,\n RESUX_HANDLER_MODULES_PATH,\n RESUX_VUE_ISLAND_MODULES_PATH,\n]);\n\nexport interface ResuxTemplateInput {\n filename: string;\n getContents: () => string | Promise<string>;\n write?: boolean;\n}\n\nexport interface ResuxTypeTemplateInput extends ResuxTemplateInput {}\n\nexport interface ResuxComponentInput {\n file: string;\n name?: string;\n global?: boolean;\n mode?: ResuxSupportMode;\n lazy?: boolean;\n}\n\nexport interface ResuxComponentsDirInput {\n path: string;\n global?: boolean;\n mode?: ResuxSupportMode;\n pathPrefix?: boolean;\n}\n\nexport interface ResuxImportInput {\n from: string;\n name: string;\n as?: string;\n}\n\nexport interface ResuxPluginInput {\n src: string;\n mode?: ResuxSupportMode;\n}\n\nexport interface ResuxRouteMiddlewareInput {\n name: string;\n src: string;\n global?: boolean;\n mode?: ResuxSupportMode;\n}\n\nexport interface ResuxServerHandlerInput {\n route: string;\n handler: string;\n middleware?: boolean;\n method?: string;\n}\n\nexport interface ResuxPrerenderRouteInput {\n route: string;\n}\n\nexport type PagesExtender = (pages: Array<Record<string, unknown>>) => void | Promise<void>;\nexport type ViteConfigExtender = (config: Record<string, unknown>) => void | Promise<void>;\nexport type NitroConfigExtender = (config: Record<string, unknown>) => void | Promise<void>;\n\nexport interface ResuxModuleContributions {\n components: ResuxComponentInput[];\n componentDirs: ResuxComponentsDirInput[];\n imports: ResuxImportInput[];\n importDirs: string[];\n plugins: ResuxPluginInput[];\n middleware: ResuxRouteMiddlewareInput[];\n serverHandlers: ResuxServerHandlerInput[];\n serverPlugins: string[];\n templates: ResuxTemplateInput[];\n typeTemplates: ResuxTypeTemplateInput[];\n pagesExtenders: PagesExtender[];\n runtimeConfigExtends: Record<string, unknown>[];\n viteConfigExtenders: ViteConfigExtender[];\n nitroConfigExtenders: NitroConfigExtender[];\n vitePlugins: unknown[];\n routeRules: Array<{ path: string; rule: Record<string, unknown> }>;\n prerenderRoutes: ResuxPrerenderRouteInput[];\n}\n\nexport interface ResuxModuleContext {\n rootDir: string;\n buildDir: string;\n options: Record<string, unknown>;\n addCss(href: string): void;\n addHead(head: Record<string, unknown>): void;\n addRouteRule(path: string, rule: Record<string, unknown>): void;\n extendRuntimeConfig(config: Record<string, unknown>): void;\n hook<K extends ResuxHookName>(name: K, handler: (payload: ResuxHookPayloads[K]) => void | Promise<void>): () => void;\n addComponent(component: ResuxComponentInput | string): void;\n addComponentsDir(dir: ResuxComponentsDirInput | string): void;\n addImports(imports: ResuxImportInput | ResuxImportInput[]): void;\n addImportsDir(dir: string): void;\n addPlugin(plugin: ResuxPluginInput | string): void;\n addRouteMiddleware(middleware: ResuxRouteMiddlewareInput): void;\n addServerHandler(handler: ResuxServerHandlerInput): void;\n addServerPlugin(plugin: string): void;\n addTemplate(template: ResuxTemplateInput): void;\n addTypeTemplate(template: ResuxTypeTemplateInput): void;\n extendPages(extender: PagesExtender): void;\n extendViteConfig(extender: ViteConfigExtender): void;\n extendNitroConfig(extender: NitroConfigExtender): void;\n addVitePlugin(plugin: unknown): void;\n addPrerenderRoutes(route: string | string[]): void;\n}\n\nexport class ResuxModuleContainer {\n readonly contributions: ResuxModuleContributions = {\n components: [],\n componentDirs: [],\n imports: [],\n importDirs: [],\n plugins: [],\n middleware: [],\n serverHandlers: [],\n serverPlugins: [],\n templates: [],\n typeTemplates: [],\n pagesExtenders: [],\n runtimeConfigExtends: [],\n viteConfigExtenders: [],\n nitroConfigExtenders: [],\n vitePlugins: [],\n routeRules: [],\n prerenderRoutes: []\n };\n\n createContext(\n config: Record<string, unknown>,\n rootDir: string,\n buildDir: string,\n hooks: ResuxHooks\n ): ResuxModuleContext {\n return {\n rootDir,\n buildDir,\n options: config,\n addCss: (href) => {\n const css = Array.isArray(config.css) ? config.css : [];\n if (!css.includes(href)) {\n css.push(href);\n }\n config.css = css;\n },\n addHead: (head) => {\n const app = isObject(config.app) ? config.app : {};\n const current = isObject(app.head) ? app.head : {};\n app.head = mergeHead(current, head);\n config.app = app;\n },\n addRouteRule: (path, rule) => {\n if (!path.startsWith(\"/\")) {\n throw new Error(`Route rules need an absolute path. Received \"${path}\".`);\n }\n const routeRules = isObject(config.routeRules) ? config.routeRules : {};\n const current = isObject(routeRules[path]) ? routeRules[path] : {};\n const merged = mergeRouteRule(path, current, rule);\n routeRules[path] = merged;\n config.routeRules = routeRules;\n this.contributions.routeRules.push({ path, rule: merged });\n },\n extendRuntimeConfig: (runtimeConfig) => {\n this.contributions.runtimeConfigExtends.push(runtimeConfig);\n const current = isObject(config.runtimeConfig) ? config.runtimeConfig : {};\n config.runtimeConfig = deepMergeObjects(current, runtimeConfig);\n },\n hook: (name, handler) => hooks.hook(name, handler),\n addComponent: (component) => {\n if (typeof component === \"string\") {\n this.contributions.components.push({ file: component });\n return;\n }\n this.contributions.components.push(component);\n },\n addComponentsDir: (dir) => {\n if (typeof dir === \"string\") {\n this.contributions.componentDirs.push({ path: dir });\n return;\n }\n this.contributions.componentDirs.push(dir);\n },\n addImports: (imports) => {\n const list = Array.isArray(imports) ? imports : [imports];\n this.contributions.imports.push(...list);\n },\n addImportsDir: (dir) => {\n this.contributions.importDirs.push(dir);\n },\n addPlugin: (plugin) => {\n if (typeof plugin === \"string\") {\n this.contributions.plugins.push({ src: plugin, mode: \"all\" });\n return;\n }\n this.contributions.plugins.push({ mode: \"all\", ...plugin });\n },\n addRouteMiddleware: (middleware) => {\n this.contributions.middleware.push(middleware);\n },\n addServerHandler: (handler) => {\n this.contributions.serverHandlers.push(handler);\n },\n addServerPlugin: (plugin) => {\n this.contributions.serverPlugins.push(plugin);\n },\n addTemplate: (template) => {\n this.contributions.templates.push(template);\n },\n addTypeTemplate: (template) => {\n this.contributions.typeTemplates.push(template);\n },\n extendPages: (extender) => {\n this.contributions.pagesExtenders.push(extender);\n },\n extendViteConfig: (extender) => {\n this.contributions.viteConfigExtenders.push(extender);\n },\n extendNitroConfig: (extender) => {\n this.contributions.nitroConfigExtenders.push(extender);\n },\n addVitePlugin: (plugin) => {\n this.contributions.vitePlugins.push(plugin);\n },\n addPrerenderRoutes: (route) => {\n const list = Array.isArray(route) ? route : [route];\n for (const item of list) {\n this.contributions.prerenderRoutes.push({ route: item });\n }\n }\n };\n }\n}\n\nfunction mergeRouteRule(\n routePath: string,\n current: Record<string, unknown>,\n next: Record<string, unknown>,\n): Record<string, unknown> {\n const headers: Record<string, unknown> = {\n ...(isObject(current.headers) ? current.headers : {}),\n ...(isObject(next.headers) ? next.headers : {}),\n };\n\n if (RESUX_STABLE_RESUMABILITY_ASSET_PATHS.has(routePath)) {\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === \"cache-control\") {\n delete headers[key];\n }\n }\n headers[\"cache-control\"] = RESUX_RUNTIME_CLIENT_CACHE_CONTROL;\n return {\n ...current,\n ...next,\n cache: false,\n headers,\n };\n }\n\n return {\n ...current,\n ...next,\n headers,\n };\n}\n\nfunction mergeHead(current: Record<string, unknown>, next: Record<string, unknown>): Record<string, unknown> {\n return {\n ...current,\n ...next,\n meta: mergeHeadArray(current.meta, next.meta),\n link: mergeHeadArray(current.link, next.link),\n style: mergeHeadArray(current.style, next.style),\n script: dedupeHeadScripts(mergeHeadArray(current.script, next.script)),\n noscript: mergeHeadArray(current.noscript, next.noscript),\n htmlAttrs: {\n ...(isObject(current.htmlAttrs) ? current.htmlAttrs : {}),\n ...(isObject(next.htmlAttrs) ? next.htmlAttrs : {}),\n },\n bodyAttrs: {\n ...(isObject(current.bodyAttrs) ? current.bodyAttrs : {}),\n ...(isObject(next.bodyAttrs) ? next.bodyAttrs : {}),\n },\n };\n}\n\nfunction mergeHeadArray(current: unknown, next: unknown): unknown[] {\n return [\n ...(Array.isArray(current) ? current : []),\n ...(Array.isArray(next) ? next : []),\n ];\n}\n\nfunction isObject(value: unknown): value is Record<string, any> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nconst FORBIDDEN_OBJECT_KEYS = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\n\nfunction deepMergeObjects(base: Record<string, unknown>, next: Record<string, unknown>): Record<string, unknown> {\n const output: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(next)) {\n if (FORBIDDEN_OBJECT_KEYS.has(key)) {\n throw new Error(`Runtime config contains unsafe key \"${key}\".`);\n }\n const current = Object.hasOwn(output, key)\n ? output[key]\n : undefined;\n output[key] = isObject(current) && isObject(value)\n ? deepMergeObjects(current, value)\n : value;\n }\n return output;\n}\n"],"mappings":";;AAKA,MAAa,4BAA4B;AACzC,MAAa,6BAA6B;AAC1C,MAAa,gCAAgC;AAC7C,MAAa,qCAAqC;AAElD,MAAM,wDAAwC,IAAI,IAAI;CACpD;CACA;CACA;AACF,CAAC;AAwGD,IAAa,uBAAb,MAAkC;CACvB,gBAA0C;EACjD,YAAY,CAAC;EACb,eAAe,CAAC;EAChB,SAAS,CAAC;EACV,YAAY,CAAC;EACb,SAAS,CAAC;EACV,YAAY,CAAC;EACb,gBAAgB,CAAC;EACjB,eAAe,CAAC;EAChB,WAAW,CAAC;EACZ,eAAe,CAAC;EAChB,gBAAgB,CAAC;EACjB,sBAAsB,CAAC;EACvB,qBAAqB,CAAC;EACtB,sBAAsB,CAAC;EACvB,aAAa,CAAC;EACd,YAAY,CAAC;EACb,iBAAiB,CAAC;CACpB;CAEA,cACE,QACA,SACA,UACA,OACoB;EACpB,OAAO;GACL;GACA;GACA,SAAS;GACT,SAAS,SAAS;IAChB,MAAM,MAAM,MAAM,QAAQ,OAAO,GAAG,IAAI,OAAO,MAAM,CAAC;IACtD,IAAI,CAAC,IAAI,SAAS,IAAI,GACpB,IAAI,KAAK,IAAI;IAEf,OAAO,MAAM;GACf;GACA,UAAU,SAAS;IACjB,MAAM,MAAM,SAAS,OAAO,GAAG,IAAI,OA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O,OAAO,QAAQ,GAAG,IACrC,OAAO,OACP,KAAA;EACJ,OAAO,OAAO,SAAS,OAAO,KAAK,SAAS,KAAK,IAC7C,iBAAiB,SAAS,KAAK,IAC/B;CACN;CACA,OAAO;AACT"}
|
package/dist/core/resux.d.ts
CHANGED
|
@@ -15,5 +15,4 @@ export interface ResuxCoreApp {
|
|
|
15
15
|
callHook: ResuxHooks["callHook"];
|
|
16
16
|
modules: ResuxModuleContainer;
|
|
17
17
|
}
|
|
18
|
-
export declare function createResux(options: ResuxCoreOptions): ResuxCoreApp;
|
|
19
|
-
//# sourceMappingURL=resux.d.ts.map
|
|
18
|
+
export declare function createResux(options: ResuxCoreOptions): ResuxCoreApp;
|
package/dist/create.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export declare function runCreateResux(args?: string[]): Promise<void>;
|
|
2
|
-
export declare function assertSafeCreateTarget(root: string, cwd: string, force: boolean): void;
|
|
3
|
-
//# sourceMappingURL=create.d.ts.map
|
|
2
|
+
export declare function assertSafeCreateTarget(root: string, cwd: string, force: boolean): void;
|
package/dist/create.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
2
3
|
import { lstat, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -63,7 +64,48 @@ async function runCreateResux(args = process.argv.slice(2)) {
|
|
|
63
64
|
await copyTemplate(path.resolve(fileURLToPath(new URL("../templates/default", import.meta.url))), root, {
|
|
64
65
|
"%PROJECT_NAME%": projectName,
|
|
65
66
|
"%PROJECT_TITLE%": title
|
|
66
|
-
});
|
|
67
|
+
}, template);
|
|
68
|
+
if (template === "minimal") {
|
|
69
|
+
await writeFile(path.join(root, "pages", "index.vue"), `<script setup lang="ts">
|
|
70
|
+
const count = ref(0);
|
|
71
|
+
|
|
72
|
+
function increment() {
|
|
73
|
+
count.value++;
|
|
74
|
+
}
|
|
75
|
+
<\/script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<main class="page">
|
|
79
|
+
<h1>Welcome to Resux</h1>
|
|
80
|
+
<p>A minimal resumable application.</p>
|
|
81
|
+
<button @click="increment">Count: {{ count }}</button>
|
|
82
|
+
</main>
|
|
83
|
+
</template>
|
|
84
|
+
|
|
85
|
+
<style scoped>
|
|
86
|
+
.page {
|
|
87
|
+
max-width: 640px;
|
|
88
|
+
margin: 4rem auto;
|
|
89
|
+
padding: 0 1rem;
|
|
90
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
91
|
+
text-align: center;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
button {
|
|
95
|
+
margin-top: 1rem;
|
|
96
|
+
padding: 0.5rem 1rem;
|
|
97
|
+
font-size: 1rem;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
}
|
|
100
|
+
</style>
|
|
101
|
+
`, "utf8");
|
|
102
|
+
await writeFile(path.join(root, "layouts", "default.vue"), `<template>
|
|
103
|
+
<div class="shell">
|
|
104
|
+
<slot />
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
`, "utf8");
|
|
108
|
+
}
|
|
67
109
|
await writeFile(path.join(root, "package.json"), createStarterPackageJson(projectName, frameworkPackage, features, template), "utf8");
|
|
68
110
|
await applyStarterFeatureScaffold(root, title, features, { hreflang });
|
|
69
111
|
await ensureStarterProjectStructure(root, title, features, template);
|
|
@@ -253,21 +295,27 @@ async function prepareTarget(root, force) {
|
|
|
253
295
|
});
|
|
254
296
|
}
|
|
255
297
|
}
|
|
256
|
-
async function copyTemplate(sourceRoot, targetRoot, replacements) {
|
|
257
|
-
await copyDirectory(sourceRoot, targetRoot, "", replacements);
|
|
298
|
+
async function copyTemplate(sourceRoot, targetRoot, replacements, template) {
|
|
299
|
+
await copyDirectory(sourceRoot, targetRoot, "", replacements, template);
|
|
258
300
|
}
|
|
259
|
-
async function copyDirectory(sourceDir, targetDir, relativeDir, replacements) {
|
|
301
|
+
async function copyDirectory(sourceDir, targetDir, relativeDir, replacements, template) {
|
|
260
302
|
await mkdir(targetDir, { recursive: true });
|
|
261
303
|
const entries = await readdir(sourceDir, { withFileTypes: true });
|
|
262
|
-
for (const entry of entries)
|
|
304
|
+
for (const entry of entries) {
|
|
305
|
+
if (template === "minimal") {
|
|
306
|
+
if (entry.isDirectory() && (entry.name === "plugins" || entry.name === "middleware" || entry.name === "islands" || entry.name === "server")) continue;
|
|
307
|
+
if (entry.isFile() && relativeDir === "pages" && entry.name === "about.vue") continue;
|
|
308
|
+
}
|
|
309
|
+
await copyEntry(entry, sourceDir, targetDir, relativeDir, replacements, template);
|
|
310
|
+
}
|
|
263
311
|
}
|
|
264
|
-
async function copyEntry(entry, sourceDir, targetDir, relativeDir, replacements) {
|
|
312
|
+
async function copyEntry(entry, sourceDir, targetDir, relativeDir, replacements, template) {
|
|
265
313
|
const source = path.join(sourceDir, entry.name);
|
|
266
314
|
const targetName = entry.name === "_gitignore" ? ".gitignore" : entry.name;
|
|
267
315
|
const target = path.join(targetDir, targetName);
|
|
268
316
|
const relativePath = path.join(relativeDir, entry.name);
|
|
269
317
|
if (entry.isDirectory()) {
|
|
270
|
-
await copyDirectory(source, target, relativePath, replacements);
|
|
318
|
+
await copyDirectory(source, target, relativePath, replacements, template);
|
|
271
319
|
return;
|
|
272
320
|
}
|
|
273
321
|
if (!entry.isFile()) return;
|
|
@@ -334,8 +382,58 @@ async function applyStarterFeatureScaffold(root, title, features, options) {
|
|
|
334
382
|
await extendDefaultLayoutNavigation(root, selected);
|
|
335
383
|
await annotateStarterReadme(root, selected);
|
|
336
384
|
}
|
|
385
|
+
const STARTER_MAIN_CSS = `:root {
|
|
386
|
+
--rx-bg: #020617;
|
|
387
|
+
--rx-surface: #0f172a;
|
|
388
|
+
--rx-text: #e2e8f0;
|
|
389
|
+
--rx-muted: #94a3b8;
|
|
390
|
+
--rx-accent: #22d3ee;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
* {
|
|
394
|
+
box-sizing: border-box;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
body {
|
|
398
|
+
margin: 0;
|
|
399
|
+
font-family: "Segoe UI", system-ui, sans-serif;
|
|
400
|
+
background: radial-gradient(circle at top, #111827 0%, var(--rx-bg) 60%);
|
|
401
|
+
color: var(--rx-text);
|
|
402
|
+
}
|
|
403
|
+
`;
|
|
404
|
+
const STARTER_LINK_CSS = `a {
|
|
405
|
+
color: var(--rx-accent);
|
|
406
|
+
}
|
|
407
|
+
`;
|
|
408
|
+
async function ensureStarterBaseFiles(root, options) {
|
|
409
|
+
await writeFile(path.join(root, ".npmrc"), options.includeTests ? "engine-strict=true\nlegacy-peer-deps=true\n" : "engine-strict=true\n", "utf8");
|
|
410
|
+
await ensureFile(path.join(root, ".env.example"), "# Runtime environment defaults\nAPP_ORIGIN=http://localhost:3000\n\n# Secret for signing production Halal Core safety reports (minimum 32 characters)\nRESUX_HALAL_REPORT_SIGNING_SECRET=\n");
|
|
411
|
+
await ensureFile(path.join(root, "types", "app.d.ts"), "import \"resuxjs/globals\";\n\nexport {};\n");
|
|
412
|
+
await ensureFile(path.join(root, "types", "assets.d.ts"), "declare module \"*.css\";\n");
|
|
413
|
+
await ensureFile(path.join(root, "assets", "css", "main.css"), options.includeLinkStyles ? STARTER_MAIN_CSS + STARTER_LINK_CSS : STARTER_MAIN_CSS);
|
|
414
|
+
}
|
|
337
415
|
async function ensureStarterProjectStructure(root, title, features, template) {
|
|
338
416
|
const selected = new Set(features);
|
|
417
|
+
if (template === "minimal") {
|
|
418
|
+
for (const relativeDir of [
|
|
419
|
+
"pages",
|
|
420
|
+
"layouts",
|
|
421
|
+
"assets/css",
|
|
422
|
+
"types",
|
|
423
|
+
"public"
|
|
424
|
+
]) await mkdir(path.join(root, relativeDir), { recursive: true });
|
|
425
|
+
await ensureStarterBaseFiles(root, {
|
|
426
|
+
includeLinkStyles: false,
|
|
427
|
+
includeTests: false
|
|
428
|
+
});
|
|
429
|
+
await ensureFile(path.join(root, "public", "favicon.svg"), `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" role="img" aria-label="Resux">
|
|
430
|
+
<rect width="128" height="128" rx="24" fill="#0f172a" />
|
|
431
|
+
<path d="M32 30h30c20 0 34 12 34 29 0 16-14 29-34 29H46v30H32z" fill="#22d3ee"/>
|
|
432
|
+
<circle cx="88" cy="93" r="11" fill="#a5f3fc"/>
|
|
433
|
+
</svg>
|
|
434
|
+
`);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
339
437
|
const shouldIncludeTests = selected.has("tests") || template === "default" || template === "full";
|
|
340
438
|
const shouldIncludeServerApi = selected.has("server-api") || template === "default" || template === "full";
|
|
341
439
|
const shouldIncludePackageExamples = selected.has("package-compatibility") || template === "package-compatibility" || template === "full";
|
|
@@ -358,32 +456,10 @@ async function ensureStarterProjectStructure(root, title, features, template) {
|
|
|
358
456
|
"types",
|
|
359
457
|
"tests"
|
|
360
458
|
]) await mkdir(path.join(root, relativeDir), { recursive: true });
|
|
361
|
-
await
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
await ensureFile(path.join(root, "assets", "css", "main.css"), `:root {
|
|
366
|
-
--rx-bg: #020617;
|
|
367
|
-
--rx-surface: #0f172a;
|
|
368
|
-
--rx-text: #e2e8f0;
|
|
369
|
-
--rx-muted: #94a3b8;
|
|
370
|
-
--rx-accent: #22d3ee;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
* {
|
|
374
|
-
box-sizing: border-box;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
body {
|
|
378
|
-
margin: 0;
|
|
379
|
-
font-family: "Segoe UI", system-ui, sans-serif;
|
|
380
|
-
background: radial-gradient(circle at top, #111827 0%, var(--rx-bg) 60%);
|
|
381
|
-
color: var(--rx-text);
|
|
382
|
-
}
|
|
383
|
-
a {
|
|
384
|
-
color: var(--rx-accent);
|
|
385
|
-
}
|
|
386
|
-
`);
|
|
459
|
+
await ensureStarterBaseFiles(root, {
|
|
460
|
+
includeLinkStyles: true,
|
|
461
|
+
includeTests: shouldIncludeTests
|
|
462
|
+
});
|
|
387
463
|
await ensureFile(path.join(root, "components", "AppHeader.vue"), `<template>
|
|
388
464
|
<header class="starter-header">
|
|
389
465
|
<ResuxLink to="/">${title}</ResuxLink>
|
|
@@ -824,6 +900,7 @@ function createStarterResuxConfig(title, features, options) {
|
|
|
824
900
|
`;
|
|
825
901
|
}
|
|
826
902
|
async function removeSeoFromPage(filePath) {
|
|
903
|
+
if (!existsSync(filePath)) return;
|
|
827
904
|
const withoutSeo = (await readFile(filePath, "utf8")).replace(/\nuseSeoMeta\(\{[\s\S]*?\}\)\n/g, "\n");
|
|
828
905
|
await writeFile(filePath, withoutSeo, "utf8");
|
|
829
906
|
}
|