@operato/scene-random 0.0.4

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/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ### [0.0.4](https://github.com/hatiolab/things-factory/compare/v0.0.3...v0.0.4) (2021-12-01)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * add @operato/scene-i18n ([92d14ff](https://github.com/hatiolab/things-factory/commit/92d14ff4bcacfb920e39470cf7537ab7560844f1))
12
+ * add @operato/scene-progressbar ([0a18f8b](https://github.com/hatiolab/things-factory/commit/0a18f8bf01337eff9a040168d36c8efdc9c35b6e))
13
+ * added @operato/scene-random ([3595d13](https://github.com/hatiolab/things-factory/commit/3595d13ea13a4112b0e361e085bf11b3d35c3391))
14
+
15
+
16
+ ### :bug: Bug Fix
17
+
18
+ * things-scene upgrade ([9e2c0b8](https://github.com/hatiolab/things-factory/commit/9e2c0b85b1aacb0a4ef656866259879a20cd5de4))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Hearty, Oh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ ## build
2
+
3
+ `$ yarn build`
4
+
5
+ | type | filename | for | tested |
6
+ | ---- | ------------------------- | -------------- | ------ |
7
+ | UMD | things-scene-random.js | modern browser | O |
8
+ | UMD | things-scene-random-ie.js | ie 11 | O |
9
+ | ESM | things-scene-random.mjs | modern browser | O |
10
+
11
+ ## publish
12
+
13
+ `$ yarn publish`
Binary file
@@ -0,0 +1 @@
1
+ export { default as Random } from './random';
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export { default as Random } from './random';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nexport { default as Random } from './random'\n"]}
@@ -0,0 +1,53 @@
1
+ import { Shape } from '@hatiolab/things-scene';
2
+ declare const Random_base: typeof Shape;
3
+ export default class Random extends Random_base {
4
+ static _image?: HTMLImageElement;
5
+ static get image(): HTMLImageElement;
6
+ private repeatTimer?;
7
+ ready(): void;
8
+ dispose(): void;
9
+ random(): void;
10
+ _initRandom(): void;
11
+ _startRepeater(): void;
12
+ _stopRepeater(): void;
13
+ _draw(context: CanvasRenderingContext2D): void;
14
+ ondblclick(e: MouseEvent): void;
15
+ get hasTextProperty(): boolean;
16
+ get controls(): never[];
17
+ get nature(): {
18
+ mutable: boolean;
19
+ resizable: boolean;
20
+ rotatable: boolean;
21
+ properties: ({
22
+ type: string;
23
+ label: string;
24
+ name: string;
25
+ property: {
26
+ options: {
27
+ display: string;
28
+ value: string;
29
+ }[];
30
+ };
31
+ placeholder?: undefined;
32
+ } | {
33
+ type: string;
34
+ label: string;
35
+ name: string;
36
+ placeholder: number;
37
+ property?: undefined;
38
+ } | {
39
+ type: string;
40
+ label: string;
41
+ name: string;
42
+ placeholder: string;
43
+ property?: undefined;
44
+ })[];
45
+ help: string;
46
+ };
47
+ }
48
+ export declare const X: {
49
+ new (...args: any[]): {
50
+ timestamp: number;
51
+ };
52
+ } & typeof Random;
53
+ export {};
@@ -0,0 +1,126 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { Component, error, RectPath, ScriptLoader, Shape } from '@hatiolab/things-scene';
5
+ const formats = [
6
+ 'bool,character,floating,integer,letter,natural,string',
7
+ 'paragraph,sentence,syllable,word',
8
+ 'age,birthday,cf,cpf,first,gender,last,name,prefix,ssn,suffix',
9
+ 'android_id,apple_token,bb_pin,wp7_anid,wp8_anid2,avatar,color',
10
+ 'company,domain,email,fbid,google_analytics,hashtag,ip,ipv6,klout,profession,tld,twitter,url',
11
+ 'address,altitude,areacode,city,coordinates,country,depth,geohash,latitude,longitude,phone,postal,province,state,street,zip',
12
+ 'ampm,date,hammertime,hour,millisecond,minute,month,second,timestamp,timezone,weekday,year',
13
+ 'cc,cc_type,currency,currency_pair,dollar,euro,exp,exp_month,exp_year',
14
+ 'coin,d4,d6,d8,d10,d12,d20,d30,d100,guid,hash'
15
+ ]
16
+ .join(',')
17
+ .split(',');
18
+ const NATURE = {
19
+ mutable: false,
20
+ resizable: true,
21
+ rotatable: true,
22
+ properties: [
23
+ {
24
+ type: 'select',
25
+ label: 'format',
26
+ name: 'format',
27
+ property: {
28
+ options: formats.map(format => ({ display: format, value: format }))
29
+ }
30
+ },
31
+ {
32
+ type: 'number',
33
+ label: 'count',
34
+ name: 'count',
35
+ placeholder: 1
36
+ },
37
+ {
38
+ type: 'number',
39
+ label: 'period',
40
+ name: 'period',
41
+ placeholder: 'milli-seconds'
42
+ }
43
+ ],
44
+ help: 'scene/component/random'
45
+ };
46
+ const RANDOM_IMAGE = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAtFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSe1G2AAAAO3RSTlMAA/sG7vXcIvjy4tLm14YJzWlkbhK6pX8aDwyqSTPJxZtEQBbAOyqRjHlNciYe6a51WrWWUjcun7JfVn5FXzIAAAjjSURBVHja7NrXdtpAGATgkUQTvdn0DjbV2In7vP975SLIlrIFLevEcKLvWseAhWbn3wWJRCKRSCQSiUQikUgkEolEIpFI/C/ajX0plSrtGztcskHP5YG7v8GlmswZ5q4cXCDnvco/XV/eJ6nUMpR4wWXprO4oV8cFaS99qqSauBTbsUuNMi7D0556fgcXoD/nUfc4d85DgTHcVXDWJHl7icHVFPJWLXO+q2J7maaBd5ynmxeXRqo4R9q8zWUKmRwFE5wdXd4WywMPgDcoFxl1hfOizVt/4yHgNXxGDHBGKo0M1QpZhGWjH7mHs9FsafO22kRUp8oQd4vzsLtNU6fYFiO6yJAxzsHxvF1DtI7EWRvfbvHKY+aQmZ9Vm+/PedwjcOyWpBx8Iy9ev/U9yHg+Py3xfbqNPGO5gtwVP7htfJdmK8WYbiF3q9hNWSxHxbRf6tWbsGCdt6IW5Fr8cIMPjwUGcuMtbNn32+OJVGbgBwLNPSNeF7Bgkbcmu3BjBqY4a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EdoLQ2G9arVkFvSibry/yENkU/s5wK7VKaYZqtcmT36nkCCwM8ECa/NZsfGGErvgd4M/5azvTmM+0eKtEjZODv4m/6IVc7tp3kb2Sylv8V1QcT55O0pVmEHOwf7XaiqTC3G439eGHMbd+t9qKhblP2+xUzoGQygrmUDiNdo2ks4+DwaqW1GoroJRVdzf5boP9ivAVYvcm12JnkUS39yaTkfie0aK/8Kcn+GaDLRSe9hkI3ehvAf/KEsCNmHzoN/l6hgRdVqnCKe4LMxL4czv9znVb0nZwd+D2hC75UpjSSY5XFr2AWW+WhdxuAQoO2fmtrUkI0Z3XQr3wI5uHSvemDl1FURRFURRFURRFURRF+a/9A+ihoIIrt6BYAAAAAElFTkSuQmCC';
47
+ export default class Random extends RectPath(Shape) {
48
+ static get image() {
49
+ if (!Random._image) {
50
+ Random._image = new Image();
51
+ Random._image.src = RANDOM_IMAGE;
52
+ }
53
+ return Random._image;
54
+ }
55
+ ready() {
56
+ super.ready();
57
+ ScriptLoader.load(['https://chancejs.com/chance.min.js']).then(() => {
58
+ this.app && this.app.isViewMode && this._initRandom();
59
+ }, error);
60
+ }
61
+ dispose() {
62
+ super.dispose();
63
+ this._stopRepeater();
64
+ }
65
+ random() {
66
+ var { format, count = 1 } = this.state;
67
+ if (!format || !count)
68
+ return;
69
+ //@ts-ignore
70
+ this.data = chance.n(chance[format], count);
71
+ }
72
+ _initRandom() {
73
+ this._stopRepeater();
74
+ this._startRepeater();
75
+ }
76
+ _startRepeater() {
77
+ var { period } = this.state;
78
+ period = Number(period);
79
+ var generatable = true;
80
+ if (period) {
81
+ this.repeatTimer = setInterval(() => {
82
+ generatable &&
83
+ this.repeatTimer &&
84
+ requestAnimationFrame(() => {
85
+ generatable = true;
86
+ this.random();
87
+ });
88
+ generatable = false;
89
+ }, period);
90
+ }
91
+ this.random();
92
+ }
93
+ _stopRepeater() {
94
+ if (this.repeatTimer)
95
+ clearTimeout(this.repeatTimer);
96
+ delete this.repeatTimer;
97
+ }
98
+ _draw(context) {
99
+ var { left, top, width, height } = this.bounds;
100
+ context.beginPath();
101
+ this.drawImage(context, Random.image, left, top, width, height);
102
+ }
103
+ ondblclick(e) {
104
+ this.random();
105
+ }
106
+ get hasTextProperty() {
107
+ return false;
108
+ }
109
+ get controls() {
110
+ return [];
111
+ }
112
+ get nature() {
113
+ return NATURE;
114
+ }
115
+ }
116
+ Component.register('random', Random);
117
+ function Timestamped(Base) {
118
+ return class extends Base {
119
+ constructor() {
120
+ super(...arguments);
121
+ this.timestamp = Date.now();
122
+ }
123
+ };
124
+ }
125
+ export const X = Timestamped(Random);
126
+ //# sourceMappingURL=random.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/random.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAExF,MAAM,OAAO,GAAG;IACd,uDAAuD;IACvD,kCAAkC;IAClC,8DAA8D;IAC9D,+DAA+D;IAC/D,6FAA6F;IAC7F,4HAA4H;IAC5H,2FAA2F;IAC3F,sEAAsE;IACtE,8CAA8C;CAC/C;KACE,IAAI,CAAC,GAAG,CAAC;KACT,KAAK,CAAC,GAAG,CAAC,CAAA;AAEb,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE;gBACR,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;aACrE;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,IAAI,EA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AC,QAAQ,EAAE,MAAM,CAAC,CAAA;AAIpC,SAAS,WAAW,CAA4B,IAAW;IACzD,OAAO,KAAM,SAAQ,IAAI;QAAlB;;YACL,cAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACxB,CAAC;KAAA,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { Component, error, RectPath, ScriptLoader, Shape } from '@hatiolab/things-scene'\n\nconst formats = [\n 'bool,character,floating,integer,letter,natural,string',\n 'paragraph,sentence,syllable,word',\n 'age,birthday,cf,cpf,first,gender,last,name,prefix,ssn,suffix',\n 'android_id,apple_token,bb_pin,wp7_anid,wp8_anid2,avatar,color',\n 'company,domain,email,fbid,google_analytics,hashtag,ip,ipv6,klout,profession,tld,twitter,url',\n 'address,altitude,areacode,city,coordinates,country,depth,geohash,latitude,longitude,phone,postal,province,state,street,zip',\n 'ampm,date,hammertime,hour,millisecond,minute,month,second,timestamp,timezone,weekday,year',\n 'cc,cc_type,currency,currency_pair,dollar,euro,exp,exp_month,exp_year',\n 'coin,d4,d6,d8,d10,d12,d20,d30,d100,guid,hash'\n]\n .join(',')\n .split(',')\n\nconst NATURE = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'format',\n name: 'format',\n property: {\n options: formats.map(format => ({ display: format, value: format }))\n }\n },\n {\n type: 'number',\n label: 'count',\n name: 'count',\n placeholder: 1\n },\n {\n type: 'number',\n label: 'period',\n name: 'period',\n placeholder: 'milli-seconds'\n }\n ],\n help: 'scene/component/random'\n}\n\nconst RANDOM_IMAGE =\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAtFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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wd+D2hC75UpjSSY5XFr2AWW+WhdxuAQoO2fmtrUkI0Z3XQr3wI5uHSvemDl1FURRFURRFURRFURRF+a/9A+ihoIIrt6BYAAAAAElFTkSuQmCC'\n\nexport default class Random extends RectPath(Shape) {\n static _image?: HTMLImageElement\n static get image() {\n if (!Random._image) {\n Random._image = new Image()\n Random._image.src = RANDOM_IMAGE\n }\n\n return Random._image\n }\n\n private repeatTimer?: NodeJS.Timer\n\n ready() {\n super.ready()\n\n ScriptLoader.load(['https://chancejs.com/chance.min.js']).then(() => {\n this.app && this.app.isViewMode && this._initRandom()\n }, error)\n }\n\n dispose() {\n super.dispose()\n this._stopRepeater()\n }\n\n random() {\n var { format, count = 1 } = this.state\n\n if (!format || !count) return\n\n //@ts-ignore\n this.data = chance.n(chance[format], count)\n }\n\n _initRandom() {\n this._stopRepeater()\n this._startRepeater()\n }\n\n _startRepeater() {\n var { period } = this.state\n period = Number(period)\n\n var generatable = true\n\n if (period) {\n this.repeatTimer = setInterval(() => {\n generatable &&\n this.repeatTimer &&\n requestAnimationFrame(() => {\n generatable = true\n this.random()\n })\n generatable = false\n }, period)\n }\n\n this.random()\n }\n\n _stopRepeater() {\n if (this.repeatTimer) clearTimeout(this.repeatTimer)\n\n delete this.repeatTimer\n }\n\n _draw(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n this.drawImage(context, Random.image, left, top, width, height)\n }\n\n ondblclick(e: MouseEvent) {\n this.random()\n }\n\n get hasTextProperty() {\n return false\n }\n\n get controls() {\n return []\n }\n\n get nature() {\n return NATURE\n }\n}\n\nComponent.register('random', Random)\n\ntype Constructor<T = {}> = new (...args: any[]) => T\n\nfunction Timestamped<TBase extends Constructor>(Base: TBase) {\n return class extends Base {\n timestamp = Date.now()\n }\n}\n\nexport const X = Timestamped(Random)\n"]}
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../node_modules/@hatiolab/things-scene/things-scene.d.ts","../src/random.ts","../src/index.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts"],"fileInfos":[{"version":"6adbf5efd0e374ff5f427a4f26a5a413e9734eee5067a0e86da69aea41910b52","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"abba1071bfd89e55e88a054b0c851ea3e8a494c340d0f3fab19eb18f6afb0c9e","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","4ddc7832014ce8dae75461c71b8e6af7281cfb2eba4d6e4c2deb6300044cf4ce","3525f1b488cc4fa081a658dbe39ab03db1b364131f4d5fe2522b4cdd08b3cbb5","badac5c7672833daed79c3c2bf881f3fcfe94e293890ab8c5ae205537baa817e","0d5a2ee1fdfa82740e0103389b9efd6bfe145a20018a2da3c02b89666181f4d9","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"92d63add669d18ebc349efbacd88966d6f2ccdddfb1b880b2db98ae3aa7bf7c4","affectsGlobalScope":true},"ccc94049a9841fe47abe5baef6be9a38fc6228807974ae675fb15dc22531b4be",{"version":"9acfe4d1ff027015151ce81d60797b04b52bffe97ad8310bb0ec2e8fd61e1303","affectsGlobalScope":true},"95843d5cfafced8f3f8a5ce57d2335f0bcd361b9483587d12a25e4bd403b8216","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","2f520601649a893e6a49a8851ebfcf4be8ce090dc1281c2a08a871cb04e8251f","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","2b8c764f856a1dd0a9a2bf23e5efddbff157de8138b0754010be561ae5fcaa90","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","6972fca26f6e9bd56197568d4379f99071a90766e06b4fcb5920a0130a9202be",{"version":"4a2628e95962c8ab756121faa3ac2ed348112ff7a87b5c286dd2cc3326546b4c","affectsGlobalScope":true},"80793b2277f31baa199234daed806fff0fb11491d1ebd3357e520c3558063f00","a049a59a02009fc023684fcfaf0ac526fe36c35dcc5d2b7d620c1750ba11b083","5533392c50c51b1a5c32b89f13145db929c574ef1c5949cf67a074a05ea107d9","b287b810b5035d5685f1df6e1e418f1ca452a3ed4f59fd5cc081dbf2045f0d9b","4b9a003b5c556c96784132945bb41c655ea11273b1917f5c8d0c154dd5fd20dd","a458dc78104cc80048ac24fdc02fe6dce254838094c2f25641b3f954d9721241",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"902cd98bf46e95caf4118a0733fb801e9e90eec3edaed6abdad77124afec9ca2","abc1c425b2ad6720433f40f1877abfa4223f0f3dd486c9c28c492179ca183cb6","cd4854d38f4eb5592afd98ab95ca17389a7dfe38013d9079e802d739bdbcc939","94eed4cc2f5f658d5e229ff1ccd38860bddf4233e347bf78edd2154dee1f2b99",{"version":"bd1a08e30569b0fb2f0b21035eb9b039871f68faa9b98accf847e9c878c5e0a9","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","ee18f2da7a037c6ceeb112a084e485aead9ea166980bf433474559eac1b46553","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","d7838022c7dab596357a9604b9c6adffe37dc34085ce0779c958ce9545bd7139","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"a7971f9fb2a32ec7788ec6cda9d7a33c02023dfe9a62db2030ad1359649d8050","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637",{"version":"b42b47e17b8ece2424ae8039feb944c2e3ba4b262986aebd582e51efbdca93dc","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","2408611d9b4146e35d1dbd1f443ccd8e187c74614a54b80300728277529dbf11","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4","d88ecca73348e7c337541c4b8b60a50aca5e87384f6b8a422fc6603c637e4c21","badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"1cdb8f094b969dcc183745dc88404e2d8fcf2a858c6e7cc2441011476573238e"],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":false,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"outDir":"./","rootDir":"..","sourceMap":true,"strict":true,"target":5},"fileIdsList":[[44,87],[47,87],[48,53,87],[49,59,60,67,76,86,87],[49,50,59,67,87],[51,87],[52,53,60,68,87],[53,76,83,87],[54,56,59,67,87],[55,87],[56,57,87],[58,59,87],[59,87],[59,60,61,76,86,87],[59,60,61,76,87],[87],[62,67,76,86,87],[59,60,62,63,67,76,83,86,87],[62,64,76,83,86,87],[44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93],[59,65,87],[66,86,87],[56,59,67,76,87],[68,87],[69,87],[47,70,87],[71,85,87,91],[72,87],[73,87],[59,74,87],[74,75,87,89],[59,76,77,78,87],[76,78,87],[76,77,87],[79,87],[80,87],[59,81,82,87],[81,82,87],[53,67,83,87],[84,87],[67,85,87],[48,62,73,86,87],[53,87],[76,87,88],[87,89],[87,90],[48,53,59,61,70,76,86,87,89,91],[76,87,92],[40,42,87],[40,41,87]],"referencedMap":[[44,1],[45,1],[47,2],[48,3],[49,4],[50,5],[51,6],[52,7],[53,8],[54,9],[55,10],[56,11],[57,11],[58,12],[59,13],[60,14],[61,15],[46,16],[93,16],[62,17],[63,18],[64,19],[94,20],[65,21],[66,22],[67,23],[68,24],[69,25],[70,26],[71,27],[72,28],[73,29],[74,30],[75,31],[76,32],[78,33],[77,34],[79,35],[80,36],[81,37],[82,38],[83,39],[84,40],[85,41],[86,42],[87,43],[88,44],[89,45],[90,46],[91,47],[92,48],[40,16],[8,16],[10,16],[9,16],[2,16],[11,16],[12,16],[13,16],[14,16],[15,16],[16,16],[17,16],[18,16],[3,16],[4,16],[22,16],[19,16],[20,16],[21,16],[23,16],[24,16],[25,16],[5,16],[26,16],[27,16],[28,16],[29,16],[6,16],[30,16],[31,16],[32,16],[33,16],[7,16],[38,16],[34,16],[35,16],[36,16],[37,16],[1,16],[39,16],[41,16],[43,49],[42,50]],"exportedModulesMap":[[44,1],[45,1],[47,2],[48,3],[49,4],[50,5],[51,6],[52,7],[53,8],[54,9],[55,10],[56,11],[57,11],[58,12],[59,13],[60,14],[61,15],[46,16],[93,16],[62,17],[63,18],[64,19],[94,20],[65,21],[66,22],[67,23],[68,24],[69,25],[70,26],[71,27],[72,28],[73,29],[74,30],[75,31],[76,32],[78,33],[77,34],[79,35],[80,36],[81,37],[82,38],[83,39],[84,40],[85,41],[86,42],[87,43],[88,44],[89,45],[90,46],[91,47],[92,48],[40,16],[8,16],[10,16],[9,16],[2,16],[11,16],[12,16],[13,16],[14,16],[15,16],[16,16],[17,16],[18,16],[3,16],[4,16],[22,16],[19,16],[20,16],[21,16],[23,16],[24,16],[25,16],[5,16],[26,16],[27,16],[28,16],[29,16],[6,16],[30,16],[31,16],[32,16],[33,16],[7,16],[38,16],[34,16],[35,16],[36,16],[37,16],[1,16],[39,16],[41,16],[43,49],[42,50]],"semanticDiagnosticsPerFile":[44,45,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,46,93,62,63,64,94,65,66,67,68,69,70,71,72,73,74,75,76,78,77,79,80,81,82,83,84,85,86,87,88,89,90,91,92,40,8,10,9,2,11,12,13,14,15,16,17,18,3,4,22,19,20,21,23,24,25,5,26,27,28,29,6,30,31,32,33,7,38,34,35,36,37,1,39,41,43,42]},"version":"4.5.2"}
@@ -0,0 +1,12 @@
1
+ # random
2
+
3
+ 무작위 문자열, 숫자 등의 데이터를 생성하는 컴포넌트.
4
+ 특히 무작위 테스트 정보 생성이 필요한 곳에서 단조 로움을 줄이는 데 도움이됩니다.
5
+
6
+ 이 컴포넌트는 배열 데이터를 생성합니다.
7
+
8
+ ## properties
9
+
10
+ - format : 데이터 포멧은 chancejs에서 사용 가능한 기능 위주로 만들어 졌으며 내용은 [chancejs](https://chancejs.com/basics/bool.html)에서 확인 바랍니다.
11
+ - count : 배열 크기
12
+ - period : 데이터 생성 주기
@@ -0,0 +1,11 @@
1
+ # random
2
+
3
+ Data generator of random strings, numbers, etc. to help reduce some monotony particularly while writing automated tests or anywhere else you need anything random.
4
+
5
+ This components returns array data
6
+
7
+ ## properties
8
+
9
+ - format : Data format that chancejs support, please check it on [chancejs](https://chancejs.com/basics/bool.html)
10
+ - count : Data array count
11
+ - period : Data generate period
@@ -0,0 +1,11 @@
1
+ # random
2
+
3
+ 随机字符串,数字等的数据生成器,以帮助减少一些测试的单调性,尤其是在编写自动测试或其他任何需要随机数据的地方。
4
+
5
+ 该组件返回数组数据。
6
+
7
+ ## properties
8
+
9
+ - format : 数据格式参考chancejs的内容,内容连接为[chancejs](https://chancejs.com/basics/bool.html)
10
+ - count : 数组的大小
11
+ - period : 数据生成周期
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@operato/scene-random",
3
+ "description": "An random data source component for things-scene.",
4
+ "license": "MIT",
5
+ "author": "heartyoh",
6
+ "version": "0.0.4",
7
+ "main": "dist/src/index.js",
8
+ "module": "dist/src/index.js",
9
+ "things-scene": true,
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "@oprato:registry": "https://registry.npmjs.org"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/hatiolab/things-factory.git",
17
+ "directory": "packages/scene-random"
18
+ },
19
+ "scripts": {
20
+ "serve": "tsc && things-factory-dev",
21
+ "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
22
+ "build": "tsc",
23
+ "prepublish": "tsc",
24
+ "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
25
+ "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
26
+ "migration": "things-factory-migration"
27
+ },
28
+ "dependencies": {
29
+ "lit": "^2.0.2"
30
+ },
31
+ "devDependencies": {
32
+ "@hatiolab/prettier-config": "^1.0.0",
33
+ "@hatiolab/things-scene": "^2.7.15",
34
+ "@operato/board": "^0.2.27",
35
+ "@things-factory/builder": "^4.0.6",
36
+ "@things-factory/operato-board": "^4.0.6",
37
+ "@types/chance": "^1.1.3",
38
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
39
+ "@typescript-eslint/parser": "^4.33.0",
40
+ "@web/dev-server": "^0.1.28",
41
+ "concurrently": "^5.3.0",
42
+ "eslint": "^7.32.0",
43
+ "eslint-config-prettier": "^8.3.0",
44
+ "husky": "^4.3.8",
45
+ "lint-staged": "^10.5.4",
46
+ "prettier": "^2.4.1",
47
+ "tslib": "^2.3.1",
48
+ "typescript": "^4.5.2"
49
+ },
50
+ "prettier": "@hatiolab/prettier-config",
51
+ "husky": {
52
+ "hooks": {
53
+ "pre-commit": "lint-staged"
54
+ }
55
+ },
56
+ "lint-staged": {
57
+ "*.ts": [
58
+ "eslint --fix",
59
+ "prettier --write"
60
+ ]
61
+ },
62
+ "gitHead": "853ccc00f65e96f0d4807400d792a76fe9ef62d1"
63
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ export { default as Random } from './random'
package/src/random.ts ADDED
@@ -0,0 +1,154 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { Component, error, RectPath, ScriptLoader, Shape } from '@hatiolab/things-scene'
6
+
7
+ const formats = [
8
+ 'bool,character,floating,integer,letter,natural,string',
9
+ 'paragraph,sentence,syllable,word',
10
+ 'age,birthday,cf,cpf,first,gender,last,name,prefix,ssn,suffix',
11
+ 'android_id,apple_token,bb_pin,wp7_anid,wp8_anid2,avatar,color',
12
+ 'company,domain,email,fbid,google_analytics,hashtag,ip,ipv6,klout,profession,tld,twitter,url',
13
+ 'address,altitude,areacode,city,coordinates,country,depth,geohash,latitude,longitude,phone,postal,province,state,street,zip',
14
+ 'ampm,date,hammertime,hour,millisecond,minute,month,second,timestamp,timezone,weekday,year',
15
+ 'cc,cc_type,currency,currency_pair,dollar,euro,exp,exp_month,exp_year',
16
+ 'coin,d4,d6,d8,d10,d12,d20,d30,d100,guid,hash'
17
+ ]
18
+ .join(',')
19
+ .split(',')
20
+
21
+ const NATURE = {
22
+ mutable: false,
23
+ resizable: true,
24
+ rotatable: true,
25
+ properties: [
26
+ {
27
+ type: 'select',
28
+ label: 'format',
29
+ name: 'format',
30
+ property: {
31
+ options: formats.map(format => ({ display: format, value: format }))
32
+ }
33
+ },
34
+ {
35
+ type: 'number',
36
+ label: 'count',
37
+ name: 'count',
38
+ placeholder: 1
39
+ },
40
+ {
41
+ type: 'number',
42
+ label: 'period',
43
+ name: 'period',
44
+ placeholder: 'milli-seconds'
45
+ }
46
+ ],
47
+ help: 'scene/component/random'
48
+ }
49
+
50
+ const RANDOM_IMAGE =
51
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAtFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSe1G2AAAAO3RSTlMAA/sG7vXcIvjy4tLm14YJzWlkbhK6pX8aDwyqSTPJxZtEQBbAOyqRjHlNciYe6a51WrWWUjcun7JfVn5FXzIAAAjjSURBVHja7NrXdtpAGATgkUQTvdn0DjbV2In7vP975SLIlrIFLevEcKLvWseAhWbn3wWJRCKRSCQSiUQikUgkEolEIpFI/C/ajX0plSrtGztcskHP5YG7v8GlmswZ5q4cXCDnvco/XV/eJ6nUMpR4wWXprO4oV8cFaS99qqSauBTbsUuNMi7D0556fgcXoD/nUfc4d85DgTHcVXDWJHl7icHVFPJWLXO+q2J7maaB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Oj4i8u239vtV5fJPedIWvzTvwo0YkNT+N83EYblEDAvhsnmbn1qMvtTWIhDZn5B6vTZh6ANHwuITqAWJGAeKmj8rm+UMtryQ7cwERxmPjFchuLVrv65Vz7TIvSsxWG55vipbEJybJ6FGwML8HGR3mrHoDIodqnvlsw6RbbVJ6tvBTQ91jnpMxU/ofUE6op5z7GlD6z7mtKYCQbrVJamOeqH1Z5TTPB37+Wx83Folj7jZYDCyCUoFkd9S5Im3yTAhiy8yobhKELiSr0h0zeeHKOv/CO12hNUqIqLKAZCVEdoLQ2G9arVkFvSibry/yENkU/s5wK7VKaYZqtcmT36nkCCwM8ECa/NZsfGGErvgd4M/5azvTmM+0eKtEjZODv4m/6IVc7tp3kb2Sylv8V1QcT55O0pVmEHOwf7XaiqTC3G439eGHMbd+t9qKhblP2+xUzoGQygrmUDiNdo2ks4+DwaqW1GoroJRVdzf5boP9ivAVYvcm12JnkUS39yaTkfie0aK/8Kcn+GaDLRSe9hkI3ehvAf/KEsCNmHzoN/l6hgRdVqnCKe4LMxL4czv9znVb0nZwd+D2hC75UpjSSY5XFr2AWW+WhdxuAQoO2fmtrUkI0Z3XQr3wI5uHSvemDl1FURRFURRFURRFURRF+a/9A+ihoIIrt6BYAAAAAElFTkSuQmCC'
52
+
53
+ export default class Random extends RectPath(Shape) {
54
+ static _image?: HTMLImageElement
55
+ static get image() {
56
+ if (!Random._image) {
57
+ Random._image = new Image()
58
+ Random._image.src = RANDOM_IMAGE
59
+ }
60
+
61
+ return Random._image
62
+ }
63
+
64
+ private repeatTimer?: NodeJS.Timer
65
+
66
+ ready() {
67
+ super.ready()
68
+
69
+ ScriptLoader.load(['https://chancejs.com/chance.min.js']).then(() => {
70
+ this.app && this.app.isViewMode && this._initRandom()
71
+ }, error)
72
+ }
73
+
74
+ dispose() {
75
+ super.dispose()
76
+ this._stopRepeater()
77
+ }
78
+
79
+ random() {
80
+ var { format, count = 1 } = this.state
81
+
82
+ if (!format || !count) return
83
+
84
+ //@ts-ignore
85
+ this.data = chance.n(chance[format], count)
86
+ }
87
+
88
+ _initRandom() {
89
+ this._stopRepeater()
90
+ this._startRepeater()
91
+ }
92
+
93
+ _startRepeater() {
94
+ var { period } = this.state
95
+ period = Number(period)
96
+
97
+ var generatable = true
98
+
99
+ if (period) {
100
+ this.repeatTimer = setInterval(() => {
101
+ generatable &&
102
+ this.repeatTimer &&
103
+ requestAnimationFrame(() => {
104
+ generatable = true
105
+ this.random()
106
+ })
107
+ generatable = false
108
+ }, period)
109
+ }
110
+
111
+ this.random()
112
+ }
113
+
114
+ _stopRepeater() {
115
+ if (this.repeatTimer) clearTimeout(this.repeatTimer)
116
+
117
+ delete this.repeatTimer
118
+ }
119
+
120
+ _draw(context: CanvasRenderingContext2D) {
121
+ var { left, top, width, height } = this.bounds
122
+
123
+ context.beginPath()
124
+ this.drawImage(context, Random.image, left, top, width, height)
125
+ }
126
+
127
+ ondblclick(e: MouseEvent) {
128
+ this.random()
129
+ }
130
+
131
+ get hasTextProperty() {
132
+ return false
133
+ }
134
+
135
+ get controls() {
136
+ return []
137
+ }
138
+
139
+ get nature() {
140
+ return NATURE
141
+ }
142
+ }
143
+
144
+ Component.register('random', Random)
145
+
146
+ type Constructor<T = {}> = new (...args: any[]) => T
147
+
148
+ function Timestamped<TBase extends Constructor>(Base: TBase) {
149
+ return class extends Base {
150
+ timestamp = Date.now()
151
+ }
152
+ }
153
+
154
+ export const X = Timestamped(Random)
@@ -0,0 +1,67 @@
1
+ <!--
2
+ @license
3
+ Copyright © HatioLab Inc. All rights reserved.
4
+ -->
5
+ <!doctype html>
6
+ <html>
7
+ <head>
8
+ <meta charset="utf-8">
9
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
10
+
11
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
12
+ <script src="../../web-component-tester/browser.js"></script>
13
+
14
+ <!-- Step 1: import the element to test -->
15
+ <link rel="import" href="../things-scene-random.html">
16
+ </head>
17
+ <body>
18
+
19
+ <!-- You can use the document as a place to set up your fixtures. -->
20
+ <test-fixture id="things-scene-random-fixture">
21
+ <template>
22
+ <things-scene-random>
23
+ <h2>things-scene-random</h2>
24
+ </things-scene-random>
25
+ </template>
26
+ </test-fixture>
27
+
28
+ <script>
29
+ suite('<things-scene-random>', function() {
30
+
31
+ var myEl;
32
+
33
+ setup(function() {
34
+ myEl = fixture('things-scene-random-fixture');
35
+ });
36
+
37
+ test('defines the "author" property', function() {
38
+ assert.equal(myEl.author.name, 'Dimitri Glazkov');
39
+ assert.equal(myEl.author.image, 'http://addyosmani.com/blog/wp-content/uploads/2013/04/unicorn.jpg');
40
+ });
41
+
42
+ test('says hello', function() {
43
+ assert.equal(myEl.sayHello(), 'things-scene-random says, Hello World!');
44
+
45
+ var greetings = myEl.sayHello('greetings Earthlings');
46
+ assert.equal(greetings, 'things-scene-random says, greetings Earthlings');
47
+ });
48
+
49
+ test('fires lasers', function(done) {
50
+ myEl.addEventListener('things-scene-random-lasers', function(event) {
51
+ assert.equal(event.detail.sound, 'Pew pew!');
52
+ done();
53
+ });
54
+ myEl.fireLasers();
55
+ });
56
+
57
+ test('distributed children', function() {
58
+ var els = myEl.getContentChildren();
59
+ assert.equal(els.length, 1, 'one distributed node');
60
+ assert.equal(els[0], myEl.querySelector('h2'), 'content distributed correctly');
61
+ });
62
+
63
+ });
64
+ </script>
65
+
66
+ </body>
67
+ </html>
@@ -0,0 +1,24 @@
1
+ <!--
2
+ @license
3
+ Copyright © HatioLab Inc. All rights reserved.
4
+ -->
5
+ <!DOCTYPE html>
6
+ <html>
7
+ <head>
8
+ <meta charset="utf-8">
9
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
10
+
11
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
12
+ <script src="../../web-component-tester/browser.js"></script>
13
+ </head>
14
+ <body>
15
+ <script>
16
+ // Load and run all tests (.html, .js):
17
+ WCT.loadSuites([
18
+ 'basic-test.html',
19
+ 'basic-test.html?dom=shadow'
20
+ ]);
21
+ </script>
22
+
23
+ </body>
24
+ </html>
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import './util'
6
+
7
+ import { expect } from 'chai'
8
+
9
+ import '../../bower_components/things-scene-core/things-scene-min'
10
+ import { Random } from '../../src/index'
11
+
12
+ describe('Random', function () {
13
+
14
+ var board;
15
+
16
+ beforeEach(function () {
17
+ board = scene.create({
18
+ model: {
19
+ components: [{
20
+ id: 'random',
21
+ type: 'random'
22
+ }]
23
+ }
24
+ })
25
+ });
26
+
27
+ it('component should be found by its id.', function () {
28
+
29
+ var component = board.findById('random')
30
+
31
+ expect(!!component).not.to.equal(false);
32
+ });
33
+ });
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ var noop = () => {}
6
+
7
+ global.Canvas = require('canvas');
8
+
9
+ Canvas.prototype.setAttribute = noop;
10
+ Canvas.prototype.style = {};
11
+
12
+ global.Image = Canvas.Image;
13
+ global.screen = {
14
+ width: 1280,
15
+ height: 800
16
+ };
17
+
18
+ global.window = global;
19
+
20
+ global.addEventListener = noop;
21
+ global.location = {};
22
+ global.getComputedStyle = noop;
@@ -0,0 +1,24 @@
1
+ import icon from './assets/random.png';
2
+
3
+ var templates = [{
4
+ type: 'random',
5
+ description: 'random data generator',
6
+ group: 'dataSource', /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */
7
+ icon,
8
+ model: {
9
+ type: "random",
10
+ left: 10,
11
+ top: 10,
12
+ width: 100,
13
+ height: 100,
14
+ hidden: true,
15
+ dataFormat: 'json',
16
+ format: 'integer',
17
+ period: 5000,
18
+ count: 1
19
+ }
20
+ }];
21
+
22
+ export default {
23
+ templates
24
+ };
@@ -0,0 +1,5 @@
1
+ {
2
+ "label.format": "format",
3
+ "label.period": "period",
4
+ "label.count": "count"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "label.format": "포멧",
3
+ "label.period": "주기",
4
+ "label.count": "수량"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "label.format": "格式",
3
+ "label.period": "周期",
4
+ "label.count": "数量"
5
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "noEmitOnError": true,
7
+ "lib": ["es2017", "dom"],
8
+ "strict": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "experimentalDecorators": true,
12
+ "importHelpers": true,
13
+ "outDir": "dist",
14
+ "sourceMap": true,
15
+ "inlineSources": true,
16
+ "rootDir": "./",
17
+ "declaration": true,
18
+ "incremental": true,
19
+ "types": ["node"]
20
+ },
21
+ "include": ["**/*.ts", "*.d.ts"]
22
+ }