@open-pioneer/runtime 0.1.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 +13 -0
- package/CustomElement.js +335 -0
- package/CustomElement.js.map +1 -0
- package/LICENSE +202 -0
- package/README.md +37 -0
- package/builtin-services/ApiServiceImpl.js +46 -0
- package/builtin-services/ApiServiceImpl.js.map +1 -0
- package/builtin-services/ApplicationContextImpl.js +32 -0
- package/builtin-services/ApplicationContextImpl.js.map +1 -0
- package/builtin-services/ApplicationLifecycleEventService.js +39 -0
- package/builtin-services/ApplicationLifecycleEventService.js.map +1 -0
- package/builtin-services/index.js +76 -0
- package/builtin-services/index.js.map +1 -0
- package/errors.js +21 -0
- package/errors.js.map +1 -0
- package/i18n.js +105 -0
- package/i18n.js.map +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/metadata/ObservableBox.js +25 -0
- package/metadata/ObservableBox.js.map +1 -0
- package/metadata/index.js +2 -0
- package/metadata/index.js.map +1 -0
- package/package.json +36 -0
- package/react-integration/PackageContext.js +6 -0
- package/react-integration/PackageContext.js.map +1 -0
- package/react-integration/ReactIntegration.js +92 -0
- package/react-integration/ReactIntegration.js.map +1 -0
- package/react-integration/hooks.js +45 -0
- package/react-integration/hooks.js.map +1 -0
- package/react-integration/index.js +3 -0
- package/react-integration/index.js.map +1 -0
- package/service-layer/InterfaceSpec.js +36 -0
- package/service-layer/InterfaceSpec.js.map +1 -0
- package/service-layer/PackageRepr.js +101 -0
- package/service-layer/PackageRepr.js.map +1 -0
- package/service-layer/ServiceLayer.js +265 -0
- package/service-layer/ServiceLayer.js.map +1 -0
- package/service-layer/ServiceLookup.js +169 -0
- package/service-layer/ServiceLookup.js.map +1 -0
- package/service-layer/ServiceRepr.js +200 -0
- package/service-layer/ServiceRepr.js.map +1 -0
- package/service-layer/verifyDependencies.js +198 -0
- package/service-layer/verifyDependencies.js.map +1 -0
package/CHANGELOG.md
ADDED
package/CustomElement.js
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { createLogger, Error, isAbortError, createAbortError, destroyResource, createManualPromise, throwAbortError, getErrorChain } from '@open-pioneer/core';
|
|
2
|
+
import { ErrorId } from './errors.js';
|
|
3
|
+
import { createPackages } from './service-layer/PackageRepr.js';
|
|
4
|
+
import { ServiceLayer } from './service-layer/ServiceLayer.js';
|
|
5
|
+
import { ReactIntegration } from './react-integration/ReactIntegration.js';
|
|
6
|
+
import { createBuiltinPackage, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_API_SERVICE, RUNTIME_AUTO_START } from './builtin-services/index.js';
|
|
7
|
+
import { initI18n } from './i18n.js';
|
|
8
|
+
|
|
9
|
+
const LOG = createLogger("runtime:CustomElement");
|
|
10
|
+
function createCustomElement(options) {
|
|
11
|
+
class PioneerApplication extends HTMLElement {
|
|
12
|
+
#shadowRoot;
|
|
13
|
+
#state;
|
|
14
|
+
static get observedAttributes() {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
const mode = options.openShadowRoot ?? import.meta.env.DEV ? "open" : "closed";
|
|
20
|
+
this.#shadowRoot = this.attachShadow({
|
|
21
|
+
mode
|
|
22
|
+
});
|
|
23
|
+
if (import.meta.env.DEV) {
|
|
24
|
+
this.$inspectElementState = () => this.#state;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
LOG.debug("Launching application");
|
|
29
|
+
if (this.#state) {
|
|
30
|
+
this.#state.destroy();
|
|
31
|
+
}
|
|
32
|
+
this.#state = new ElementState(this, this.#shadowRoot, options);
|
|
33
|
+
this.#state.start();
|
|
34
|
+
}
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
LOG.debug("Shutting down application");
|
|
37
|
+
this.#state?.destroy();
|
|
38
|
+
this.#state = void 0;
|
|
39
|
+
LOG.debug("Application destroyed");
|
|
40
|
+
}
|
|
41
|
+
when() {
|
|
42
|
+
if (!this.#state) {
|
|
43
|
+
return Promise.reject(
|
|
44
|
+
new Error(
|
|
45
|
+
ErrorId.NOT_MOUNTED,
|
|
46
|
+
"Cannot use the application's API because the HTML element has not yet been mounted into the DOM."
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return this.#state.whenAPI();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return PioneerApplication;
|
|
54
|
+
}
|
|
55
|
+
class ElementState {
|
|
56
|
+
hostElement;
|
|
57
|
+
shadowRoot;
|
|
58
|
+
options;
|
|
59
|
+
// Public API
|
|
60
|
+
apiPromise;
|
|
61
|
+
// Present when callers are waiting for the API
|
|
62
|
+
api;
|
|
63
|
+
// Present once started
|
|
64
|
+
state = "not-started";
|
|
65
|
+
locale;
|
|
66
|
+
container;
|
|
67
|
+
config;
|
|
68
|
+
serviceLayer;
|
|
69
|
+
lifecycleEvents;
|
|
70
|
+
reactIntegration;
|
|
71
|
+
stylesWatch;
|
|
72
|
+
constructor(hostElement, shadowRoot, options) {
|
|
73
|
+
this.hostElement = hostElement;
|
|
74
|
+
this.shadowRoot = shadowRoot;
|
|
75
|
+
this.options = options;
|
|
76
|
+
}
|
|
77
|
+
start() {
|
|
78
|
+
if (this.state !== "not-started") {
|
|
79
|
+
throw new Error(ErrorId.INTERNAL, `Cannot start element in state '${this.state}'`);
|
|
80
|
+
}
|
|
81
|
+
this.state = "starting";
|
|
82
|
+
this.startImpl().catch((e) => {
|
|
83
|
+
this.destroy();
|
|
84
|
+
if (!isAbortError(e)) {
|
|
85
|
+
logError(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
destroy() {
|
|
90
|
+
if (this.state === "destroyed") {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (this.state === "started") {
|
|
94
|
+
try {
|
|
95
|
+
this.triggerApplicationLifecycleEvent("before-stop");
|
|
96
|
+
} catch (e) {
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this.state = "destroyed";
|
|
100
|
+
this.apiPromise?.reject(createAbortError());
|
|
101
|
+
this.reactIntegration = destroyResource(this.reactIntegration);
|
|
102
|
+
this.shadowRoot.replaceChildren();
|
|
103
|
+
this.container = void 0;
|
|
104
|
+
this.lifecycleEvents = void 0;
|
|
105
|
+
this.serviceLayer = destroyResource(this.serviceLayer);
|
|
106
|
+
this.stylesWatch = destroyResource(this.stylesWatch);
|
|
107
|
+
}
|
|
108
|
+
whenAPI() {
|
|
109
|
+
if (this.api) {
|
|
110
|
+
return Promise.resolve(this.api);
|
|
111
|
+
}
|
|
112
|
+
const apiPromise = this.apiPromise ??= createManualPromise();
|
|
113
|
+
return apiPromise.promise;
|
|
114
|
+
}
|
|
115
|
+
async startImpl() {
|
|
116
|
+
const { options, shadowRoot, hostElement } = this;
|
|
117
|
+
const config = this.config = await gatherConfig(hostElement, options);
|
|
118
|
+
this.checkAbort();
|
|
119
|
+
LOG.debug("Application config is", config);
|
|
120
|
+
const i18n = await initI18n(options.appMetadata, config.locale);
|
|
121
|
+
this.checkAbort();
|
|
122
|
+
const container = this.container = createContainer(i18n.locale);
|
|
123
|
+
const styles = this.initStyles();
|
|
124
|
+
shadowRoot.replaceChildren(container, ...styles);
|
|
125
|
+
const { serviceLayer, packages } = this.initServiceLayer({
|
|
126
|
+
container,
|
|
127
|
+
properties: config.properties,
|
|
128
|
+
i18n
|
|
129
|
+
});
|
|
130
|
+
this.lifecycleEvents = getInternalService(
|
|
131
|
+
serviceLayer,
|
|
132
|
+
RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE
|
|
133
|
+
);
|
|
134
|
+
await this.initAPI(serviceLayer);
|
|
135
|
+
this.checkAbort();
|
|
136
|
+
this.reactIntegration = new ReactIntegration({
|
|
137
|
+
rootNode: container,
|
|
138
|
+
container: shadowRoot,
|
|
139
|
+
serviceLayer,
|
|
140
|
+
packages
|
|
141
|
+
});
|
|
142
|
+
this.render();
|
|
143
|
+
this.state = "started";
|
|
144
|
+
this.triggerApplicationLifecycleEvent("after-start");
|
|
145
|
+
LOG.debug("Application started");
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
this.reactIntegration?.render(this.options.component ?? emptyComponent, {});
|
|
149
|
+
}
|
|
150
|
+
initStyles() {
|
|
151
|
+
const builtinStyles = ":host { all: initial; display: block; }";
|
|
152
|
+
const builtinStylesNode = document.createElement("style");
|
|
153
|
+
applyStyles(builtinStylesNode, { value: builtinStyles });
|
|
154
|
+
const appStyles = this.options.appMetadata?.styles;
|
|
155
|
+
const appStylesNode = document.createElement("style");
|
|
156
|
+
applyStyles(appStylesNode, appStyles);
|
|
157
|
+
if (import.meta.hot) {
|
|
158
|
+
this.stylesWatch = appStyles?.on?.("changed", () => {
|
|
159
|
+
LOG.debug("Application styles changed");
|
|
160
|
+
applyStyles(appStylesNode, appStyles);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return [builtinStylesNode, appStylesNode];
|
|
164
|
+
}
|
|
165
|
+
initServiceLayer(config) {
|
|
166
|
+
const options = this.options;
|
|
167
|
+
const { container, properties, i18n } = config;
|
|
168
|
+
const packageMetadata = options.appMetadata?.packages ?? {};
|
|
169
|
+
const builtinPackage = createBuiltinPackage({
|
|
170
|
+
host: this.hostElement,
|
|
171
|
+
shadowRoot: this.shadowRoot,
|
|
172
|
+
container,
|
|
173
|
+
locale: i18n.locale,
|
|
174
|
+
supportedLocales: i18n.supportedLocales
|
|
175
|
+
});
|
|
176
|
+
const { serviceLayer, packages } = createServiceLayer({
|
|
177
|
+
packageMetadata,
|
|
178
|
+
builtinPackage,
|
|
179
|
+
properties,
|
|
180
|
+
i18n
|
|
181
|
+
});
|
|
182
|
+
this.serviceLayer = serviceLayer;
|
|
183
|
+
if (LOG.isDebug()) {
|
|
184
|
+
LOG.debug("Launching service layer with packages", Object.fromEntries(packages));
|
|
185
|
+
}
|
|
186
|
+
serviceLayer.start();
|
|
187
|
+
return { serviceLayer, packages };
|
|
188
|
+
}
|
|
189
|
+
async initAPI(serviceLayer) {
|
|
190
|
+
const apiService = getInternalService(serviceLayer, RUNTIME_API_SERVICE);
|
|
191
|
+
try {
|
|
192
|
+
const api = this.api = await apiService.getApi();
|
|
193
|
+
LOG.debug("Application API initialized to", api);
|
|
194
|
+
this.apiPromise?.resolve(api);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
throw new Error(ErrorId.INTERNAL, "Failed to gather the application's API methods.", {
|
|
197
|
+
cause: e
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
triggerApplicationLifecycleEvent(event) {
|
|
202
|
+
this.lifecycleEvents?.emitLifecycleEvent(event);
|
|
203
|
+
}
|
|
204
|
+
checkAbort() {
|
|
205
|
+
if (this.state === "destroyed") {
|
|
206
|
+
throwAbortError();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function createContainer(locale) {
|
|
211
|
+
const container = document.createElement("div");
|
|
212
|
+
container.classList.add("pioneer-root");
|
|
213
|
+
container.style.minHeight = "100%";
|
|
214
|
+
container.style.height = "100%";
|
|
215
|
+
if (locale) {
|
|
216
|
+
container.lang = locale;
|
|
217
|
+
}
|
|
218
|
+
return container;
|
|
219
|
+
}
|
|
220
|
+
function createServiceLayer(config) {
|
|
221
|
+
const { packageMetadata, properties, builtinPackage, i18n } = config;
|
|
222
|
+
let packages;
|
|
223
|
+
try {
|
|
224
|
+
packages = createPackages(packageMetadata ?? {}, i18n, properties);
|
|
225
|
+
} catch (e) {
|
|
226
|
+
throw new Error(ErrorId.INVALID_METADATA, "Failed to parse package metadata.", {
|
|
227
|
+
cause: e
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
{
|
|
231
|
+
const index = packages.findIndex((pkg) => pkg.name === builtinPackage.name);
|
|
232
|
+
if (index >= 0) {
|
|
233
|
+
packages.splice(index, 1);
|
|
234
|
+
}
|
|
235
|
+
packages.push(builtinPackage);
|
|
236
|
+
}
|
|
237
|
+
const forcedReferences = [
|
|
238
|
+
{
|
|
239
|
+
interfaceName: RUNTIME_API_SERVICE
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
interfaceName: RUNTIME_AUTO_START,
|
|
246
|
+
all: true
|
|
247
|
+
}
|
|
248
|
+
];
|
|
249
|
+
const serviceLayer = new ServiceLayer(packages, forcedReferences);
|
|
250
|
+
return {
|
|
251
|
+
packages: new Map(packages.map((pkg) => [pkg.name, pkg])),
|
|
252
|
+
serviceLayer
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function getInternalService(serviceLayer, interfaceName) {
|
|
256
|
+
const result = serviceLayer.getService(
|
|
257
|
+
"@open-pioneer/runtime",
|
|
258
|
+
{
|
|
259
|
+
interfaceName
|
|
260
|
+
},
|
|
261
|
+
{ ignoreDeclarationCheck: true }
|
|
262
|
+
);
|
|
263
|
+
if (result.type !== "found") {
|
|
264
|
+
throw new Error(
|
|
265
|
+
ErrorId.INTERNAL,
|
|
266
|
+
`Failed to find instance of '${interfaceName}' (result type '${result.type}'). This is a builtin service that must be present exactly once.`
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
return result.value.getInstanceOrThrow();
|
|
270
|
+
}
|
|
271
|
+
async function gatherConfig(hostElement, options) {
|
|
272
|
+
let configs;
|
|
273
|
+
try {
|
|
274
|
+
const staticConfig = options.config ?? {};
|
|
275
|
+
const dynamicConfig = await options.resolveConfig?.({
|
|
276
|
+
getAttribute(name) {
|
|
277
|
+
return hostElement.getAttribute(name) ?? void 0;
|
|
278
|
+
}
|
|
279
|
+
}) ?? {};
|
|
280
|
+
configs = [staticConfig, dynamicConfig];
|
|
281
|
+
} catch (e) {
|
|
282
|
+
throw new Error(
|
|
283
|
+
ErrorId.CONFIG_RESOLUTION_FAILED,
|
|
284
|
+
"Failed to resolve application properties.",
|
|
285
|
+
{
|
|
286
|
+
cause: e
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
return mergeConfigs(configs);
|
|
291
|
+
}
|
|
292
|
+
function mergeConfigs(configs) {
|
|
293
|
+
const mergedConfig = Object.assign(
|
|
294
|
+
{
|
|
295
|
+
locale: void 0,
|
|
296
|
+
properties: {}
|
|
297
|
+
},
|
|
298
|
+
...configs
|
|
299
|
+
);
|
|
300
|
+
const mergedProperties = mergedConfig.properties = {};
|
|
301
|
+
for (const config of configs) {
|
|
302
|
+
for (const [packageName, packageProperties] of Object.entries(config.properties ?? {})) {
|
|
303
|
+
const mergedPackageProps = mergedProperties[packageName] ??= {};
|
|
304
|
+
Object.assign(mergedPackageProps, packageProperties);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return mergedConfig;
|
|
308
|
+
}
|
|
309
|
+
function applyStyles(styleNode, styles) {
|
|
310
|
+
const cssValue = styles?.value ?? "";
|
|
311
|
+
const cssNode = document.createTextNode(cssValue);
|
|
312
|
+
styleNode.replaceChildren(cssNode);
|
|
313
|
+
}
|
|
314
|
+
function logError(e) {
|
|
315
|
+
if (e instanceof Error) {
|
|
316
|
+
const chain = getErrorChain(e).reverse();
|
|
317
|
+
if (chain.length === 1) {
|
|
318
|
+
console.error(e);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
let n = 1;
|
|
322
|
+
for (const error of chain) {
|
|
323
|
+
console.error(`#${n}`, error);
|
|
324
|
+
++n;
|
|
325
|
+
}
|
|
326
|
+
} else {
|
|
327
|
+
console.error("Unexpected error", e);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function emptyComponent() {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export { createCustomElement };
|
|
335
|
+
//# sourceMappingURL=CustomElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomElement.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/CustomElement.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ComponentType } from \"react\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n destroyResource,\n Error,\n isAbortError,\n ManualPromise,\n Resource,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata, PackageMetadata } from \"./metadata\";\nimport { PackageRepr, createPackages } from \"./service-layer/PackageRepr\";\nimport { ServiceLayer } from \"./service-layer/ServiceLayer\";\nimport { getErrorChain } from \"@open-pioneer/core\";\nimport { ReactIntegration } from \"./react-integration/ReactIntegration\";\nimport { ApiMethods, ApiService } from \"./api\";\nimport {\n createBuiltinPackage,\n RUNTIME_API_SERVICE,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n RUNTIME_AUTO_START\n} from \"./builtin-services\";\nimport { ReferenceSpec } from \"./service-layer/InterfaceSpec\";\nimport { PropertiesRegistry } from \"./PropertiesRegistry\";\nimport { AppI18n, initI18n } from \"./i18n\";\nimport { ApplicationLifecycleEventService } from \"./builtin-services/ApplicationLifecycleEventService\";\nconst LOG = createLogger(\"runtime:CustomElement\");\n\n/**\n * Options for the {@link createCustomElement} function.\n */\nexport interface CustomElementOptions {\n /**\n * Rendered UI component.\n */\n component?: ComponentType<Record<string, string>>;\n\n /**\n * Application metadata (packages, services etc.).\n * This is usually autogenerated by importing the virtual `\"open-pioneer:app\"` module.\n */\n appMetadata?: ApplicationMetadata;\n\n /**\n * Application defined configuration.\n * All instances of the web component will share this static configuration.\n *\n * These will override default properties of the application's packages.\n */\n config?: ApplicationConfig;\n\n /**\n * Function to provide additional application defined configuration parameters.\n *\n * Compared to {@link config}, this function receives a context object\n * that allows the developer to provide dynamic properties on a per-application basis.\n *\n * Parameters returned by this function take precedence over the ones defined by {@link config}.\n */\n resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;\n\n /**\n * Whether the shadow root element is accessible from the outside.\n * Defaults to `false` in production mode and `true` during development to make testing easier.\n */\n openShadowRoot?: boolean;\n}\n\n/**\n * A context object that is passed to the `resolveProperties` function.\n */\nexport interface ConfigContext {\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Runtime application configuration.\n */\nexport interface ApplicationConfig {\n /**\n * Set this value to a locale string (e.g. \"en\") to for the application's locale.\n * The default behavior is to choose an appropriate locale for the current user based\n * on the browser's settings.\n *\n * The locale must be supported by the application.\n */\n locale?: string | undefined;\n\n /**\n * Properties specified here will override default properties of the application's packages.\n */\n properties?: ApplicationProperties | undefined;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n */\nexport interface RawApplicationProperties {\n /**\n * Key: the name of the package.\n * Value: A record of configuration properties (key/value pairs).\n *\n * Properties will override default property values in the package.\n */\n [packageName: string]: Record<string, unknown>;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n *\n * Properties are typed when the package contains type definitions for them.\n */\nexport type ApplicationProperties = RawApplicationProperties & Partial<PropertiesRegistry>;\n\n/**\n * The interface implemented by web components produced via {@link createCustomElement}.\n */\nexport interface ApplicationElement extends HTMLElement {\n /** Resolves to the element's API when the application has started. */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * The class returned by a call to {@link createCustomElement}.\n */\nexport interface ApplicationElementConstructor {\n new (): ApplicationElement;\n}\n\n/**\n * Creates a new custom element class (web component) that can be registered within a DOM.\n *\n * @example\n * ```ts\n * import * as appMetadata from \"open-pioneer:app\";\n *\n * const CustomElementClazz = createCustomElement({\n * component: <div>Hello World!</div>,\n * appMetadata\n * });\n * customElements.define(\"sample-element\", CustomElementClazz);\n * ```\n */\nexport function createCustomElement(options: CustomElementOptions): ApplicationElementConstructor {\n class PioneerApplication extends HTMLElement implements ApplicationElement {\n #shadowRoot: ShadowRoot;\n #state: ElementState | undefined;\n\n static get observedAttributes(): string[] {\n return [];\n }\n\n constructor() {\n super();\n\n const mode = options.openShadowRoot ?? import.meta.env.DEV ? \"open\" : \"closed\";\n this.#shadowRoot = this.attachShadow({\n mode: mode\n });\n\n if (import.meta.env.DEV) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).$inspectElementState = () => this.#state;\n }\n }\n\n connectedCallback() {\n LOG.debug(\"Launching application\");\n\n if (this.#state) {\n this.#state.destroy();\n }\n\n this.#state = new ElementState(this, this.#shadowRoot, options);\n this.#state.start();\n }\n\n disconnectedCallback() {\n LOG.debug(\"Shutting down application\");\n\n this.#state?.destroy();\n this.#state = undefined;\n\n LOG.debug(\"Application destroyed\");\n }\n\n when() {\n if (!this.#state) {\n return Promise.reject(\n new Error(\n ErrorId.NOT_MOUNTED,\n \"Cannot use the application's API because the HTML element has not yet been mounted into the DOM.\"\n )\n );\n }\n\n return this.#state.whenAPI();\n }\n }\n return PioneerApplication;\n}\n\nclass ElementState {\n private hostElement: HTMLElement;\n private shadowRoot: ShadowRoot;\n private options: CustomElementOptions;\n\n // Public API\n private apiPromise: ManualPromise<ApiMethods> | undefined; // Present when callers are waiting for the API\n private api: ApiMethods | undefined; // Present once started\n\n private state = \"not-started\" as \"not-started\" | \"starting\" | \"started\" | \"destroyed\";\n private locale: string | undefined;\n private container: HTMLDivElement | undefined;\n private config: ApplicationConfig | undefined;\n private serviceLayer: ServiceLayer | undefined;\n private lifecycleEvents: ApplicationLifecycleEventService | undefined;\n private reactIntegration: ReactIntegration | undefined;\n private stylesWatch: Resource | undefined;\n\n constructor(hostElement: HTMLElement, shadowRoot: ShadowRoot, options: CustomElementOptions) {\n this.hostElement = hostElement;\n this.shadowRoot = shadowRoot;\n this.options = options;\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, `Cannot start element in state '${this.state}'`);\n }\n\n this.state = \"starting\";\n this.startImpl().catch((e) => {\n // TODO: Error splash?\n this.destroy();\n if (!isAbortError(e)) {\n logError(e);\n }\n });\n }\n\n destroy() {\n if (this.state === \"destroyed\") {\n return;\n }\n\n // Only call event listener when 'started' was also signalled.\n if (this.state === \"started\") {\n try {\n this.triggerApplicationLifecycleEvent(\"before-stop\");\n } catch (e) {\n void e; // Ignored\n }\n }\n this.state = \"destroyed\";\n this.apiPromise?.reject(createAbortError());\n this.reactIntegration = destroyResource(this.reactIntegration);\n this.shadowRoot.replaceChildren();\n this.container = undefined;\n this.lifecycleEvents = undefined;\n this.serviceLayer = destroyResource(this.serviceLayer);\n this.stylesWatch = destroyResource(this.stylesWatch);\n }\n\n whenAPI(): Promise<ApiMethods> {\n if (this.api) {\n return Promise.resolve(this.api);\n }\n\n const apiPromise = (this.apiPromise ??= createManualPromise());\n return apiPromise.promise;\n }\n\n private async startImpl() {\n const { options, shadowRoot, hostElement } = this;\n\n // Resolve custom application config\n const config = (this.config = await gatherConfig(hostElement, options));\n this.checkAbort();\n LOG.debug(\"Application config is\", config);\n\n // Decide on locale and load i18n messages (if any).\n const i18n = await initI18n(options.appMetadata, config.locale);\n this.checkAbort();\n\n // Setup application root node in the shadow dom\n const container = (this.container = createContainer(i18n.locale));\n const styles = this.initStyles();\n shadowRoot.replaceChildren(container, ...styles);\n\n // Launch the service layer\n const { serviceLayer, packages } = this.initServiceLayer({\n container,\n properties: config.properties,\n i18n\n });\n this.lifecycleEvents = getInternalService<ApplicationLifecycleEventService>(\n serviceLayer,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n );\n\n await this.initAPI(serviceLayer);\n this.checkAbort();\n\n // Launch react\n this.reactIntegration = new ReactIntegration({\n rootNode: container,\n container: shadowRoot,\n serviceLayer,\n packages\n });\n this.render();\n this.state = \"started\";\n\n this.triggerApplicationLifecycleEvent(\"after-start\");\n LOG.debug(\"Application started\");\n }\n\n private render() {\n this.reactIntegration?.render(this.options.component ?? emptyComponent, {});\n }\n\n private initStyles() {\n // Prevent inheritance of certain css values and normalize to display: block by default.\n // See https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/\n const builtinStyles = \":host { all: initial; display: block; }\";\n const builtinStylesNode = document.createElement(\"style\");\n applyStyles(builtinStylesNode, { value: builtinStyles });\n\n const appStyles = this.options.appMetadata?.styles;\n const appStylesNode = document.createElement(\"style\");\n applyStyles(appStylesNode, appStyles);\n if (import.meta.hot) {\n this.stylesWatch = appStyles?.on?.(\"changed\", () => {\n LOG.debug(\"Application styles changed\");\n applyStyles(appStylesNode, appStyles);\n });\n }\n return [builtinStylesNode, appStylesNode];\n }\n\n private initServiceLayer(config: {\n container: HTMLDivElement;\n properties: ApplicationProperties;\n i18n: AppI18n;\n }) {\n const options = this.options;\n const { container, properties, i18n } = config;\n const packageMetadata = options.appMetadata?.packages ?? {};\n const builtinPackage = createBuiltinPackage({\n host: this.hostElement,\n shadowRoot: this.shadowRoot,\n container: container,\n locale: i18n.locale,\n supportedLocales: i18n.supportedLocales\n });\n const { serviceLayer, packages } = createServiceLayer({\n packageMetadata,\n builtinPackage,\n properties,\n i18n\n });\n this.serviceLayer = serviceLayer;\n\n if (LOG.isDebug()) {\n LOG.debug(\"Launching service layer with packages\", Object.fromEntries(packages));\n }\n serviceLayer.start();\n return { serviceLayer, packages };\n }\n\n private async initAPI(serviceLayer: ServiceLayer) {\n const apiService = getInternalService<ApiService>(serviceLayer, RUNTIME_API_SERVICE);\n try {\n const api = (this.api = await apiService.getApi());\n LOG.debug(\"Application API initialized to\", api);\n this.apiPromise?.resolve(api);\n } catch (e) {\n throw new Error(ErrorId.INTERNAL, \"Failed to gather the application's API methods.\", {\n cause: e\n });\n }\n }\n\n private triggerApplicationLifecycleEvent(event: \"after-start\" | \"before-stop\") {\n this.lifecycleEvents?.emitLifecycleEvent(event);\n }\n\n private checkAbort() {\n if (this.state === \"destroyed\") {\n throwAbortError();\n }\n }\n}\n\nfunction createContainer(locale: string) {\n // Setup application root node in the shadow dom\n const container = document.createElement(\"div\");\n container.classList.add(\"pioneer-root\");\n container.style.minHeight = \"100%\";\n container.style.height = \"100%\";\n if (locale) {\n container.lang = locale;\n }\n return container;\n}\n\nfunction createServiceLayer(config: {\n packageMetadata: Record<string, PackageMetadata> | undefined;\n properties: ApplicationProperties;\n builtinPackage: PackageRepr;\n i18n: AppI18n;\n}) {\n const { packageMetadata, properties, builtinPackage, i18n } = config;\n\n let packages: PackageRepr[];\n try {\n packages = createPackages(packageMetadata ?? {}, i18n, properties);\n } catch (e) {\n throw new Error(ErrorId.INVALID_METADATA, \"Failed to parse package metadata.\", {\n cause: e\n });\n }\n\n // Add builtin services defined within this package.\n {\n const index = packages.findIndex((pkg) => pkg.name === builtinPackage.name);\n if (index >= 0) {\n packages.splice(index, 1);\n }\n packages.push(builtinPackage);\n }\n\n // Automatically required references (-> forces services to start)\n const forcedReferences: ReferenceSpec[] = [\n {\n interfaceName: RUNTIME_API_SERVICE\n },\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n },\n {\n interfaceName: RUNTIME_AUTO_START,\n all: true\n }\n ];\n const serviceLayer = new ServiceLayer(packages, forcedReferences);\n return {\n packages: new Map(packages.map((pkg) => [pkg.name, pkg])),\n serviceLayer: serviceLayer\n };\n}\n\nfunction getInternalService<T = unknown>(serviceLayer: ServiceLayer, interfaceName: string) {\n const result = serviceLayer.getService(\n \"@open-pioneer/runtime\",\n {\n interfaceName\n },\n { ignoreDeclarationCheck: true }\n );\n if (result.type !== \"found\") {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find instance of '${interfaceName}' (result type '${result.type}').` +\n ` This is a builtin service that must be present exactly once.`\n );\n }\n\n return result.value.getInstanceOrThrow() as T;\n}\n\n/**\n * Gathers application properties by reading them from the options object\n * and by (optionally) invoking the `resolveProperties` hook.\n */\nasync function gatherConfig(hostElement: HTMLElement, options: CustomElementOptions) {\n let configs: ApplicationConfig[];\n try {\n const staticConfig = options.config ?? {};\n const dynamicConfig =\n (await options.resolveConfig?.({\n getAttribute(name) {\n return hostElement.getAttribute(name) ?? undefined;\n }\n })) ?? {};\n\n configs = [staticConfig, dynamicConfig];\n } catch (e) {\n throw new Error(\n ErrorId.CONFIG_RESOLUTION_FAILED,\n \"Failed to resolve application properties.\",\n {\n cause: e\n }\n );\n }\n\n return mergeConfigs(configs);\n}\n\n/**\n * Merges application configurations into a single object.\n * Properties / config parameters at a later position overwrite properties from earlier ones.\n */\nfunction mergeConfigs(configs: ApplicationConfig[]): Required<ApplicationConfig> {\n // Merge simple values by assigning them in order\n const mergedConfig: Required<ApplicationConfig> = Object.assign(\n {\n locale: undefined,\n properties: {}\n } satisfies ApplicationConfig,\n ...configs\n );\n\n // Deep merge for application properties\n const mergedProperties: ApplicationProperties = (mergedConfig.properties = {});\n for (const config of configs) {\n for (const [packageName, packageProperties] of Object.entries(config.properties ?? {})) {\n const mergedPackageProps = (mergedProperties[packageName] ??= {});\n Object.assign(mergedPackageProps, packageProperties);\n }\n }\n\n return mergedConfig;\n}\n\n// Applies application styles to the given style node.\n// Can be called multiple times in development mode to implement hot reloading.\nfunction applyStyles(styleNode: HTMLStyleElement, styles: { value: string } | undefined) {\n const cssValue = styles?.value ?? \"\";\n const cssNode = document.createTextNode(cssValue);\n styleNode.replaceChildren(cssNode);\n}\n\nfunction logError(e: unknown) {\n if (e instanceof Error) {\n const chain = getErrorChain(e).reverse();\n if (chain.length === 1) {\n console.error(e);\n return;\n }\n\n let n = 1;\n for (const error of chain) {\n console.error(`#${n}`, error);\n ++n;\n }\n } else {\n console.error(\"Unexpected error\", e);\n }\n}\n\nfunction emptyComponent() {\n return null;\n}\n"],"names":[],"mappings":";;;;;;;;AA+BA,MAAM,GAAA,GAAM,aAAa,uBAAuB,CAAA,CAAA;AAwHzC,SAAS,oBAAoB,OAA8D,EAAA;AAC9F,EAAA,MAAM,2BAA2B,WAA0C,CAAA;AAAA,IACvE,WAAA,CAAA;AAAA,IACA,MAAA,CAAA;AAAA,IAEA,WAAW,kBAA+B,GAAA;AACtC,MAAA,OAAO,EAAC,CAAA;AAAA,KACZ;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AA,CAAe,QAAQ,CAAA,CAAA;AAChD,EAAA,SAAA,CAAU,gBAAgB,OAAO,CAAA,CAAA;AACrC,CAAA;AAEA,SAAS,SAAS,CAAY,EAAA;AAC1B,EAAA,IAAI,aAAa,KAAO,EAAA;AACpB,IAAA,MAAM,KAAQ,GAAA,aAAA,CAAc,CAAC,CAAA,CAAE,OAAQ,EAAA,CAAA;AACvC,IAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACpB,MAAA,OAAA,CAAQ,MAAM,CAAC,CAAA,CAAA;AACf,MAAA,OAAA;AAAA,KACJ;AAEA,IAAA,IAAI,CAAI,GAAA,CAAA,CAAA;AACR,IAAA,KAAA,MAAW,SAAS,KAAO,EAAA;AACvB,MAAQ,OAAA,CAAA,KAAA,CAAM,CAAI,CAAA,EAAA,CAAA,CAAA,CAAA,EAAK,KAAK,CAAA,CAAA;AAC5B,MAAE,EAAA,CAAA,CAAA;AAAA,KACN;AAAA,GACG,MAAA;AACH,IAAQ,OAAA,CAAA,KAAA,CAAM,oBAAoB,CAAC,CAAA,CAAA;AAAA,GACvC;AACJ,CAAA;AAEA,SAAS,cAAiB,GAAA;AACtB,EAAO,OAAA,IAAA,CAAA;AACX;;;;"}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @open-pioneer/runtime
|
|
2
|
+
|
|
3
|
+
Implements the runtime environment for open pioneer apps.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
Import the `createCustomElement` function from this package to create your application as a Web Component:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// my-app/app.js
|
|
11
|
+
import { createCustomElement } from "@open-pioneer/runtime";
|
|
12
|
+
import * as appMetadata from "open-pioneer:app";
|
|
13
|
+
import { AppUI } from "./AppUI";
|
|
14
|
+
|
|
15
|
+
const Element = createCustomElement({
|
|
16
|
+
component: AppUI,
|
|
17
|
+
appMetadata
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
customElements.define("my-app", Element);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
In this example, `Element` is a custom web component class registered as `<my-app>`.
|
|
24
|
+
The application renders the `AppUI` (a react component) and automatically contains services, styles etc. its package dependencies.
|
|
25
|
+
HTML sites or JavaScript code can now instantiate the application by creating a DOM-Element:
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<!-- some-site/index.html -->
|
|
29
|
+
<!DOCTYPE html>
|
|
30
|
+
<html>
|
|
31
|
+
<body>
|
|
32
|
+
<!-- Contains the app once the script has been loaded -->
|
|
33
|
+
<my-app></my-app>
|
|
34
|
+
<script type="module" src="/apps/my-app/app.ts"></script>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
37
|
+
```
|