@lwrjs/everywhere 0.10.0-alpha.2 → 0.10.0-alpha.20

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.
Files changed (41) hide show
  1. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/981eca8f72a57fecd21a35a5dfee2751/config.js +10 -0
  2. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_20/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +18 -0
  3. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{2_38_1/s/8cf6b94d9c0b398c70c97fdca2759caa → 2_50_0/s/b40440e2e29d782101f05d6085a324e9}/lwc.js +560 -584
  4. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_10_0-alpha_2/s/c538071acf5bde58e816967a14c465c3 → 0_10_0-alpha_20/s/cb931ebef2b89dcf8ab51456e3a68864}/lwr_everywhereAmd.js +4 -4
  5. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/0_10_0-alpha_20/s/5e6db37af51f0d23be4893abe5eeb913/lwr_init.js +163 -0
  6. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_10_0-alpha_2/s/b9b0d37c87017e0845caa60b6f4b88f9 → 0_10_0-alpha_20/s/e768d044ed1b7b7babca2f39e1cbca58}/lwr_loader.js +105 -14
  7. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_10_0-alpha_2/s/3426e42c3e22ce07ab2adc62c4c523a0 → 0_10_0-alpha_20/s/7a802ee7a2430244c1f66bce2c2eafef}/lwr_metrics.js +14 -2
  8. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/0_10_0-alpha_20/s/a152b8d35f12ca1b5147c5cd1ee155fb/lwr_profiler.js +102 -0
  9. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_10_0-alpha_2 → 0_10_0-alpha_20}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +2 -2
  10. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_10_0-alpha_2 → 0_10_0-alpha_20}/lwr-error-shim.js +2 -1
  11. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_10_0-alpha_2 → 0_10_0-alpha_20}/lwr-loader-shim.bundle.js +583 -259
  12. package/build/assets/amd/lwr-everywhere-debug.js +536 -278
  13. package/build/assets/amd/lwr-everywhere-min.js +6 -1
  14. package/build/assets/amd/lwr-everywhere.js +536 -278
  15. package/build/assets/core/lwr-everywhere-debug.js +534 -276
  16. package/build/assets/core/lwr-everywhere-min.js +6 -1
  17. package/build/assets/core/lwr-everywhere.js +534 -276
  18. package/build/assets/esm/lwr-everywhere-debug.js +10 -3
  19. package/build/assets/esm/lwr-everywhere-min.js +1 -1
  20. package/build/assets/esm/lwr-everywhere.js +10 -3
  21. package/build/generate.js +5 -10
  22. package/build/index.js +1 -1
  23. package/build/modules/lwr/everywhereAmd/everywhereAmd.d.ts +1 -1
  24. package/build/modules/lwr/host/host.html +1 -1
  25. package/build/modules/lwr/host/host.js +2 -2
  26. package/build/modules/lwr/setupLDS/setupLDS.js +8 -5
  27. package/build/modules/lwr/vault/vault.d.ts +1 -1
  28. package/build/utils.d.ts +1 -1
  29. package/package.json +15 -13
  30. package/src/generate.ts +7 -11
  31. package/src/index.ts +4 -1
  32. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/e8b5228f499eea69a8f669aada1f8042/config.js +0 -10
  33. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_2/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -18
  34. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/0_10_0-alpha_2/s/206e6e0af6f019fdfd86d87d56331bc2/lwr_init.js +0 -97
  35. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/0_10_0-alpha_2/s/e25f3b0b8b5c096acebf847d0a83ea62/lwr_profiler.js +0 -68
  36. package/build/modules/@salesforce/lds-default-luvio/lds-default-luvio.d.ts +0 -24
  37. package/build/modules/@salesforce/lds-default-luvio/lds-default-luvio.js +0 -60
  38. package/build/modules/lwr/setupNodeLDS/network.d.ts +0 -3
  39. package/build/modules/lwr/setupNodeLDS/network.js +0 -88
  40. package/build/modules/lwr/setupNodeLDS/setupNodeLDS.d.ts +0 -2
  41. package/build/modules/lwr/setupNodeLDS/setupNodeLDS.js +0 -14
