@itrocks/framework 1.5.2 → 1.6.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 CHANGED
@@ -74,6 +74,16 @@ import { beforeFrameworkRun } from '@itrocks/framework'
74
74
  beforeFrameworkRun(() => import('./src/dependencies'))
75
75
  ```
76
76
 
77
+ ### Applications in subdirectories
78
+
79
+ The framework supports public mount paths such as `/showtime/`. The reverse proxy sets `X-Forwarded-Prefix: /showtime`;
80
+ no business routes or filesystem paths need that prefix. Rendering uses the current request's public URL callback,
81
+ including framework URL-valued data attributes. The home container supplies a `<base>` for browser-relative endpoints
82
+ and the import map. Application containers must provide the same base element before their scripts and links.
83
+ Application browser code should use base-relative endpoints or resolve them against `document.baseURI`.
84
+
85
+ For an Apache proxy, use `ProxyPass "/showtime/" "http://127.0.0.1:3456/"` and set the prefix header within that location.
86
+
77
87
  ### Request languages
78
88
 
79
89
  The framework can select one translation catalog for each request without sharing language state between concurrent
@@ -98,21 +98,24 @@ function bind() {
98
98
  const containerData = Object.assign(defaultContainerData(request), this);
99
99
  const contained = !request.request.headers['xhr-info'] && config_1.config.container?.file;
100
100
  const template = new template_1.Template(data, containerData);
101
+ template.applicationPath = request.request.applicationPath.bind(request.request);
102
+ template.publicUrl = request.request.publicUrl.bind(request.request);
103
+ template.urlAttributes.push('data-custom-list-route', 'data-fetch', 'data-feed', 'data-route');
101
104
  return this.htmlResponse(await template.parseFile(templateFile, contained && (0, node_path_1.join)(app_dir_1.appDir, config_1.config.container.file)), statusCode, headers);
102
105
  };
103
106
  }
104
107
  function configContainerData() {
105
108
  const configContainerData = config_1.config.container?.data ?? {};
106
109
  for (const [name, value] of Object.entries(configContainerData)) {
107
- if ((typeof value === 'string') && '@.'.includes(value[0])) {
108
- const exported = value.includes(':')
109
- ? require(value.split(':')[0])[value.split(':')[1]]
110
- : (require(value).default ?? Object.values(require(value))[0]);
111
- configContainerData[name] =
112
- (0, class_type_1.isAnyFunction)(exported) ? exported(config_1.config[name]) :
113
- (0, class_type_2.isAnyType)(exported) ? new exported(config_1.config[name]) :
114
- exported;
115
- }
110
+ if (!(typeof value === 'string') || !'@.'.includes(value[0]))
111
+ continue;
112
+ const exported = value.includes(':')
113
+ ? require(value.split(':')[0])[value.split(':')[1]]
114
+ : (require(value).default ?? Object.values(require(value))[0]);
115
+ configContainerData[name] =
116
+ (0, class_type_1.isAnyFunction)(exported) ? exported(config_1.config[name]) :
117
+ (0, class_type_2.isAnyType)(exported) ? new exported(config_1.config[name]) :
118
+ exported;
116
119
  }
117
120
  return configContainerData;
118
121
  }
package/package.json CHANGED
@@ -125,5 +125,5 @@
125
125
  "build:test": "tsc -p test/tsconfig.json",
126
126
  "test": "npm run build && npm run build:test && node --test test/*.test.js test/*.test.mjs"
127
127
  },
128
- "version": "1.5.2"
128
+ "version": "1.6.0"
129
129
  }
@@ -22,7 +22,10 @@ async function activate(entry) {
22
22
  if (!entry.article.isConnected || mounted.has(entry.article))
23
23
  return;
24
24
  integration = new ListPropertySelect(entry.article, {
25
- ...entry.options, advice: configuration.advice, metadata, templateUrl: '/property-select/template/html',
25
+ ...entry.options,
26
+ advice: configuration.advice,
27
+ metadata,
28
+ templateUrl: 'property-select/template/html',
26
29
  mountSelector: (content, title) => register(entry.article, content, title)
27
30
  });
28
31
  mounted.set(entry.article, integration);
@@ -3,9 +3,9 @@ export class HttpMetadataProvider {
3
3
  fetcher;
4
4
  initial;
5
5
  constructor(options = {}) {
6
- this.initial = options.initial;
7
- this.endpoint = options.endpoint ?? '/property-select';
6
+ this.endpoint = options.endpoint ?? 'property-select';
8
7
  this.fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
8
+ this.initial = options.initial;
9
9
  }
10
10
  configuration(root, signal) {
11
11
  return this.request('configuration', root, '', signal);