svelte-common 4.4.41 → 4.5.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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "stylelint-config-standard"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "4.4.41",
3
+ "version": "4.5.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -9,6 +9,7 @@
9
9
  "keywords": [
10
10
  "component",
11
11
  "svelte",
12
+ "vite",
12
13
  "web"
13
14
  ],
14
15
  "contributors": [
@@ -19,28 +20,40 @@
19
20
  ],
20
21
  "license": "BSD-2-Clause",
21
22
  "scripts": {
23
+ "prepare": "vite build",
22
24
  "start": "vite dev",
23
25
  "test": "npm run test:ava && npm run test:cafe",
24
- "test:cafe": "testcafe $BROWSER:headless tests/cafe/*.js -s build/test --page-request-timeout 9000 --app-init-delay 3000 --app \"vite dev\"",
26
+ "test:cafe": "testcafe $BROWSER:headless tests/cafe/*.js -s build/test --page-request-timeout 9000 --app-init-delay 3000 --app \"vite\"",
25
27
  "test:ava": "ava --timeout 2m tests/*.mjs",
26
28
  "docs": "documentation readme --section=API ./src/**/*.mjs",
27
- "lint": "documentation lint ./src/index.mjs && npm run lint:docs",
28
- "lint:docs": "documentation lint ./src/**/*.mjs"
29
+ "lint": "npm run lint:css && npm run lint:docs && documentation lint ./src/index.mjs",
30
+ "lint:docs": "documentation lint ./src/**/*.mjs",
31
+ "lint:css": "stylelint ./src/*.css",
32
+ "preview": "vite preview"
29
33
  },
30
34
  "dependencies": {
31
35
  "svelte-command": "^1.1.12",
32
36
  "svelte-entitlement": "^1.2.22"
33
37
  },
34
38
  "devDependencies": {
39
+ "@semantic-release/commit-analyzer": "^9.0.2",
40
+ "@semantic-release/exec": "^6.0.3",
41
+ "@semantic-release/release-notes-generator": "^10.0.3",
35
42
  "@sveltejs/vite-plugin-svelte": "^1.0.0-next.49",
36
43
  "ava": "^4.3.0",
37
44
  "documentation": "^13.2.5",
38
45
  "mf-styling": "^1.2.22",
46
+ "npm-pkgbuild": "^10.7.10",
39
47
  "semantic-release": "^19.0.3",
48
+ "stylelint": "^14.9.1",
49
+ "stylelint-config-standard": "^26.0.0",
40
50
  "svelte": "^3.48.0",
41
51
  "testcafe": "^1.19.0",
42
52
  "vite": "^2.9.12"
43
53
  },
54
+ "optionalDependencies": {
55
+ "mf-hosting": "^1.6.3"
56
+ },
44
57
  "repository": {
45
58
  "type": "git",
46
59
  "url": "https://github.com/arlac77/svelte-common.git"
@@ -49,11 +62,37 @@
49
62
  "url": "https://github.com/arlac77/svelte-common/issues"
50
63
  },
51
64
  "homepage": "https://github.com/arlac77/svelte-common#readme",
65
+ "pkgbuild": {
66
+ "content": {
67
+ "${install.dir}": {
68
+ "base": "build"
69
+ },
70
+ "${nginx.sites.dir}${name}.conf": "pkg/nginx.conf"
71
+ },
72
+ "hooks": "pkg/hooks.sh",
73
+ "groups": "web"
74
+ },
75
+ "release": {
76
+ "plugins": [
77
+ "@semantic-release/commit-analyzer",
78
+ "@semantic-release/release-notes-generator",
79
+ "@semantic-release/npm",
80
+ [
81
+ "@semantic-release/exec",
82
+ {
83
+ "publishCmd": "npx npm-pkgbuild --available --verbose"
84
+ }
85
+ ],
86
+ "@semantic-release/github"
87
+ ]
88
+ },
52
89
  "template": {
53
90
  "inheritFrom": [
54
91
  "arlac77/template-arlac77-github",
55
92
  "arlac77/template-ava",
56
93
  "arlac77/template-cloudflare",
94
+ "arlac77/template-css",
95
+ "arlac77/template-pacman",
57
96
  "arlac77/template-svelte-component#next"
58
97
  ]
59
98
  }
package/pkg/hooks.sh ADDED
@@ -0,0 +1,12 @@
1
+
2
+ post_install() {
3
+ systemctl reload nginx
4
+ }
5
+
6
+ post_upgrade() {
7
+ systemctl reload nginx
8
+ }
9
+
10
+ post_remove() {
11
+ systemctl reload nginx
12
+ }
package/pkg/nginx.conf ADDED
@@ -0,0 +1,5 @@
1
+ location {{http.path}} {
2
+ alias {{install.dir}};
3
+ gzip_static on;
4
+ add_header Content-Security-Policy "{{csp.header}}" always;
5
+ }
@@ -1,4 +1,3 @@
1
-
2
1
  <table class="bordered striped">
3
2
  <tbody>
