@salla.sa/twilight 1.6.15 → 2.0.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.
Files changed (115) hide show
  1. package/README.md +4 -214
  2. package/components/README.md +55 -0
  3. package/components/dist/cjs/index-9441fd8e.js +1554 -0
  4. package/components/dist/cjs/index.cjs.js +2 -0
  5. package/components/dist/cjs/loader.cjs.js +21 -0
  6. package/components/dist/cjs/salla-login_2.cjs.entry.js +131 -0
  7. package/components/dist/cjs/twilight-components.cjs.js +19 -0
  8. package/components/dist/collection/collection-manifest.json +13 -0
  9. package/components/dist/collection/components/generate-summary.js +35 -0
  10. package/components/dist/collection/components/salla-login/salla-login.css +104 -0
  11. package/components/dist/collection/components/salla-login/salla-login.js +113 -0
  12. package/components/dist/collection/components/search-modal/search-modal.css +9 -0
  13. package/components/dist/collection/components/search-modal/search-modal.js +161 -0
  14. package/components/dist/collection/index.js +1 -0
  15. package/components/dist/collection/interfaces/colors.js +1 -0
  16. package/components/dist/collection/interfaces/index.js +2 -0
  17. package/components/dist/collection/interfaces/ratio.js +1 -0
  18. package/components/dist/collection/plugins/tailwind-theme/index.js +32 -0
  19. package/components/dist/collection/plugins/tailwind-theme/scripts/generator.js +51 -0
  20. package/components/dist/collection/utils/utils.js +16 -0
  21. package/components/dist/esm/index-63e5409f.js +1527 -0
  22. package/components/dist/esm/index.js +1 -0
  23. package/components/dist/esm/loader.js +17 -0
  24. package/components/dist/esm/polyfills/core-js.js +11 -0
  25. package/components/dist/esm/polyfills/css-shim.js +1 -0
  26. package/components/dist/esm/polyfills/dom.js +79 -0
  27. package/components/dist/esm/polyfills/es5-html-element.js +1 -0
  28. package/components/dist/esm/polyfills/index.js +34 -0
  29. package/components/dist/esm/polyfills/system.js +6 -0
  30. package/components/dist/esm/salla-login_2.entry.js +126 -0
  31. package/components/dist/esm/twilight-components.js +17 -0
  32. package/components/dist/index.cjs.js +1 -0
  33. package/components/dist/index.js +1 -0
  34. package/components/dist/twilight-components/index.esm.js +0 -0
  35. package/components/dist/twilight-components/p-3d53781c.js +1 -0
  36. package/components/dist/twilight-components/p-fccb89fa.entry.js +1 -0
  37. package/components/dist/twilight-components/twilight-components.esm.js +1 -0
  38. package/components/dist/types/components/salla-login/salla-login.d.ts +14 -0
  39. package/components/dist/types/components/search-modal/search-modal.d.ts +26 -0
  40. package/components/dist/types/components.d.ts +76 -0
  41. package/components/dist/types/index.d.ts +6 -0
  42. package/components/dist/types/interfaces/colors.d.ts +1 -0
  43. package/components/dist/types/interfaces/index.d.ts +2 -0
  44. package/components/dist/types/interfaces/ratio.d.ts +1 -0
  45. package/components/dist/types/stencil-public-runtime.d.ts +1563 -0
  46. package/components/dist/types/utils/utils.d.ts +6 -0
  47. package/components/loader/cdn.js +3 -0
  48. package/components/loader/index.cjs.js +3 -0
  49. package/components/loader/index.d.ts +13 -0
  50. package/components/loader/index.es2017.js +3 -0
  51. package/components/loader/index.js +4 -0
  52. package/components/loader/package.json +10 -0
  53. package/components/package.json +70 -0
  54. package/components/src/plugins/tailwind-theme/index.js +32 -0
  55. package/components/src/plugins/tailwind-theme/package.json +27 -0
  56. package/components/src/plugins/tailwind-theme/readme.md +47 -0
  57. package/components/src/plugins/tailwind-theme/safe-list-css.txt +19 -0
  58. package/components/src/plugins/tailwind-theme/utilities.json +1 -0
  59. package/components.js +1 -0
  60. package/dist/twilight.js +2 -0
  61. package/dist/twilight.js.LICENSE.txt +27 -0
  62. package/package.json +53 -63
  63. package/postInstall.js +2 -0
  64. package/tailwind.js +1 -0
  65. package/tailwind_css_list.js +1 -0
  66. package/watcher.js +20 -62
  67. package/LICENSE.md +0 -674
  68. package/dist/@salla.sa/twilight.min.js +0 -20
  69. package/dist/@salla.sa/twilight.min.js.map +0 -1
  70. package/dist/cjs/index.js +0 -2
  71. package/dist/cjs/index.js.map +0 -1
  72. package/dist/esm/index.js +0 -2
  73. package/dist/esm/index.js.map +0 -1
  74. package/types/actions.d.ts +0 -47
  75. package/types/api/auth/index.d.ts +0 -17
  76. package/types/api/auth/request.d.ts +0 -42
  77. package/types/api/auth/response.d.ts +0 -22
  78. package/types/api/cart/index.d.ts +0 -24
  79. package/types/api/cart/request.d.ts +0 -8
  80. package/types/api/cart/response.d.ts +0 -66
  81. package/types/api/comment.d.ts +0 -18
  82. package/types/api/currency.d.ts +0 -17
  83. package/types/api/document.d.ts +0 -3
  84. package/types/api/index.d.ts +0 -110
  85. package/types/api/loyalty.d.ts +0 -226
  86. package/types/api/order.d.ts +0 -15
  87. package/types/api/product/index.d.ts +0 -17
  88. package/types/api/product/request.d.ts +0 -53
  89. package/types/api/product/response.d.ts +0 -103
  90. package/types/api/profile.d.ts +0 -60
  91. package/types/api/rating.d.ts +0 -49
  92. package/types/api/scope.d.ts +0 -42
  93. package/types/api/wishlist.d.ts +0 -7
  94. package/types/common.d.ts +0 -75
  95. package/types/event/auth.d.ts +0 -18
  96. package/types/event/cart.d.ts +0 -30
  97. package/types/event/comment.d.ts +0 -7
  98. package/types/event/currency.d.ts +0 -9
  99. package/types/event/document.d.ts +0 -29
  100. package/types/event/index.d.ts +0 -48
  101. package/types/event/infiniteScroll.d.ts +0 -12
  102. package/types/event/loyalty.d.ts +0 -14
  103. package/types/event/order.d.ts +0 -11
  104. package/types/event/product.d.ts +0 -30
  105. package/types/event/profile.d.ts +0 -19
  106. package/types/event/rating.d.ts +0 -13
  107. package/types/event/scope.d.ts +0 -15
  108. package/types/event/wishlist.d.ts +0 -8
  109. package/types/helpers/app-helpers.d.ts +0 -29
  110. package/types/index.d.ts +0 -37
  111. package/types/lib/config.ts +0 -14
  112. package/types/lib/form.d.ts +0 -8
  113. package/types/lib/lang.d.ts +0 -14
  114. package/types/lib/notify.d.ts +0 -14
  115. package/types/tiwlight-config.d.ts +0 -74
