@salla.sa/twilight-bundles 0.1.1 ā 0.1.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/bin/tw-init.js +288 -0
- package/package.json +8 -7
- package/dist/twilight-bundles.cjs +0 -23
- package/dist/twilight-bundles.js +0 -707
- package/dist/vite-plugins/build.cjs +0 -1
- package/dist/vite-plugins/build.js +0 -46
- package/dist/vite-plugins/demo.cjs +0 -1560
- package/dist/vite-plugins/demo.js +0 -1678
- package/dist/vite-plugins/index.cjs +0 -1
- package/dist/vite-plugins/index.js +0 -8
- package/dist/vite-plugins/transform.cjs +0 -2
- package/dist/vite-plugins/transform.js +0 -22
- package/scripts/dev.js +0 -63
- package/scripts/preinstall.js +0 -5
- package/src/components/salla-base-component.ts +0 -25
- package/src/components/salla-custom-component.ts +0 -12
- package/src/helpers/helpers.ts +0 -65
- package/src/index.ts +0 -127
- package/src/vite-plugins/build.ts +0 -68
- package/src/vite-plugins/demo/index.ts +0 -161
- package/src/vite-plugins/demo/template.ts +0 -1620
- package/src/vite-plugins/transform.ts +0 -32
- package/tsconfig.json +0 -26
- package/types/global.d.ts +0 -18
- package/types/vite-plugin.d.ts +0 -34
- package/vite-plugins.d.ts +0 -13
- package/vite-plugins.ts +0 -14
- package/vite.config.ts +0 -49
package/bin/tw-init.js
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { execSync } from 'child_process';
|
|
6
|
+
import readline from 'readline';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check if the twilight-bundles.json file exists in the current directory
|
|
10
|
+
* @param {string} projectRoot - The project root directory
|
|
11
|
+
* @returns {boolean} - True if the file exists
|
|
12
|
+
*/
|
|
13
|
+
function twilightBundlesExists(projectRoot) {
|
|
14
|
+
const bundlePath = path.join(projectRoot, 'twilight-bundle.json');
|
|
15
|
+
return fs.existsSync(bundlePath);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Check if the starter-kit package is installed
|
|
20
|
+
* @param {string} projectRoot - The project root directory
|
|
21
|
+
* @returns {boolean} - True if the package is installed
|
|
22
|
+
*/
|
|
23
|
+
function starterKitInstalled(projectRoot) {
|
|
24
|
+
try {
|
|
25
|
+
// Check if the package is in node_modules
|
|
26
|
+
const nodeModulesPath = path.join(projectRoot, 'node_modules', '@salla.sa', 'twilight-bundles-starter-kit');
|
|
27
|
+
return fs.existsSync(nodeModulesPath);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Install the starter-kit package
|
|
35
|
+
* @param {string} projectRoot - The project root directory
|
|
36
|
+
* @returns {boolean} - True if installation was successful
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Install the starter-kit package
|
|
40
|
+
* @param {string} projectRoot - The project root directory
|
|
41
|
+
* @returns {Promise<boolean>} - Promise resolving to true if installation was successful
|
|
42
|
+
*/
|
|
43
|
+
function installStarterKit(projectRoot) {
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
try {
|
|
46
|
+
console.log('š¦ Installing @salla.sa/twilight-bundles-starter-kit...');
|
|
47
|
+
|
|
48
|
+
// Check if pnpm exists on the system
|
|
49
|
+
try {
|
|
50
|
+
execSync('pnpm --version', { stdio: 'ignore' });
|
|
51
|
+
console.log('š¦ Using pnpm as package manager');
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error('ā pnpm is required but not installed');
|
|
54
|
+
console.log('Please install pnpm globally using: npm install -g pnpm');
|
|
55
|
+
resolve(false);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Install the package using pnpm
|
|
60
|
+
const installCommand = 'pnpm add @salla.sa/twilight-bundles-starter-kit@latest';
|
|
61
|
+
|
|
62
|
+
console.log(`š¦ Running: ${installCommand}`);
|
|
63
|
+
console.log('ā ļø This may take a moment...');
|
|
64
|
+
|
|
65
|
+
// Ask for confirmation before running the command
|
|
66
|
+
const rl = readline.createInterface({
|
|
67
|
+
input: process.stdin,
|
|
68
|
+
output: process.stdout
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
rl.question('Do you want to continue with the installation? (y/n): ', (answer) => {
|
|
72
|
+
rl.close();
|
|
73
|
+
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
74
|
+
try {
|
|
75
|
+
execSync(installCommand, { stdio: 'inherit', cwd: projectRoot });
|
|
76
|
+
console.log('ā
@salla.sa/twilight-bundles-starter-kit installed successfully');
|
|
77
|
+
resolve(true);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error('ā Failed to install @salla.sa/twilight-bundles-starter-kit:', error.message);
|
|
80
|
+
resolve(false);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
console.log('ā Installation cancelled');
|
|
84
|
+
process.exit(0);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error('ā Failed to install @salla.sa/twilight-bundles-starter-kit:', error.message);
|
|
89
|
+
resolve(false);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Copy files from starter-kit to the target directory
|
|
96
|
+
* @param {string} projectRoot - The project root directory
|
|
97
|
+
* @returns {boolean} - True if copy was successful
|
|
98
|
+
*/
|
|
99
|
+
function copyStarterKitFiles(projectRoot) {
|
|
100
|
+
try {
|
|
101
|
+
console.log('š Copying starter-kit files to your project...');
|
|
102
|
+
|
|
103
|
+
// Get the path to the starter-kit package
|
|
104
|
+
const starterKitPath = path.join(projectRoot, 'node_modules', '@salla.sa', 'twilight-bundles-starter-kit');
|
|
105
|
+
|
|
106
|
+
// Files and directories to copy
|
|
107
|
+
const itemsToCopy = [
|
|
108
|
+
'src',
|
|
109
|
+
'tsconfig.json',
|
|
110
|
+
'twilight-bundle.json',
|
|
111
|
+
'vite.config.ts',
|
|
112
|
+
'README.md'
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
// Copy each item
|
|
116
|
+
for (const item of itemsToCopy) {
|
|
117
|
+
const sourcePath = path.join(starterKitPath, item);
|
|
118
|
+
const targetPath = path.join(projectRoot, item);
|
|
119
|
+
|
|
120
|
+
// Skip if target already exists
|
|
121
|
+
if (fs.existsSync(targetPath)) {
|
|
122
|
+
console.log(`ā ļø ${item} already exists, skipping...`);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Copy directory recursively
|
|
127
|
+
if (fs.statSync(sourcePath).isDirectory()) {
|
|
128
|
+
copyDirectoryRecursive(sourcePath, targetPath);
|
|
129
|
+
} else {
|
|
130
|
+
// Copy file
|
|
131
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
console.log(`ā
Copied ${item}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return true;
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error('ā Failed to copy starter-kit files:', error.message);
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Copy a directory recursively
|
|
146
|
+
* @param {string} source - Source directory
|
|
147
|
+
* @param {string} target - Target directory
|
|
148
|
+
*/
|
|
149
|
+
function copyDirectoryRecursive(source, target) {
|
|
150
|
+
// Create target directory if it doesn't exist
|
|
151
|
+
if (!fs.existsSync(target)) {
|
|
152
|
+
fs.mkdirSync(target, { recursive: true });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Get all items in the source directory
|
|
156
|
+
const items = fs.readdirSync(source);
|
|
157
|
+
|
|
158
|
+
// Copy each item
|
|
159
|
+
for (const item of items) {
|
|
160
|
+
const sourcePath = path.join(source, item);
|
|
161
|
+
const targetPath = path.join(target, item);
|
|
162
|
+
|
|
163
|
+
// Copy directory recursively or file directly
|
|
164
|
+
if (fs.statSync(sourcePath).isDirectory()) {
|
|
165
|
+
copyDirectoryRecursive(sourcePath, targetPath);
|
|
166
|
+
} else {
|
|
167
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Merge package.json from starter-kit with the current package.json
|
|
174
|
+
* @param {string} projectRoot - The project root directory
|
|
175
|
+
* @returns {boolean} - True if merge was successful
|
|
176
|
+
*/
|
|
177
|
+
function mergePackageJson(projectRoot) {
|
|
178
|
+
try {
|
|
179
|
+
console.log('š Merging package.json...');
|
|
180
|
+
|
|
181
|
+
// Get the path to the starter-kit package.json
|
|
182
|
+
const starterKitPackageJsonPath = path.join(
|
|
183
|
+
projectRoot,
|
|
184
|
+
'node_modules',
|
|
185
|
+
'@salla.sa',
|
|
186
|
+
'twilight-bundles-starter-kit',
|
|
187
|
+
'package.json'
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
// Get the path to the current package.json
|
|
191
|
+
const currentPackageJsonPath = path.join(projectRoot, 'package.json');
|
|
192
|
+
|
|
193
|
+
// Read the package.json files
|
|
194
|
+
const starterKitPackageJson = JSON.parse(fs.readFileSync(starterKitPackageJsonPath, 'utf8'));
|
|
195
|
+
const currentPackageJson = JSON.parse(fs.readFileSync(currentPackageJsonPath, 'utf8'));
|
|
196
|
+
|
|
197
|
+
// Merge the package.json files
|
|
198
|
+
const mergedPackageJson = {
|
|
199
|
+
...currentPackageJson,
|
|
200
|
+
scripts: {
|
|
201
|
+
...starterKitPackageJson.scripts,
|
|
202
|
+
...currentPackageJson.scripts
|
|
203
|
+
},
|
|
204
|
+
dependencies: {
|
|
205
|
+
...currentPackageJson.dependencies,
|
|
206
|
+
'lit': starterKitPackageJson.dependencies.lit || '^3.2.1',
|
|
207
|
+
'@salla.sa/twilight-bundles': starterKitPackageJson.dependencies['@salla.sa/twilight-bundles'] || '^0.1.1'
|
|
208
|
+
},
|
|
209
|
+
devDependencies: {
|
|
210
|
+
...starterKitPackageJson.devDependencies,
|
|
211
|
+
...currentPackageJson.devDependencies
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// Write the merged package.json
|
|
216
|
+
fs.writeFileSync(
|
|
217
|
+
currentPackageJsonPath,
|
|
218
|
+
JSON.stringify(mergedPackageJson, null, 2)
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
console.log('ā
package.json merged successfully');
|
|
222
|
+
return true;
|
|
223
|
+
} catch (error) {
|
|
224
|
+
console.error('ā Failed to merge package.json:', error.message);
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Initialize a new Twilight Bundles project
|
|
231
|
+
* @param {string} [projectRootArg] - Optional project root directory
|
|
232
|
+
*/
|
|
233
|
+
async function initTwilightBundles(projectRootArg) {
|
|
234
|
+
// Get project root from arguments or default to current directory
|
|
235
|
+
const projectRoot = projectRootArg || process.cwd();
|
|
236
|
+
|
|
237
|
+
console.log('š Initializing Salla Twilight Bundles Project š\n');
|
|
238
|
+
|
|
239
|
+
// Check if twilight-bundle.json already exists
|
|
240
|
+
if (twilightBundlesExists(projectRoot)) {
|
|
241
|
+
console.log('ā ļø This directory already contains a Twilight Bundles project (twilight-bundle.json exists)');
|
|
242
|
+
console.log('If you want to start a new project, please create a new directory and run this command again.');
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Check if starter-kit is installed
|
|
247
|
+
let starterKitReady = starterKitInstalled(projectRoot);
|
|
248
|
+
|
|
249
|
+
// Install starter-kit if not installed
|
|
250
|
+
if (!starterKitReady) {
|
|
251
|
+
starterKitReady = await installStarterKit(projectRoot);
|
|
252
|
+
if (!starterKitReady) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Copy starter-kit files
|
|
258
|
+
if (!copyStarterKitFiles(projectRoot)) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Merge package.json
|
|
263
|
+
if (!mergePackageJson(projectRoot)) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
console.log('\nš Twilight Bundles project initialized successfully!\n');
|
|
268
|
+
console.log('Next steps:');
|
|
269
|
+
console.log('1. Run "pnpm install" to install dependencies');
|
|
270
|
+
console.log('2. Run "pnpm run dev" to start the development server');
|
|
271
|
+
console.log('3. Create new components using "pnpm run create-component <component-name>"');
|
|
272
|
+
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Parse command-line arguments and run the script
|
|
277
|
+
const args = process.argv.slice(2);
|
|
278
|
+
const projectRoot = args[0] || process.cwd(); // First argument is the project root, default to current directory
|
|
279
|
+
|
|
280
|
+
// Run the script with the parsed arguments
|
|
281
|
+
(async () => {
|
|
282
|
+
try {
|
|
283
|
+
await initTwilightBundles(projectRoot);
|
|
284
|
+
} catch (error) {
|
|
285
|
+
console.error('\nā An unexpected error occurred:', error.message);
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salla.sa/twilight-bundles",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "SDK for Salla Twilight Bundles - Develop and build custom components for Salla platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/twilight-bundles.js",
|
|
7
7
|
"module": "./dist/twilight-bundles.js",
|
|
8
8
|
"bin": {
|
|
9
|
-
"tw-component": "./bin/tw-component.js"
|
|
9
|
+
"tw-component": "./bin/tw-component.js",
|
|
10
|
+
"tw-init": "./bin/tw-init.js"
|
|
10
11
|
},
|
|
11
12
|
"exports": {
|
|
12
13
|
".": {
|
|
@@ -37,21 +38,21 @@
|
|
|
37
38
|
],
|
|
38
39
|
"author": "Salla",
|
|
39
40
|
"license": "MIT",
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"registry": "https://registry.npmjs.org/"
|
|
44
|
+
},
|
|
40
45
|
"dependencies": {
|
|
41
46
|
"glob": "^11.0.1",
|
|
42
47
|
"lit": "^3.1.0",
|
|
43
48
|
"uuid": "^11.1.0"
|
|
44
49
|
},
|
|
45
|
-
"peerDependencies": {
|
|
46
|
-
"systemjs": "^6.14.2"
|
|
47
|
-
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@types/node": "^20.17.16",
|
|
50
52
|
"@types/systemjs": "^6.15.1",
|
|
51
53
|
"esbuild": "^0.25.0",
|
|
52
|
-
"systemjs": "^6.14.2",
|
|
53
54
|
"typescript": "^5.7.3",
|
|
54
|
-
"vite": "^6.1.
|
|
55
|
+
"vite": "^6.1.6"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"preinstall": "node scripts/preinstall.js",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const H=globalThis,V=H.ShadowRoot&&(H.ShadyCSS===void 0||H.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,q=Symbol(),F=new WeakMap;let rt=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==q)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(V&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=F.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&F.set(e,t))}return t}toString(){return this.cssText}};const dt=n=>new rt(typeof n=="string"?n:n+"",void 0,q),ut=(n,...t)=>{const e=n.length===1?n[0]:t.reduce((s,i,r)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+n[r+1],n[0]);return new rt(e,n,q)},pt=(n,t)=>{if(V)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=H.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,n.appendChild(s)}},G=V?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return dt(e)})(n):n;/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright 2017 Google LLC
|
|
8
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const{is:mt,defineProperty:$t,getOwnPropertyDescriptor:ft,getOwnPropertyNames:gt,getOwnPropertySymbols:_t,getPrototypeOf:yt}=Object,f=globalThis,Q=f.trustedTypes,At=Q?Q.emptyScript:"",L=f.reactiveElementPolyfillSupport,C=(n,t)=>n,N={toAttribute(n,t){switch(t){case Boolean:n=n?At:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},J=(n,t)=>!mt(n,t),X={attribute:!0,type:String,converter:N,reflect:!1,hasChanged:J};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),f.litPropertyMetadata??(f.litPropertyMetadata=new WeakMap);class v extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=X){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&$t(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:r}=ft(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return i==null?void 0:i.call(this)},set(o){const l=i==null?void 0:i.call(this);r.call(this,o),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??X}static _$Ei(){if(this.hasOwnProperty(C("elementProperties")))return;const t=yt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(C("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(C("properties"))){const e=this.properties,s=[...gt(e),..._t(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(G(i))}else t!==void 0&&e.push(G(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return pt(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostConnected)==null?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostDisconnected)==null?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){var r;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((r=s.converter)==null?void 0:r.toAttribute)!==void 0?s.converter:N).toAttribute(e,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){var r;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const o=s.getPropertyOptions(i),l=typeof o.converter=="function"?{fromAttribute:o.converter}:((r=o.converter)==null?void 0:r.fromAttribute)!==void 0?o.converter:N;this._$Em=i,this[i]=l.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){if(s??(s=this.constructor.getPropertyOptions(t)),!(s.hasChanged??J)(this[t],e))return;this.P(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),s.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,o]of i)o.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],o)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(s=this._$EO)==null||s.forEach(i=>{var r;return(r=i.hostUpdate)==null?void 0:r.call(i)}),this.update(e)):this._$EU()}catch(i){throw t=!1,this._$EU(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}}v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[C("elementProperties")]=new Map,v[C("finalized")]=new Map,L==null||L({ReactiveElement:v}),(f.reactiveElementVersions??(f.reactiveElementVersions=[])).push("2.0.4");/**
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright 2017 Google LLC
|
|
12
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const P=globalThis,k=P.trustedTypes,Y=k?k.createPolicy("lit-html",{createHTML:n=>n}):void 0,at="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,lt="?"+$,vt=`<${lt}>`,y=document,U=()=>y.createComment(""),x=n=>n===null||typeof n!="object"&&typeof n!="function",K=Array.isArray,St=n=>K(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",j=`[
|
|
14
|
-
\f\r]`,E=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,tt=/-->/g,et=/>/g,g=RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^
|
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),st=/'/g,it=/"/g,ht=/^(?:script|style|textarea|title)$/i,b=Symbol.for("lit-noChange"),d=Symbol.for("lit-nothing"),nt=new WeakMap,_=y.createTreeWalker(y,129);function ct(n,t){if(!K(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Y!==void 0?Y.createHTML(t):t}const bt=(n,t)=>{const e=n.length-1,s=[];let i,r=t===2?"<svg>":t===3?"<math>":"",o=E;for(let l=0;l<e;l++){const a=n[l];let c,u,h=-1,p=0;for(;p<a.length&&(o.lastIndex=p,u=o.exec(a),u!==null);)p=o.lastIndex,o===E?u[1]==="!--"?o=tt:u[1]!==void 0?o=et:u[2]!==void 0?(ht.test(u[2])&&(i=RegExp("</"+u[2],"g")),o=g):u[3]!==void 0&&(o=g):o===g?u[0]===">"?(o=i??E,h=-1):u[1]===void 0?h=-2:(h=o.lastIndex-u[2].length,c=u[1],o=u[3]===void 0?g:u[3]==='"'?it:st):o===it||o===st?o=g:o===tt||o===et?o=E:(o=g,i=void 0);const m=o===g&&n[l+1].startsWith("/>")?" ":"";r+=o===E?a+vt:h>=0?(s.push(c),a.slice(0,h)+at+a.slice(h)+$+m):a+$+(h===-2?l:m)}return[ct(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class R{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let r=0,o=0;const l=t.length-1,a=this.parts,[c,u]=bt(t,e);if(this.el=R.createElement(c,s),_.currentNode=this.el.content,e===2||e===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(i=_.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const h of i.getAttributeNames())if(h.endsWith(at)){const p=u[o++],m=i.getAttribute(h).split($),O=/([.?@])?(.*)/.exec(p);a.push({type:1,index:r,name:O[2],strings:m,ctor:O[1]==="."?Et:O[1]==="?"?Ct:O[1]==="@"?Pt:D}),i.removeAttribute(h)}else h.startsWith($)&&(a.push({type:6,index:r}),i.removeAttribute(h));if(ht.test(i.tagName)){const h=i.textContent.split($),p=h.length-1;if(p>0){i.textContent=k?k.emptyScript:"";for(let m=0;m<p;m++)i.append(h[m],U()),_.nextNode(),a.push({type:2,index:++r});i.append(h[p],U())}}}else if(i.nodeType===8)if(i.data===lt)a.push({type:2,index:r});else{let h=-1;for(;(h=i.data.indexOf($,h+1))!==-1;)a.push({type:7,index:r}),h+=$.length-1}r++}}static createElement(t,e){const s=y.createElement("template");return s.innerHTML=t,s}}function w(n,t,e=n,s){var o,l;if(t===b)return t;let i=s!==void 0?(o=e._$Co)==null?void 0:o[s]:e._$Cl;const r=x(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==r&&((l=i==null?void 0:i._$AO)==null||l.call(i,!1),r===void 0?i=void 0:(i=new r(n),i._$AT(n,e,s)),s!==void 0?(e._$Co??(e._$Co=[]))[s]=i:e._$Cl=i),i!==void 0&&(t=w(n,i._$AS(n,t.values),i,s)),t}class wt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??y).importNode(e,!0);_.currentNode=i;let r=_.nextNode(),o=0,l=0,a=s[0];for(;a!==void 0;){if(o===a.index){let c;a.type===2?c=new M(r,r.nextSibling,this,t):a.type===1?c=new a.ctor(r,a.name,a.strings,this,t):a.type===6&&(c=new Tt(r,this,t)),this._$AV.push(c),a=s[++l]}o!==(a==null?void 0:a.index)&&(r=_.nextNode(),o++)}return _.currentNode=y,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class M{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=d,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=w(this,t,e),x(t)?t===d||t==null||t===""?(this._$AH!==d&&this._$AR(),this._$AH=d):t!==this._$AH&&t!==b&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):St(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==d&&x(this._$AH)?this._$AA.nextSibling.data=t:this.T(y.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=R.createElement(ct(s.h,s.h[0]),this.options)),s);if(((r=this._$AH)==null?void 0:r._$AD)===i)this._$AH.p(e);else{const o=new wt(i,this),l=o.u(this.options);o.p(e),this.T(l),this._$AH=o}}_$AC(t){let e=nt.get(t.strings);return e===void 0&&nt.set(t.strings,e=new R(t)),e}k(t){K(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const r of t)i===e.length?e.push(s=new M(this.O(U()),this.O(U()),this,this.options)):s=e[i],s._$AI(r),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}}class D{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,r){this.type=1,this._$AH=d,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=d}_$AI(t,e=this,s,i){const r=this.strings;let o=!1;if(r===void 0)t=w(this,t,e,0),o=!x(t)||t!==this._$AH&&t!==b,o&&(this._$AH=t);else{const l=t;let a,c;for(t=r[0],a=0;a<r.length-1;a++)c=w(this,l[s+a],e,a),c===b&&(c=this._$AH[a]),o||(o=!x(c)||c!==this._$AH[a]),c===d?t=d:t!==d&&(t+=(c??"")+r[a+1]),this._$AH[a]=c}o&&!i&&this.j(t)}j(t){t===d?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Et extends D{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===d?void 0:t}}class Ct extends D{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==d)}}class Pt extends D{constructor(t,e,s,i,r){super(t,e,s,i,r),this.type=5}_$AI(t,e=this){if((t=w(this,t,e,0)??d)===b)return;const s=this._$AH,i=t===d&&s!==d||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==d&&(s===d||i);i&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class Tt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){w(this,t)}}const B=P.litHtmlPolyfillSupport;B==null||B(R,M),(P.litHtmlVersions??(P.litHtmlVersions=[])).push("3.2.1");const Ut=(n,t,e)=>{const s=(e==null?void 0:e.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const r=(e==null?void 0:e.renderBefore)??null;s._$litPart$=i=new M(t.insertBefore(U(),r),r,void 0,e??{})}return i._$AI(n),i};/**
|
|
16
|
-
* @license
|
|
17
|
-
* Copyright 2017 Google LLC
|
|
18
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/let T=class extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Ut(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return b}};var ot;T._$litElement$=!0,T.finalized=!0,(ot=globalThis.litElementHydrateSupport)==null||ot.call(globalThis,{LitElement:T});const W=globalThis.litElementPolyfillSupport;W==null||W({LitElement:T});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
|
|
20
|
-
* @license
|
|
21
|
-
* Copyright 2017 Google LLC
|
|
22
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/const xt={attribute:!0,type:String,converter:N,reflect:!1,hasChanged:J},Rt=(n=xt,t,e)=>{const{kind:s,metadata:i}=e;let r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),r.set(e.name,n),s==="accessor"){const{name:o}=e;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,a,n)},init(l){return l!==void 0&&this.P(o,void 0,n),l}}}if(s==="setter"){const{name:o}=e;return function(l){const a=this[o];t.call(this,l),this.requestUpdate(o,a,n)}}throw Error("Unsupported decorator location: "+s)};function z(n){return(t,e)=>typeof e=="object"?Rt(n,t,e):((s,i,r)=>{const o=i.hasOwnProperty(r);return i.constructor.createProperty(r,o?{...s,wrapped:!0}:s),o?Object.getOwnPropertyDescriptor(i,r):void 0})(n,t,e)}class S{static onBundlesReady(){return S.makeSureSallaIsReady().then(()=>Salla.event.onlyWhen("twilight-bundles::initiated"))}static initializeSalla(){if(Salla.status==="ready"){salla.log("Salla is ready");return}const t=document.currentScript||document.querySelector('script[src*="twilight-bundles.js"]'),e=t==null?void 0:t.hasAttribute("demo-mode"),s=t==null?void 0:t.getAttribute("store-id"),i=JSON.parse((t==null?void 0:t.getAttribute("config"))||"false");return e||i||s?Salla.init(i||{debug:!0,store:{id:s||1510890315}}):Salla.onReady()}static makeSureSallaIsReady(){return window.Salla?Promise.resolve(S.initializeSalla()):new Promise((t,e)=>{let s;const i=setTimeout(()=>{window.clearInterval(s),e(new Error("Timeout: Salla object not found after 10 seconds"))},1e4);s=window.setInterval(()=>{window.Salla&&(window.clearInterval(s),clearTimeout(i),t(S.initializeSalla()))},50)})}}var Mt=Object.defineProperty,I=(n,t,e,s)=>{for(var i=void 0,r=n.length-1,o;r>=0;r--)(o=n[r])&&(i=o(t,e,i)||i);return i&&Mt(t,e,i),i};const Z=class Z extends T{constructor(){super(...arguments),this.key="",this.data={},this.imports={},this.shadowRootMode="open"}createRenderRoot(){return this.shadowRootMode!==!1?this.attachShadow({mode:this.shadowRootMode||"closed"}):this}static register(t){const e={component:this,dynamicTagName:`${t}-${Math.random().toString(36).substring(2,8)}`};return S.onBundlesReady().then(()=>Salla.bundles.registerComponent(t,e))}};Z.styles=ut`:host { display: block; }`;let A=Z;I([z()],A.prototype,"key");I([z()],A.prototype,"data");I([z()],A.prototype,"imports");I([z()],A.prototype,"shadowRootMode");class Ot extends HTMLElement{connectedCallback(){var e;let t=(e=this.getAttribute("component-name"))==null?void 0:e.replace(/^salla-/,"");if(!t)return Salla.error("Component name is required",this),Promise.resolve();this.innerHTML=`<!-- Loading ${t} -->`,this.removeAttribute("component-name"),Salla.bundles.renderCustomComponentDom(`salla-${t}`,this)}}class Ht{constructor(){this.components=new Map,this.pendingComponents=[],this.initialized=!1,Salla.onReady().then(()=>{if(Salla.bundles){Salla.log("TwilightBundles is already initialized");return}this.init(),Salla.bundles=this,Salla.event.emit("twilight-bundles::initiated"),this.registerCustomComponents()})}async init(){this.initialized||(this.initialized=!0)}registerCustomComponents(){var t;HTMLElement.registerSallaComponent=function(e){Salla.bundles.registerComponent(e,{component:this,dynamicTagName:`${e}-${Math.random().toString(36).substring(2,8)}`})},(t=window.customComponents)==null||t.forEach(e=>{const s=document.createElement("script");s.type="module",s.src=e,document.head.appendChild(s)})}renderCustomComponentDom(t,e){salla.log("Rendering custom component",t),e.getAttribute("component-name");const s=this.components.get(t);return s?this.renderDynamicCustomComponentDom(s.dynamicTagName,e):this.pendingComponents.push({tagName:t,component:e})}renderDynamicCustomComponentDom(t,e){const s=document.createElement(t);Array.from(e.attributes).forEach(i=>s.setAttribute(i.name,i.value||"")),e.before(s),e.remove()}registerComponent(t,e){if(this.components.has(t))return console.warn(`Component ${t} is already registered into the this.components map. Skipping.`);if(!e.dynamicTagName)return console.warn(`Component ${t} is missing dynamicTagName. Skipping.`);if(!e.component)return console.warn(`Component ${t} is missing component. Skipping.`);if(window.customElements.get(e.dynamicTagName))return console.warn(`Component ${e.dynamicTagName} is already registered into the window custom elements. Skipping.`);window.customElements.define(e.dynamicTagName,e.component),this.components.set(t,e),Salla.log("Component registered:",e.dynamicTagName);const s=this.pendingComponents.filter(i=>i.tagName===t);s.length&&(s.forEach(i=>{this.renderDynamicCustomComponentDom(e.dynamicTagName,i.component)}),this.pendingComponents=this.pendingComponents.filter(i=>i.tagName!==t),Salla.log("Pending Components rendered:",t,e.dynamicTagName))}}S.makeSureSallaIsReady().then(()=>new Ht).then(()=>window.customElements.get("salla-custom-component")||window.customElements.define("salla-custom-component",Ot));exports.SallaComponent=A;
|