@symbo.ls/create 2.34.20 → 2.34.22

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.
@@ -63,6 +63,9 @@ const prepareContext = async (app, context = {}) => {
63
63
  context.routerOptions = (0, import_router.initRouter)(app, context);
64
64
  context.defaultExtends = [uikit.Box];
65
65
  context.version = import_package.version;
66
+ if (context.sharedLibraries) {
67
+ (0, import_prepare.prepareSharedLibs)(context);
68
+ }
66
69
  if (context.forceDomql3) {
67
70
  for (const key2 in context.components) {
68
71
  if (!key2.includes("smbls.") && context.components.hasOwnProperty(key2)) {
@@ -28,7 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var prepare_exports = {};
30
30
  __export(prepare_exports, {
31
- UIkitWithPrefix: () => UIkitWithPrefix,
32
31
  getCDNUrl: () => getCDNUrl,
33
32
  prepareComponents: () => prepareComponents,
34
33
  prepareDependencies: () => prepareDependencies,
@@ -36,6 +35,7 @@ __export(prepare_exports, {
36
35
  prepareMethods: () => prepareMethods,
37
36
  preparePages: () => preparePages,
38
37
  prepareRequire: () => prepareRequire,
38
+ prepareSharedLibs: () => prepareSharedLibs,
39
39
  prepareState: () => prepareState,
40
40
  prepareUtils: () => prepareUtils,
41
41
  prepareWindow: () => prepareWindow
@@ -79,12 +79,12 @@ const getCDNUrl = (packageName, version = "latest", provider = "skypack") => {
79
79
  const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.skypack;
80
80
  return cdnConfig.formatUrl(packageName, version);
81
81
  };
82
- const UIkitWithPrefix = () => {
82
+ const UIkitWithPrefix = (prefix = "smbls") => {
83
83
  const newObj = {};
84
84
  for (const key in uikit) {
85
85
  if (Object.prototype.hasOwnProperty.call(uikit, key)) {
86
86
  if ((0, import_utils.checkIfKeyIsComponent)(key)) {
87
- newObj[`smbls.${key}`] = uikit[key];
87
+ newObj[`${prefix}.${key}`] = uikit[key];
88
88
  } else {
89
89
  newObj[key] = uikit[key];
90
90
  }
@@ -139,9 +139,14 @@ const prepareDependencies = async ({
139
139
  try {
140
140
  const fallbackUrl = getCDNUrl(dependency, version, "symbols") + random;
141
141
  await utils.loadRemoteScript(fallbackUrl, { document: document2 });
142
- console.log(`Successfully loaded ${dependency} from fallback (symbols.ls)`);
142
+ console.log(
143
+ `Successfully loaded ${dependency} from fallback (symbols.ls)`
144
+ );
143
145
  } catch (fallbackError) {
144
- console.error(`Failed to load ${dependency} from fallback:`, fallbackError);
146
+ console.error(
147
+ `Failed to load ${dependency} from fallback:`,
148
+ fallbackError
149
+ );
145
150
  }
146
151
  }
147
152
  }
@@ -239,3 +244,15 @@ const preparePages = (app, context) => {
239
244
  return pages2;
240
245
  }, pages);
241
246
  };
247
+ const prepareSharedLibs = (context) => {
248
+ const sharedLibraries = context.sharedLibraries;
249
+ for (let i = 0; i < sharedLibraries.length; i++) {
250
+ const sharedLib = sharedLibraries[i];
251
+ if (context.type === "template") {
252
+ (0, import_utils.overwriteShallow)(context.designSystem, sharedLib.designSystem);
253
+ (0, import_utils.deepMerge)(context, sharedLib, ["designSystem"], 1);
254
+ } else {
255
+ (0, import_utils.deepMerge)(context, sharedLib, [], 1);
256
+ }
257
+ }
258
+ };
@@ -35,7 +35,8 @@ import {
35
35
  preparePages,
36
36
  prepareState,
37
37
  prepareUtils,
38
- prepareMethods
38
+ prepareMethods,
39
+ prepareSharedLibs
39
40
  } from "./prepare.js";
40
41
  import { temporaryDomqlHackReverse } from "@symbo.ls/utils";
41
42
  const prepareContext = async (app, context = {}) => {
@@ -59,6 +60,9 @@ const prepareContext = async (app, context = {}) => {
59
60
  context.routerOptions = initRouter(app, context);
60
61
  context.defaultExtends = [uikit.Box];
61
62
  context.version = version;
63
+ if (context.sharedLibraries) {
64
+ prepareSharedLibs(context);
65
+ }
62
66
  if (context.forceDomql3) {
63
67
  for (const key2 in context.components) {
64
68
  if (!key2.includes("smbls.") && context.components.hasOwnProperty(key2)) {
@@ -23,7 +23,8 @@ import {
23
23
  deepClone,
24
24
  merge,
25
25
  checkIfKeyIsComponent,
26
- isDevelopment
26
+ isDevelopment,
27
+ overwriteShallow
27
28
  } from "@domql/utils";
28
29
  import { initEmotion } from "./initEmotion.js";
29
30
  import * as uikit from "@symbo.ls/uikit";
@@ -62,12 +63,12 @@ const getCDNUrl = (packageName, version = "latest", provider = "skypack") => {
62
63
  const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.skypack;
63
64
  return cdnConfig.formatUrl(packageName, version);
64
65
  };
65
- const UIkitWithPrefix = () => {
66
+ const UIkitWithPrefix = (prefix = "smbls") => {
66
67
  const newObj = {};
67
68
  for (const key in uikit) {
68
69
  if (Object.prototype.hasOwnProperty.call(uikit, key)) {
69
70
  if (checkIfKeyIsComponent(key)) {
70
- newObj[`smbls.${key}`] = uikit[key];
71
+ newObj[`${prefix}.${key}`] = uikit[key];
71
72
  } else {
72
73
  newObj[key] = uikit[key];
73
74
  }
@@ -114,9 +115,14 @@ const prepareDependencies = async ({
114
115
  try {
115
116
  const fallbackUrl = getCDNUrl(dependency, version, "symbols") + random;
116
117
  await utils.loadRemoteScript(fallbackUrl, { document: document2 });
117
- console.log(`Successfully loaded ${dependency} from fallback (symbols.ls)`);
118
+ console.log(
119
+ `Successfully loaded ${dependency} from fallback (symbols.ls)`
120
+ );
118
121
  } catch (fallbackError) {
119
- console.error(`Failed to load ${dependency} from fallback:`, fallbackError);
122
+ console.error(
123
+ `Failed to load ${dependency} from fallback:`,
124
+ fallbackError
125
+ );
120
126
  }
121
127
  }
122
128
  }
@@ -214,8 +220,19 @@ const preparePages = (app, context) => {
214
220
  return pages2;
215
221
  }, pages);
216
222
  };
223
+ const prepareSharedLibs = (context) => {
224
+ const sharedLibraries = context.sharedLibraries;
225
+ for (let i = 0; i < sharedLibraries.length; i++) {
226
+ const sharedLib = sharedLibraries[i];
227
+ if (context.type === "template") {
228
+ overwriteShallow(context.designSystem, sharedLib.designSystem);
229
+ deepMerge(context, sharedLib, ["designSystem"], 1);
230
+ } else {
231
+ deepMerge(context, sharedLib, [], 1);
232
+ }
233
+ }
234
+ };
217
235
  export {
218
- UIkitWithPrefix,
219
236
  getCDNUrl,
220
237
  prepareComponents,
221
238
  prepareDependencies,
@@ -223,6 +240,7 @@ export {
223
240
  prepareMethods,
224
241
  preparePages,
225
242
  prepareRequire,
243
+ prepareSharedLibs,
226
244
  prepareState,
227
245
  prepareUtils,
228
246
  prepareWindow
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@symbo.ls/create",
3
- "version": "2.34.20",
3
+ "version": "2.34.22",
4
4
  "license": "MIT",
5
- "gitHead": "ee2e9cb9831ae904b984868e68219e95fd9ceeaf",
5
+ "gitHead": "7c230f00e3044681e6ab652e1f638eeea8dac1ec",
6
6
  "type": "module",
7
7
  "module": "src/index.js",
8
8
  "main": "src/index.js",
@@ -29,17 +29,17 @@
29
29
  "prepublish": "npm run build; npm run copy:package:cjs"
30
30
  },
31
31
  "dependencies": {
32
- "@domql/emotion": "^2.34.20",
33
- "@domql/event": "^2.34.20",
34
- "@domql/report": "^2.34.20",
35
- "@domql/router": "^2.34.20",
36
- "@symbo.ls/fetch": "^2.34.20",
37
- "@symbo.ls/init": "^2.34.20",
38
- "@symbo.ls/scratch": "^2.34.20",
39
- "@symbo.ls/sync": "^2.34.20",
40
- "@symbo.ls/uikit": "^2.34.20",
41
- "@symbo.ls/utils": "^2.34.20",
42
- "domql": "^2.34.20"
32
+ "@domql/emotion": "^2.34.22",
33
+ "@domql/event": "^2.34.22",
34
+ "@domql/report": "^2.34.22",
35
+ "@domql/router": "^2.34.22",
36
+ "@symbo.ls/fetch": "^2.34.22",
37
+ "@symbo.ls/init": "^2.34.22",
38
+ "@symbo.ls/scratch": "^2.34.22",
39
+ "@symbo.ls/sync": "^2.34.22",
40
+ "@symbo.ls/uikit": "^2.34.22",
41
+ "@symbo.ls/utils": "^2.34.22",
42
+ "domql": "^2.34.22"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@babel/core": "^7.27.1"
@@ -23,7 +23,8 @@ import {
23
23
  preparePages,
24
24
  prepareState,
25
25
  prepareUtils,
26
- prepareMethods
26
+ prepareMethods,
27
+ prepareSharedLibs
27
28
  } from './prepare.js'
28
29
 
29
30
  import { temporaryDomqlHackReverse } from '@symbo.ls/utils'
@@ -50,6 +51,10 @@ export const prepareContext = async (app, context = {}) => {
50
51
  context.defaultExtends = [uikit.Box]
51
52
  context.version = version
52
53
 
54
+ if (context.sharedLibraries) {
55
+ prepareSharedLibs(context)
56
+ }
57
+
53
58
  // Iterate over components and pages to run domql3hack
54
59
  if (context.forceDomql3) {
55
60
  for (const key in context.components) {
package/src/prepare.js CHANGED
@@ -6,7 +6,8 @@ import {
6
6
  deepClone,
7
7
  merge,
8
8
  checkIfKeyIsComponent,
9
- isDevelopment
9
+ isDevelopment,
10
+ overwriteShallow
10
11
  } from '@domql/utils'
11
12
  import { initEmotion } from './initEmotion.js'
12
13
 
@@ -34,7 +35,8 @@ function onlyDotsAndNumbers(str) {
34
35
  const CDN_PROVIDERS = {
35
36
  skypack: {
36
37
  url: 'https://cdn.skypack.dev',
37
- formatUrl: (pkg, version) => `${CDN_PROVIDERS.skypack.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}`
38
+ formatUrl: (pkg, version) =>
39
+ `${CDN_PROVIDERS.skypack.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}`
38
40
  },
39
41
  symbols: {
40
42
  url: 'https://pkg.symbo.ls',
@@ -47,17 +49,21 @@ const CDN_PROVIDERS = {
47
49
  }
48
50
  }
49
51
 
50
- export const getCDNUrl = (packageName, version = 'latest', provider = 'skypack') => {
52
+ export const getCDNUrl = (
53
+ packageName,
54
+ version = 'latest',
55
+ provider = 'skypack'
56
+ ) => {
51
57
  const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.skypack
52
58
  return cdnConfig.formatUrl(packageName, version)
53
59
  }
54
60
 
55
- export const UIkitWithPrefix = () => {
61
+ const UIkitWithPrefix = (prefix = 'smbls') => {
56
62
  const newObj = {}
57
63
  for (const key in uikit) {
58
64
  if (Object.prototype.hasOwnProperty.call(uikit, key)) {
59
65
  if (checkIfKeyIsComponent(key)) {
60
- newObj[`smbls.${key}`] = uikit[key]
66
+ newObj[`${prefix}.${key}`] = uikit[key]
61
67
  } else {
62
68
  newObj[key] = uikit[key]
63
69
  }
@@ -114,7 +120,7 @@ export const prepareDependencies = async ({
114
120
  try {
115
121
  if (cachedDeps[dependency]) return
116
122
  cachedDeps[dependency] = true
117
- await utils.loadRemoteScript(url, { document, type: "module" })
123
+ await utils.loadRemoteScript(url, { document, type: 'module' })
118
124
  } catch (e) {
119
125
  console.error(`Failed to load ${dependency} from ${cdnProvider}:`, e)
120
126
 
@@ -122,9 +128,14 @@ export const prepareDependencies = async ({
122
128
  try {
123
129
  const fallbackUrl = getCDNUrl(dependency, version, 'symbols') + random
124
130
  await utils.loadRemoteScript(fallbackUrl, { document })
125
- console.log(`Successfully loaded ${dependency} from fallback (symbols.ls)`)
131
+ console.log(
132
+ `Successfully loaded ${dependency} from fallback (symbols.ls)`
133
+ )
126
134
  } catch (fallbackError) {
127
- console.error(`Failed to load ${dependency} from fallback:`, fallbackError)
135
+ console.error(
136
+ `Failed to load ${dependency} from fallback:`,
137
+ fallbackError
138
+ )
128
139
  }
129
140
  }
130
141
  }
@@ -137,62 +148,63 @@ export const prepareRequire = async (packages, ctx) => {
137
148
  const windowOpts = ctx.window || window
138
149
  const defaultProvider = ctx.cdnProvider || 'skypack'
139
150
 
140
- const initRequire = async ctx => async (key, provider) => {
151
+ const initRequire = async (ctx) => async (key, provider) => {
141
152
  const windowOpts = ctx.window || window
142
153
  const pkg = windowOpts.packages[key]
143
154
  if (typeof pkg === 'function') return pkg()
144
155
  return pkg
145
156
  }
146
157
 
147
- const initRequireOnDemand = async ctx => async (key, provider = defaultProvider) => {
148
- const { dependenciesOnDemand } = ctx
149
- const documentOpts = ctx.document || document
150
- const windowOpts = ctx.window || window
151
- if (!windowOpts.packages[key]) {
152
- const random = isDevelopment() ? `?${Math.random()}` : ''
153
- if (dependenciesOnDemand && dependenciesOnDemand[key]) {
154
- const version = dependenciesOnDemand[key]
155
- const url = getCDNUrl(key, version, provider) + random
156
- try {
157
- await ctx.utils.loadRemoteScript(url, {
158
- window: windowOpts,
159
- document: documentOpts,
160
-
161
- })
162
- } catch (e) {
163
- console.error(`Failed to load ${key} from ${provider}:`, e)
164
- // Fallback to symbo if not already using it
165
- if (provider !== 'symbols') {
166
- const fallbackUrl = getCDNUrl(key, version, 'symbols') + random
167
- await ctx.utils.loadRemoteScript(fallbackUrl, {
158
+ const initRequireOnDemand =
159
+ async (ctx) =>
160
+ async (key, provider = defaultProvider) => {
161
+ const { dependenciesOnDemand } = ctx
162
+ const documentOpts = ctx.document || document
163
+ const windowOpts = ctx.window || window
164
+ if (!windowOpts.packages[key]) {
165
+ const random = isDevelopment() ? `?${Math.random()}` : ''
166
+ if (dependenciesOnDemand && dependenciesOnDemand[key]) {
167
+ const version = dependenciesOnDemand[key]
168
+ const url = getCDNUrl(key, version, provider) + random
169
+ try {
170
+ await ctx.utils.loadRemoteScript(url, {
168
171
  window: windowOpts,
169
172
  document: documentOpts
170
173
  })
174
+ } catch (e) {
175
+ console.error(`Failed to load ${key} from ${provider}:`, e)
176
+ // Fallback to symbo if not already using it
177
+ if (provider !== 'symbols') {
178
+ const fallbackUrl = getCDNUrl(key, version, 'symbols') + random
179
+ await ctx.utils.loadRemoteScript(fallbackUrl, {
180
+ window: windowOpts,
181
+ document: documentOpts
182
+ })
183
+ }
171
184
  }
172
- }
173
- } else {
174
- const url = getCDNUrl(key, 'latest', provider) + random
175
- try {
176
- await ctx.utils.loadRemoteScript(url, {
177
- window: windowOpts,
178
- document: documentOpts,
179
- })
180
- } catch (e) {
181
- console.error(`Failed to load ${key} from ${provider}:`, e)
182
- // Fallback to symbo if not already using it
183
- if (provider !== 'symbols') {
184
- const fallbackUrl = getCDNUrl(key, 'latest', 'symbols') + random
185
- await ctx.utils.loadRemoteScript(fallbackUrl, {
185
+ } else {
186
+ const url = getCDNUrl(key, 'latest', provider) + random
187
+ try {
188
+ await ctx.utils.loadRemoteScript(url, {
186
189
  window: windowOpts,
187
190
  document: documentOpts
188
191
  })
192
+ } catch (e) {
193
+ console.error(`Failed to load ${key} from ${provider}:`, e)
194
+ // Fallback to symbo if not already using it
195
+ if (provider !== 'symbols') {
196
+ const fallbackUrl = getCDNUrl(key, 'latest', 'symbols') + random
197
+ await ctx.utils.loadRemoteScript(fallbackUrl, {
198
+ window: windowOpts,
199
+ document: documentOpts
200
+ })
201
+ }
189
202
  }
203
+ windowOpts.packages[key] = 'loadedOnDeman'
190
204
  }
191
- windowOpts.packages[key] = 'loadedOnDeman'
192
205
  }
206
+ return await windowOpts.require(key, provider)
193
207
  }
194
- return await windowOpts.require(key, provider)
195
- }
196
208
 
197
209
  if (windowOpts.packages) {
198
210
  windowOpts.packages = merge(windowOpts.packages, packages)
@@ -237,3 +249,16 @@ export const preparePages = (app, context) => {
237
249
  return pages
238
250
  }, pages)
239
251
  }
252
+
253
+ export const prepareSharedLibs = (context) => {
254
+ const sharedLibraries = context.sharedLibraries
255
+ for (let i = 0; i < sharedLibraries.length; i++) {
256
+ const sharedLib = sharedLibraries[i]
257
+ if (context.type === 'template') {
258
+ overwriteShallow(context.designSystem, sharedLib.designSystem)
259
+ deepMerge(context, sharedLib, ['designSystem'], 1)
260
+ } else {
261
+ deepMerge(context, sharedLib, [], 1)
262
+ }
263
+ }
264
+ }