zuby 1.0.65 → 1.0.67
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/config.js +10 -1
- package/contexts/pageContext.d.ts +1 -1
- package/contexts/pageContext.js +3 -3
- package/package.json +1 -1
- package/server/index.js +3 -3
- package/types.d.ts +4 -2
package/config.js
CHANGED
|
@@ -114,7 +114,16 @@ export const getZubyInternalConfig = async (configFilePath, cache = true) => {
|
|
|
114
114
|
path,
|
|
115
115
|
templateType: TEMPLATES.handler,
|
|
116
116
|
}),
|
|
117
|
-
addToHead: (element) =>
|
|
117
|
+
addToHead: (element, front = false) => {
|
|
118
|
+
if (front)
|
|
119
|
+
return zubyConfig.headElements?.unshift(element);
|
|
120
|
+
zubyConfig.headElements?.push(element);
|
|
121
|
+
},
|
|
122
|
+
addToBody: (element, front = false) => {
|
|
123
|
+
if (front)
|
|
124
|
+
return zubyConfig.bodyElements?.unshift(element);
|
|
125
|
+
zubyConfig.bodyElements?.push(element);
|
|
126
|
+
},
|
|
118
127
|
injectToEntry: (scriptCode, position = 'bottom') => {
|
|
119
128
|
if (position === 'top')
|
|
120
129
|
return zubyConfig.entryScriptsTop?.push(scriptCode);
|
|
@@ -14,7 +14,7 @@ export declare class PageContext {
|
|
|
14
14
|
protected _headElements: (string | (() => any))[];
|
|
15
15
|
protected _bodyElements: (string | (() => any))[];
|
|
16
16
|
protected _globalContext: GlobalContext;
|
|
17
|
-
constructor(options
|
|
17
|
+
constructor(options?: {
|
|
18
18
|
url?: URL;
|
|
19
19
|
initialPath?: string;
|
|
20
20
|
title?: string;
|
package/contexts/pageContext.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getGlobalContext } from './globalContext.js';
|
|
2
2
|
export class PageContext {
|
|
3
|
-
constructor(options) {
|
|
3
|
+
constructor(options = {}) {
|
|
4
4
|
this._request = options?.request;
|
|
5
5
|
this._url = options?.url || new URL(options?.request?.url || '/', 'http://localhost/');
|
|
6
6
|
this._initialPath = options?.initialPath || this._url.pathname;
|
|
@@ -13,8 +13,8 @@ export class PageContext {
|
|
|
13
13
|
this._cache = 0;
|
|
14
14
|
this._headers = options?.headers || new Headers();
|
|
15
15
|
this._globalContext = options?.globalContext || getGlobalContext();
|
|
16
|
-
this._headElements = [...(this._globalContext
|
|
17
|
-
this._bodyElements = [...(this._globalContext
|
|
16
|
+
this._headElements = [...(this._globalContext?.headElements || [])];
|
|
17
|
+
this._bodyElements = [...(this._globalContext?.bodyElements || [])];
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* The current URL of the page.
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -1844,7 +1844,7 @@ var getGlobalContext = () => {
|
|
|
1844
1844
|
|
|
1845
1845
|
// src/contexts/pageContext.ts
|
|
1846
1846
|
var PageContext = class {
|
|
1847
|
-
constructor(options) {
|
|
1847
|
+
constructor(options = {}) {
|
|
1848
1848
|
this._request = options?.request;
|
|
1849
1849
|
this._url = options?.url || new URL(options?.request?.url || "/", "http://localhost/");
|
|
1850
1850
|
this._initialPath = options?.initialPath || this._url.pathname;
|
|
@@ -1857,8 +1857,8 @@ var PageContext = class {
|
|
|
1857
1857
|
this._cache = 0;
|
|
1858
1858
|
this._headers = options?.headers || new Headers();
|
|
1859
1859
|
this._globalContext = options?.globalContext || getGlobalContext();
|
|
1860
|
-
this._headElements = [...this._globalContext
|
|
1861
|
-
this._bodyElements = [...this._globalContext
|
|
1860
|
+
this._headElements = [...this._globalContext?.headElements || []];
|
|
1861
|
+
this._bodyElements = [...this._globalContext?.bodyElements || []];
|
|
1862
1862
|
}
|
|
1863
1863
|
/**
|
|
1864
1864
|
* The current URL of the page.
|
package/types.d.ts
CHANGED
|
@@ -199,7 +199,7 @@ export interface ZubyConfig {
|
|
|
199
199
|
image?: {
|
|
200
200
|
/**
|
|
201
201
|
* The path to the image loader function.
|
|
202
|
-
* @default 'zuby/imageLoader.js'
|
|
202
|
+
* @default 'zuby/image/imageLoader.js'
|
|
203
203
|
*/
|
|
204
204
|
loader?: string;
|
|
205
205
|
/**
|
|
@@ -427,6 +427,7 @@ export interface ZubyPlugin extends VitePlugin {
|
|
|
427
427
|
}
|
|
428
428
|
export interface ZubyConfigSetupHookParams {
|
|
429
429
|
config: ZubyConfig;
|
|
430
|
+
logger: ZubyLogger;
|
|
430
431
|
command: 'dev' | 'build';
|
|
431
432
|
addEntryTemplate: (entryFile: string) => void;
|
|
432
433
|
addAppTemplate: (appFile: string, path?: string) => void;
|
|
@@ -436,7 +437,8 @@ export interface ZubyConfigSetupHookParams {
|
|
|
436
437
|
addLoaderTemplate: (loaderFile: string, path?: string) => void;
|
|
437
438
|
addPage: (pageFile: string, path?: string) => void;
|
|
438
439
|
addHandler: (handlerFile: string, path?: string) => void;
|
|
439
|
-
addToHead: (element: string) => void;
|
|
440
|
+
addToHead: (element: string, front?: boolean) => void;
|
|
441
|
+
addToBody: (element: string, front?: boolean) => void;
|
|
440
442
|
injectToEntry: (scriptCode: string, position?: 'top' | 'bottom') => void;
|
|
441
443
|
}
|
|
442
444
|
export interface ZubyConfigDoneHookParams extends ZubyConfigSetupHookParams {
|