@stacksjs/stx 0.2.116 → 0.2.117

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/dist/menubar.d.ts CHANGED
@@ -30,6 +30,7 @@ export declare interface MenuBarMenuItem {
30
30
  export declare interface MenuBarAppOptions<T extends Record<string, unknown>> {
31
31
  name: string
32
32
  template: string
33
+ templateSource?: string
33
34
  preferences?: T
34
35
  context?: (preferences: Preferences<T>) => Record<string, unknown> | Promise<Record<string, unknown>>
35
36
  routes?: Routes<T>
package/dist/menubar.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createPreferences, createWindow, setAutoLaunch } from "@stacksjs/desktop";
2
- import { renderTemplate } from "./render.js";
2
+ import { renderTemplate, renderTemplateString } from "./render.js";
3
3
  const MENU_BAR_WINDOW = {
4
4
  width: 320,
5
5
  height: 640,
@@ -42,11 +42,7 @@ export function createMenuBarApp(options) {
42
42
  routes.set(key, handler);
43
43
  let server = null, window = null, url = null;
44
44
  async function renderPopup() {
45
- const context = await options.context?.(preferences) ?? {}, html = await renderTemplate(options.template, {
46
- context,
47
- wrapInDocument: !0,
48
- title: options.name
49
- });
45
+ const renderOptions = { context: await options.context?.(preferences) ?? {}, wrapInDocument: !0, title: options.name }, html = options.templateSource ? await renderTemplateString(options.templateSource, options.template, renderOptions) : await renderTemplate(options.template, renderOptions);
50
46
  return new Response(html, { headers: { "Content-Type": "text/html; charset=utf-8" } });
51
47
  }
52
48
  function serve() {
package/dist/render.d.ts CHANGED
@@ -24,6 +24,20 @@ export declare function renderTemplate(filePath: string, renderOptions?: RenderO
24
24
  * @returns The rendered HTML string
25
25
  */
26
26
  export declare function renderString(template: string, context?: Record<string, unknown>, options?: { templateOnly?: boolean }): Promise<string>;
27
+ /**
28
+ * Render template content that is already in memory, resolving includes and
29
+ * components relative to `filePath`.
30
+ *
31
+ * Use this when the template cannot be read from disk at runtime — most often an
32
+ * app compiled to a single binary, where the `.stx` file is embedded at build
33
+ * time via `import source from './app.stx' with { type: 'text' }` and
34
+ * `filePath` only anchors relative lookups.
35
+ *
36
+ * @param content - The stx template source
37
+ * @param filePath - Path the template came from, used to resolve relative includes
38
+ * @param renderOptions - Additional rendering options
39
+ */
40
+ export declare function renderTemplateString(content: string, filePath: string, renderOptions?: RenderOptions): Promise<string>;
27
41
  // ============================================================================
28
42
  // Types
29
43
  // ============================================================================
package/dist/render.js CHANGED
@@ -89,7 +89,7 @@ export async function renderTemplate(filePath, renderOptions = {}) {
89
89
  export async function renderString(template, context = {}, options) {
90
90
  return renderTemplateString(template, process.cwd(), { context, ...options });
91
91
  }
92
- async function renderTemplateString(content, filePath, renderOptions = {}) {
92
+ export async function renderTemplateString(content, filePath, renderOptions = {}) {
93
93
  const { templateContent, serverScripts, clientScripts } = parseTemplate(content), options = {
94
94
  ...defaultConfig,
95
95
  ...renderOptions.options
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.116",
4
+ "version": "0.2.117",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.12",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.116",
121
- "@stacksjs/sanitizer": "0.2.116",
120
+ "@stacksjs/desktop": "0.2.117",
121
+ "@stacksjs/sanitizer": "0.2.117",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.116",
123
+ "bun-plugin-stx": "0.2.117",
124
124
  "bunfig": "^0.15.15",
125
- "stx-router": "0.2.116",
125
+ "stx-router": "0.2.117",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.1.9",
128
128
  "ts-syntax-highlighter": "^0.2.1"