@symbo.ls/create 2.27.8 → 2.27.10

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.
@@ -36,15 +36,18 @@ var import_domql = __toESM(require("domql"), 1);
36
36
  var uikit = __toESM(require("@symbo.ls/uikit"), 1);
37
37
  var import_utils = require("@domql/utils");
38
38
  var import_event = require("@domql/event");
39
- var import_define = require("./define");
40
- var import_router = require("./router");
41
- var import_syncExtend = require("./syncExtend");
42
- var import_prepare = require("./prepare");
39
+ var import_define = require("./define.js");
40
+ var import_router = require("./router.js");
41
+ var import_syncExtend = require("./syncExtend.js");
42
+ var import_prepare = require("./prepare.js");
43
43
  const prepareContext = (app, context = {}) => {
44
44
  const key = context.key = context.key || ((0, import_utils.isString)(app) ? app : "smblsapp");
45
45
  context.define = context.define || import_define.defaultDefine;
46
46
  context.window = (0, import_prepare.prepareWindow)(context);
47
- const [scratcDesignSystem, emotion, registry] = (0, import_prepare.prepareDesignSystem)(key, context);
47
+ const [scratcDesignSystem, emotion, registry] = (0, import_prepare.prepareDesignSystem)(
48
+ key,
49
+ context
50
+ );
48
51
  context.designSystem = scratcDesignSystem;
49
52
  context.registry = registry;
50
53
  context.emotion = emotion;
@@ -79,12 +82,15 @@ const createDomqlElement = async (app, ctx) => {
79
82
  app.context = ctx;
80
83
  app.data = app.data || {};
81
84
  app.data.frameListeners = (0, import_event.initAnimationFrame)(ctx);
82
- (0, import_prepare.prepareRequire)({
83
- functions: ctx.functions,
84
- utils: ctx.utils,
85
- snippets: ctx.snippets,
86
- ...ctx.files
87
- }, ctx);
85
+ (0, import_prepare.prepareRequire)(
86
+ {
87
+ functions: ctx.functions,
88
+ utils: ctx.utils,
89
+ snippets: ctx.snippets,
90
+ ...ctx.files
91
+ },
92
+ ctx
93
+ );
88
94
  (0, import_syncExtend.initializeSync)(app, ctx);
89
95
  (0, import_syncExtend.initializeInspect)(app, ctx);
90
96
  (0, import_syncExtend.initializeNotifications)(app, ctx);
package/dist/cjs/index.js CHANGED
@@ -36,36 +36,57 @@ __export(index_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(index_exports);
38
38
  var import_utils = require("@domql/utils");
39
- var utils = __toESM(require("./utilImports"), 1);
40
- var import_router = require("./router");
41
- var import_ferchOnCreate = require("./ferchOnCreate");
42
- var import_options = __toESM(require("./options"), 1);
39
+ var utils = __toESM(require("./utilImports.js"), 1);
40
+ var import_router = require("./router.js");
41
+ var import_ferchOnCreate = require("./ferchOnCreate.js");
42
+ var import_options = __toESM(require("./options.js"), 1);
43
43
  var import_dynamic = __toESM(require("@symbo.ls/init/dynamic.json"), 1);
44
- var import_createDomql = require("./createDomql");
44
+ var import_createDomql = require("./createDomql.js");
45
45
  const mergeWithLocalFile = (options, optionsExternalFile) => (0, import_utils.deepMerge)(
46
46
  options,
47
47
  (0, import_utils.isObject)(optionsExternalFile) ? optionsExternalFile : import_dynamic.default || {}
48
48
  );
49
49
  const create = (App, options = import_options.default, optionsExternalFile) => {
50
- const redefinedOptions = { ...import_options.default, ...mergeWithLocalFile(options, optionsExternalFile) };
50
+ const redefinedOptions = {
51
+ ...import_options.default,
52
+ ...mergeWithLocalFile(options, optionsExternalFile)
53
+ };
51
54
  const domqlApp = (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
52
55
  (0, import_router.popStateRouter)(domqlApp, redefinedOptions);
53
- if (redefinedOptions.on && redefinedOptions.on.create) redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
56
+ if (redefinedOptions.on && redefinedOptions.on.create)
57
+ redefinedOptions.on.create(
58
+ domqlApp,
59
+ domqlApp.state,
60
+ domqlApp.context,
61
+ redefinedOptions
62
+ );
54
63
  return domqlApp;
55
64
  };
56
65
  const createAsync = (App, options = import_options.default, optionsExternalFile) => {
57
66
  const domqlApp = create(App, options, optionsExternalFile);
58
- const redefinedOptions = { ...import_options.default, ...mergeWithLocalFile(options, optionsExternalFile) };
67
+ const redefinedOptions = {
68
+ ...import_options.default,
69
+ ...mergeWithLocalFile(options, optionsExternalFile)
70
+ };
59
71
  const key = redefinedOptions.key;
60
72
  (0, import_ferchOnCreate.fetchAsync)(domqlApp, key, { utils, ...redefinedOptions });
61
73
  return domqlApp;
62
74
  };
63
75
  const createSync = async (App, options = import_options.default, optionsExternalFile) => {
64
- const redefinedOptions = { ...import_options.default, ...mergeWithLocalFile(options, optionsExternalFile) };
76
+ const redefinedOptions = {
77
+ ...import_options.default,
78
+ ...mergeWithLocalFile(options, optionsExternalFile)
79
+ };
65
80
  const key = options.key;
66
81
  await (0, import_ferchOnCreate.fetchSync)(key, redefinedOptions);
67
82
  const domqlApp = await (0, import_createDomql.createDomqlElement)(App, redefinedOptions);
68
- if (redefinedOptions.on && redefinedOptions.on.create) await redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
83
+ if (redefinedOptions.on && redefinedOptions.on.create)
84
+ await redefinedOptions.on.create(
85
+ domqlApp,
86
+ domqlApp.state,
87
+ domqlApp.context,
88
+ redefinedOptions
89
+ );
69
90
  return domqlApp;
70
91
  };
71
92
  const createSkeleton = (App = {}, options = import_options.default, optionsExternalFile) => {
@@ -25,7 +25,7 @@ var import_emotion = require("@domql/emotion");
25
25
  var import_emotion2 = require("@symbo.ls/emotion");
26
26
  var import_init = require("@symbo.ls/init");
27
27
  var import_utils = require("@domql/utils");
28
- var import_options = require("./options");
28
+ var import_options = require("./options.js");
29
29
  var import_default_config = require("@symbo.ls/default-config");
30
30
  const initEmotion = (key, options = {}) => {
31
31
  var _a;
@@ -23,7 +23,7 @@ __export(options_exports, {
23
23
  default: () => options_default
24
24
  });
25
25
  module.exports = __toCommonJS(options_exports);
26
- var import_define = require("./define");
26
+ var import_define = require("./define.js");
27
27
  const DESIGN_SYSTEM_OPTIONS = {
28
28
  useReset: true,
29
29
  useVariable: true,
@@ -41,11 +41,11 @@ __export(prepare_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(prepare_exports);
43
43
  var import_utils = require("@domql/utils");
44
- var import_initEmotion = require("./initEmotion");
44
+ var import_initEmotion = require("./initEmotion.js");
45
45
  var uikit = __toESM(require("@symbo.ls/uikit"), 1);
46
- var utils = __toESM(require("./utilImports"), 1);
46
+ var utils = __toESM(require("./utilImports.js"), 1);
47
47
  var routerUtils = __toESM(require("@domql/router"), 1);
48
- const ENV = "development";
48
+ // @preserve-env
49
49
  const prepareWindow = (context) => {
50
50
  if (typeof window === "undefined") window = globalThis || {};
51
51
  if (typeof document === "undefined") {
@@ -75,7 +75,14 @@ const prepareComponents = (context) => {
75
75
  return context.components ? { ...UIkitWithPrefix(), ...context.components } : UIkitWithPrefix();
76
76
  };
77
77
  const prepareUtils = (context) => {
78
- return { ...utils, ...routerUtils, ...utils.scratchUtils, ...context.utils, ...context.snippets, ...context.functions };
78
+ return {
79
+ ...utils,
80
+ ...routerUtils,
81
+ ...utils.scratchUtils,
82
+ ...context.utils,
83
+ ...context.snippets,
84
+ ...context.functions
85
+ };
79
86
  };
80
87
  const prepareMethods = (context) => {
81
88
  return {
@@ -101,7 +108,7 @@ const prepareDependencies = ({
101
108
  if (version === "loading" || version === "error") {
102
109
  continue;
103
110
  }
104
- const random = ENV === "development" ? `?${Math.random()}` : "";
111
+ const random = (0, import_utils.isDevelopment)() ? `?${Math.random()}` : "";
105
112
  let url = `https://pkg.symbo.ls/${dependency}/${version}.js${random}`;
106
113
  if (dependency.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
107
114
  url = `https://pkg.symbo.ls/${dependency}${random}`;
@@ -130,7 +137,7 @@ const prepareRequire = (packages, ctx) => {
130
137
  const documentOpts = ctx2.document || document;
131
138
  const windowOpts2 = ctx2.window || window;
132
139
  if (!windowOpts2.packages[key]) {
133
- const random = ENV === "development" ? `?${Math.random()}` : "";
140
+ const random = (0, import_utils.isDevelopment)() ? `?${Math.random()}` : "";
134
141
  if (dependenciesOnDemand && dependenciesOnDemand[key]) {
135
142
  const version = dependenciesOnDemand[key];
136
143
  const url = `https://pkg.symbo.ls/${key}/${version}.js${random}`;
@@ -18,9 +18,14 @@ import DOM from "domql";
18
18
  import * as uikit from "@symbo.ls/uikit";
19
19
  import { isString, isNode, isObject } from "@domql/utils";
20
20
  import { initAnimationFrame } from "@domql/event";
21
- import { defaultDefine } from "./define";
22
- import { initRouter } from "./router";
23
- import { initializeExtend, initializeInspect, initializeNotifications, initializeSync } from "./syncExtend";
21
+ import { defaultDefine } from "./define.js";
22
+ import { initRouter } from "./router.js";
23
+ import {
24
+ initializeExtend,
25
+ initializeInspect,
26
+ initializeNotifications,
27
+ initializeSync
28
+ } from "./syncExtend.js";
24
29
  import {
25
30
  prepareComponents,
26
31
  prepareDependencies,
@@ -31,12 +36,15 @@ import {
31
36
  prepareState,
32
37
  prepareUtils,
33
38
  prepareMethods
34
- } from "./prepare";
39
+ } from "./prepare.js";
35
40
  const prepareContext = (app, context = {}) => {
36
41
  const key = context.key = context.key || (isString(app) ? app : "smblsapp");
37
42
  context.define = context.define || defaultDefine;
38
43
  context.window = prepareWindow(context);
39
- const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(key, context);
44
+ const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(
45
+ key,
46
+ context
47
+ );
40
48
  context.designSystem = scratcDesignSystem;
41
49
  context.registry = registry;
42
50
  context.emotion = emotion;
@@ -71,11 +79,14 @@ const createDomqlElement = async (app, ctx) => {
71
79
  app.context = ctx;
72
80
  app.data = app.data || {};
73
81
  app.data.frameListeners = initAnimationFrame(ctx);
74
- prepareRequire(__spreadValues({
75
- functions: ctx.functions,
76
- utils: ctx.utils,
77
- snippets: ctx.snippets
78
- }, ctx.files), ctx);
82
+ prepareRequire(
83
+ __spreadValues({
84
+ functions: ctx.functions,
85
+ utils: ctx.utils,
86
+ snippets: ctx.snippets
87
+ }, ctx.files),
88
+ ctx
89
+ );
79
90
  initializeSync(app, ctx);
80
91
  initializeInspect(app, ctx);
81
92
  initializeNotifications(app, ctx);
package/dist/esm/index.js CHANGED
@@ -15,12 +15,12 @@ var __spreadValues = (a, b) => {
15
15
  return a;
16
16
  };
17
17
  import { deepMerge, isObject, isUndefined } from "@domql/utils";
18
- import * as utils from "./utilImports";
19
- import { popStateRouter } from "./router";
20
- import { fetchAsync, fetchSync } from "./ferchOnCreate";
21
- import DEFAULT_CREATE_OPTIONS from "./options";
18
+ import * as utils from "./utilImports.js";
19
+ import { popStateRouter } from "./router.js";
20
+ import { fetchAsync, fetchSync } from "./ferchOnCreate.js";
21
+ import DEFAULT_CREATE_OPTIONS from "./options.js";
22
22
  import DYNAMIC_JSON from "@symbo.ls/init/dynamic.json";
23
- import { createDomqlElement } from "./createDomql";
23
+ import { createDomqlElement } from "./createDomql.js";
24
24
  const mergeWithLocalFile = (options, optionsExternalFile) => deepMerge(
25
25
  options,
26
26
  isObject(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
@@ -29,7 +29,13 @@ const create = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
29
29
  const redefinedOptions = __spreadValues(__spreadValues({}, DEFAULT_CREATE_OPTIONS), mergeWithLocalFile(options, optionsExternalFile));
30
30
  const domqlApp = createDomqlElement(App, redefinedOptions);
31
31
  popStateRouter(domqlApp, redefinedOptions);
32
- if (redefinedOptions.on && redefinedOptions.on.create) redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
32
+ if (redefinedOptions.on && redefinedOptions.on.create)
33
+ redefinedOptions.on.create(
34
+ domqlApp,
35
+ domqlApp.state,
36
+ domqlApp.context,
37
+ redefinedOptions
38
+ );
33
39
  return domqlApp;
34
40
  };
35
41
  const createAsync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
@@ -44,7 +50,13 @@ const createSync = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExternal
44
50
  const key = options.key;
45
51
  await fetchSync(key, redefinedOptions);
46
52
  const domqlApp = await createDomqlElement(App, redefinedOptions);
47
- if (redefinedOptions.on && redefinedOptions.on.create) await redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions);
53
+ if (redefinedOptions.on && redefinedOptions.on.create)
54
+ await redefinedOptions.on.create(
55
+ domqlApp,
56
+ domqlApp.state,
57
+ domqlApp.context,
58
+ redefinedOptions
59
+ );
48
60
  return domqlApp;
49
61
  };
50
62
  const createSkeleton = (App = {}, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
@@ -18,7 +18,7 @@ import { transformDOMQLEmotion } from "@domql/emotion";
18
18
  import { emotion as defaultEmotion } from "@symbo.ls/emotion";
19
19
  import { init } from "@symbo.ls/init";
20
20
  import { deepClone, deepMerge } from "@domql/utils";
21
- import { DESIGN_SYSTEM_OPTIONS } from "./options";
21
+ import { DESIGN_SYSTEM_OPTIONS } from "./options.js";
22
22
  import { DEFAULT_CONFIG } from "@symbo.ls/default-config";
23
23
  const initEmotion = (key, options = {}) => {
24
24
  var _a;
@@ -1,4 +1,4 @@
1
- import { defaultDefine } from "./define";
1
+ import { defaultDefine } from "./define.js";
2
2
  const DESIGN_SYSTEM_OPTIONS = {
3
3
  useReset: true,
4
4
  useVariable: true,
@@ -22,13 +22,14 @@ import {
22
22
  deepMerge,
23
23
  deepClone,
24
24
  merge,
25
- checkIfKeyIsComponent
25
+ checkIfKeyIsComponent,
26
+ isDevelopment
26
27
  } from "@domql/utils";
27
- import { initEmotion } from "./initEmotion";
28
+ import { initEmotion } from "./initEmotion.js";
28
29
  import * as uikit from "@symbo.ls/uikit";
29
- import * as utils from "./utilImports";
30
+ import * as utils from "./utilImports.js";
30
31
  import * as routerUtils from "@domql/router";
31
- const ENV = "development";
32
+ // @preserve-env
32
33
  const prepareWindow = (context) => {
33
34
  if (typeof window === "undefined") window = globalThis || {};
34
35
  if (typeof document === "undefined") {
@@ -83,7 +84,7 @@ const prepareDependencies = ({
83
84
  if (version === "loading" || version === "error") {
84
85
  continue;
85
86
  }
86
- const random = ENV === "development" ? `?${Math.random()}` : "";
87
+ const random = isDevelopment() ? `?${Math.random()}` : "";
87
88
  let url = `https://pkg.symbo.ls/${dependency}/${version}.js${random}`;
88
89
  if (dependency.split("/").length > 2 || !onlyDotsAndNumbers(version)) {
89
90
  url = `https://pkg.symbo.ls/${dependency}${random}`;
@@ -112,7 +113,7 @@ const prepareRequire = (packages, ctx) => {
112
113
  const documentOpts = ctx2.document || document;
113
114
  const windowOpts2 = ctx2.window || window;
114
115
  if (!windowOpts2.packages[key]) {
115
- const random = ENV === "development" ? `?${Math.random()}` : "";
116
+ const random = isDevelopment() ? `?${Math.random()}` : "";
116
117
  if (dependenciesOnDemand && dependenciesOnDemand[key]) {
117
118
  const version = dependenciesOnDemand[key];
118
119
  const url = `https://pkg.symbo.ls/${key}/${version}.js${random}`;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@symbo.ls/create",
3
- "version": "2.27.8",
3
+ "version": "2.27.10",
4
4
  "license": "MIT",
5
- "gitHead": "e783fd54228d5c7aaab9d4b5624199a17a6c4713",
5
+ "gitHead": "668d24f518bdb163357897504c5912c085638d3e",
6
6
  "type": "module",
7
7
  "module": "src/index.js",
8
8
  "main": "src/index.js",
@@ -10,9 +10,9 @@
10
10
  "jsdelivr": "dist/iife/index.js",
11
11
  "exports": {
12
12
  ".": {
13
- "default": "./dist/esm/index.js",
14
13
  "import": "./dist/esm/index.js",
15
- "require": "./dist/cjs/index.js"
14
+ "require": "./dist/cjs/index.js",
15
+ "default": "./dist/esm/index.js"
16
16
  }
17
17
  },
18
18
  "source": "src/index.js",
@@ -22,24 +22,24 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
25
- "build:esm": "cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=es2017 --format=esm --outdir=dist/esm",
26
- "build:cjs": "cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=node16 --format=cjs --outdir=dist/cjs",
27
- "build:iife": "cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=node16 --format=iife --outdir=dist/iife",
25
+ "build:esm": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=es2017 --format=esm --outdir=dist/esm",
26
+ "build:cjs": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=node16 --format=cjs --outdir=dist/cjs",
27
+ "build:iife": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild src/*.js --target=node16 --format=iife --outdir=dist/iife",
28
28
  "build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
29
29
  "prepublish": "npm run build; npm run copy:package:cjs"
30
30
  },
31
31
  "dependencies": {
32
- "@domql/emotion": "^2.27.8",
33
- "@domql/event": "^2.27.8",
34
- "@domql/report": "^2.27.8",
35
- "@domql/router": "^2.27.8",
36
- "@symbo.ls/fetch": "^2.27.8",
37
- "@symbo.ls/init": "^2.27.8",
38
- "@symbo.ls/scratch": "^2.27.8",
39
- "@symbo.ls/sync": "^2.27.8",
40
- "@symbo.ls/uikit": "^2.27.8",
41
- "@symbo.ls/utils": "^2.27.8",
42
- "domql": "^2.27.8"
32
+ "@domql/emotion": "^2.27.10",
33
+ "@domql/event": "^2.27.10",
34
+ "@domql/report": "^2.27.10",
35
+ "@domql/router": "^2.27.10",
36
+ "@symbo.ls/fetch": "^2.27.10",
37
+ "@symbo.ls/init": "^2.27.10",
38
+ "@symbo.ls/scratch": "^2.27.10",
39
+ "@symbo.ls/sync": "^2.27.10",
40
+ "@symbo.ls/uikit": "^2.27.10",
41
+ "@symbo.ls/utils": "^2.27.10",
42
+ "domql": "^2.27.10"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@babel/core": "^7.26.0"
@@ -5,9 +5,14 @@ import * as uikit from '@symbo.ls/uikit'
5
5
 
6
6
  import { isString, isNode, isObject } from '@domql/utils'
7
7
  import { initAnimationFrame } from '@domql/event'
8
- import { defaultDefine } from './define'
9
- import { initRouter } from './router'
10
- import { initializeExtend, initializeInspect, initializeNotifications, initializeSync } from './syncExtend'
8
+ import { defaultDefine } from './define.js'
9
+ import { initRouter } from './router.js'
10
+ import {
11
+ initializeExtend,
12
+ initializeInspect,
13
+ initializeNotifications,
14
+ initializeSync
15
+ } from './syncExtend.js'
11
16
 
12
17
  import {
13
18
  prepareComponents,
@@ -19,14 +24,17 @@ import {
19
24
  prepareState,
20
25
  prepareUtils,
21
26
  prepareMethods
22
- } from './prepare'
27
+ } from './prepare.js'
23
28
 
24
29
  export const prepareContext = (app, context = {}) => {
25
30
  // const rcFileKey = process?.env?.SYMBOLS_KEY
26
- const key = context.key = context.key || (isString(app) ? app : 'smblsapp')
31
+ const key = (context.key = context.key || (isString(app) ? app : 'smblsapp'))
27
32
  context.define = context.define || defaultDefine
28
33
  context.window = prepareWindow(context)
29
- const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(key, context)
34
+ const [scratcDesignSystem, emotion, registry] = prepareDesignSystem(
35
+ key,
36
+ context
37
+ )
30
38
  context.designSystem = scratcDesignSystem
31
39
  context.registry = registry
32
40
  context.emotion = emotion
@@ -65,12 +73,15 @@ export const createDomqlElement = async (app, ctx) => {
65
73
  app.data = app.data || {}
66
74
  app.data.frameListeners = initAnimationFrame(ctx)
67
75
 
68
- prepareRequire({
69
- functions: ctx.functions,
70
- utils: ctx.utils,
71
- snippets: ctx.snippets,
72
- ...ctx.files
73
- }, ctx)
76
+ prepareRequire(
77
+ {
78
+ functions: ctx.functions,
79
+ utils: ctx.utils,
80
+ snippets: ctx.snippets,
81
+ ...ctx.files
82
+ },
83
+ ctx
84
+ )
74
85
 
75
86
  initializeSync(app, ctx)
76
87
  initializeInspect(app, ctx)
package/src/index.js CHANGED
@@ -2,36 +2,57 @@
2
2
 
3
3
  import { deepMerge, isObject, isUndefined } from '@domql/utils'
4
4
 
5
- import * as utils from './utilImports'
5
+ import * as utils from './utilImports.js'
6
6
 
7
- import { popStateRouter } from './router'
8
- import { fetchAsync, fetchSync } from './ferchOnCreate'
7
+ import { popStateRouter } from './router.js'
8
+ import { fetchAsync, fetchSync } from './ferchOnCreate.js'
9
9
 
10
- import DEFAULT_CREATE_OPTIONS from './options'
11
- import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json'
12
- import { createDomqlElement } from './createDomql'
10
+ import DEFAULT_CREATE_OPTIONS from './options.js'
11
+ import DYNAMIC_JSON from '@symbo.ls/init/dynamic.json' with { type: 'json' }
12
+ import { createDomqlElement } from './createDomql.js'
13
13
 
14
- const mergeWithLocalFile = (options, optionsExternalFile) => deepMerge(
15
- options,
16
- isObject(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
17
- )
14
+ const mergeWithLocalFile = (options, optionsExternalFile) =>
15
+ deepMerge(
16
+ options,
17
+ isObject(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
18
+ )
18
19
 
19
- export const create = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
20
- const redefinedOptions = { ...DEFAULT_CREATE_OPTIONS, ...mergeWithLocalFile(options, optionsExternalFile) }
20
+ export const create = (
21
+ App,
22
+ options = DEFAULT_CREATE_OPTIONS,
23
+ optionsExternalFile
24
+ ) => {
25
+ const redefinedOptions = {
26
+ ...DEFAULT_CREATE_OPTIONS,
27
+ ...mergeWithLocalFile(options, optionsExternalFile)
28
+ }
21
29
 
22
30
  const domqlApp = createDomqlElement(App, redefinedOptions)
23
31
 
24
32
  popStateRouter(domqlApp, redefinedOptions)
25
33
 
26
- if (redefinedOptions.on && redefinedOptions.on.create) redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions)
34
+ if (redefinedOptions.on && redefinedOptions.on.create)
35
+ redefinedOptions.on.create(
36
+ domqlApp,
37
+ domqlApp.state,
38
+ domqlApp.context,
39
+ redefinedOptions
40
+ )
27
41
 
28
42
  return domqlApp
29
43
  }
30
44
 
31
- export const createAsync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
45
+ export const createAsync = (
46
+ App,
47
+ options = DEFAULT_CREATE_OPTIONS,
48
+ optionsExternalFile
49
+ ) => {
32
50
  const domqlApp = create(App, options, optionsExternalFile)
33
51
 
34
- const redefinedOptions = { ...DEFAULT_CREATE_OPTIONS, ...mergeWithLocalFile(options, optionsExternalFile) }
52
+ const redefinedOptions = {
53
+ ...DEFAULT_CREATE_OPTIONS,
54
+ ...mergeWithLocalFile(options, optionsExternalFile)
55
+ }
35
56
  // const SYMBOLS_KEY = process.env.SYMBOLS_KEY
36
57
  const key = redefinedOptions.key
37
58
  fetchAsync(domqlApp, key, { utils, ...redefinedOptions })
@@ -39,20 +60,37 @@ export const createAsync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExtern
39
60
  return domqlApp
40
61
  }
41
62
 
42
- export const createSync = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
43
- const redefinedOptions = { ...DEFAULT_CREATE_OPTIONS, ...mergeWithLocalFile(options, optionsExternalFile) }
63
+ export const createSync = async (
64
+ App,
65
+ options = DEFAULT_CREATE_OPTIONS,
66
+ optionsExternalFile
67
+ ) => {
68
+ const redefinedOptions = {
69
+ ...DEFAULT_CREATE_OPTIONS,
70
+ ...mergeWithLocalFile(options, optionsExternalFile)
71
+ }
44
72
 
45
73
  // const SYMBOLS_KEY = process.env.SYMBOLS_KEY
46
74
  const key = options.key
47
75
  await fetchSync(key, redefinedOptions)
48
76
 
49
77
  const domqlApp = await createDomqlElement(App, redefinedOptions)
50
- if (redefinedOptions.on && redefinedOptions.on.create) await (redefinedOptions.on.create(domqlApp, domqlApp.state, domqlApp.context, redefinedOptions))
78
+ if (redefinedOptions.on && redefinedOptions.on.create)
79
+ await redefinedOptions.on.create(
80
+ domqlApp,
81
+ domqlApp.state,
82
+ domqlApp.context,
83
+ redefinedOptions
84
+ )
51
85
 
52
86
  return domqlApp
53
87
  }
54
88
 
55
- export const createSkeleton = (App = {}, options = DEFAULT_CREATE_OPTIONS, optionsExternalFile) => {
89
+ export const createSkeleton = (
90
+ App = {},
91
+ options = DEFAULT_CREATE_OPTIONS,
92
+ optionsExternalFile
93
+ ) => {
56
94
  return create(
57
95
  {
58
96
  deps: { isUndefined },
@@ -5,7 +5,7 @@ import { emotion as defaultEmotion } from '@symbo.ls/emotion'
5
5
  import { init } from '@symbo.ls/init'
6
6
  import { deepClone, deepMerge } from '@domql/utils'
7
7
 
8
- import { DESIGN_SYSTEM_OPTIONS } from './options'
8
+ import { DESIGN_SYSTEM_OPTIONS } from './options.js'
9
9
  import { DEFAULT_CONFIG } from '@symbo.ls/default-config'
10
10
 
11
11
  export const initEmotion = (key, options = {}) => {
@@ -15,10 +15,12 @@ export const initEmotion = (key, options = {}) => {
15
15
 
16
16
  if (!initOptions.emotion) initOptions.emotion = defaultEmotion
17
17
 
18
- const registry = options.registry || transformDOMQLEmotion(initOptions.emotion, options)
19
- const designSystem = (initOptions.useDefaultConfig || options.designSystem?.useDefaultConfig)
20
- ? deepMerge(options.designSystem, deepClone(DEFAULT_CONFIG))
21
- : options.designSystem || deepClone(DEFAULT_CONFIG)
18
+ const registry =
19
+ options.registry || transformDOMQLEmotion(initOptions.emotion, options)
20
+ const designSystem =
21
+ initOptions.useDefaultConfig || options.designSystem?.useDefaultConfig
22
+ ? deepMerge(options.designSystem, deepClone(DEFAULT_CONFIG))
23
+ : options.designSystem || deepClone(DEFAULT_CONFIG)
22
24
 
23
25
  const scratchSystem = init(designSystem, {
24
26
  key,
package/src/options.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { defaultDefine } from './define'
3
+ import { defaultDefine } from './define.js'
4
4
 
5
5
  export const DESIGN_SYSTEM_OPTIONS = {
6
6
  useReset: true,
package/src/prepare.js CHANGED
@@ -5,19 +5,20 @@ import {
5
5
  deepMerge,
6
6
  deepClone,
7
7
  merge,
8
- checkIfKeyIsComponent
8
+ checkIfKeyIsComponent,
9
+ isDevelopment
9
10
  } from '@domql/utils'
10
- import { initEmotion } from './initEmotion'
11
+ import { initEmotion } from './initEmotion.js'
11
12
 
12
13
  import * as uikit from '@symbo.ls/uikit'
13
- import * as utils from './utilImports'
14
+ import * as utils from './utilImports.js'
14
15
  import * as routerUtils from '@domql/router'
15
16
 
16
- const ENV = process.env.NODE_ENV
17
+ // @preserve-env
17
18
 
18
- export const prepareWindow = (context) => {
19
- if (typeof (window) === 'undefined') window = globalThis || {} // eslint-disable-line
20
- if (typeof (document) === 'undefined') {
19
+ export const prepareWindow = context => {
20
+ if (typeof window === 'undefined') window = globalThis || {} // eslint-disable-line
21
+ if (typeof document === 'undefined') {
21
22
  if (!window.document) window.document = globalThis.document || { body: {} }
22
23
  document = window.document // eslint-disable-line
23
24
  }
@@ -44,20 +45,34 @@ export const UIkitWithPrefix = () => {
44
45
  }
45
46
 
46
47
  export const prepareComponents = context => {
47
- return context.components ? { ...UIkitWithPrefix(), ...context.components } : UIkitWithPrefix()
48
+ return context.components
49
+ ? { ...UIkitWithPrefix(), ...context.components }
50
+ : UIkitWithPrefix()
48
51
  }
49
52
 
50
53
  export const prepareUtils = context => {
51
- return { ...utils, ...routerUtils, ...utils.scratchUtils, ...context.utils, ...context.snippets, ...context.functions }
54
+ return {
55
+ ...utils,
56
+ ...routerUtils,
57
+ ...utils.scratchUtils,
58
+ ...context.utils,
59
+ ...context.snippets,
60
+ ...context.functions
61
+ }
52
62
  }
53
63
 
54
- export const prepareMethods = (context) => {
64
+ export const prepareMethods = context => {
55
65
  return {
56
66
  ...(context.methods || {}),
57
67
  require: context.utils.require,
58
68
  requireOnDemand: context.utils.requireOnDemand,
59
69
  call: function (fnKey, ...args) {
60
- return (context.utils[fnKey] || context.functions[fnKey] || context.methods[fnKey] || context.snippets[fnKey])?.call(this, ...args)
70
+ return (
71
+ context.utils[fnKey] ||
72
+ context.functions[fnKey] ||
73
+ context.methods[fnKey] ||
74
+ context.snippets[fnKey]
75
+ )?.call(this, ...args)
61
76
  }
62
77
  }
63
78
  }
@@ -77,7 +92,7 @@ export const prepareDependencies = ({
77
92
  continue
78
93
  }
79
94
 
80
- const random = ENV === 'development' ? `?${Math.random()}` : ''
95
+ const random = isDevelopment() ? `?${Math.random()}` : ''
81
96
  let url = `https://pkg.symbo.ls/${dependency}/${version}.js${random}`
82
97
 
83
98
  if (dependency.split('/').length > 2 || !onlyDotsAndNumbers(version)) {
@@ -113,7 +128,7 @@ export const prepareRequire = (packages, ctx) => {
113
128
  const documentOpts = ctx.document || document
114
129
  const windowOpts = ctx.window || window
115
130
  if (!windowOpts.packages[key]) {
116
- const random = ENV === 'development' ? `?${Math.random()}` : ''
131
+ const random = isDevelopment() ? `?${Math.random()}` : ''
117
132
  if (dependenciesOnDemand && dependenciesOnDemand[key]) {
118
133
  const version = dependenciesOnDemand[key]
119
134
  const url = `https://pkg.symbo.ls/${key}/${version}.js${random}`