4
3
  <slot />
@@ -13,9 +13,9 @@
13
13
  const a = anchor.getBoundingClientRect();
14
14
  const c = content.getBoundingClientRect();
15
15
 
16
- console.log("A",a);
17
- console.log("C",c);
18
-
16
+ console.log("A", a);
17
+ console.log("C", c);
18
+
19
19
  a.x -= OFFSET;
20
20
  a.y -= OFFSET;
21
21
  c.x -= OFFSET;
@@ -62,12 +62,14 @@
62
62
 
63
63
  onMount(() => {
64
64
  layoutPath();
65
- path.onmouseout = e => { close(); };
65
+ path.onmouseout = e => {
66
+ close();
67
+ };
66
68
  });
67
69
  </script>
68
70
 
69
71
  <svg class="acc" width="10000" height="10000">
70
- <path bind:this={path}/>
72
+ <path bind:this={path} />
71
73
  </svg>
72
74
  <div bind:this={anchor} on:mouseleave={close}>
73
75
  <slot name="anchor" />
@@ -1,7 +1,6 @@
1
1
  <script>
2
- import { formatBytes } from "../util.mjs";
3
- export let value;
4
- </script>
5
-
6
- <span>{formatBytes(value)}</span>
7
-
2
+ import { formatBytes } from "../util.mjs";
3
+ export let value;
4
+ </script>
5
+
6
+ <span>{formatBytes(value)}</span>
@@ -1,12 +1,24 @@
1
1
  <script>
2
+ import { setContext } from "svelte";
3
+
2
4
  export let columns = [];
5
+ const dataGrid = {
6
+ columns,
7
+ addColumn: c => {
8
+ console.log("addColumn", c);
9
+ columns.push(c);
10
+ }
11
+ };
12
+
13
+ setContext("DATA_GRID", dataGrid);
14
+
3
15
  export let source = { entries: [] };
4
16
  </script>
5
17
 
6
18
  <table>
7
19
  <thead>
8
20
  {#each columns as column}
9
- <th>{column.title||column.id}</th>
21
+ <svelte:component this={column.component} />
10
22
  {/each}
11
23
  </thead>
12
24
  <tbody>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ import { setContext, getContext } from "svelte";
3
+
4
+ const dataGrid = getContext("DATA_GRID");
5
+
6
+ dataGrid.addColumn({ id, component: this});
7
+ export let id;
8
+ </script>
9
+
10
+ <th {id}>
11
+ <slot />
12
+ </th>
@@ -11,6 +11,7 @@
11
11
  open = true;
12
12
  }
13
13
  </script>
14
+
14
15
  {#if open}
15
16
  <AnchorContentCatcher close={hide}>
16
17
  <a href=" " slot="anchor">
@@ -4,8 +4,15 @@
4
4
 
5
5
  export let server;
6
6
 
7
- if(!server) { server = {}; }
8
- const memory = server.memory || { heapTotal: 0, heapUsed: 0, external: 0, rss: 0 };
7
+ if (!server) {
8
+ server = {};
9
+ }
10
+ const memory = server.memory || {
11
+ heapTotal: 0,
12
+ heapUsed: 0,
13
+ external: 0,
14
+ rss: 0
15
+ };
9
16
  </script>
10
17
 
11
18
  <tr>
@@ -28,20 +35,20 @@
28
35
  <tr>
29
36
  <td />
30
37
  <td>Heap Total</td>
31
- <td><Bytes value={memory.heapTotal}/></td>
38
+ <td><Bytes value={memory.heapTotal} /></td>
32
39
  </tr>
33
40
  <tr>
34
41
  <td />
35
42
  <td>Heap Used</td>
36
- <td><Bytes value={memory.heapUsed}/></td>
43
+ <td><Bytes value={memory.heapUsed} /></td>
37
44
  </tr>
38
45
  <tr>
39
46
  <td />
40
47
  <td>External</td>
41
- <td><Bytes value={memory.external}/></td>
48
+ <td><Bytes value={memory.external} /></td>
42
49
  </tr>
43
50
  <tr>
44
51
  <td />
45
52
  <td>RSS</td>
46
- <td><Bytes value={memory.rss}/></td>
53
+ <td><Bytes value={memory.rss} /></td>
47
54
  </tr>
@@ -6,12 +6,12 @@
6
6
  <td colspan="3">Service Worker</td>
7
7
  </tr>
8
8
  <tr>
9
- <td></td>
9
+ <td />
10
10
  <td>State</td>
11
11
  <td>{serviceWorker.state}</td>
12
12
  </tr>
13
13
  <tr>
14
- <td></td>
14
+ <td />
15
15
  <td>scriptURL</td>
16
16
  <td>{serviceWorker.scriptURL}</td>
17
17
  </tr>
@@ -13,12 +13,14 @@
13
13
  <td colspan="2">
14
14
  <CommandButton
15
15
  command={new Command(() => serviceWorkerRegistration.update(), {
16
- title: 'Update',
17
- shortcuts: 'Command+u'
18
- })} />
16
+ title: "Update",
17
+ shortcuts: "Command+u"
18
+ })}
19
+ />
19
20
  <CommandButton
