Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 50 additions & 44 deletions types/ClientContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,99 +8,105 @@ import { NullstackSettings } from "./Settings";
import { NullstackWorker } from "./Worker";

/**
* https://nullstack.app/context
* @see https://nullstack.app/context
*/
export type NullstackClientContext = {

/**
* Information about the document `head` metatags.
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
page?: NullstackPage,
page?: NullstackPage;

/**
* Information about the app manifest and some metatags.
*
* https://nullstack.app/context-project
* @see https://nullstack.app/context-project
*/
project?: NullstackProject,
project?: NullstackProject;

/**
* Gives you granular control of your PWA behavior.
*
* https://nullstack.app/service-worker
*
* @see https://nullstack.app/service-worker
*/
worker?: NullstackWorker,
worker?: NullstackWorker;

/**
* It gives you information about the instance lifecycle and it's unique [key](https://nullstack.app/instance-self#instance-key).
*
* https://nullstack.app/instance-self
* It gives you information about the instance lifecycle and it's unique key.
*
* @see https://nullstack.app/instance-self
* @see https://nullstack.app/instance-self#instance-key
*/
self?: NullstackSelf,
self?: NullstackSelf;

/**
* It gives you information about the element dataset.
*
* Any `data-*` attributes will receive a respective camelized key on this object.
*
* Only on client.
*
* https://nullstack.app/context-data
*
* @scope client
* @see https://nullstack.app/context-data
*/
data?: object,
data?: Record<string, string>;

/**
* It gives you all active instances of the application.
*
* Adding a [key](https://nullstack.app/instance-self#instance-key) to a Component adds it here.
*
* Only on client.
*
* https://nullstack.app/context-instances
*
* @scope client
* @see https://nullstack.app/context-instances
*/
instances?: object,
instances?: Record<string, any>;

/**
* It gives you information about the current environment.
*
* https://nullstack.app/context-environment
*
* @see https://nullstack.app/context-environment
*/
environment?: NullstackEnvironment,
environment?: NullstackEnvironment;

/**
* Each query string param is mapped to this object.
*
* https://nullstack.app/routes-and-params#params
*
* @see https://nullstack.app/routes-and-params#params
* @example
* "/?expanded=true&page=2" === {expanded: true, page: 2}
* ```
* "/?expanded=true&page=2" ===
* {expanded: true, page: 2}
* ```
*/
params?: NullstackParams,
params?: NullstackParams;

/**
* Nullstack router.
*
* https://nullstack.app/routes-and-params#router
*
* @see https://nullstack.app/routes-and-params#router
*/
router?: NullstackRouter,
router?: NullstackRouter;

/**
* You can assign any key with any type of public information.
*
* .env `NULLSTACK_SETTINGS_PUBLIC_KEY` -> `settings.publicKey`
*
* https://nullstack.app/context-settings
*
* @example
* ```
* // .env NULLSTACK_SETTINGS_PUBLIC_KEY
* settings.publicKey
* ```
* @see https://nullstack.app/context-settings
*/
settings?: NullstackSettings,
settings?: NullstackSettings;

/**
* Children elements of this component.
*
* https://nullstack.app/renderable-components#components-with-children
*
* @see https://nullstack.app/renderable-components#components-with-children
*/
children?: any,
children?: any;

[key: string]: any
/**
* Custom context prop.
*/
[key: string]: any;

};
16 changes: 8 additions & 8 deletions types/Environment.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export type NullstackEnvironment = {

client: boolean,
client: boolean;

server: boolean,
server: boolean;

development: boolean,
development: boolean;

production: boolean,
production: boolean;

static: boolean,
static: boolean;

/**
* md5 hash of the current environment folder outputs.
*
* https://nullstack.app/context-environment
*
* @see https://nullstack.app/context-environment
*/
key: string
key: string;

};
76 changes: 41 additions & 35 deletions types/Page.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,84 @@ export type NullstackPage = {

/**
* Current page title
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
title: string,
title: string;

/**
* Path to site banner at **public** folder
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
image: string,
image: string;

/**
* Current page description
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
description?: string,
description?: string;

/**
* Absolute canonical url
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
canonical: string,
canonical: string;

/**
* Current page locale, example: `en-US`
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
locale: string,
locale: string;

/**
* Related to robots.txt file generation
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
robots: string,
robots: string;

schema?: object,
schema?: any;

/**
* Represents the `changefreq` key in the **sitemap.xml**
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
changes: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never',
changes:
| "always"
| "hourly"
| "daily"
| "weekly"
| "monthly"
| "yearly"
| "never";

/**
* Represents the `priority` key in the **sitemap.xml**
*
* sitemaps assume a `0.5` priority
*
* https://nullstack.app/context-page
*
* sitemaps assumes a `0.5` priority
*
* @see https://nullstack.app/context-page
*/
priority: number,
priority: number;

/**
* The page current HTTP response, example: `200`
*
* https://nullstack.app/context-page
*
* @see https://nullstack.app/context-page
*/
status: number,
status: number;

/**
* Event raised when `page.title` changes.
*
* Only on client.
*
* https://nullstack.app/context-page#custom-events
*
* @scope client
* @see https://nullstack.app/context-page#custom-events
*/
event: string
event: string;

};
2 changes: 1 addition & 1 deletion types/Params.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type NullstackParams = {
[key: string]: string | boolean
[key: string]: string | boolean;
};
24 changes: 12 additions & 12 deletions types/Plugin.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { NullstackClientContext } from './ClientContext';
import { NullstackClientContext } from "./ClientContext";

type NullstackNode = {
type: string | boolean,
type: string | boolean;
attributes: {
route: string,
html: string,
[key: string]: any
},
children: any[]
route: string;
html: string;
[key: string]: any;
};
children: any[];
};

interface NullstackNodeContext extends NullstackClientContext {
node: NullstackNode
node: NullstackNode;
}

export type NullstackPlugin = {
Expand All @@ -20,22 +20,22 @@ export type NullstackPlugin = {
* Runs transformation to node element
* @param context Context with node attributes
*/
transform(context: NullstackNodeContext),
transform(context: NullstackNodeContext);

/**
* Load something when plugin installs
* @param context Application context
*/
load?(context: NullstackClientContext),
load?(context: NullstackClientContext);

/**
* Use plugin in the server environment
*/
server?: boolean,
server?: boolean;

/**
* Use plugin in the client environment
*/
client?: boolean
client?: boolean;

};
Loading