prototype.exe 0.0.1 → 0.0.3
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.js +1 -0
- package/package.json +1 -1
- package/src/prototype.js +93 -12
package/package.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = exports = Symbol.export;
|
package/package.json
CHANGED
package/src/prototype.js
CHANGED
|
@@ -233,6 +233,7 @@ Define (Date, "io", class {
|
|
|
233
233
|
if (date instanceof Date) this.date = date;
|
|
234
234
|
else if (date) this.date = new Date (date);
|
|
235
235
|
else this.date = new Date ();
|
|
236
|
+
this.utc = new Date.io.utc (this.date);
|
|
236
237
|
}
|
|
237
238
|
iso () { return this.format ("iso"); }
|
|
238
239
|
format (format = "default") {
|
|
@@ -267,12 +268,51 @@ Define (Date, "io", class {
|
|
|
267
268
|
stamp () { return this.date; }
|
|
268
269
|
});
|
|
269
270
|
|
|
271
|
+
Define (Date.io, "utc", class {
|
|
272
|
+
constructor (datetime) {
|
|
273
|
+
this.datetime = datetime;
|
|
274
|
+
}
|
|
275
|
+
iso () {
|
|
276
|
+
return this.format ("iso");
|
|
277
|
+
}
|
|
278
|
+
format (format = "default") {
|
|
279
|
+
var date = {
|
|
280
|
+
"Y": this.year (),
|
|
281
|
+
"M": this.month (), "m": Date.month.name [this.month ()],
|
|
282
|
+
"D": this.day (), "d": Date.day.name [this.week ()], "W": this.week (),
|
|
283
|
+
"H": this.hour (), "h": this.hour ("meredian"),
|
|
284
|
+
"I": this.minute (),
|
|
285
|
+
"S": this.second (),
|
|
286
|
+
"A": this.meredian (),
|
|
287
|
+
}
|
|
288
|
+
format = Date.format [format] || format;
|
|
289
|
+
var formated = format.split ("");
|
|
290
|
+
var result = [];
|
|
291
|
+
for (var i in formated) {
|
|
292
|
+
result.push (date [formated [i]] || formated [i]);
|
|
293
|
+
}
|
|
294
|
+
return result.join ("");
|
|
295
|
+
}
|
|
296
|
+
year () { return this.datetime.getUTCFullYear (); }
|
|
297
|
+
month () { return (this.datetime.getUTCMonth () + 1).toString ().padStart (2, "0"); }
|
|
298
|
+
day () { return this.datetime.getUTCDate ().toString ().padStart (2, "0"); }
|
|
299
|
+
week () { return (this.datetime.getUTCDay () || 7).toString ().padStart (2, "0"); }
|
|
300
|
+
hour (meredian) { if (meredian) { var hour = this.datetime.getUTCHours (); if (this.meredian () === "PM") if (hour === 12) return hour.toString (); else return (hour - 12).toString ().padStart (2, "0"); else return hour.toString ().padStart (2, "0"); } else return this.datetime.getUTCHours ().toString ().padStart (2, "0"); }
|
|
301
|
+
minute () { return this.datetime.getUTCMinutes ().toString ().padStart (2, "0"); }
|
|
302
|
+
second () { return this.datetime.getUTCSeconds ().toString ().padStart (2, "0"); }
|
|
303
|
+
mili () { return this.datetime.getMilliseconds ().toString ().padStart (3, "0"); }
|
|
304
|
+
meredian () { if (this.datetime.getHours () > 11) return "PM"; else return "AM"; }
|
|
305
|
+
time () { return this.datetime.getTime (); }
|
|
306
|
+
stamp () { return this.datetime; }
|
|
307
|
+
});
|
|
308
|
+
|
|
270
309
|
Define (Date, "format", function (format, date) { return new Date.io (date).format (format); });
|
|
271
310
|
Define (Date.format, "iso", "Y-M-D");
|
|
272
311
|
Define (Date.format, "number", "YMD");
|
|
273
312
|
Define (Date.format, "default", "m D, Y");
|
|
274
313
|
Define (Date.format, "full", "d, m D, Y - h:I:S A");
|
|
275
314
|
Define (Date.format, "monthly", "Y-M");
|
|
315
|
+
Define (Date.format, "time", "H:I:S");
|
|
276
316
|
|
|
277
317
|
Define (Date, "month", {
|
|
278
318
|
name: {
|
|
@@ -381,6 +421,16 @@ Define (Promise, "io", function (context) {
|
|
|
381
421
|
});
|
|
382
422
|
});
|
|
383
423
|
|
|
424
|
+
Define (Promise.prototype, "next", function (context) {
|
|
425
|
+
var fp = function () {}
|
|
426
|
+
if (context.success || context.error || context.end) return this.then (context.success || fp).catch (context.error || fp).finally (context.end || fp);
|
|
427
|
+
else return this.then (context || fp).catch (fp).finally (fp);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
Define (Promise.prototype, "pipe", function (context) {
|
|
431
|
+
return this.next (context);
|
|
432
|
+
});
|
|
433
|
+
|
|
384
434
|
/**
|
|
385
435
|
* url
|
|
386
436
|
*
|
|
@@ -638,10 +688,12 @@ Function.cookie.data = {}
|
|
|
638
688
|
*/
|
|
639
689
|
|
|
640
690
|
Define (Function, "path", function () {});
|
|
641
|
-
Define (Function.path, "require", function () { return Function.path.api =
|
|
691
|
+
Define (Function.path, "require", function (api) { return Function.path.api = api; });
|
|
642
692
|
Define (Function.path, "join", function (... path) { return Function.path.api.join (... path); });
|
|
643
693
|
Define (Function.path, "exist", function (... path) { return Function.file.api.existsSync (Function.path.api.join (... path)); });
|
|
644
694
|
Define (Function.path, "current", function (path) { return "./" + path; });
|
|
695
|
+
Define (Function.path, "io", function (io) { if (Array.isArray (io)) Function.path.io.value = io; else return Function.path.io.value.includes (io); });
|
|
696
|
+
Function.path.io ([]);
|
|
645
697
|
|
|
646
698
|
/**
|
|
647
699
|
* file
|
|
@@ -654,8 +706,8 @@ Define (Function.path, "current", function (path) { return "./" + path; });
|
|
|
654
706
|
*/
|
|
655
707
|
|
|
656
708
|
Define (Function, "file", function () {});
|
|
657
|
-
Define (Function.file, "require", function () { return Function.file.api =
|
|
658
|
-
Define (Function.file, "write", function (file, data, context) { if (context) return Function.file.api.writeFile (file, data, context); else return Function.file.api.writeFileSync (file, data); });
|
|
709
|
+
Define (Function.file, "require", function (api) { return Function.file.api = api; });
|
|
710
|
+
Define (Function.file, "write", function (file, data, context) { if (Function.path.io ("write") === false) return null; if (context) return Function.file.api.writeFile (file, data, context); else return Function.file.api.writeFileSync (file, data); });
|
|
659
711
|
Define (Function.file, "read", function (file, context) { if (context) return Function.file.api.readFile (file, context); else return Function.file.api.readFileSync (file); });
|
|
660
712
|
Define (Function.file, "exist", function (file) { return Function.file.api.lstatSync (file).isFile (); });
|
|
661
713
|
Define (Function.file, "extension", {text: ".txt", json: ".json"});
|
|
@@ -674,7 +726,7 @@ Define (Function.dir, "exist", function (dir) { return Function.file.api.lstatSy
|
|
|
674
726
|
*/
|
|
675
727
|
|
|
676
728
|
Define (Function, "hash", function () {});
|
|
677
|
-
Define (Function.hash, "require", function () { Function.hash.crypto.api =
|
|
729
|
+
Define (Function.hash, "require", function (api) { Function.hash.crypto.api = api; });
|
|
678
730
|
Define (Function.hash, "crypto", function () {});
|
|
679
731
|
Define (Function.hash, "md5", function (input) { return Function.hash.crypto.api.createHash ("md5").update (input).digest ("hex"); });
|
|
680
732
|
Define (Function.hash, "sha1", function (input) { return Function.hash.crypto.api.createHash ("sha1").update (input).digest ("hex"); });
|
|
@@ -702,7 +754,7 @@ Define (Function.unique, "id", function () {
|
|
|
702
754
|
*/
|
|
703
755
|
|
|
704
756
|
Define (Function, "http", function () {});
|
|
705
|
-
Define (Function.http, "require", function () { return Function.http.api =
|
|
757
|
+
Define (Function.http, "require", function (api) { return Function.http.api = api; });
|
|
706
758
|
|
|
707
759
|
/**
|
|
708
760
|
* socket.io
|
|
@@ -715,7 +767,7 @@ Define (Function.http, "require", function () { return Function.http.api = requi
|
|
|
715
767
|
*/
|
|
716
768
|
|
|
717
769
|
Define (Function, "socket", function () {});
|
|
718
|
-
Define (Function.socket, "require", function () { return Function.socket.api =
|
|
770
|
+
Define (Function.socket, "require", function (api) { return Function.socket.api = api; });
|
|
719
771
|
Define (Function.socket, "io", class {});
|
|
720
772
|
Define (Function.socket, "server", function (app, option = {}) {
|
|
721
773
|
var server = Function.http.api.createServer (app);
|
|
@@ -851,24 +903,26 @@ Define (Function, "html", class {
|
|
|
851
903
|
for (var i in this.var.link.style) this.markup.push (2, "link", {rel: "stylesheet", href: this.var.link.style [i]});
|
|
852
904
|
this.markup.push (2, "link", {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css"});
|
|
853
905
|
this.markup.push (2, "link", {rel: "stylesheet", href: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.min.css"});
|
|
854
|
-
if (this.var ["theme:style.css"]) this.markup.push (2, "link", {rel: "stylesheet", href: this.var ["theme:style.css"]});
|
|
906
|
+
if (false) if (this.var ["theme:style.css"]) this.markup.push (2, "link", {rel: "stylesheet", href: this.var ["theme:style.css"]});
|
|
855
907
|
this.markup.push (2, "link", {rel: "stylesheet", href: this.var ["vue.css:bundle"]});
|
|
856
908
|
if (this.var ["gtag:id"]) this.markup.push (2, `<script src="https://www.googletagmanager.com/gtag/js?id=${this.var ['gtag:id']}" async></script>`);
|
|
857
909
|
if (false) if (this.var ["google:auth"]) this.markup.push (2, `<script src="https://accounts.google.com/gsi/client" async></script>`);
|
|
858
910
|
this.markup.script (2, {src: "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"});
|
|
859
911
|
this.markup.script (2, {src: "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"});
|
|
860
|
-
if (this.var ["prototype.js"]) this.markup.script (2, {src: this.var ["prototype.js"]});
|
|
912
|
+
if (false) if (this.var ["prototype.js"]) this.markup.script (2, {src: this.var ["prototype.js"]});
|
|
861
913
|
this.markup.push (2, `<script type="module" src="${this.var ['vue.js:bundle']}" crossorigin></script>`);
|
|
862
914
|
this.markup.push (2, `<script type="application/ld+json">{"@context": "https://schema.org", "@type": "WebPage", "name": "${this.var.site.name}", "alternateName": "${this.var ['site:alternate-name']}", "url": "${this.var ['canonical']}", "description": "${this.var ['description']}"}</script>`);
|
|
863
915
|
this.markup.push (2, `<script type="application/ld+json">{"@context": "https://schema.org", "@graph": [{"@type": "website", "@id": "${this.var ['canonical']}", "name": "${this.var.site.name}", "url": "${this.var ['canonical']}", "description": "${this.var ['description']}"}]}</script>`);
|
|
864
916
|
this.markup.push (2, `<script>$.app = function () {}</script>`);
|
|
865
917
|
this.markup.push (2, `<script>$.app.id = "{{ $.app.id }}"</script>`);
|
|
918
|
+
this.markup.push (2, `<script>$.app.reference = {{ $.app.reference }}</script>`);
|
|
866
919
|
this.markup.push (2, `<script>$.app.var = {{ $.app.var }}</script>`);
|
|
867
920
|
this.markup.push (2, `<script>$.app.document = {{ $.app.document }}</script>`);
|
|
868
921
|
this.markup.push (2, `<script>$.app.theme = {{ $.app.theme }}</script>`);
|
|
869
922
|
this.markup.push (2, `<script>$.app.router = {{ $.app.router }}</script>`);
|
|
870
923
|
this.markup.push (2, `<script>$.app.visitor = {{ $.app.visitor }}</script>`);
|
|
871
|
-
this.markup.push (2, `<script>$.app.cookie = {
|
|
924
|
+
this.markup.push (2, `<script>$.app.cookie = {{ $.app.cookie }}</script>`);
|
|
925
|
+
// this.markup.push (2, `<script>$.app.cookie = {name: "${this.var.cookie.name}", host: "${this.var.cookie.host}"}</script>`);
|
|
872
926
|
this.markup.push (2, `<script>$.app.error = {{ $.app.error }}</script>`);
|
|
873
927
|
this.markup.push (2, `<script>window.onload = function () {}</script>`);
|
|
874
928
|
if (this.var ["gtag:id"]) this.markup.push (2, `<script>window.dataLayer = window.dataLayer || []; function gtag () { dataLayer.push (arguments); gtag ("js", new Date ()); gtag ("config", "${this.var ['gtag:id']}"); }</script>`);
|
|
@@ -894,6 +948,35 @@ Define (Function, "html", class {
|
|
|
894
948
|
}
|
|
895
949
|
});
|
|
896
950
|
|
|
951
|
+
Define (Function.html, "error", function (error) {
|
|
952
|
+
var description = `The Status Code ${error.id} was an error on this server. That's all we know.`;
|
|
953
|
+
var markup = new Function.html.markup ("html");
|
|
954
|
+
markup.push (0, "html", {lang: "en", translate: "no", prefix: "og: http://ogp.me/ns#"});
|
|
955
|
+
markup.push (1, "head", {profile: "#"});
|
|
956
|
+
markup.push (2, `<title>Error</title>`);
|
|
957
|
+
markup.push (2, "meta", {"http-equiv": "X-UA-Compatible", content: "IE=edge"});
|
|
958
|
+
markup.push (2, "meta", {"http-equiv": "X-Cross-Origin", content: "*"});
|
|
959
|
+
markup.push (2, "meta", {charset: "UTF-8"});
|
|
960
|
+
markup.push (2, "meta", {name: "description", content: description});
|
|
961
|
+
markup.push (2, "meta", {name: "viewport", content: "width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=1"});
|
|
962
|
+
markup.push (2, "meta", {name: "robots", content: [Function.html.attribute.content (["noindex", "nofollow"]), "max-snippet:-1, max-video-preview:-1, max-image-preview:large"]});
|
|
963
|
+
markup.push (2, "meta", {name: "google", content: "notranslate"});
|
|
964
|
+
markup.push (2, "meta", {name: "googlebot", content: "notranslate"});
|
|
965
|
+
markup.push (2, "meta", {name: "googlebot-news", content: ["noindex", "nofollow"]});
|
|
966
|
+
markup.push (1, `</head>`);
|
|
967
|
+
markup.push (1, `<body>`);
|
|
968
|
+
markup.push (2, `<h1>Error</h1>`);
|
|
969
|
+
markup.push (2, `<hr>`);
|
|
970
|
+
markup.push (2, `<h3>Request ID : ${error.serial}</h3>`);
|
|
971
|
+
markup.push (2, `<h3>Request URL : ${error.url}</h3>`);
|
|
972
|
+
markup.push (2, `<h3>Message : ${error.message}</h3>`);
|
|
973
|
+
markup.push (2, `<hr>`);
|
|
974
|
+
markup.push (2, `<p><em>${description}</em></p>`);
|
|
975
|
+
markup.push (1, `</body>`);
|
|
976
|
+
markup.push (0, `</html>`);
|
|
977
|
+
return markup.render ();
|
|
978
|
+
});
|
|
979
|
+
|
|
897
980
|
Define (Function.html, "prop", function (prop) {
|
|
898
981
|
var attribute = "";
|
|
899
982
|
if (typeof prop === "string") attribute = " " + prop.trim ();
|
|
@@ -1313,7 +1396,7 @@ Symbol.export = {
|
|
|
1313
1396
|
object: Object, array: Array, string: String, number: Number, function: Function,
|
|
1314
1397
|
date: Date, time: Date.time, timeout: Date.timeout, datetime: new Date.io,
|
|
1315
1398
|
event: Event, promise: Promise,
|
|
1316
|
-
url: URL, path: Function.path, file: Function.file, dir: Function.dir,
|
|
1399
|
+
url: URL, path: Function.path, file: Function.file, dir: Function.dir, http: Function.http,
|
|
1317
1400
|
db: Function.db, database: Function.database,
|
|
1318
1401
|
cookie: Function.cookie, session: Function.session, ls: Function.ls,
|
|
1319
1402
|
markup: Function.markup, html: Function.html, css: Function.css, js: Function.js, json: JSON, xml: Function.xml, serialize: Function.serialize,
|
|
@@ -1330,8 +1413,6 @@ Symbol.export = {
|
|
|
1330
1413
|
zero: 0, one: 1,
|
|
1331
1414
|
}
|
|
1332
1415
|
|
|
1333
|
-
var JScript = Symbol.export;
|
|
1334
|
-
|
|
1335
1416
|
/**
|
|
1336
1417
|
* the end
|
|
1337
1418
|
*
|