20
- command={new Command(() => serviceWorkerRegistration.unregister(), {
21
- title: 'Unregister'
22
- })} />
21
+ command={new Command(() => serviceWorkerRegistration.unregister(), {
22
+ title: "Unregister"
23
+ })}
24
+ />
23
25
  </td>
24
26
  </tr>
@@ -1,8 +1,5 @@
1
1
  <script>
2
- import {
3
- EntitlementBadges,
4
- Entitlement
5
- } from "svelte-entitlement";
2
+ import { EntitlementBadges, Entitlement } from "svelte-entitlement";
6
3
  import DateTime from "./DateTime.svelte";
7
4
  export let session;
8
5
  </script>
@@ -18,7 +15,7 @@
18
15
  <tr>
19
16
  <td />
20
17
  <td>Expiration</td>
21
- <td class={session.isValid ? 'ok' : 'error'}>
18
+ <td class={session.isValid ? "ok" : "error"}>
22
19
  <DateTime date={session.expirationDate} />
23
20
  </td>
24
21
  </tr>
@@ -29,6 +26,7 @@
29
26
  <EntitlementBadges
30
27
  entitlements={[...session.entitlements]
31
28
  .sort()
32
- .map(name => new Entitlement(name))} />
29
+ .map(name => new Entitlement(name))}
30
+ />
33
31
  </td>
34
32
  </tr>
package/src/index.svelte CHANGED
@@ -10,6 +10,7 @@
10
10
  import ServiceWorkerDetails from "./components/ServiceWorkerDetails.svelte";
11
11
  import ServiceWorkerRegistrationDetails from "./components/ServiceWorkerRegistrationDetails.svelte";
12
12
  import DataGrid from "./components/DataGrid.svelte";
13
+ import DataGridColumn from "./components/DataGridColumn.svelte";
13
14
  import TopNav from "./components/TopNav.svelte";
14
15
  import Menue from "./components/Menue.svelte";
15
16
  import Collapse from "./components/Collapse.svelte";
@@ -23,6 +24,7 @@
23
24
  TopNav,
24
25
  Menue,
25
26
  DataGrid,
27
+ DataGridColumn,
26
28
  Collapse,
27
29
  Modal,
28
30
  Peer,
@@ -43,5 +45,4 @@
43
45
  formatSecondsSinceEpoch
44
46
  } from "./util.mjs";
45
47
  export { initializeServiceWorker } from "./service-worker.mjs";
46
-
47
48
  </script>
package/src/util.mjs CHANGED
@@ -34,8 +34,8 @@ export function formatDurationISO(seconds) {
34
34
  let t = false;
35
35
 
36
36
  for (const d of durationsISO) {
37
- if(seconds < 86400 && ! t) {
38
- out += 'T';
37
+ if (seconds < 86400 && !t) {
38
+ out += "T";
39
39
  t = true;
40
40
  }
41
41
 
package/vite.config.js CHANGED
@@ -1,24 +1,23 @@
1
- import { readFile } from "fs/promises";
2
1
  import { svelte } from "@sveltejs/vite-plugin-svelte";
2
+ //import { extractFromPackage } from "npm-pkgbuild/src/module.mjs";
3
3
  import { defineConfig } from "vite";
4
4
 
5
- const encodingOptions = { encoding: "utf8" };
6
-
7
5
  export default defineConfig(async ({ command, mode }) => {
8
- const pkg = JSON.parse(
9
- await readFile(
10
- new URL("package.json", import.meta.url).pathname,
11
- encodingOptions
12
- )
6
+ const { extractFromPackage } = await import(
7
+ new URL("node_modules/npm-pkgbuild/src/module.mjs", import.meta.url)
13
8
  );
14
-
9
+ const res = extractFromPackage({
10
+ dir: new URL("./", import.meta.url).pathname
11
+ });
12
+ const first = await res.next();
13
+ const pkg = first.value;
14
+ const properties = pkg.properties;
15
+ const base = properties["http.path"] + "/";
15
16
  const production = mode === "production";
16
17
 
17
- process.env["VITE_NAME"] = pkg.name;
18
- process.env["VITE_DESCRIPTION"] = pkg.description;
19
- process.env["VITE_VERSION"] = pkg.version;
20
-
21
- const base = `/components/${pkg.name}/example/`;
18
+ process.env["VITE_NAME"] = properties.name;
19
+ process.env["VITE_DESCRIPTION"] = properties.description;
20
+ process.env["VITE_VERSION"] = properties.version;
22
21
 
23
22
  return {
24
23
  base,
@@ -38,7 +37,7 @@ export default defineConfig(async ({ command, mode }) => {
38
37
  },
39
38
  server: { host: true },
40
39
  build: {
41
- outDir: "../build",
40
+ outDir: "../../../build",
42
41
  target: "esnext",
43
42
  emptyOutDir: true,
44
43
  minify: production,