package/package.json CHANGED
@@ -1,65 +1,55 @@
1
1
  {
2
- "name": "@salla.sa/twilight",
3
- "version": "1.6.15",
4
- "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
- "main": "dist/cjs",
6
- "module": "dist/esm",
7
- "types": "types/index.d.ts",
8
- "scripts": {
9
- "build": "npx rollup --config --preserveSymlinks=true",
10
- "watch": "npx rollup --watch --config --preserveSymlinks=true"
11
- },
12
- "keywords": [
13
- "salla",
14
- "theme",
15
- "utils",
16
- "events",
17
- "requests"
18
- ],
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/SallaApp/twilight.git"
22
- },
23
- "author": "Salla.sa",
24
- "license": "MIT",
25
- "files": [
26
- "dist",
27
- "types",
28
- "watcher.js",
29
- "package.json",
30
- "postInstall.js"
31
- ],
32
- "homepage": "https://salla.dev",
33
- "dependencies": {
34
- "@salla.sa/base": "^1.6.15",
35
- "@salla.sa/twilight-tailwind-theme": "^1.6.15",
36
- "axios": "^0.27.2",
37
- "infinite-scroll": "^4.0.1",
38
- "jwt-decode": "^3.1.2",
39
- "lang.js": "^1.1.14",
40
- "websocket": "^1.0.34"
41
- },
42
- "devDependencies": {
43
- "@babel/core": "^7.18.10",
44
- "@babel/preset-env": "^7.18.10",
45
- "@rollup/plugin-babel": "^5.3.1",
46
- "@rollup/plugin-commonjs": "^22.0.2",
47
- "@rollup/plugin-node-resolve": "^13.1.3",
48
- "babel-loader": "^8.2.5",
49
- "rollup-plugin-analyzer": "^4.0.0",
50
- "rollup-plugin-cleaner": "^1.0.0",
51
- "rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22",
52
- "rollup-plugin-node-polyfills": "^0.2.1",
53
- "rollup-plugin-serve": "^2.0.1",
54
- "rollup-plugin-terser": "^7.0.2",
55
- "rollup-plugin-version-injector": "^1.3.3",
56
- "rollup-plugin-watch": "^1.0.1",
57
- "webpack": "^5.74.0",
58
- "webpack-build-notifier": "^2.3.0",
59
- "webpack-cli": "^4.10.0"
60
- },
61
- "peerDependencies": {
62
- "webpack": "^4 || ^5"
63
- },
64
- "gitHead": "4785838b20f24f09a8ce69951dd26fb159800d1b"
2
+ "name": "@salla.sa/twilight",
3
+ "version": "2.0.0",
4
+ "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
+ "main": "dist/twilight.js",
6
+ "scripts": {
7
+ "prod": "webpack --mode production",
8
+ "watch": "webpack --mode development --watch",
9
+ "postinstall": "node ./postInstall.js"
10
+ },
11
+ "keywords": [
12
+ "salla",
13
+ "theme",
14
+ "utils",
15
+ "events",
16
+ "requests"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/SallaApp/twilight-js.git"
21
+ },
22
+ "author": "Salla.sa",
23
+ "license": "MIT",
24
+ "files": [
25
+ "dist",
26
+ "watcher.js",
27
+ "tailwind.js",
28
+ "package.json",
29
+ "components.js",
30
+ "postInstall.js",
31
+ "components/dist",
32
+ "components/loader",
33
+ "tailwind_css_list.js"
34
+ ],
35
+ "homepage": "https://salla.dev",
36
+ "dependencies": {
37
+ "@salla.sa/applepay": "~1.0",
38
+ "axios": "^0.23.0",
39
+ "eventemitter2": "^6.4.5",
40
+ "infinite-scroll": "^4.0.1",
41
+ "lang.js": "^1.1.14",
42
+ "store": "^2.0.12"
43
+ },
44
+ "devDependencies": {
45
+ "@babel/core": "^7.16.0",
46
+ "babel-loader": "^8.2.3",
47
+ "glob": "^7.2.0",
48
+ "webpack": "^5.64.2",
49
+ "webpack-build-notifier": "^2.3.0",
50
+ "webpack-cli": "^4.9.1"
51
+ },
52
+ "peerDependencies": {
53
+ "webpack": "^4 || ^5"
54
+ }
65
55
  }
