@t4h.framework/vite-panel-plugin 0.3.1 → 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/CHANGELOG.md +8 -0
- package/README.md +8 -8
- package/dist/node.d.ts +2 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +3 -2
- package/dist/node.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @t4h.framework/vite-panel-plugin
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#212](https://github.com/tech4humans-brasil/framework/pull/212) [`8f50cc5`](https://github.com/tech4humans-brasil/framework/commit/8f50cc5c494fd76b08536a08da397d2255d47d31) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - `render` takes a `nonce` that marks the inline config script, so a host with a
|
|
8
|
+
`script-src` Content Security Policy can serve the panel without
|
|
9
|
+
`'unsafe-inline'`.
|
|
10
|
+
|
|
3
11
|
## 0.3.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -86,14 +86,14 @@ import {
|
|
|
86
86
|
} from '@t4h.framework/vite-panel-plugin/node'
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
| Export | Use
|
|
90
|
-
| -------------------------- |
|
|
91
|
-
| `createPanelHandler` | The whole panel as one `node:http` middleware — the page for a navigation under `basePath`, the assets for everything else. What the plugin uses
|
|
92
|
-
| `createPanelAssetsHandler` | The hashed assets, cached forever, for a host that mounts them at a shared public path; `index: false` so a miss falls through
|
|
93
|
-
| `render` | `index.html` with the whole `PanelConfig` and the `<base href>` in place; `{ baseHref }` overrides the default `` `${basePath}/`
|
|
94
|
-
| `PANEL_CLIENT_DIST` | `dist/client`, the built SPA
|
|
95
|
-
| `PANEL_CLIENT_ASSETS_DIR` | `dist/client/assets`, safe to serve publicly and cache forever — the names are hashed and `index.html` is not in there
|
|
96
|
-
| `assertPanelBuilt` | Throws when the package was not built
|
|
89
|
+
| Export | Use |
|
|
90
|
+
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
91
|
+
| `createPanelHandler` | The whole panel as one `node:http` middleware — the page for a navigation under `basePath`, the assets for everything else. What the plugin uses |
|
|
92
|
+
| `createPanelAssetsHandler` | The hashed assets, cached forever, for a host that mounts them at a shared public path; `index: false` so a miss falls through |
|
|
93
|
+
| `render` | `index.html` with the whole `PanelConfig` and the `<base href>` in place; `{ baseHref }` overrides the default `` `${basePath}/` ``, `{ nonce }` marks the config script for a `script-src` CSP |
|
|
94
|
+
| `PANEL_CLIENT_DIST` | `dist/client`, the built SPA |
|
|
95
|
+
| `PANEL_CLIENT_ASSETS_DIR` | `dist/client/assets`, safe to serve publicly and cache forever — the names are hashed and `index.html` is not in there |
|
|
96
|
+
| `assertPanelBuilt` | Throws when the package was not built |
|
|
97
97
|
|
|
98
98
|
The runtime serves one panel per project version, so `basePath` carries the
|
|
99
99
|
tenant and the version while the assets live at a single shared path. Splitting
|
package/dist/node.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export type NodeMiddleware = (req: IncomingMessage, res: ServerResponse, next: (
|
|
|
7
7
|
export declare function assertPanelBuilt(): void;
|
|
8
8
|
export interface RenderOptions {
|
|
9
9
|
baseHref?: string;
|
|
10
|
+
nonce?: string;
|
|
10
11
|
}
|
|
11
|
-
export declare function render(config: PanelConfig, { baseHref }?: RenderOptions): string;
|
|
12
|
+
export declare function render(config: PanelConfig, { baseHref, nonce }?: RenderOptions): string;
|
|
12
13
|
export interface PanelAssetsHandlerOptions {
|
|
13
14
|
root?: string;
|
|
14
15
|
immutable?: boolean;
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AACA,OAA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ET,wBAAgB,gBAAgB,IAAI,IAAI,CAKvC;AAUD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,EAAE,QAAgC,EAAE,KAAK,EAAE,GAAE,aAAkB,GAC9D,MAAM,CAWR;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,IAA8B,EAC9B,SAAgB,GACjB,GAAE,yBAA8B,GAAG,cAAc,CAQjD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ1E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQ5E;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,QAAQ,GACT,EAAE,mBAAmB,GAAG,cAAc,CA+BtC"}
|
package/dist/node.js
CHANGED
|
@@ -17,11 +17,12 @@ function readTemplate() {
|
|
|
17
17
|
assertPanelBuilt();
|
|
18
18
|
return (template ??= fs.readFileSync(INDEX_HTML, 'utf8'));
|
|
19
19
|
}
|
|
20
|
-
export function render(config, { baseHref = `${config.basePath}
|
|
20
|
+
export function render(config, { baseHref = `${config.basePath}/`, nonce } = {}) {
|
|
21
21
|
const json = JSON.stringify(config).replaceAll('</', '<\\/');
|
|
22
|
+
const nonceAttribute = nonce === undefined ? '' : ` nonce="${nonce}"`;
|
|
22
23
|
return readTemplate()
|
|
23
24
|
.replace(BASE_PLACEHOLDER, `<base href="${baseHref}" />`)
|
|
24
|
-
.replace(CONFIG_PLACEHOLDER, `<script>window.${PANEL_CONFIG_GLOBAL} = ${json}</script>`);
|
|
25
|
+
.replace(CONFIG_PLACEHOLDER, `<script${nonceAttribute}>window.${PANEL_CONFIG_GLOBAL} = ${json}</script>`);
|
|
25
26
|
}
|
|
26
27
|
export function createPanelAssetsHandler({ root = PANEL_CLIENT_ASSETS_DIR, immutable = true, } = {}) {
|
|
27
28
|
assertPanelBuilt();
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AAExB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,WAAW,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,mBAAmB,EAAoB,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAQN,MAAM,mBAAmB,CAAA;AAE1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAC3C,MAAM,CAAC,IAAI,CAAC,OAAO,EACnB,IAAI,EACJ,MAAM,EACN,QAAQ,CACT,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAA;AAE7E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAA;AAE7D,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AAE5C,MAAM,kBAAkB,GAAG,qBAAqB,CAAA;AAQhD,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,6BAA6B,iBAAiB,gDAAgD,CAC/F,CAAA;AACL,CAAC;AAED,IAAI,QAA4B,CAAA;AAEhC,SAAS,YAAY;IACnB,gBAAg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GAAG,EAAE,GAAG,EAAE;YACpB,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAA;YAElB,IAAI,EAAE,CAAA;QACR,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t4h.framework/vite-panel-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Panel UI plugin for T4H Framework",
|
|
5
5
|
"homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/vite-panel-plugin",
|
|
6
6
|
"bugs": "https://github.com/tech4humans-brasil/framework/issues",
|