pinstripe 0.24.1 → 0.27.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/LICENSE +1 -1
- package/README.md +3 -1
- package/lib/class.js +1 -63
- package/lib/component.js +66 -91
- package/lib/components/_file_importer.js +1 -1
- package/lib/components/index.js +1 -0
- package/lib/components/{a.js → pinstripe_anchor.js} +2 -5
- package/lib/components/{document.js → pinstripe_document.js} +18 -0
- package/lib/components/{form.js → pinstripe_form.js} +2 -2
- package/lib/components/pinstripe_frame.js +17 -9
- package/lib/components/pinstripe_overlay.js +1 -1
- package/lib/components/{script.js → pinstripe_script.js} +0 -2
- package/lib/components/pinstripe_skeleton.js +1 -1
- package/lib/constants.js +1 -25
- package/lib/index.js +3 -12
- package/lib/inflector.js +1 -172
- package/lib/initialize.js +2 -0
- package/lib/internal.js +7 -0
- package/lib/lru_cache.js +1 -52
- package/lib/registry.js +1 -129
- package/lib/trapify.js +1 -31
- package/lib/virtual_node.js +1 -170
- package/package.json +11 -38
- package/babel.config.cjs +0 -18
- package/cli.js +0 -46
- package/jest.config.cjs +0 -6
- package/lib/app.js +0 -35
- package/lib/apps/_file_importer.js +0 -1
- package/lib/apps/docs.js +0 -6
- package/lib/apps/main.js +0 -6
- package/lib/client.js +0 -20
- package/lib/command.js +0 -41
- package/lib/commands/_file_importer.js +0 -1
- package/lib/commands/drop_database.js +0 -6
- package/lib/commands/generate_app.js +0 -41
- package/lib/commands/generate_command.js +0 -39
- package/lib/commands/generate_component.js +0 -51
- package/lib/commands/generate_migration.js +0 -55
- package/lib/commands/generate_model.js +0 -43
- package/lib/commands/generate_project.js +0 -133
- package/lib/commands/generate_service.js +0 -32
- package/lib/commands/generate_static_site.js +0 -74
- package/lib/commands/generate_view.js +0 -44
- package/lib/commands/init_database.js +0 -9
- package/lib/commands/list_apps.js +0 -15
- package/lib/commands/list_commands.js +0 -15
- package/lib/commands/list_components.js +0 -16
- package/lib/commands/list_migrations.js +0 -15
- package/lib/commands/list_models.js +0 -15
- package/lib/commands/list_services.js +0 -15
- package/lib/commands/list_views.js +0 -39
- package/lib/commands/migrate_database.js +0 -6
- package/lib/commands/purge_old_sessions.js +0 -12
- package/lib/commands/reset_database.js +0 -9
- package/lib/commands/seed_database.js +0 -6
- package/lib/commands/show_config.js +0 -6
- package/lib/commands/start_repl.js +0 -6
- package/lib/commands/start_server.js +0 -31
- package/lib/components/pinstripe_markdown_editor.js +0 -73
- package/lib/components/pinstripe_silo.js +0 -2
- package/lib/context.js +0 -40
- package/lib/database/client.js +0 -242
- package/lib/database/column_reference.js +0 -13
- package/lib/database/constants.js +0 -87
- package/lib/database/index.js +0 -7
- package/lib/database/migration.js +0 -30
- package/lib/database/migrator.js +0 -28
- package/lib/database/row.js +0 -390
- package/lib/database/singleton.js +0 -12
- package/lib/database/table.js +0 -516
- package/lib/database/table_reference.js +0 -33
- package/lib/database/union.js +0 -128
- package/lib/database.js +0 -139
- package/lib/defer.js +0 -35
- package/lib/defer.test.js +0 -37
- package/lib/escape_html.js +0 -2
- package/lib/extensions/_file_importer.js +0 -2
- package/lib/extensions/multi-tenant/database/row.js +0 -27
- package/lib/extensions/multi-tenant/database/table.js +0 -30
- package/lib/extensions/multi-tenant/database.js +0 -8
- package/lib/extensions/multi-tenant/index.js +0 -4
- package/lib/extensions/multi-tenant/migrations/1627976174_create_tenant_table_and_add_tenant_id_to_existing_tables.js +0 -20
- package/lib/extensions/multi-tenant/migrations/_file_importer.js +0 -2
- package/lib/extensions/multi-tenant/services/_file_importer.js +0 -2
- package/lib/extensions/multi-tenant/services/database.js +0 -32
- package/lib/html.js +0 -72
- package/lib/import_all.js +0 -94
- package/lib/lru_cache.test.js +0 -45
- package/lib/markdown.js +0 -58
- package/lib/model.js +0 -110
- package/lib/project.js +0 -72
- package/lib/service_consumer.js +0 -16
- package/lib/service_factory.js +0 -20
- package/lib/services/_file_importer.js +0 -1
- package/lib/services/app.js +0 -11
- package/lib/services/args.js +0 -9
- package/lib/services/bot.js +0 -69
- package/lib/services/cli_utils.js +0 -77
- package/lib/services/client_builder.js +0 -70
- package/lib/services/config.js +0 -66
- package/lib/services/cookies.js +0 -19
- package/lib/services/create_model.js +0 -8
- package/lib/services/database.js +0 -14
- package/lib/services/defer.js +0 -8
- package/lib/services/fetch.js +0 -115
- package/lib/services/format_date.js +0 -8
- package/lib/services/fs_builder.js +0 -132
- package/lib/services/inflector.js +0 -8
- package/lib/services/initial_params.js +0 -13
- package/lib/services/params.js +0 -13
- package/lib/services/parse_html.js +0 -8
- package/lib/services/project.js +0 -8
- package/lib/services/render_form.js +0 -165
- package/lib/services/render_html.js +0 -8
- package/lib/services/render_markdown.js +0 -9
- package/lib/services/render_view.js +0 -6
- package/lib/services/repl.js +0 -54
- package/lib/services/run_command.js +0 -8
- package/lib/services/run_in_new_workspace.js +0 -11
- package/lib/services/send_mail.js +0 -47
- package/lib/services/server.js +0 -105
- package/lib/services/view.js +0 -6
- package/lib/singleton.js +0 -13
- package/lib/string_reader.js +0 -22
- package/lib/unescape_html.js +0 -2
- package/lib/unescape_html.test.js +0 -9
- package/lib/util.js +0 -3
- package/lib/validation_error.js +0 -7
- package/lib/view.js +0 -82
- package/lib/view_file_importers/md.js +0 -42
- package/lib/views/_file_importer.js +0 -1
- package/lib/views/main/assets/javascripts/all.js.js +0 -7
- package/lib/views/main/assets/javascripts/all.js.map.js +0 -7
- package/lib/views/main/assets/stylesheets/all.css.js +0 -28
- package/lib/views/main/assets/stylesheets/components/button.css +0 -43
- package/lib/views/main/assets/stylesheets/components/card.css +0 -29
- package/lib/views/main/assets/stylesheets/components/form.css +0 -4
- package/lib/views/main/assets/stylesheets/components/frame.css +0 -3
- package/lib/views/main/assets/stylesheets/components/input.css +0 -40
- package/lib/views/main/assets/stylesheets/components/label.css +0 -9
- package/lib/views/main/assets/stylesheets/components/overlay.css +0 -11
- package/lib/views/main/assets/stylesheets/components/pagination.css +0 -60
- package/lib/views/main/assets/stylesheets/components/progress_bar.css +0 -20
- package/lib/views/main/assets/stylesheets/components/textarea.css +0 -10
- package/lib/views/main/assets/stylesheets/global.css +0 -120
- package/lib/views/main/assets/stylesheets/reset.css +0 -74
- package/lib/views/main/assets/stylesheets/vars.css +0 -25
- package/lib/virtual_node.test.js +0 -28
- package/lib/workspace.js +0 -21
- /package/lib/components/{body.js → pinstripe_body.js} +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
## What is Pinstripe?
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Is front-end framework that surgically updates your app's DOM when a page changes.
|
|
7
|
+
|
|
8
|
+
This gives the performance of a SPA using with a fraction of the complexity using well established classical patterns.
|
|
7
9
|
|
|
8
10
|
## License
|
|
9
11
|
|
package/lib/class.js
CHANGED
|
@@ -1,64 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
static extend(){
|
|
5
|
-
return class extends this {};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
static include(...includes){
|
|
9
|
-
includes.forEach(include => {
|
|
10
|
-
if(typeof include.meta == 'function') include.meta.call(this);
|
|
11
|
-
this.prototype.assignProps(include, name => name != 'meta');
|
|
12
|
-
});
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static assignProps(...sources){
|
|
17
|
-
return assignProps(this, ...sources);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static new(...args){
|
|
21
|
-
return new this(...args);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static get parent(){
|
|
25
|
-
return this.__proto__;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
constructor(...args){
|
|
29
|
-
let out = this.initialize(...args);
|
|
30
|
-
if(typeof out?.then == 'function'){
|
|
31
|
-
return out.then(out => out || this);
|
|
32
|
-
}
|
|
33
|
-
return out || this;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
initialize(){
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
assignProps(...sources){
|
|
41
|
-
return assignProps(this, ...sources);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const assignProps = (target, ...sources) => {
|
|
46
|
-
const fn = typeof sources[sources.length - 1] == 'function' ? sources.pop() : () => true;
|
|
47
|
-
|
|
48
|
-
sources.forEach(source => {
|
|
49
|
-
Object.getOwnPropertyNames(source).forEach(name => {
|
|
50
|
-
if(!fn(name)){
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const descriptor = { ...Object.getOwnPropertyDescriptor(source, name) };
|
|
54
|
-
const { get: targetGet, set: targetSet } = (Object.getOwnPropertyDescriptor(target, name) || {});
|
|
55
|
-
const { get = targetGet, set = targetSet } = descriptor;
|
|
56
|
-
|
|
57
|
-
if(get) descriptor.get = get;
|
|
58
|
-
if(set) descriptor.set = set;
|
|
59
|
-
|
|
60
|
-
Object.defineProperty(target, name, descriptor);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
return target;
|
|
64
|
-
};
|
|
2
|
+
export { Class } from '@blognami/util';
|
package/lib/component.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
import { fileURLToPath } from 'url'; // pinstripe-if-client: const fileURLToPath = undefined;
|
|
3
|
-
|
|
4
2
|
import { Class } from './class.js';
|
|
5
3
|
import { TEXT_ONLY_TAGS } from './constants.js';
|
|
6
4
|
import { Inflector } from './inflector.js';
|
|
7
5
|
import { VirtualNode } from './virtual_node.js';
|
|
8
6
|
import { Registry } from './registry.js';
|
|
9
7
|
import { ComponentEvent } from './component_event.js';
|
|
10
|
-
import { Client } from './client.js'; // pinstripe-if-client: const Client = undefined;
|
|
11
8
|
|
|
12
9
|
export const Component = Class.extend().include({
|
|
13
10
|
meta(){
|
|
11
|
+
this.assignProps({ name: 'Component' });
|
|
12
|
+
|
|
14
13
|
this.include(Registry);
|
|
15
14
|
|
|
16
15
|
this.assignProps({
|
|
@@ -18,7 +17,7 @@ export const Component = Class.extend().include({
|
|
|
18
17
|
if(!node._component){
|
|
19
18
|
node._component = Component.new(node, true);
|
|
20
19
|
node._component = Component.create(
|
|
21
|
-
node._component.attributes['data-component'] || node._component.type,
|
|
20
|
+
node._component.attributes['data-component'] || (node._component.type == '#document' ? 'pinstripe-document' : node._component.type),
|
|
22
21
|
node
|
|
23
22
|
);
|
|
24
23
|
if(node.isConnected) node._component.trigger('init', { bubbles: false });
|
|
@@ -30,30 +29,6 @@ export const Component = Class.extend().include({
|
|
|
30
29
|
return Inflector.instance.dasherize(name);
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
|
-
|
|
34
|
-
this.FileImporter.register('js', {
|
|
35
|
-
meta(){
|
|
36
|
-
const { importFile } = this.prototype;
|
|
37
|
-
|
|
38
|
-
this.include({
|
|
39
|
-
async importFile(params){
|
|
40
|
-
const { filePath, relativeFilePathWithoutExtension } = params;
|
|
41
|
-
if((await import(filePath)).default){
|
|
42
|
-
Client.instance.addModule(`
|
|
43
|
-
import { Component } from ${JSON.stringify(fileURLToPath(`${import.meta.url}/../index.js`))};
|
|
44
|
-
import include from ${JSON.stringify(filePath)};
|
|
45
|
-
Component.register(${JSON.stringify(relativeFilePathWithoutExtension)}, include);
|
|
46
|
-
`);
|
|
47
|
-
} else {
|
|
48
|
-
Client.instance.addModule(`
|
|
49
|
-
import ${JSON.stringify(filePath)};
|
|
50
|
-
`);
|
|
51
|
-
}
|
|
52
|
-
return importFile.call(this, params);
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
32
|
},
|
|
58
33
|
|
|
59
34
|
initialize(node, skipInit = false){
|
|
@@ -64,38 +39,17 @@ export const Component = Class.extend().include({
|
|
|
64
39
|
this._registeredAbortControllers = [];
|
|
65
40
|
this._virtualNodeFilters = [];
|
|
66
41
|
|
|
67
|
-
if(skipInit) return;
|
|
68
|
-
|
|
69
42
|
this.addVirtualNodeFilter(function(){
|
|
70
43
|
this.traverse(normalizeVirtualNode);
|
|
71
44
|
});
|
|
72
45
|
|
|
46
|
+
if(skipInit) return;
|
|
47
|
+
|
|
73
48
|
const { autofocus } = this.attributes;
|
|
74
49
|
|
|
75
50
|
if(autofocus){
|
|
76
51
|
this.setTimeout(() => this.node.focus());
|
|
77
52
|
}
|
|
78
|
-
|
|
79
|
-
const { autosubmit, trigger, decorate } = this.data;
|
|
80
|
-
|
|
81
|
-
// replace with pinstripe-autosubmitter?
|
|
82
|
-
if(autosubmit){
|
|
83
|
-
let hash = JSON.stringify(this.values);
|
|
84
|
-
this.setInterval(() => {
|
|
85
|
-
const newHash = JSON.stringify(this.values);
|
|
86
|
-
if(hash != newHash){
|
|
87
|
-
hash = newHash;
|
|
88
|
-
this.trigger('submit');
|
|
89
|
-
}
|
|
90
|
-
}, 100);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// replace with script?
|
|
94
|
-
if(trigger){
|
|
95
|
-
this.setTimeout(() => {
|
|
96
|
-
this.trigger(trigger);
|
|
97
|
-
}, 0);
|
|
98
|
-
}
|
|
99
53
|
},
|
|
100
54
|
|
|
101
55
|
get type(){
|
|
@@ -112,21 +66,13 @@ export const Component = Class.extend().include({
|
|
|
112
66
|
return out;
|
|
113
67
|
},
|
|
114
68
|
|
|
115
|
-
get
|
|
116
|
-
const { attributes } = this;
|
|
69
|
+
get params(){
|
|
117
70
|
const out = {};
|
|
71
|
+
const { attributes } = this;
|
|
118
72
|
Object.keys(attributes).forEach(name => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
normalizedName = normalizedName.toLowerCase().replace(/-[a-z]/g, item => item[1].toUpperCase());
|
|
123
|
-
const value = attributes[name];
|
|
124
|
-
try {
|
|
125
|
-
out[normalizedName] = JSON.parse(value);
|
|
126
|
-
} catch(e){
|
|
127
|
-
out[normalizedName] = value;
|
|
128
|
-
}
|
|
129
|
-
})
|
|
73
|
+
const normalizedName = name.replace(/^data-/, '').replace(/-[a-z]/g, item => item[1].toUpperCase());
|
|
74
|
+
out[normalizedName] = attributes[name];
|
|
75
|
+
});
|
|
130
76
|
return out;
|
|
131
77
|
},
|
|
132
78
|
|
|
@@ -134,6 +80,10 @@ export const Component = Class.extend().include({
|
|
|
134
80
|
return this.node.textContent;
|
|
135
81
|
},
|
|
136
82
|
|
|
83
|
+
get html(){
|
|
84
|
+
return this.node.innerHTML;
|
|
85
|
+
},
|
|
86
|
+
|
|
137
87
|
get realParent(){
|
|
138
88
|
if(this.node.parentNode) return this.constructor.instanceFor(this.node.parentNode);
|
|
139
89
|
if(this.node.host instanceof Element) return this.constructor.instanceFor(this.node.host);
|
|
@@ -365,7 +315,7 @@ export const Component = Class.extend().include({
|
|
|
365
315
|
remove(){
|
|
366
316
|
if(this.realParent){
|
|
367
317
|
clean.call(this);
|
|
368
|
-
|
|
318
|
+
remove.call(this);
|
|
369
319
|
}
|
|
370
320
|
return this;
|
|
371
321
|
},
|
|
@@ -385,9 +335,9 @@ export const Component = Class.extend().include({
|
|
|
385
335
|
const html = arg1;
|
|
386
336
|
cleanChildren.call(this);
|
|
387
337
|
if(TEXT_ONLY_TAGS.includes(this.type)){
|
|
388
|
-
insert.call(this, { type: '#text', attributes: { value: html }, children: [] });
|
|
338
|
+
insert.call(new Component(this.node, true), { type: '#text', attributes: { value: html }, children: [] }, null, false);
|
|
389
339
|
} else {
|
|
390
|
-
patchChildren.call(this, createVirtualNode.call(this, html).children);
|
|
340
|
+
patchChildren.call(new Component(this.node, true), createVirtualNode.call(this, html).children);
|
|
391
341
|
}
|
|
392
342
|
initChildren.call(this);
|
|
393
343
|
return this.children;
|
|
@@ -493,13 +443,17 @@ export const Component = Class.extend().include({
|
|
|
493
443
|
return this[collection].find(item => item.is(selector));
|
|
494
444
|
},
|
|
495
445
|
|
|
496
|
-
findAll(){
|
|
446
|
+
findAll(...args){
|
|
497
447
|
if(args.length == 1) args.unshift('descendants');
|
|
498
448
|
const [ collection, selector ] = args;
|
|
499
449
|
return this[collection].filter(item => item.is(selector));
|
|
500
450
|
}
|
|
501
451
|
});
|
|
502
452
|
|
|
453
|
+
function remove(){
|
|
454
|
+
this.node.parentNode.removeChild(this.node);
|
|
455
|
+
}
|
|
456
|
+
|
|
503
457
|
const matchesSelector = (() => {
|
|
504
458
|
if(typeof window == 'undefined') return () => false;
|
|
505
459
|
const node = document.documentElement;
|
|
@@ -551,10 +505,10 @@ function initChildren(){
|
|
|
551
505
|
function prepend(html, referenceChild){
|
|
552
506
|
const out = [];
|
|
553
507
|
if(TEXT_ONLY_TAGS.includes(this.type)){
|
|
554
|
-
out.push(insert.call(this, { type: '#text', attributes: { value: html }, children: [] }, referenceChild));
|
|
508
|
+
out.push(insert.call(new Component(this.node, true), { type: '#text', attributes: { value: html }, children: [] }, referenceChild));
|
|
555
509
|
} else {
|
|
556
510
|
createVirtualNode.call(this, html).children.forEach((virtualChild) => {
|
|
557
|
-
out.push(insert.call(this, virtualChild, referenceChild));
|
|
511
|
+
out.push(insert.call(new Component(this.node, true), virtualChild, referenceChild));
|
|
558
512
|
});
|
|
559
513
|
}
|
|
560
514
|
return out;
|
|
@@ -574,11 +528,10 @@ function patch(attributes, virtualChildren){
|
|
|
574
528
|
}
|
|
575
529
|
patchAttributes.call(this, attributes);
|
|
576
530
|
if(isEmptyFrame) return;
|
|
577
|
-
if(this.
|
|
578
|
-
patchChildren.call(this.
|
|
579
|
-
patchChildren.call(this, []);
|
|
531
|
+
if(this.type == 'template'){
|
|
532
|
+
patchChildren.call(new Component(this.node.content, true), virtualChildren);
|
|
580
533
|
} else {
|
|
581
|
-
patchChildren.call(this, virtualChildren);
|
|
534
|
+
patchChildren.call(new Component(this.node, true), virtualChildren);
|
|
582
535
|
}
|
|
583
536
|
}
|
|
584
537
|
|
|
@@ -620,22 +573,22 @@ function patchChildren(virtualChildren){
|
|
|
620
573
|
} else if(virtualChild.type == '#doctype'){
|
|
621
574
|
// ignore
|
|
622
575
|
} else if(virtualChild.type.match(/^#(text|comment)/)){
|
|
623
|
-
insert.call(this, virtualChild, child);
|
|
576
|
+
insert.call(this, virtualChild, child, false);
|
|
624
577
|
} else {
|
|
625
578
|
while(children.length > 0 && children[0].type.match(/^#/)){
|
|
626
|
-
children.shift()
|
|
579
|
+
remove.call(children.shift());
|
|
627
580
|
}
|
|
628
581
|
child = children[0]
|
|
629
582
|
if(child && child.type == virtualChild.type){
|
|
630
|
-
patch.call(children.shift(), virtualChild.attributes, virtualChild.children);
|
|
583
|
+
patch.call(new Component(children.shift().node, true), virtualChild.attributes, virtualChild.children);
|
|
631
584
|
} else {
|
|
632
|
-
insert.call(this, virtualChild, child);
|
|
585
|
+
insert.call(new Component(this.node, true), virtualChild, child, false);
|
|
633
586
|
}
|
|
634
587
|
}
|
|
635
588
|
}
|
|
636
589
|
|
|
637
590
|
while(children.length > 0){
|
|
638
|
-
children.shift()
|
|
591
|
+
remove.call(children.shift());
|
|
639
592
|
}
|
|
640
593
|
}
|
|
641
594
|
|
|
@@ -656,26 +609,30 @@ function insert(virtualNode, referenceChild, returnComponent = true){
|
|
|
656
609
|
}
|
|
657
610
|
|
|
658
611
|
children.forEach(child => {
|
|
659
|
-
|
|
612
|
+
if(type == 'template'){
|
|
613
|
+
insert.call(new Component(node.content, true), child, null, false);
|
|
614
|
+
} else {
|
|
615
|
+
insert.call(new Component(node, true), child, null, false);
|
|
616
|
+
}
|
|
660
617
|
})
|
|
661
618
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
);
|
|
667
|
-
} else {
|
|
668
|
-
this.node.insertBefore(
|
|
669
|
-
node,
|
|
670
|
-
referenceChild && referenceChild.node
|
|
671
|
-
);
|
|
672
|
-
}
|
|
619
|
+
this.node.insertBefore(
|
|
620
|
+
node,
|
|
621
|
+
referenceChild && referenceChild.node
|
|
622
|
+
);
|
|
673
623
|
|
|
674
624
|
if(returnComponent){
|
|
675
625
|
return Component.instanceFor(node);
|
|
676
626
|
}
|
|
677
627
|
}
|
|
678
628
|
|
|
629
|
+
const COMPONENT_MAP = {
|
|
630
|
+
a: 'pinstripe-anchor',
|
|
631
|
+
body: 'pinstripe-body',
|
|
632
|
+
form: 'pinstripe-body',
|
|
633
|
+
|
|
634
|
+
};
|
|
635
|
+
|
|
679
636
|
function normalizeVirtualNode(){
|
|
680
637
|
if(!this.parent && this.children.some(child => child.type == 'html')){
|
|
681
638
|
this.children = [
|
|
@@ -695,6 +652,24 @@ function normalizeVirtualNode(){
|
|
|
695
652
|
if(this.parent && this.parent.type == 'textarea' && this.type == '#text'){
|
|
696
653
|
this.attributes.value = this.attributes.value.replace(/^\n/, '');
|
|
697
654
|
}
|
|
655
|
+
|
|
656
|
+
if(!this.attributes['data-component']){
|
|
657
|
+
if(this.type == 'a'){
|
|
658
|
+
this.attributes['data-component'] = 'pinstripe-anchor';
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
if(this.type == 'body'){
|
|
662
|
+
this.attributes['data-component'] = 'pinstripe-body';
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if(this.type == 'form'){
|
|
666
|
+
this.attributes['data-component'] = 'pinstripe-form';
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
if(this.type == 'script' && this.attributes.type == 'pinstripe'){
|
|
670
|
+
this.attributes['data-component'] = 'pinstripe-script';
|
|
671
|
+
}
|
|
672
|
+
}
|
|
698
673
|
}
|
|
699
674
|
|
|
700
675
|
ComponentEvent.Component = Component;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Component as default } from '
|
|
1
|
+
export { Component as default } from '../component.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -4,18 +4,15 @@ import { loadFrame, getFrame } from "./helpers.js";
|
|
|
4
4
|
export default {
|
|
5
5
|
initialize(...args){
|
|
6
6
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
7
|
-
|
|
8
|
-
const { ignoreEventsFromChildren = false } = this.data;
|
|
9
7
|
this.on('click', (event) => {
|
|
10
|
-
|
|
11
|
-
const { confirm, target = '_self', method = 'GET', href, placeholder } = { ...this.attributes, ...this.data };
|
|
8
|
+
const { confirm, target = '_self', method = 'GET', href, placeholder } = this.params;
|
|
12
9
|
if(new URL(href, window.location.href).host != window.location.host) return;
|
|
13
10
|
event.preventDefault();
|
|
14
11
|
event.stopPropagation();
|
|
15
12
|
loadFrame.call(this, confirm, target, method, href, placeholder);
|
|
16
13
|
});
|
|
17
14
|
|
|
18
|
-
const { target = '_self', method = 'GET', href,
|
|
15
|
+
const { target = '_self', method = 'GET', href, placeholder, preload } = this.params;
|
|
19
16
|
if(method == 'GET' && target != '_blank'){
|
|
20
17
|
const frame = target == '_overlay' ? this.frame : getFrame.call(this, target);
|
|
21
18
|
if(preload != undefined) this.document.preload(new URL(href, frame.url));
|
|
@@ -6,6 +6,17 @@ const preloading = {};
|
|
|
6
6
|
export default {
|
|
7
7
|
meta(){
|
|
8
8
|
this.include('pinstripe-frame');
|
|
9
|
+
|
|
10
|
+
this.prototype.assignProps({
|
|
11
|
+
get meta(){
|
|
12
|
+
const out = {};
|
|
13
|
+
this.head.findAll('meta').forEach(({ params }) => {
|
|
14
|
+
const { name, content } = params;
|
|
15
|
+
if(name) out[name] = content;
|
|
16
|
+
});
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
})
|
|
9
20
|
},
|
|
10
21
|
|
|
11
22
|
initialize(...args){
|
|
@@ -17,6 +28,13 @@ export default {
|
|
|
17
28
|
},
|
|
18
29
|
|
|
19
30
|
isDocument: true,
|
|
31
|
+
|
|
32
|
+
get head(){
|
|
33
|
+
if(!this._head){
|
|
34
|
+
this._head = this.find('head');
|
|
35
|
+
}
|
|
36
|
+
return this._head;
|
|
37
|
+
},
|
|
20
38
|
|
|
21
39
|
get body(){
|
|
22
40
|
if(!this._body){
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
initialize(...args){
|
|
6
6
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
7
7
|
|
|
8
|
-
const { confirm, target = '_self', method = 'GET', action } =
|
|
8
|
+
const { confirm, target = '_self', method = 'GET', action } = this.params;
|
|
9
9
|
|
|
10
10
|
this.on('submit', (event) => {
|
|
11
11
|
event.preventDefault();
|
|
@@ -20,6 +20,6 @@ export default {
|
|
|
20
20
|
isForm: true,
|
|
21
21
|
|
|
22
22
|
get hasUnsavedChanges(){
|
|
23
|
-
return this.
|
|
23
|
+
return this.params.hasUnsavedChanges == 'true' || JSON.stringify(this.values) != this._initialHash;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
@@ -5,12 +5,14 @@ export default {
|
|
|
5
5
|
initialize(...args){
|
|
6
6
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
7
7
|
|
|
8
|
-
let { loadOnInit } = this.
|
|
9
|
-
if(loadOnInit == undefined)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
let { loadOnInit } = this.params;
|
|
9
|
+
if(loadOnInit == undefined) {
|
|
10
|
+
loadOnInit = this.children.length == 0;
|
|
11
|
+
} else {
|
|
12
|
+
loadOnInit = loadOnInit == 'true';
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
if(loadOnInit) this.on('init', () => this.load());
|
|
14
16
|
},
|
|
15
17
|
|
|
16
18
|
isFrame: true,
|
|
@@ -18,7 +20,7 @@ export default {
|
|
|
18
20
|
get url(){
|
|
19
21
|
if(this._url === undefined){
|
|
20
22
|
this._url = new URL(
|
|
21
|
-
this.
|
|
23
|
+
this.params.url || window.location,
|
|
22
24
|
this.frame ? this.frame.url : window.location
|
|
23
25
|
);
|
|
24
26
|
}
|
|
@@ -34,13 +36,18 @@ export default {
|
|
|
34
36
|
|
|
35
37
|
loading: false,
|
|
36
38
|
|
|
39
|
+
loadWasBlocked: false,
|
|
40
|
+
|
|
37
41
|
async load(url = this.url, options = {}){
|
|
38
|
-
if(this.loading)
|
|
42
|
+
if(this.loading) {
|
|
43
|
+
this.loadWasBlocked = true;
|
|
44
|
+
return;
|
|
45
|
+
};
|
|
39
46
|
this.loading = true;
|
|
40
47
|
this.abort();
|
|
41
48
|
const { method = 'GET', placeholderUrl } = options;
|
|
42
49
|
const cachedHtml = method == 'GET' ? loadCache.get(url.toString()) : undefined;
|
|
43
|
-
|
|
50
|
+
if(cachedHtml) this.patch(cachedHtml);
|
|
44
51
|
let minimumDelay = 0;
|
|
45
52
|
if(!cachedHtml && placeholderUrl){
|
|
46
53
|
const placeholderHtml = loadCache.get(placeholderUrl.toString());
|
|
@@ -53,7 +60,8 @@ export default {
|
|
|
53
60
|
const response = await this.fetch(url, { minimumDelay, ...options });
|
|
54
61
|
const html = await response.text();
|
|
55
62
|
this.loading = false;
|
|
56
|
-
if(html == cachedHtml) return
|
|
63
|
+
if(html == cachedHtml && !this.loadWasBlocked) return;
|
|
64
|
+
this.loadWasBlocked = false;
|
|
57
65
|
if(method == 'GET') loadCache.put(url.toString(), html);
|
|
58
66
|
this.patch(html);
|
|
59
67
|
}
|
|
@@ -35,7 +35,7 @@ export default {
|
|
|
35
35
|
if(window.getSelection().type == 'Range') return;
|
|
36
36
|
|
|
37
37
|
let canRemove = true;
|
|
38
|
-
this.descendants.filter(n => n.isForm).forEach(({ hasUnsavedChanges,
|
|
38
|
+
this.descendants.filter(n => n.isForm).forEach(({ hasUnsavedChanges, params: { unsavedChangesConfirm } }) => {
|
|
39
39
|
if(hasUnsavedChanges && unsavedChangesConfirm && !confirm(unsavedChangesConfirm)){
|
|
40
40
|
canRemove = false;
|
|
41
41
|
}
|
|
@@ -3,7 +3,7 @@ export default {
|
|
|
3
3
|
initialize(...args){
|
|
4
4
|
this.constructor.parent.prototype.initialize.call(this, ...args);
|
|
5
5
|
|
|
6
|
-
const { height = 'auto', width = '100%', radius = '3px' } = this.
|
|
6
|
+
const { height = 'auto', width = '100%', radius = '3px' } = this.params
|
|
7
7
|
|
|
8
8
|
this.shadow.patch(`
|
|
9
9
|
<style>
|
package/lib/constants.js
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export
|
|
3
|
-
'area',
|
|
4
|
-
'base',
|
|
5
|
-
'br',
|
|
6
|
-
'embed',
|
|
7
|
-
'hr',
|
|
8
|
-
'iframe',
|
|
9
|
-
'img',
|
|
10
|
-
'input',
|
|
11
|
-
'link',
|
|
12
|
-
'meta',
|
|
13
|
-
'param',
|
|
14
|
-
'slot',
|
|
15
|
-
'source',
|
|
16
|
-
'track'
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
export const TEXT_ONLY_TAGS = [
|
|
20
|
-
'script',
|
|
21
|
-
'style'
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
export const IS_SERVER = typeof window == 'undefined';
|
|
25
|
-
|
|
26
|
-
export const IS_CLIENT = !IS_SERVER;
|
|
2
|
+
export { SELF_CLOSING_TAGS, TEXT_ONLY_TAGS, IS_SERVER, IS_CLIENT } from '@blognami/util';
|
package/lib/index.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
import './initialize.js';
|
|
3
|
+
|
|
4
|
+
export { Component } from './component.js';
|
|
3
5
|
|
|
4
|
-
export * from './app.js'; // pinstripe-if-client: export const App = undefined;
|
|
5
|
-
export * from './command.js'; // pinstripe-if-client: export const Command = undefined;
|
|
6
|
-
export * from './context.js'; // pinstripe-if-client: export const Context = undefined;
|
|
7
|
-
export * from './component.js';
|
|
8
|
-
export * from './database.js'; // pinstripe-if-client: export const Database = undefined;
|
|
9
|
-
export * from './html.js'; // pinstripe-if-client: export const Html = undefined;
|
|
10
|
-
export * from './import_all.js'; // pinstripe-if-client: export const importAll = undefined;
|
|
11
|
-
export * from './project.js'; // pinstripe-if-client: export const project = undefined;
|
|
12
|
-
export * from './service_factory.js'; // pinstripe-if-client: export const ServiceFactory = undefined;
|
|
13
|
-
export * from './view.js'; // pinstripe-if-client: export const View = undefined;
|
|
14
|
-
export * from './workspace.js'; // pinstripe-if-client: export const Workspace = undefined;
|