@@ -9,6 +9,7 @@
9
9
  function getConfiguration(options) {
10
10
  const { format, server, apiVersion, apiPrefix, locale, bundle, debug } = options;
11
11
  const thisUrl = new URL(import.meta.url);
12
+
12
13
  // URLs
13
14
  const ORIGIN = server || thisUrl.origin || '';
14
15
  const PREFIX = `${apiPrefix}/${apiVersion}`;
@@ -17,9 +18,11 @@ function getConfiguration(options) {
17
18
  const ENDPOINT = bundle
18
19
  ? `${ORIGIN}${PREFIX}/bundle/${format}/${POSTFIX}${BUNDLE_ID}-0/module/mi/`
19
20
  : `${ORIGIN}${PREFIX}/module/${format}/${POSTFIX}/mi/`;
21
+
20
22
  // Component specifiers and URIs
21
- const BOOT_MODULE = `lwr/everywhere${format === 'esm' ? 'Esm' : 'Amd'}/v/0_10_0-alpha_2`;
23
+ const BOOT_MODULE = `lwr/everywhere${format === 'esm' ? 'Esm' : 'Amd'}/v/0_10_0-alpha_20`;
22
24
  const BOOT_URI = `${ENDPOINT}${encodeURIComponent(BOOT_MODULE)}/latest${debug ? '?debug' : ''}`;
25
+
23
26
  // Client Bootstrap Config
24
27
  const config = {
25
28
  appId: 'lwre',
@@ -39,17 +42,21 @@ function getConfiguration(options) {
39
42
  if (debug && config.endpoints) {
40
43
  config.endpoints.modifiers = { debug: 'true' };
41
44
  }
45
+
42
46
  return config;
43
47
  }
44
48
 
45
49
  /** LWR Everywhere module for ESM **/
50
+
46
51
  // Process the LWR Client Bootstrap Config
47
- const configOptions = { "format": "esm", "apiVersion": "1", "apiPrefix": "", "bundle": false, "debug": true };
52
+ const configOptions = {"format":"esm","apiVersion":"1","apiPrefix":"","bundle":false,"debug":true} ;
48
53
  const configuration = getConfiguration(configOptions);
49
54
  const { bootstrapModule, imports, index = {}, importMappings, endpoints } = configuration;
55
+
50
56
  // Set up the ESM loader; Export the LWRE APIs
51
57
  const { initEsm, authenticate, createComponent } = await import(
52
- /* webpackIgnore: true */ index[bootstrapModule]);
58
+ /* webpackIgnore: true */ index[bootstrapModule]
59
+ );
53
60
  initEsm({ imports, index, importMappings, endpoints });
54
61
 
55
62
  export { authenticate, createComponent };
@@ -1 +1 @@
1
- globalThis.process={env:{NODE_ENV:"production"}};const e=function(e){const{format:o,server:i,apiVersion:n,apiPrefix:t,locale:p,bundle:r,debug:s}=e,a=new URL(import.meta.url),m=i||a.origin||"",d=`${t}/${n}`,$="0"+(p?`/l/${p}`:""),u="/bi/3_A,B,O,S,EG,JLMT,C,D,F,H,I,K,N,P,Q,R",l=r?`${m}${d}/bundle/${o}/${$}${u}-0/module/mi/`:`${m}${d}/module/${o}/${$}/mi/`,b=`lwr/everywhere${"esm"===o?"Esm":"Amd"}/v/0_10_0-alpha_2`,g=`${l}${encodeURIComponent(b)}/latest${s?"?debug":""}`,c={appId:"lwre",autoBoot:!0,bootstrapModule:b,baseUrl:m,imports:{[g]:[b]},index:{[b]:g},endpoints:{uris:{module:l,mapping:`${m}${d}/mapping/${o}/${$}${r?u:""}/mp/`}}};return s&&c.endpoints&&(c.endpoints.modifiers={debug:"true"}),c}({format:"esm",apiVersion:"1",apiPrefix:"",bundle:!0,debug:!1}),{bootstrapModule:o,imports:i,index:n={},importMappings:t,endpoints:p}=e,{initEsm:r,authenticate:s,createComponent:a}=await import(n[o]);r({imports:i,index:n,importMappings:t,endpoints:p});export{s as authenticate,a as createComponent};
1
+ globalThis.process={env:{NODE_ENV:"production"}};const e=function(e){const{format:o,server:i,apiVersion:n,apiPrefix:t,locale:p,bundle:r,debug:s}=e,a=new URL(import.meta.url),m=i||a.origin||"",d=`${t}/${n}`,$="0"+(p?`/l/${p}`:""),u="/bi/3_A,B,O,S,EG,JLMT,C,D,F,H,I,K,N,P,Q,R",l=r?`${m}${d}/bundle/${o}/${$}${u}-0/module/mi/`:`${m}${d}/module/${o}/${$}/mi/`,b=`lwr/everywhere${"esm"===o?"Esm":"Amd"}/v/0_10_0-alpha_20`,g=`${l}${encodeURIComponent(b)}/latest${s?"?debug":""}`,c={appId:"lwre",autoBoot:!0,bootstrapModule:b,baseUrl:m,imports:{[g]:[b]},index:{[b]:g},endpoints:{uris:{module:l,mapping:`${m}${d}/mapping/${o}/${$}${r?u:""}/mp/`}}};return s&&c.endpoints&&(c.endpoints.modifiers={debug:"true"}),c}({format:"esm",apiVersion:"1",apiPrefix:"",bundle:!0,debug:!1}),{bootstrapModule:o,imports:i,index:n={},importMappings:t,endpoints:p}=e,{initEsm:r,authenticate:s,createComponent:a}=await import(n[o]);r({imports:i,index:n,importMappings:t,endpoints:p});export{s as authenticate,a as createComponent};
@@ -9,6 +9,7 @@
9
9
  function getConfiguration(options) {
10
10
  const { format, server, apiVersion, apiPrefix, locale, bundle, debug } = options;
11
11
  const thisUrl = new URL(import.meta.url);
12
+
12
13
  // URLs
13
14
  const ORIGIN = server || thisUrl.origin || '';
14
15
  const PREFIX = `${apiPrefix}/${apiVersion}`;
@@ -17,9 +18,11 @@ function getConfiguration(options) {
17
18
  const ENDPOINT = bundle
18
19
  ? `${ORIGIN}${PREFIX}/bundle/${format}/${POSTFIX}${BUNDLE_ID}-0/module/mi/`
19
20
  : `${ORIGIN}${PREFIX}/module/${format}/${POSTFIX}/mi/`;
21
+
20
22
  // Component specifiers and URIs
21
- const BOOT_MODULE = `lwr/everywhere${format === 'esm' ? 'Esm' : 'Amd'}/v/0_10_0-alpha_2`;
23
+ const BOOT_MODULE = `lwr/everywhere${format === 'esm' ? 'Esm' : 'Amd'}/v/0_10_0-alpha_20`;
22
24
  const BOOT_URI = `${ENDPOINT}${encodeURIComponent(BOOT_MODULE)}/latest${debug ? '?debug' : ''}`;
25
+
23
26
  // Client Bootstrap Config
24
27
  const config = {
25
28
  appId: 'lwre',
@@ -39,17 +42,21 @@ function getConfiguration(options) {
39
42
  if (debug && config.endpoints) {
40
43
  config.endpoints.modifiers = { debug: 'true' };
41
44
  }
45
+
42
46
  return config;
43
47
  }
44
48
 
45
49
  /** LWR Everywhere module for ESM **/
50
+
46
51
  // Process the LWR Client Bootstrap Config
47
- const configOptions = { "format": "esm", "apiVersion": "1", "apiPrefix": "", "bundle": true, "debug": false };
52
+ const configOptions = {"format":"esm","apiVersion":"1","apiPrefix":"","bundle":true,"debug":false} ;
48
53
  const configuration = getConfiguration(configOptions);
49
54
  const { bootstrapModule, imports, index = {}, importMappings, endpoints } = configuration;
55
+
50
56
  // Set up the ESM loader; Export the LWRE APIs
51
57
  const { initEsm, authenticate, createComponent } = await import(
52
- /* webpackIgnore: true */ index[bootstrapModule]);
58
+ /* webpackIgnore: true */ index[bootstrapModule]
59
+ );
53
60
  initEsm({ imports, index, importMappings, endpoints });
54
61
 
55
62
  export { authenticate, createComponent };
package/build/generate.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
- import typescript from 'typescript';
4
3
  import { rollup } from 'rollup';
5
- import replace from '@rollup/plugin-replace';
6
- import { terser } from 'rollup-plugin-terser';
7
4
  import { resolveModule } from '@lwc/module-resolver';
5
+ import replace from '@rollup/plugin-replace';
6
+ import terser from '@rollup/plugin-terser';
8
7
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
9
8
  // @ts-ignore: This package has no types
10
- import typescriptPlugin from 'rollup-plugin-typescript';
9
+ import typescriptPlugin from '@rollup/plugin-sucrase';
11
10
  import { rootPath, version } from '@lwrjs/everywhere/package';
12
11
  const CORE_VERSION = '0_0_1';
13
12
  const NPM_VERSION = version.replace(/\./g, '_');
14
13
  const NPM2CORE_REGEX = new RegExp(`/v/${NPM_VERSION}`, 'g');
15
14
  /* istanbul ignore next */
16
15
  const lwcResolver = {
16
+ name: 'lwc-resolver',
17
17
  resolveId(importee, importer) {
18
18
  if (importee === 'lwr/loader') {
19
19
  try {
@@ -58,7 +58,6 @@ export async function generate(options) {
58
58
  bundle,
59
59
  debug,
60
60
  };
61
- const rootDir = path.join(rootPath, 'src');
62
61
  const theBundle = await rollup({
63
62
  input: path.join(rootPath, `src/${format}-client.ts`),
64
63
  plugins: [
@@ -71,11 +70,7 @@ export async function generate(options) {
71
70
  preventAssignment: true,
72
71
  }),
73
72
  typescriptPlugin({
74
- typescript,
75
- // the following options are needed to run outside this package
76
- rootDir,
77
- include: [rootDir + '/**/*'],
78
- tsconfig: path.join(rootPath, 'tsconfig.json'),
73
+ transforms: ['typescript'],
79
74
  }),
80
75
  minify && terser(),
81
76
  lwcResolver,
package/build/index.js CHANGED
@@ -23,7 +23,7 @@ export default class LwrEverywhereClientProvider {
23
23
  specifier,
24
24
  type: 'application/javascript',
25
25
  content: fs.readFileSync(absFilepath).toString(),
26
- src: this.context.resourceRegistry.resolveResourceUri({ specifier, version }, environment),
26
+ src: await this.context.resourceRegistry.resolveResourceUri({ specifier, version }, environment),
27
27
  };
28
28
  }
29
29
  return undefined;
@@ -1,4 +1,4 @@
1
- import { ServiceAPI } from '@lwrjs/types';
1
+ import type { ServiceAPI } from '@lwrjs/types';
2
2
  export declare function initAmd(services: ServiceAPI, mappingEndpoint: string, coreVersion: string): void;
3
3
  export declare function authenticate(authInfo: {
4
4
  access_token?: string;
@@ -1,5 +1,5 @@
1
1
  <template>
2
2
  <div role="region" aria-live="polite" tabindex="-1">
3
- <lwr-dynamic lwc:dynamic={ctor}></lwr-dynamic>
3
+ <lwc:component lwc:is={ctor} class="lwr-dynamic"></lwc:component>
4
4
  </div>
5
5
  </template>
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/ban-ts-comment */
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  import { LightningElement, api } from 'lwc'; // @ts-ignore: Use LWC module resolver
4
+ // @ts-ignore
4
5
 
5
6
  // Host component constants
6
7
  const SPECIFIER_REGEX = /^@?[\w-]+(\/[\w-]+)*$/;
@@ -58,7 +59,7 @@ export default class LwrHost extends LightningElement {
58
59
 
59
60
  // Update public (@api) properties on the embedded content
60
61
  setProperties(properties) {
61
- const dynamicContent = this.template.querySelector('lwr-dynamic');
62
+ const dynamicContent = this.template.querySelector('.lwr-dynamic');
62
63
  if (dynamicContent) {
63
64
  Object.entries(properties).forEach(([key, value]) => {
64
65
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -104,7 +105,6 @@ export default class LwrHost extends LightningElement {
104
105
 
105
106
  // Navigate via the bridge, which is hooked into its descendent root router
106
107
  // The host component cannot call "lwr/navigation" APIs; it has no access to a NavigationContext
107
-
108
108
  navigate(pageRef) {
109
109
  if (pageRef && this.bridge && this.bridge.navigate(pageRef)) {
110
110
  // CLEAR the pending page reference if the navigation event was fired
@@ -1,12 +1,15 @@
1
- import { Luvio, Store, Environment } from '@luvio/engine';
2
- // import { setDefaultLuvio } from 'force/ldsEngine'; // TODO: uncomment if available on-core
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ import { Luvio, Environment, InMemoryStore } from '@luvio/engine'; // @ts-ignore: Use LWC module resolution
3
+ import { setDefaultLuvio } from 'force/ldsEngine';
3
4
  import { networkAdapter } from './network';
4
5
 
5
- // This module is used with LWR Java apps, the "force/ldsEngine" module is available on-core
6
6
  // Set the default Luvio instance for LWR Everywhere
7
7
  // It uses a fetch-based "web" network adapter with OAuth headers
8
+ // Note: For LWR Node.js apps, "@salesforce/lds-default-luvio" is aliased to "force/ldsEngine"
8
9
 
9
10
  export default function () {
10
- /* const luvio = */new Luvio(new Environment(new Store(), networkAdapter));
11
- // setDefaultLuvio({ luvio });
11
+ const luvio = new Luvio(new Environment(new InMemoryStore(), networkAdapter));
12
+ setDefaultLuvio({
13
+ luvio
14
+ });
12
15
  }
@@ -1,4 +1,4 @@
1
- declare type AuthInfo = {
1
+ type AuthInfo = {
2
2
  access_token?: string;
3
3
  instance_url: string;
4
4
  };
package/build/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ClientBootstrapConfig } from '@lwrjs/types';
2
- export declare type GlobalThis = {
2
+ export type GlobalThis = {
3
3
  [key: string]: unknown;
4
4
  };
5
5
  export interface EverywhereClientBootstrapOptions {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lwrjs/everywhere",
3
3
  "description": "LWR Everywhere",
4
- "version": "0.10.0-alpha.2",
4
+ "version": "0.10.0-alpha.20",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,16 +43,19 @@
43
43
  "build": "tsc -b && node ../../../bin/pack-lwc --dir src/modules build/modules && yarn build:amd && yarn build:scripts"
44
44
  },
45
45
  "dependencies": {
46
+ "@luvio/engine": "0.128.0",
46
47
  "@rollup/plugin-replace": "^2.4.2",
47
- "rollup-plugin-terser": "^7.0.2",
48
- "rollup-plugin-typescript": "^1.0.1"
48
+ "@rollup/plugin-sucrase": "^5.0.1",
49
+ "@rollup/plugin-terser": "^0.4.3",
50
+ "@salesforce/lds-default-luvio": "1.163.1"
49
51
  },
50
52
  "devDependencies": {
51
- "@luvio/engine": "0.47.5",
52
- "@lwc/module-resolver": "2.38.1",
53
- "@lwrjs/loader": "0.10.0-alpha.2",
54
- "@lwrjs/router": "0.10.0-alpha.2",
55
- "@lwrjs/types": "0.10.0-alpha.2"
53
+ "@locker/trusted-types": "0.19.5",
54
+ "@lwc/module-resolver": "2.50.0",
55
+ "@lwrjs/loader": "0.10.0-alpha.20",
56
+ "@lwrjs/router": "0.10.0-alpha.20",
57
+ "@lwrjs/types": "0.10.0-alpha.20",
58
+ "lwr": "0.10.0-alpha.20"
56
59
  },
57
60
  "lwc": {
58
61
  "modules": [
@@ -60,12 +63,11 @@
60
63
  "dir": "build/modules"
61
64
  },
62
65
  {
63
- "name": "lwr/setupLDS",
64
- "path": "build/modules/lwr/setupNodeLDS/setupNodeLDS.js"
66
+ "name": "force/ldsEngine",
67
+ "path": "../../../node_modules/@salesforce/lds-default-luvio/dist/es/es2018/main.js"
65
68
  }
66
69
  ],
67
70
  "expose": [
68
- "@salesforce/lds-default-luvio",
69
71
  "lwr/everywhere",
70
72
  "lwr/everywhereAmd",
71
73
  "lwr/everywhereEsm",
@@ -75,7 +77,7 @@
75
77
  ]
76
78
  },
77
79
  "engines": {
78
- "node": ">=16.0.0 <20"
80
+ "node": ">=16.0.0"
79
81
  },
80
- "gitHead": "592cda0637513885477829beea35a86407b342d4"
82
+ "gitHead": "45a867fc54e98f77dd442ccd5f668e23027b9246"
81
83
  }
package/src/generate.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import type { EverywhereClientBootstrapOptions } from './utils';
2
2
  import path from 'path';
3
3
  import fs from 'fs';
4
- import typescript from 'typescript';
4
+ import type { Plugin } from 'rollup';
5
5
  import { rollup } from 'rollup';
6
- import replace from '@rollup/plugin-replace';
7
- import { terser } from 'rollup-plugin-terser';
8
6
  import { resolveModule } from '@lwc/module-resolver';
7
+ import replace from '@rollup/plugin-replace';
8
+ import terser from '@rollup/plugin-terser';
9
9
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
10
  // @ts-ignore: This package has no types
11
- import typescriptPlugin from 'rollup-plugin-typescript';
11
+ import typescriptPlugin from '@rollup/plugin-sucrase';
12
12
  import { rootPath, version } from '@lwrjs/everywhere/package';
13
13
 
14
14
  const CORE_VERSION = '0_0_1';
@@ -17,6 +17,7 @@ const NPM2CORE_REGEX = new RegExp(`/v/${NPM_VERSION}`, 'g');
17
17
 
18
18
  /* istanbul ignore next */
19
19
  const lwcResolver = {
20
+ name: 'lwc-resolver',
20
21
  resolveId(importee: string, importer: string): string | undefined {
21
22
  if (importee === 'lwr/loader') {
22
23
  try {
@@ -31,7 +32,7 @@ const lwcResolver = {
31
32
  }
32
33
  return undefined;
33
34
  },
34
- };
35
+ } as Plugin;
35
36
 
36
37
  export interface GenerationOptions extends EverywhereClientBootstrapOptions {
37
38
  minify?: boolean;
@@ -78,7 +79,6 @@ export async function generate(options: GenerationOptions): Promise<void> {
78
79
  bundle,
79
80
  debug,
80
81
  };
81
- const rootDir = path.join(rootPath, 'src');
82
82
  const theBundle = await rollup({
83
83
  input: path.join(rootPath, `src/${format}-client.ts`),
84
84
  plugins: [
@@ -91,11 +91,7 @@ export async function generate(options: GenerationOptions): Promise<void> {
91
91
  preventAssignment: true,
92
92
  }),
93
93
  typescriptPlugin({
94
- typescript,
95
- // the following options are needed to run outside this package
96
- rootDir,
97
- include: [rootDir + '/**/*'],
98
- tsconfig: path.join(rootPath, 'tsconfig.json'),
94
+ transforms: ['typescript'],
99
95
  }),
100
96
  minify && terser(),
101
97
  lwcResolver,
package/src/index.ts CHANGED
@@ -39,7 +39,10 @@ export default class LwrEverywhereClientProvider implements ResourceProvider {
39
39
  specifier,
40
40
  type: 'application/javascript',
41
41
  content: fs.readFileSync(absFilepath).toString(),
42
- src: this.context.resourceRegistry.resolveResourceUri({ specifier, version }, environment),
42
+ src: await this.context.resourceRegistry.resolveResourceUri(
43
+ { specifier, version },
44
+ environment,
45
+ ),
43
46
  };
44
47
  }
45
48
  return undefined;
@@ -1,10 +0,0 @@
1
- /* This script is generated */
2
- /* Client Bootstrap configuration */
3
- globalThis.LWR = globalThis.LWR || {};
4
- Object.assign(globalThis.LWR, {"appId":"amd-bootstrap","bootstrapModule":"@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_2","autoBoot":true,"imports":{"/1/module/amd/1/l/en-US/mi/%40lwrjs%2Fapp-service%2Famd-bootstrap%2Fmodule%2Famd%2Fv%2F0_10_0-alpha_2/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js":["@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_2"],"/1/module/amd/1/l/en-US/mi/lwr%2Finit%2Fv%2F0_10_0-alpha_2/s/206e6e0af6f019fdfd86d87d56331bc2/lwr_init.js":["lwr/init/v/0_10_0-alpha_2"],"/1/module/amd/1/l/en-US/mi/lwr%2Fmetrics%2Fv%2F0_10_0-alpha_2/s/3426e42c3e22ce07ab2adc62c4c523a0/lwr_metrics.js":["lwr/metrics/v/0_10_0-alpha_2"],"/1/module/amd/1/l/en-US/mi/lwr%2Fprofiler%2Fv%2F0_10_0-alpha_2/s/e25f3b0b8b5c096acebf847d0a83ea62/lwr_profiler.js":["lwr/profiler/v/0_10_0-alpha_2"],"/1/module/amd/1/l/en-US/mi/lwc%2Fv%2F2_38_1/s/8cf6b94d9c0b398c70c97fdca2759caa/lwc.js":["lwc/v/2_38_1"],"/1/module/amd/1/l/en-US/mi/lwr%2FeverywhereAmd%2Fv%2F0_10_0-alpha_2/s/c538071acf5bde58e816967a14c465c3/lwr_everywhereAmd.js":["lwr/everywhereAmd/v/0_10_0-alpha_2"],"/1/module/amd/1/l/en-US/mi/lwr%2Fvault%2Fv%2F0_10_0-alpha_2/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js":["lwr/vault/v/0_10_0-alpha_2"]},"index":{"@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_2":"/1/module/amd/1/l/en-US/mi/%40lwrjs%2Fapp-service%2Famd-bootstrap%2Fmodule%2Famd%2Fv%2F0_10_0-alpha_2/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js","lwr/init/v/0_10_0-alpha_2":"/1/module/amd/1/l/en-US/mi/lwr%2Finit%2Fv%2F0_10_0-alpha_2/s/206e6e0af6f019fdfd86d87d56331bc2/lwr_init.js","lwr/metrics/v/0_10_0-alpha_2":"/1/module/amd/1/l/en-US/mi/lwr%2Fmetrics%2Fv%2F0_10_0-alpha_2/s/3426e42c3e22ce07ab2adc62c4c523a0/lwr_metrics.js","lwr/profiler/v/0_10_0-alpha_2":"/1/module/amd/1/l/en-US/mi/lwr%2Fprofiler%2Fv%2F0_10_0-alpha_2/s/e25f3b0b8b5c096acebf847d0a83ea62/lwr_profiler.js","lwc/v/2_38_1":"/1/module/amd/1/l/en-US/mi/lwc%2Fv%2F2_38_1/s/8cf6b94d9c0b398c70c97fdca2759caa/lwc.js","lwr/everywhereAmd/v/0_10_0-alpha_2":"/1/module/amd/1/l/en-US/mi/lwr%2FeverywhereAmd%2Fv%2F0_10_0-alpha_2/s/c538071acf5bde58e816967a14c465c3/lwr_everywhereAmd.js","lwr/vault/v/0_10_0-alpha_2":"/1/module/amd/1/l/en-US/mi/lwr%2Fvault%2Fv%2F0_10_0-alpha_2/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js"},"rootComponents":["lwr/everywhereAmd/v/0_10_0-alpha_2"],"requiredModules":["@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_2"],"preloadModules":["lwr/init/v/0_10_0-alpha_2","lwr/metrics/v/0_10_0-alpha_2","lwc/v/2_38_1","lwr/everywhereAmd/v/0_10_0-alpha_2"],"endpoints":{"uris":{"mapping":"/1/mapping/amd/1/l/en-US/mp/"}}});
5
- globalThis.process = { env: { NODE_ENV: "compat" } };
6
- // Appended by Static Site Generator
7
- if (!globalThis.LWR.imports) { globalThis.LWR.imports = {}; }
8
- Object.assign(globalThis.LWR.imports, {"/1/module/amd/1/l/en-US/mi/lwr%2Floader%2Fv%2F0_10_0-alpha_2/s/b9b0d37c87017e0845caa60b6f4b88f9/lwr_loader.js":["lwr/loader/v/0_10_0-alpha_2"]})
9
- if (!globalThis.LWR.index) { globalThis.LWR.index = {}; }
10
- Object.assign(globalThis.LWR.index, {"lwr/loader/v/0_10_0-alpha_2":"/1/module/amd/1/l/en-US/mi/lwr%2Floader%2Fv%2F0_10_0-alpha_2/s/b9b0d37c87017e0845caa60b6f4b88f9/lwr_loader.js"})
@@ -1,18 +0,0 @@
1
- LWR.define('@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_2', ['lwr/loader/v/0_10_0-alpha_2', 'lwr/init/v/0_10_0-alpha_2'], function (_0_10_0Alpha_2$1, _0_10_0Alpha_2) { 'use strict';
2
-
3
- const clientBootstrapConfig = globalThis.LWR;
4
-
5
- // initialize additional non-configured root components
6
- const { rootComponents, ssrProps } = clientBootstrapConfig;
7
- Promise.all(rootComponents.map(async (rootSpecifier) => {
8
- const element = _0_10_0Alpha_2.toKebabCase(rootSpecifier);
9
- return _0_10_0Alpha_2$1.load(rootSpecifier, '@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_2').then(({default: Ctor}) => {
10
- _0_10_0Alpha_2.init([[element, Ctor]], ssrProps);
11
- });
12
- }));
13
-
14
- globalThis.LWR = Object.freeze({
15
- define: globalThis.LWR.define,
16
- });
17
-
18
- });
@@ -1,97 +0,0 @@
1
- LWR.define('lwr/init/v/0_10_0-alpha_2', ['exports', 'lwr/metrics/v/0_10_0-alpha_2', 'lwr/profiler/v/0_10_0-alpha_2', 'lwc/v/2_38_1'], function (exports, _0_10_0Alpha_2$1, _0_10_0Alpha_2, _2_38_1) { 'use strict';
2
-
3
- function initializeWebComponent(elementName, Ctor) {
4
- return _2_38_1.createElement(elementName, {
5
- is: Ctor
6
- });
7
- }
8
-
9
- /**
10
- * Convert a module specifier into a valid CustomElement registry name:
11
- * - remove any version linking
12
- * - change / to -
13
- * - convert uppercase letters into "-${lowercase}"
14
- * eg: "c/app" => "c-app"
15
- * eg: "my/helloWorld" => "my-hello-world"
16
- * eg: "lwr/example/v/1.0.0" => "lwr-example"
17
- * @param specifier The bare specifier to convert
18
- */
19
- function toKebabCase(specifier) {
20
- return specifier.replace(/\/v\/[a-zA-Z0-9-_.]+$/, '').replace('/', '-').replace(/([A-Z])/g, c => `-${c.toLowerCase()}`);
21
- }
22
-
23
- /**
24
- * This method maps between attribute names
25
- * and the corresponding props name.
26
- */
27
- const CAMEL_REGEX = /-([a-z])/g;
28
- function getPropFromAttrName(propName) {
29
- return propName.replace(CAMEL_REGEX, g => g[1].toUpperCase());
30
- }
31
-
32
- /**
33
- * Import any requested static application dependencies, define the root
34
- * application component(s) into the CustomElement registry, and inject them.
35
- * @param rootModules - An array of arrays, each one holding a pair of
36
- * bare specifier and corresponding LightningElement constructor
37
- * @example - [['x/appRoot', appCtor], ['x/nav', navCtor]]
38
- */
39
- function init(rootModules) {
40
- if (typeof customElements !== 'undefined' && typeof document !== 'undefined') {
41
- const container = document.querySelector('[lwr-root]');
42
- rootModules.forEach(([moduleSpecifier, ctor]) => {
43
- // Kebab-case the specifier
44
- const elementName = toKebabCase(moduleSpecifier);
45
-
46
- // Append the root element to the DOM, if it does not exist
47
- // this is for SPA like routes (one component at the root level) utilizing the lwr-root directive
48
- let el = document.body.querySelector(elementName);
49
- if (!el) {
50
- el = initializeWebComponent(elementName, ctor);
51
- if (container) {
52
- // Append to a node with the "lwr-root" attribute
53
- container.appendChild(el);
54
- } else {
55
- // Otherwise, add the root to the <body>
56
- document.body.appendChild(el);
57
- }
58
- } else {
59
- // We have rendered/ssred an HTML page and we need to reify the components
60
- // Due to the bug described on the header, for each custom element
61
- // we collect the attributes and we replace the element with the new synthetic contructor
62
- const customElements = document.querySelectorAll(elementName);
63
- customElements.forEach(customElement => {
64
- const newElement = initializeWebComponent(elementName, ctor);
65
- for (const {
66
- name,
67
- value
68
- } of customElement.attributes) {
69
- newElement.setAttribute(name, value);
70
- const prop = getPropFromAttrName(name);
71
- if (prop in newElement) {
72
- // Set attributes as properties too for reactivity
73
- newElement[prop] = value;
74
- }
75
- }
76
-
77
- // Move the children
78
- while (customElement.childNodes.length > 0) {
79
- newElement.appendChild(customElement.childNodes[0]);
80
- }
81
- customElement.parentElement.replaceChild(newElement, customElement);
82
- });
83
- }
84
- });
85
- }
86
- _0_10_0Alpha_2.logOperationStart({
87
- id: _0_10_0Alpha_2$1.BOOTSTRAP_END
88
- });
89
- }
90
-
91
- exports.getPropFromAttrName = getPropFromAttrName;
92
- exports.init = init;
93
- exports.toKebabCase = toKebabCase;
94
-
95
- Object.defineProperty(exports, '__esModule', { value: true });
96
-
97
- });
@@ -1,68 +0,0 @@
1
- LWR.define('lwr/profiler/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use strict';
2
-
3
- var Phase;
4
- (function (Phase) {
5
- Phase[Phase["Start"] = 0] = "Start";
6
- Phase[Phase["End"] = 1] = "End";
7
- })(Phase || (Phase = {}));
8
- // Attach a custom dispatcher
9
- let customDispatcher;
10
- function attachDispatcher(dispatcher) {
11
- customDispatcher = dispatcher;
12
- }
13
-
14
- // Check if the Performance API is available
15
- // e.g. JSDom (used in Jest) doesn't implement these
16
- const perf = globalThis.performance;
17
- const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
18
-
19
- // For marking request metrics
20
- // Fallback to the Performance API if there is no custom dispatcher
21
- function logOperationStart({
22
- id,
23
- specifier
24
- }) {
25
- if (customDispatcher) {
26
- customDispatcher({
27
- id,
28
- phase: Phase.Start,
29
- specifier
30
- });
31
- } else if (isPerfSupported) {
32
- perf.mark(id + (specifier ? `.${specifier}` : ''));
33
- }
34
- }
35
-
36
- // For measuring duration metrics
37
- // Fallback to the Performance API if there is no custom dispatcher
38
- /* istanbul ignore next */
39
- function logOperationEnd({
40
- id,
41
- specifier
42
- }) {
43
- if (customDispatcher) {
44
- customDispatcher({
45
- id,
46
- phase: Phase.End,
47
- specifier
48
- });
49
- } else if (isPerfSupported) {
50
- const suffix = specifier ? `.${specifier}` : '';
51
- const markName = id + suffix;
52
- const measureName = `${id}.duration${suffix}`;
53
- perf.measure(measureName, markName);
54
-
55
- // Clear the created mark and measure to avoid filling the performance entry buffer
56
- // Even if they get deleted, existing PerformanceObservers preserve copies of the entries
57
- perf.clearMarks(markName);
58
- perf.clearMeasures(measureName);
59
- }
60
- }
61
-
62
- exports.attachDispatcher = attachDispatcher;
63
- exports.logOperationEnd = logOperationEnd;
64
- exports.logOperationStart = logOperationStart;
65
-
66
- Object.defineProperty(exports, '__esModule', { value: true });
67
-
68
- });
@@ -1,24 +0,0 @@
1
- import { Luvio } from '@luvio/engine';
2
- export declare type Callback = (luvio: Luvio) => void;
3
- /**
4
- * Constructs/sets the default Luvio instance. Any previously-set default luvio instance
5
- * is overwritten.
6
- */
7
- export declare function setDefaultLuvio({ luvio }: {
8
- luvio: Luvio;
9
- }): void;
10
- /**
11
- * Registers a callback to be invoked with the default Luvio instance. Note that the
12
- * callback may be invoked multiple times if the default Luvio changes.
13
- *
14
- * @param callback callback to be invoked with default Luvio instance
15
- */
16
- export declare function withDefaultLuvio(callback: Callback): void;
17
- export declare type Registration = {
18
- id: string;
19
- };
20
- export declare type RegistrationCallback<R = Registration> = (registration: R) => void;
21
- export declare function forEachRegistration(callback: RegistrationCallback): void;
22
- export declare function withRegistration<R extends Registration>(id: R['id'], callback: RegistrationCallback<R>): void;
23
- export declare function register<R extends Registration = Registration>(r: R): void;
24
- //# sourceMappingURL=lds-default-luvio.d.ts.map
@@ -1,60 +0,0 @@
1
- // temp from https://github.com/salesforce-experience-platform-emu/lds-lightning-platform/blob/main/packages/lds-default-luvio/src/main.ts
2
-
3
- // callback used to inform interested parties that a new default Luvio has been set.
4
-
5
- // most recently set default Luvio instance
6
- let defaultLuvio;
7
-
8
- // callbacks to be invoked when default luvio instance is set/changed
9
- const callbacks = [];
10
-
11
- /**
12
- * Constructs/sets the default Luvio instance. Any previously-set default luvio instance
13
- * is overwritten.
14
- */
15
- export function setDefaultLuvio({
16
- luvio
17
- }) {
18
- if (luvio === undefined) {
19
- throw new Error('unable to construct default Luvio instance from supplied parameters');
20
- }
21
- defaultLuvio = luvio;
22
-
23
- // inform observers
24
- for (let i = 0; i < callbacks.length; ++i) {
25
- callbacks[i](defaultLuvio);
26
- }
27
- }
28
-
29
- /**
30
- * Registers a callback to be invoked with the default Luvio instance. Note that the
31
- * callback may be invoked multiple times if the default Luvio changes.
32
- *
33
- * @param callback callback to be invoked with default Luvio instance
34
- */
35
- export function withDefaultLuvio(callback) {
36
- if (defaultLuvio) {
37
- callback(defaultLuvio);
38
- }
39
- callbacks.push(callback);
40
- }
41
-
42
- // export * from './registry'; see below
43
-
44
- const registryCallbacks = [];
45
- const registrations = [];
46
- export function forEachRegistration(callback) {
47
- registryCallbacks.push(callback);
48
- registrations.forEach(r => callback(r));
49
- }
50
- export function withRegistration(id, callback) {
51
- forEachRegistration(r => {
52
- if (r.id === id) {
53
- callback(r);
54
- }
55
- });
56
- }
57
- export function register(r) {
58
- registrations.push(r);
59
- registryCallbacks.forEach(callback => callback(r));
60
- }