primate 0.1.1 → 0.2.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/package.json +1 -1
- package/source/client/Action.js +4 -6
- package/source/client/App.js +1 -4
- package/source/client/Client.js +4 -10
- package/source/client/document.js +6 -0
- package/source/server/Bundler.js +1 -1
- package/source/server/domain/Domain.js +2 -9
- package/source/server/servers/content-security-policy.json +1 -2
- package/source/server/types/Date.js +2 -2
- package/source/server/constructible.js +0 -8
package/package.json
CHANGED
package/source/client/Action.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import Element from "../Element.js";
|
|
2
2
|
import View from "./View.js";
|
|
3
3
|
import Base from "./Base.js";
|
|
4
|
-
|
|
5
|
-
const base = document.baseURI.replace(document.location.origin, "");
|
|
6
|
-
const full = `${document.location.origin}${base}`;
|
|
4
|
+
import {origin_base} from "./document.js";
|
|
7
5
|
|
|
8
6
|
export default class Action extends Base {
|
|
9
7
|
constructor(name, context) {
|
|
@@ -75,7 +73,7 @@ export default class Action extends Base {
|
|
|
75
73
|
}
|
|
76
74
|
event.preventDefault();
|
|
77
75
|
const data = await this.write(target.action, this.get_form_data(target));
|
|
78
|
-
return data.pathname === document.location.href.replace(
|
|
76
|
+
return data.pathname === document.location.href.replace(origin_base, "")
|
|
79
77
|
? this.view.update(data.payload)
|
|
80
78
|
: this.context.run(data);
|
|
81
79
|
}
|
|
@@ -94,8 +92,8 @@ export default class Action extends Base {
|
|
|
94
92
|
}
|
|
95
93
|
if (target !== null) {
|
|
96
94
|
const href = Element.value(target, "href");
|
|
97
|
-
const url = new URL(href,
|
|
98
|
-
if (event.button === 0 && url.href.startsWith(
|
|
95
|
+
const url = new URL(href, origin_base);
|
|
96
|
+
if (event.button === 0 && url.href.startsWith(origin_base)) {
|
|
99
97
|
event.preventDefault();
|
|
100
98
|
if (href !== "") {
|
|
101
99
|
const data = await this.read(href);
|
package/source/client/App.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import Client from "./Client.js";
|
|
2
2
|
|
|
3
|
-
const host = document.location.host;
|
|
4
|
-
const base = document.baseURI.replace(document.location.origin, "");
|
|
5
|
-
|
|
6
3
|
export default class App {
|
|
7
4
|
constructor() {
|
|
8
5
|
this.definitions = {};
|
|
9
6
|
}
|
|
10
7
|
|
|
11
8
|
run() {
|
|
12
|
-
this.client = new Client(
|
|
9
|
+
this.client = new Client();
|
|
13
10
|
this.client.open();
|
|
14
11
|
}
|
|
15
12
|
|
package/source/client/Client.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import Context from "./Context.js";
|
|
2
2
|
import {contexts} from "./exports.js";
|
|
3
|
+
import {base, host, origin_base} from "./document.js";
|
|
3
4
|
|
|
4
5
|
const events = ["submit", "click", "change", "input"];
|
|
5
6
|
let back = undefined;
|
|
7
|
+
const location = `wss://${host}${base}`;
|
|
6
8
|
|
|
7
9
|
export default class Client {
|
|
8
10
|
constructor(conf) {
|
|
@@ -18,14 +20,10 @@ export default class Client {
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
get location() {
|
|
22
|
-
return `wss://${this.conf.host}${this.conf.base}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
23
|
open() {
|
|
26
24
|
return this.connection?.readyState === 1 ? this
|
|
27
25
|
: new Promise(resolve => {
|
|
28
|
-
const connection = new WebSocket(
|
|
26
|
+
const connection = new WebSocket(location);
|
|
29
27
|
connection.addEventListener("message", ({data}) => data === "open"
|
|
30
28
|
? resolve(this)
|
|
31
29
|
: this.receive(JSON.parse(data)));
|
|
@@ -56,13 +54,9 @@ export default class Client {
|
|
|
56
54
|
return this.send("write", url, payload);
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
get full() {
|
|
60
|
-
return `${document.location.origin}${this.conf.base}`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
57
|
async send(type, url, payload = {}) {
|
|
64
58
|
await this.open();
|
|
65
|
-
const {pathname, search} = new URL(url,
|
|
59
|
+
const {pathname, search} = new URL(url, origin_base);
|
|
66
60
|
return new Promise(resolve => {
|
|
67
61
|
back = data => resolve(data);
|
|
68
62
|
this.connection.send(JSON.stringify({type, pathname, search, payload}));
|
package/source/server/Bundler.js
CHANGED
|
@@ -125,7 +125,7 @@ export default class Bundler {
|
|
|
125
125
|
|
|
126
126
|
register(src, source) {
|
|
127
127
|
const integrity = `${algorithm}-${hash(source)}`;
|
|
128
|
-
this.scripts.push({src
|
|
128
|
+
this.scripts.push({"src": `${this.conf.base}${src}`, integrity});
|
|
129
129
|
this.hashes.add(integrity);
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -45,14 +45,7 @@ export default class Domain extends Base {
|
|
|
45
45
|
return cache(this, "store", async () => {
|
|
46
46
|
const logic = path => import(`${path}/${this.store_file}`);
|
|
47
47
|
const store = await fallback(this.conf.paths.data.stores, preset, logic);
|
|
48
|
-
|
|
49
|
-
const instance = store.default;
|
|
50
|
-
|
|
51
|
-
const message = `${instance.constructor.name} must instance Store`;
|
|
52
|
-
const error = () => { throw new InternalServerError(message); };
|
|
53
|
-
assert(instance instanceof Store, error);
|
|
54
|
-
|
|
55
|
-
return instance.open();
|
|
48
|
+
return store.default.open();
|
|
56
49
|
});
|
|
57
50
|
}
|
|
58
51
|
|
|
@@ -126,7 +119,7 @@ export default class Domain extends Base {
|
|
|
126
119
|
static deserialize(serialized) {
|
|
127
120
|
const fields = this._fields;
|
|
128
121
|
return new this(Object.keys(serialized)
|
|
129
|
-
|
|
122
|
+
.filter(property => fields[property] !== undefined)
|
|
130
123
|
.map(property =>
|
|
131
124
|
({property,
|
|
132
125
|
"value": fields[property].deserialize(serialized[property])}))
|