package/postInstall.js ADDED
@@ -0,0 +1,2 @@
1
+ const version = process.env.npm_package_version;
2
+ console.log(`Salla Twilight =>  ${version}`)
package/tailwind.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./components/src/plugins/tailwind-theme/index.js');
@@ -0,0 +1 @@
1
+ module.exports = require('path').resolve(__dirname, 'components/src/plugins/tailwind-theme/safe-list-css.txt');
package/watcher.js CHANGED
@@ -2,8 +2,6 @@ const path = require('path');
2
2
  const glob = require("glob");
3
3
  const color = {normal: "\x1b[0m", red: "\x1b[31m", green: "\x1b[32m", yellow: "\x1b[33m", cyan: "\x1b[36m",}
4
4
  const {execSync} = require("child_process");
5
- const fs = require("fs");
6
- const WebSocketClient = require('websocket').client;
7
5
  //const webpack = require("webpack");
8
6
  /**
9
7
  * @callback HookCallback
@@ -50,26 +48,10 @@ const WebSocketClient = require('websocket').client;
50
48
  * @property {boolean} isWin
51
49
  */
52
50
  class WatcherPlugin {
53
- constructor(params = {}) {
54
- try{
55
- if(!params.theme_id){
56
- // this is another way to get params from cli
57
- let cachePath = path.join(process.cwd(), "/node_modules/.salla-cli");
58
- if(fs.existsSync(cachePath)) params = JSON.parse(fs.readFileSync(cachePath, 'utf8'));
59
- }
60
- }catch(err){}
61
-
62
- let {wsport = 8001, sallaCli = "salla", theme_id, upload_url, store_id, draft_id} = params;
63
-
64
- this.sallaCli = sallaCli;
65
- this.theme_id = theme_id;
66
- this.upload_url = upload_url;
67
- this.store_id = store_id;
68
- this.draft_id = draft_id;
69
- this.wsport = wsport;
70
- this.files = {};
51
+ constructor(sallaCli = 'salla') {
52
+ this.sallaCli = sallaCli;
71
53
  }
72
-
54
+
73
55
  /**
74
56
  * @param {Compiler} compiler
75
57
  */
@@ -83,19 +65,9 @@ class WatcherPlugin {
83
65
 
84
66
  console.log(color.green, '✓ Listening to webpack watch.', color.normal);
85
67
  this.addFilesToWatcher(compiler);
86
- this.connectToWsServer();
87
68
  this.watchingChangedFiles(compiler);
88
- this.afterCompile(compiler);
89
- }
90
-
91
- /**
92
- * @param {Compiler} compiler
93
- */
94
- afterCompile(compiler) {
95
- compiler.hooks.afterCompile.tap('SallaAfterCompilePlugin', (compilation) => {
96
- if(this.connection) this.connection.sendUTF(JSON.stringify({ msg: "reload" }));
97
- });
98
69
  }
70
+
99
71
  /**
100
72
  * @param {Compiler} compiler
101
73
  */
@@ -104,10 +76,8 @@ class WatcherPlugin {
104
76
  let files = this.isWebpack5
105
77
  ? Array.from(compiler_.modifiedFiles || [])
106
78
  : Object.keys(compiler_.watchFileSystem.watcher.mtimes);
107
-
108
- files.map((file) => {
109
- if (file.toLowerCase().endsWith(".twig")) this.addToQ(file);
110
- });
79
+ files.filter(file => file.toLowerCase().endsWith('.twig'))
80
+ .forEach(file => execSync(`${this.sallaCli} theme sync -f "${file}" -t ${this.draftId}`, {stdio: 'inherit'}));
111
81
  }
112
82
  );
113
83
  }
