@hyperspan/framework 0.5.0 → 0.5.1

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/assets.js CHANGED
@@ -22,12 +22,12 @@ async function buildClientJS() {
22
22
  const jsFile = output.outputs[0].path.split("/").reverse()[0];
23
23
  clientJSFiles.set("_hs", { src: `${CLIENTJS_PUBLIC_PATH}/${jsFile}` });
24
24
  }
25
- function renderClientJS(module, onLoad) {
25
+ function renderClientJS(module, loadScript) {
26
26
  if (!module.__CLIENT_JS) {
27
27
  throw new Error(`[Hyperspan] Client JS was not loaded by Hyperspan! Ensure the filename ends with .client.ts to use this render method.`);
28
28
  }
29
29
  return html.raw(module.__CLIENT_JS.renderScriptTag({
30
- onLoad: onLoad ? typeof onLoad === "string" ? onLoad : functionToString(onLoad) : undefined
30
+ loadScript: loadScript ? typeof loadScript === "string" ? loadScript : functionToString(loadScript) : undefined
31
31
  }));
32
32
  }
33
33
  function functionToString(fn) {
package/dist/server.js CHANGED
@@ -54,8 +54,8 @@ export const __CLIENT_JS = {
54
54
  esmName: "${esmName}",
55
55
  sourceFile: "${args.path}",
56
56
  outputFile: "${result.outputs[0].path}",
57
- renderScriptTag: ({ onLoad }) => {
58
- const fn = onLoad ? (typeof onLoad === 'string' ? onLoad : \`const fn = \${functionToString(onLoad)}; fn(${fnArgs});\`) : '';
57
+ renderScriptTag: ({ loadScript }) => {
58
+ const fn = loadScript ? (typeof loadScript === 'string' ? loadScript : \`const fn = \${functionToString(loadScript)}; fn(${fnArgs});\`) : '';
59
59
  return \`<script type="module" data-source-id="${jsId}">import ${exports} from "${esmName}";
60
60
  \${fn}</script>\`;
61
61
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperspan/framework",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Hyperspan Web Framework",
5
5
  "main": "dist/server.ts",
6
6
  "types": "src/server.ts",
package/src/assets.ts CHANGED
@@ -36,7 +36,7 @@ export async function buildClientJS() {
36
36
  /**
37
37
  * Render a client JS module as a script tag
38
38
  */
39
- export function renderClientJS<T>(module: T, onLoad?: (module: T) => void | string) {
39
+ export function renderClientJS<T>(module: T, loadScript?: ((module: T) => void) | string) {
40
40
  // @ts-ignore
41
41
  if (!module.__CLIENT_JS) {
42
42
  throw new Error(
@@ -47,7 +47,11 @@ export function renderClientJS<T>(module: T, onLoad?: (module: T) => void | stri
47
47
  return html.raw(
48
48
  // @ts-ignore
49
49
  module.__CLIENT_JS.renderScriptTag({
50
- onLoad: onLoad ? (typeof onLoad === 'string' ? onLoad : functionToString(onLoad)) : undefined,
50
+ loadScript: loadScript
51
+ ? typeof loadScript === 'string'
52
+ ? loadScript
53
+ : functionToString(loadScript)
54
+ : undefined,
51
55
  })
52
56
  );
53
57
  }
package/src/plugins.ts CHANGED
@@ -71,8 +71,8 @@ export const __CLIENT_JS = {
71
71
  esmName: "${esmName}",
72
72
  sourceFile: "${args.path}",
73
73
  outputFile: "${result.outputs[0].path}",
74
- renderScriptTag: ({ onLoad }) => {
75
- const fn = onLoad ? (typeof onLoad === 'string' ? onLoad : \`const fn = \${functionToString(onLoad)}; fn(${fnArgs});\`) : '';
74
+ renderScriptTag: ({ loadScript }) => {
75
+ const fn = loadScript ? (typeof loadScript === 'string' ? loadScript : \`const fn = \${functionToString(loadScript)}; fn(${fnArgs});\`) : '';
76
76
  return \`<script type="module" data-source-id="${jsId}">import ${exports} from "${esmName}";\n\${fn}</script>\`;
77
77
  },
78
78
  }