pinstripe 0.24.0 → 0.26.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 +40 -90
- package/lib/components/_file_importer.js +1 -1
- package/lib/components/a.js +2 -5
- package/lib/components/document.js +18 -0
- package/lib/components/form.js +2 -2
- package/lib/components/index.js +1 -0
- package/lib/components/pinstripe_frame.js +16 -8
- package/lib/components/pinstripe_overlay.js +1 -1
- package/lib/components/pinstripe_skeleton.js +1 -1
- package/lib/components/script.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 -37
- 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/inflector.js
CHANGED
|
@@ -1,173 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
import { Singleton } from "./singleton.js";
|
|
4
|
-
|
|
5
|
-
export const Inflector = Class.extend().include({
|
|
6
|
-
|
|
7
|
-
meta(){
|
|
8
|
-
this.include(Singleton);
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
initialize(){
|
|
12
|
-
this.pluralizeRules = [];
|
|
13
|
-
this.singularizeRules = [];
|
|
14
|
-
|
|
15
|
-
this.definePlural(/$/, 's');
|
|
16
|
-
this.definePlural(/s$/i, 's');
|
|
17
|
-
this.definePlural(/^(ax|test)is$/i, '$1es');
|
|
18
|
-
this.definePlural(/(octop|vir)us$/i, '$1i');
|
|
19
|
-
this.definePlural(/(octop|vir)i$/i, '$1i');
|
|
20
|
-
this.definePlural(/(alias|status)$/i, '$1es');
|
|
21
|
-
this.definePlural(/(bu)s$/i, '$1ses');
|
|
22
|
-
this.definePlural(/(buffal|tomat)o$/i, '$1oes');
|
|
23
|
-
this.definePlural(/([ti])um$/i, '$1a');
|
|
24
|
-
this.definePlural(/([ti])a$/i, '$1a');
|
|
25
|
-
this.definePlural(/sis$/i, 'ses');
|
|
26
|
-
this.definePlural(/(?:([^f])fe|([lr])f)$/i, '$1$2ves');
|
|
27
|
-
this.definePlural(/(hive)$/i, '$1s');
|
|
28
|
-
this.definePlural(/([^aeiouy]|qu)y$/i, '$1ies');
|
|
29
|
-
this.definePlural(/(x|ch|ss|sh)$/i, '$1es');
|
|
30
|
-
this.definePlural(/(matr|vert|ind)(?:ix|ex)$/i, '$1ices');
|
|
31
|
-
this.definePlural(/^(m|l)ouse$/i, '$1ice');
|
|
32
|
-
this.definePlural(/^(m|l)ice$/i, '$1ice');
|
|
33
|
-
this.definePlural(/^(ox)$/i, '$1en');
|
|
34
|
-
this.definePlural(/^(oxen)$/i, '$1');
|
|
35
|
-
this.definePlural(/(quiz)$/i, '$1zes');
|
|
36
|
-
|
|
37
|
-
this.defineSingular(/s$/i, '');
|
|
38
|
-
this.defineSingular(/(ss)$/i, '$1');
|
|
39
|
-
this.defineSingular(/(n)ews$/i, '$1ews');
|
|
40
|
-
this.defineSingular(/([ti])a$/i, '$1um');
|
|
41
|
-
this.defineSingular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis');
|
|
42
|
-
this.defineSingular(/(^analy)(sis|ses)$/i, '$1sis');
|
|
43
|
-
this.defineSingular(/([^f])ves$/i, '$1fe');
|
|
44
|
-
this.defineSingular(/(hive)s$/i, '$1');
|
|
45
|
-
this.defineSingular(/(tive)s$/i, '$1');
|
|
46
|
-
this.defineSingular(/([lr])ves$/i, '$1f');
|
|
47
|
-
this.defineSingular(/([^aeiouy]|qu)ies$/i, '$1y');
|
|
48
|
-
this.defineSingular(/(s)eries$/i, '$1eries');
|
|
49
|
-
this.defineSingular(/(m)ovies$/i, '$1ovie');
|
|
50
|
-
this.defineSingular(/(x|ch|ss|sh)es$/i, '$1');
|
|
51
|
-
this.defineSingular(/^(m|l)ice$/i, '$1ouse');
|
|
52
|
-
this.defineSingular(/(bus)(es)?$/i, '$1');
|
|
53
|
-
this.defineSingular(/(o)es$/i, '$1');
|
|
54
|
-
this.defineSingular(/(shoe)s$/i, '$1');
|
|
55
|
-
this.defineSingular(/(cris|test)(is|es)$/i, '$1is');
|
|
56
|
-
this.defineSingular(/^(a)x[ie]s$/i, '$1xis');
|
|
57
|
-
this.defineSingular(/(octop|vir)(us|i)$/i, '$1us');
|
|
58
|
-
this.defineSingular(/(alias|status)(es)?$/i, '$1');
|
|
59
|
-
this.defineSingular(/^(ox)en/i, '$1');
|
|
60
|
-
this.defineSingular(/(vert|ind)ices$/i, '$1ex');
|
|
61
|
-
this.defineSingular(/(matr)ices$/i, '$1ix');
|
|
62
|
-
this.defineSingular(/(quiz)zes$/i, '$1');
|
|
63
|
-
this.defineSingular(/(database)s$/i, '$1');
|
|
64
|
-
|
|
65
|
-
this.defineIrregular('person', 'people');
|
|
66
|
-
this.defineIrregular('man', 'men');
|
|
67
|
-
this.defineIrregular('child', 'children');
|
|
68
|
-
this.defineIrregular('sex', 'sexes');
|
|
69
|
-
this.defineIrregular('move', 'moves');
|
|
70
|
-
this.defineIrregular('zombie', 'zombies');
|
|
71
|
-
|
|
72
|
-
this.defineUncountable('equipment');
|
|
73
|
-
this.defineUncountable('information');
|
|
74
|
-
this.defineUncountable('rice');
|
|
75
|
-
this.defineUncountable('money');
|
|
76
|
-
this.defineUncountable('species');
|
|
77
|
-
this.defineUncountable('series');
|
|
78
|
-
this.defineUncountable('fish');
|
|
79
|
-
this.defineUncountable('sheep');
|
|
80
|
-
this.defineUncountable('jeans');
|
|
81
|
-
this.defineUncountable('police');
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
definePlural(...args){
|
|
85
|
-
this.pluralizeRules.unshift(args);
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
defineSingular(...args){
|
|
89
|
-
this.singularizeRules.unshift(args);
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
defineIrregular(singular, plural){
|
|
93
|
-
const s0 = singular[0];
|
|
94
|
-
const srest = singular.substr(1);
|
|
95
|
-
|
|
96
|
-
const p0 = plural[0]
|
|
97
|
-
const prest = plural.substr(1);
|
|
98
|
-
|
|
99
|
-
if (s0.toUpperCase() == p0.toUpperCase()){
|
|
100
|
-
this.definePlural(new RegExp(`(${s0})${srest}$`, 'i'), `$1${prest}`);
|
|
101
|
-
this.definePlural(new RegExp(`(${p0})${prest}$`, 'i'), `$1${prest}`);
|
|
102
|
-
|
|
103
|
-
this.defineSingular(new RegExp(`(${s0})${srest}$`, 'i'), `$1${srest}`);
|
|
104
|
-
this.defineSingular(new RegExp(`(${p0})${prest}$`, 'i'), `$1${srest}`);
|
|
105
|
-
} else {
|
|
106
|
-
this.definePlural(new RegExp(`${s0.toUpperCase()}${caseInsensitive(srest)}$`), `${p0.toUpperCase()}${prest}`);
|
|
107
|
-
this.definePlural(new RegExp(`${s0.toLowerCase()}${caseInsensitive(srest)}$`), `${p0.toLowerCase()}${prest}`);
|
|
108
|
-
this.definePlural(new RegExp(`${p0.toUpperCase()}${caseInsensitive(prest)}$`), `${p0.toUpperCase()}${prest}`);
|
|
109
|
-
this.definePlural(new RegExp(`${p0.toLowerCase()}${caseInsensitive(prest)}$`), `${p0.toLowerCase()}${prest}`);
|
|
110
|
-
|
|
111
|
-
this.defineSingular(new RegExp(`${s0.toUpperCase()}${caseInsensitive(srest)}$`), `${s0.toUpperCase()}${srest}`);
|
|
112
|
-
this.defineSingular(new RegExp(`${s0.toLowerCase()}${caseInsensitive(srest)}$`), `${s0.toLowerCase()}${srest}`);
|
|
113
|
-
this.defineSingular(new RegExp(`${p0.toUpperCase()}${caseInsensitive(prest)}$`), `${s0.toUpperCase()}${srest}`);
|
|
114
|
-
this.defineSingular(new RegExp(`${p0.toLowerCase()}${caseInsensitive(prest)}$`), `${s0.toLowerCase()}${srest}`);
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
defineUncountable(singularAndPlural){
|
|
119
|
-
this.defineIrregular(singularAndPlural, singularAndPlural);
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
pluralize(word){
|
|
123
|
-
word = `${word}`;
|
|
124
|
-
for(let i in this.pluralizeRules){
|
|
125
|
-
const [pattern, replacement] = this.pluralizeRules[i];
|
|
126
|
-
if(word.match(pattern)){
|
|
127
|
-
return word.replace(pattern, replacement);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
singularize(word){
|
|
133
|
-
word = `${word}`;
|
|
134
|
-
for(let i in this.singularizeRules){
|
|
135
|
-
const [pattern, replacement] = this.singularizeRules[i];
|
|
136
|
-
if(word.match(pattern)){
|
|
137
|
-
return word.replace(pattern, replacement);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
snakeify(stringable){
|
|
143
|
-
return `${stringable}`.split(/\//).map(segment =>
|
|
144
|
-
segment.replace(/([A-Z])/g, '_$1').toLocaleLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/(^_|_$)/g, '')
|
|
145
|
-
).join('/');
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
dasherize(stringable){
|
|
149
|
-
return this.snakeify(stringable).replace(/_/g, '-');
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
capitalize(stringable){
|
|
153
|
-
const [first, ...rest] = `${stringable}`;
|
|
154
|
-
return `${first.toLocaleUpperCase()}${rest.join('')}`;
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
uncapitalize(stringable){
|
|
158
|
-
const [first, ...rest] = `${stringable}`;
|
|
159
|
-
return `${first.toLocaleLowerCase()}${rest.join('')}`;
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
pascalize(stringable){
|
|
163
|
-
return this.snakeify(stringable).replace(/^[0-9]+/, '').split(/[^a-z0-9]+/).map(word => this.capitalize(word)).join('');
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
camelize(stringable){
|
|
167
|
-
return this.uncapitalize(this.pascalize(stringable));
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const caseInsensitive = (string) => string.replace(/[a-z]/gi, (c) => `[${c.toUpperCase()}${c.toLowerCase()}]`);
|
|
172
|
-
|
|
173
|
-
export const inflector = Inflector.instance;
|
|
2
|
+
export { Inflector, inflector } from '@blognami/util';
|
package/lib/initialize.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { Component } from './component.js';
|
|
3
3
|
|
|
4
4
|
if(typeof window != 'undefined'){
|
|
5
|
+
const [ styleEl ] = Component.new(document.head, true).prepend(`<style>body { display: none; }</style>`);
|
|
5
6
|
window.addEventListener('DOMContentLoaded', () => {
|
|
6
7
|
const documentComponent = Component.instanceFor(document);
|
|
7
8
|
documentComponent.observe({ add: true }, component => component.descendants);
|
|
8
9
|
documentComponent.patch(document.documentElement.outerHTML);
|
|
10
|
+
styleEl.remove();
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
|
package/lib/internal.js
ADDED
package/lib/lru_cache.js
CHANGED
|
@@ -1,53 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const LruCache = Class.extend().include({
|
|
5
|
-
meta(){
|
|
6
|
-
this.assignProps({
|
|
7
|
-
maxEntries: 1000
|
|
8
|
-
});
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
initialize(){
|
|
12
|
-
this.entries = {};
|
|
13
|
-
this.index = [];
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
put(key, value){
|
|
17
|
-
if(!this.entries[key]){
|
|
18
|
-
this.entries[key] = { key, position: this.index.length };
|
|
19
|
-
this.index.push(this.entries[key]);
|
|
20
|
-
this.promote(key);
|
|
21
|
-
this.evict();
|
|
22
|
-
}
|
|
23
|
-
this.entries[key].value = value;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
get(key){
|
|
27
|
-
const entry = this.entries[key];
|
|
28
|
-
if(!entry) return;
|
|
29
|
-
this.promote(key);
|
|
30
|
-
return entry.value;
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
hasEntry(key){
|
|
34
|
-
return !!this.entries[key];
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
promote(key){
|
|
38
|
-
const entry = this.entries[key];
|
|
39
|
-
if(!entry || entry.position == 0) return;
|
|
40
|
-
const previousEntry = this.index[entry.position - 1];
|
|
41
|
-
this.index[entry.position] = previousEntry;
|
|
42
|
-
this.index[previousEntry.position] = entry;
|
|
43
|
-
previousEntry.position++;
|
|
44
|
-
entry.position--;
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
evict(){
|
|
48
|
-
while(this.index.length > this.constructor.maxEntries){
|
|
49
|
-
const entry = this.index.pop();
|
|
50
|
-
delete this.entries[entry.key];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
2
|
+
export { LruCache } from '@blognami/util';
|
package/lib/registry.js
CHANGED
|
@@ -1,130 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const Registry = {
|
|
5
|
-
meta(){
|
|
6
|
-
|
|
7
|
-
const { include } = this;
|
|
8
|
-
|
|
9
|
-
this.assignProps({
|
|
10
|
-
registry: this,
|
|
11
|
-
|
|
12
|
-
mixins: {},
|
|
13
|
-
|
|
14
|
-
cache: {},
|
|
15
|
-
|
|
16
|
-
get names(){
|
|
17
|
-
return Object.keys(this.mixins).sort();
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
get includedIn(){
|
|
21
|
-
const out = [];
|
|
22
|
-
this.names.forEach(name => {
|
|
23
|
-
if(this.for(name).includes.includes(this.name) && !out.includes(name)){
|
|
24
|
-
out.push(name);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
return out;
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
normalizeName(name){
|
|
31
|
-
return name;
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
normalizeMixin(name, mixin, previousMixin){
|
|
35
|
-
return {
|
|
36
|
-
meta(){
|
|
37
|
-
if(previousMixin) this.include(previousMixin);
|
|
38
|
-
this.include(mixin);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
register(name, mixin = {}){
|
|
44
|
-
const normalizedName = this.normalizeName(name);
|
|
45
|
-
this.mixins[normalizedName] = this.normalizeMixin(normalizedName, mixin, this.mixins[normalizedName]);
|
|
46
|
-
this.clearCache();
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
unregister(name){
|
|
50
|
-
const normalizedName = this.normalizeName(name);
|
|
51
|
-
delete this.mixins[normalizedName];
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
clearCache(){
|
|
55
|
-
this.registry.cache = {};
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
createInitialMixin(name){
|
|
59
|
-
return {};
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
for(name){
|
|
63
|
-
const normalizedName = this.normalizeName(name);
|
|
64
|
-
if(!this.cache.classes) this.cache.classes = {};
|
|
65
|
-
const { classes } = this.cache;
|
|
66
|
-
if(!classes[normalizedName]){
|
|
67
|
-
classes[normalizedName] = this.registry.extend().include({
|
|
68
|
-
meta(){
|
|
69
|
-
this.assignProps({ name: normalizedName, includes: [] });
|
|
70
|
-
this.include(this.createInitialMixin(normalizedName));
|
|
71
|
-
this.include(this.mixins[normalizedName] || {});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return classes[normalizedName];
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
include(...includes){
|
|
79
|
-
includes.forEach(current => {
|
|
80
|
-
if(typeof current == 'string'){
|
|
81
|
-
if(!this.mixins[current]) throw new Error(`Named include '${current}' does not exist.`);
|
|
82
|
-
if(!this.includes.includes(current)) this.includes.push(current);
|
|
83
|
-
return include.call(this, this.mixins[current]);
|
|
84
|
-
}
|
|
85
|
-
return include.call(this, current);
|
|
86
|
-
});
|
|
87
|
-
return this;
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
create(name, ...args){
|
|
91
|
-
return this.for(name).new(...args);
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
get FileImporter(){
|
|
95
|
-
if(!this.registry.hasOwnProperty('_FileImporter')){
|
|
96
|
-
this.registry._FileImporter = Class.extend().include({
|
|
97
|
-
meta(){
|
|
98
|
-
this.include(Registry);
|
|
99
|
-
|
|
100
|
-
this.assignProps({
|
|
101
|
-
async importFile({ extension, ...rest }){
|
|
102
|
-
await this.create(extension).importFile({ extension, ...rest });
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
importFile(){
|
|
108
|
-
// by default do nothing
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const that = this;
|
|
113
|
-
this.registry._FileImporter.register('js', {
|
|
114
|
-
async importFile({ filePath, relativeFilePathWithoutExtension }){
|
|
115
|
-
if(relativeFilePathWithoutExtension == '_file_importer') return;
|
|
116
|
-
const include = (await import(filePath)).default;
|
|
117
|
-
if(!include) return;
|
|
118
|
-
that.register(relativeFilePathWithoutExtension, include);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return this.registry._FileImporter;
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
async importFile(...args){
|
|
126
|
-
await this.FileImporter.importFile(...args);
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
};
|
|
2
|
+
export { Registry, registries } from '@blognami/util';
|
package/lib/trapify.js
CHANGED
|
@@ -1,32 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
const TRAP_NAMES = ['get' ,'deleteProperty' ,'ownKeys' ,'has' ,'apply' ,'defineProperty' ,'getPrototypeOf' ,'setPrototypeOf' ,'isExtensible' ,'preventExtensions' ,'getOwnPropertyDescriptor' ,'enumerate' ,'construct'];
|
|
4
|
-
|
|
5
|
-
export const trapify = o => new Proxy(new Proxy(o, {
|
|
6
|
-
get(target, name, ...args){
|
|
7
|
-
const descriptor = getPropertyDescriptor(target, name);
|
|
8
|
-
if(descriptor){
|
|
9
|
-
const { get, value } = descriptor;
|
|
10
|
-
if(get) return get.call(trapify(target));
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
if(getPropertyDescriptor(target, '__getMissing')) return target.__getMissing.call(trapify(target), target, name, ...args);
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
set(target, name, value, ...args){
|
|
17
|
-
const descriptor = getPropertyDescriptor(target, name);
|
|
18
|
-
if(descriptor){
|
|
19
|
-
const { set } = descriptor;
|
|
20
|
-
if(set) return set.call(trapify(target), value);
|
|
21
|
-
}
|
|
22
|
-
if(getPropertyDescriptor(target, '__setMissing')) return target.__setMissing.call(trapify(target), target, name, value, ...args);
|
|
23
|
-
target[name] = value;
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
}), TRAP_NAMES.reduce((traps, name) => {
|
|
27
|
-
const methodName = `__${name}`;
|
|
28
|
-
if(getPropertyDescriptor(o, methodName)) traps[name] = (target, ...args) => target[methodName].call(trapify(target), target, ...args);
|
|
29
|
-
return traps;
|
|
30
|
-
}, {}));
|
|
31
|
-
|
|
32
|
-
const getPropertyDescriptor = (o, name) => o ? Object.getOwnPropertyDescriptor(o, name) || getPropertyDescriptor(Object.getPrototypeOf(o), name) : undefined;
|
|
2
|
+
export { trapify } from '@blognami/util';
|
package/lib/virtual_node.js
CHANGED
|
@@ -1,171 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
import { unescapeHtml } from './unescape_html.js';
|
|
4
|
-
import { StringReader } from './string_reader.js';
|
|
5
|
-
import { SELF_CLOSING_TAGS, TEXT_ONLY_TAGS } from './constants.js';
|
|
6
|
-
|
|
7
|
-
class CloseTag {
|
|
8
|
-
constructor(type){
|
|
9
|
-
this.type = type;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class VirtualNode {
|
|
14
|
-
|
|
15
|
-
static fromString(html){
|
|
16
|
-
const out = new this();
|
|
17
|
-
out.appendHtml(html);
|
|
18
|
-
return out;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static deserialize(o, parent = null){
|
|
22
|
-
const { type, attributes, children } = typeof o == 'string' ? JSON.parse(o) : o;
|
|
23
|
-
const out = new this(parent, type, attributes);
|
|
24
|
-
out.children = children.map(
|
|
25
|
-
child => this.deserialize(child, this)
|
|
26
|
-
);
|
|
27
|
-
return out;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
constructor(parent = null, type = '#fragment', attributes = {}){
|
|
31
|
-
this.parent = parent;
|
|
32
|
-
this.type = type;
|
|
33
|
-
this.attributes = attributes;
|
|
34
|
-
this.children = [];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get text(){
|
|
38
|
-
const out = [];
|
|
39
|
-
this.traverse(node => {
|
|
40
|
-
if(node.type == '#text'){
|
|
41
|
-
out.push(node.attributes.value);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return out.join('');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
appendNode(type, attributes = {}){
|
|
48
|
-
const out = new this.constructor(this, type, attributes);
|
|
49
|
-
this.children.push(out);
|
|
50
|
-
return out;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
appendHtml(html){
|
|
54
|
-
if(!(html instanceof StringReader)){
|
|
55
|
-
html = new StringReader(html);
|
|
56
|
-
|
|
57
|
-
while(html.length > 0){
|
|
58
|
-
try {
|
|
59
|
-
this.appendHtml(html);
|
|
60
|
-
} catch(e){
|
|
61
|
-
if(e instanceof CloseTag){
|
|
62
|
-
//do nothing
|
|
63
|
-
} else {
|
|
64
|
-
throw e;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
while(html.length > 0){
|
|
73
|
-
let matches;
|
|
74
|
-
|
|
75
|
-
if(matches = html.match(/^[^<]+/)){
|
|
76
|
-
this.appendNode('#text', {value: unescapeHtml(matches[0])})
|
|
77
|
-
} else if(matches = html.match(/^<!DOCTYPE[^>]*>/i)){
|
|
78
|
-
if(!this.parent){
|
|
79
|
-
this.appendNode('#doctype');
|
|
80
|
-
}
|
|
81
|
-
} else if(matches = html.match(/^<!--([\s\S]*?)-->/i)){
|
|
82
|
-
this.appendNode('#comment', {value: matches[1]});
|
|
83
|
-
} else if(matches = html.match(/^<([^>\s]+)/)){
|
|
84
|
-
const type = matches[1].toLowerCase();
|
|
85
|
-
const attributes = {};
|
|
86
|
-
|
|
87
|
-
while(html.length > 0){
|
|
88
|
-
if(matches = html.match(/^\s*([\w-]+)\s*=\s*\"([^\"]*)\"/)){
|
|
89
|
-
attributes[matches[1]] = unescapeHtml(matches[2]);
|
|
90
|
-
} else if(matches = html.match(/^\s*([\w-]+)\s*=\s*\'([^\']*)\'/)){
|
|
91
|
-
attributes[matches[1]] = unescapeHtml(matches[2]);
|
|
92
|
-
} else if(matches = html.match(/^\s*([\w-]+)\s*=\s*([^\s>]+)/)){
|
|
93
|
-
attributes[matches[1]] = unescapeHtml(matches[2]);
|
|
94
|
-
} else if(matches = html.match(/^\s*([\w-]+)/)){
|
|
95
|
-
attributes[matches[1]] = null;
|
|
96
|
-
} else {
|
|
97
|
-
html.match(/^[^>]*>/);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if(matches = type.match(/^\/(.*)/)){
|
|
103
|
-
throw new CloseTag(matches[1]);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const child = this.appendNode(type, attributes);
|
|
107
|
-
|
|
108
|
-
if(SELF_CLOSING_TAGS.includes(type)){
|
|
109
|
-
// do nothing
|
|
110
|
-
} else if(TEXT_ONLY_TAGS.includes(type) && (matches = html.match(new RegExp(`^([\\s\\S]*?)<\\/${type}[^>]*>`)))){
|
|
111
|
-
child.appendNode('#text', {value: matches[1]});
|
|
112
|
-
} else if(TEXT_ONLY_TAGS.includes(type) && (matches = html.match(/^([\s\S]+)/))){
|
|
113
|
-
child.appendNode('#text', {value: matches[1]});
|
|
114
|
-
} else {
|
|
115
|
-
try {
|
|
116
|
-
child.appendHtml(html);
|
|
117
|
-
} catch(e){
|
|
118
|
-
if(e instanceof CloseTag && e.type == type){
|
|
119
|
-
//do nothing
|
|
120
|
-
} else {
|
|
121
|
-
throw e;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
} else if(matches = html.match(/^[\s\S]/)) {
|
|
126
|
-
this.appendNode('#text', {value: matches[0]});
|
|
127
|
-
} else {
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
traverse(fn){
|
|
135
|
-
fn.call(this, this);
|
|
136
|
-
this.children.forEach(child => child.traverse(fn));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
serialize(){
|
|
140
|
-
return JSON.stringify(this, ['type', 'attributes', 'children']);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
toString(){
|
|
144
|
-
if(this.type == '#doctype') return '<!DOCTYPE html>';
|
|
145
|
-
if(this.type == '#text'){
|
|
146
|
-
if(this.parent && TEXT_ONLY_TAGS.includes(this.parent.type)) return this.attributes.value;
|
|
147
|
-
return escapeHtml(this.attributes.value);
|
|
148
|
-
}
|
|
149
|
-
if(this.type == '#comment') return `<!--${escapeHtml(this.attributes.value)}-->`;
|
|
150
|
-
const out = [];
|
|
151
|
-
if(this.type != '#fragment'){
|
|
152
|
-
out.push(`<${this.type}`);
|
|
153
|
-
Object.keys(this.attributes).forEach(name => {
|
|
154
|
-
const value = this.attributes[name];
|
|
155
|
-
if(value){
|
|
156
|
-
out.push(` ${name}="${escapeHtml(value)}"`);
|
|
157
|
-
} else {
|
|
158
|
-
out.push(` ${name}`);
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
out.push('>');
|
|
162
|
-
}
|
|
163
|
-
this.children.forEach(child => {
|
|
164
|
-
out.push(child.toString());
|
|
165
|
-
});
|
|
166
|
-
if(this.type != '#fragment' && !SELF_CLOSING_TAGS.includes(this.type)) out.push(`</${this.type}>`);
|
|
167
|
-
return out.join('');
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export const parseHtml = html => VirtualNode.fromString(html);
|
|
2
|
+
export { VirtualNode, parseHtml } from '@blognami/util';
|
package/package.json
CHANGED
|
@@ -1,50 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "pinstripe",
|
|
4
|
-
"description": "
|
|
5
|
-
"version": "0.
|
|
4
|
+
"description": "Surgically updates your app's DOM when a page changes.",
|
|
5
|
+
"version": "0.26.0",
|
|
6
6
|
"author": "Jody Salt",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./lib/index.js",
|
|
10
|
-
"./
|
|
11
|
-
"./multi-tenant": "./lib/extensions/multi-tenant/index.js",
|
|
12
|
-
"./util": "./lib/util.js"
|
|
13
|
-
},
|
|
14
|
-
"bin": {
|
|
15
|
-
"pinstripe": "./cli.js"
|
|
10
|
+
"./internal": "./lib/internal.js"
|
|
16
11
|
},
|
|
17
12
|
"scripts": {
|
|
18
|
-
"clean": "rm -rf ./node_modules"
|
|
19
|
-
"start": "IS_LOCAL_PINSTRIPE=true pinstripe start-server",
|
|
20
|
-
"test": "yarn test:unit",
|
|
21
|
-
"test:unit": "jest lib"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@babel/core": "^7.9.0",
|
|
25
|
-
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
|
|
26
|
-
"@babel/preset-env": "^7.9.0",
|
|
27
|
-
"babel-jest": "^25.1.0",
|
|
28
|
-
"jest": "^28.0.1",
|
|
29
|
-
"jest-environment-jsdom": "^29.1.2"
|
|
13
|
+
"clean": "rm -rf ./node_modules"
|
|
30
14
|
},
|
|
31
15
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"js-yaml": "^4.1.0",
|
|
39
|
-
"luxon": "^2.3.1",
|
|
40
|
-
"markdown-it": "^12.2.0",
|
|
41
|
-
"memfs": "^3.2.2",
|
|
42
|
-
"mime-types": "^2.1.28",
|
|
43
|
-
"mysql2": "^2.3.3",
|
|
44
|
-
"nodemailer": "^6.7.2",
|
|
45
|
-
"sqlite3": "^5.0.2",
|
|
46
|
-
"tmp": "^0.2.1",
|
|
47
|
-
"unionfs": "^4.4.0"
|
|
16
|
+
"@blognami/util": "^0.26.0"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git://github.com/blognami/blognami.git",
|
|
21
|
+
"directory": "packages/pinstripe"
|
|
48
22
|
},
|
|
49
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "981a4f7fdb5c28e6255a80e6a3cf1d3e4c8fc971"
|
|
50
24
|
}
|
package/babel.config.cjs
DELETED