@@ -123,7 +93,7 @@ class WatcherPlugin {
123
93
  }
124
94
 
125
95
  getEntry() {
126
- let viewsPath = path.join(process.cwd(), "src/views");
96
+ let viewsPath = path.join(process.cwd(), "views");
127
97
  return this.isWin && this.isWebpack5
128
98
  ? viewsPath
129
99
  : glob.sync(path.join(viewsPath, "**/*.twig"), {absolute: true});
@@ -134,31 +104,19 @@ class WatcherPlugin {
134
104
  * @return {boolean}
135
105
  */
136
106
  canWatch(options) {
137
- if (!options.watch) return false;
138
- return !!this.theme_id;
139
- }
140
- connectToWsServer(){
141
- // connect to live reload server
142
- let client = new WebSocketClient();
143
- client.on('connectFailed', (error)=> {
144
- console.error('[x] Oops! Hot reload is currently not working. Check the error message for details: ',error.toString());
145
- });
146
-
147
- client.on('connect', (connection)=> {
148
- this.connection = connection;
149
- console.log(color.green, `✓ Performing hot reload on port ws://localhost:${this.wsport}`, color.normal);
150
- });
151
- client.connect(`ws://localhost:${this.wsport}`, 'echo-protocol');
152
- }
153
- addToQ(file) {
154
- if (this.files[file]) clearTimeout(this.files[file]);
155
- this.files[file] = setTimeout(() => {
156
- execSync(
157
- `${this.sallaCli} theme sync -f "${file}" -id ${this.theme_id} -store_id ${this.store_id} -draft_id ${this.draft_id} -upload_url ${this.upload_url}`,
158
- { stdio: "inherit" }
159
- );
160
- delete this.files[file];
161
- }, 700);
107
+ if (options.mode !== 'development' || !options.watch) {
108
+ console.log(color.green, `✓ Skipping Watching Theme files in production.`, color.normal);
109
+ return false;
110
+ }
111
+ //if theme id not existed go out
112
+ try {
113
+ this.draftId = require(path.resolve(process.cwd(), 'theme.json')).draft_id
114
+ return !!this.draftId;
115
+ } catch (e) {
116
+ let command = color.cyan + this.sallaCli + ' theme watch' + color.red
117
+ console.log(color.red, `X Theme files won't sync! if you want to sync them, run: ${command}`, color.normal);
118
+ return false;
119
+ }
162
120
  }
163
121
  }
164
122