@arcanewizards/timecode-toolbox 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/start.js CHANGED
@@ -31,6 +31,53 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  ));
32
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
33
 
34
+ // ../../node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js
35
+ var require_escape_html = __commonJS({
36
+ "../../node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js"(exports2, module2) {
37
+ "use strict";
38
+ var matchHtmlRegExp = /["'&<>]/;
39
+ module2.exports = escapeHtml;
40
+ function escapeHtml(string) {
41
+ var str = "" + string;
42
+ var match = matchHtmlRegExp.exec(str);
43
+ if (!match) {
44
+ return str;
45
+ }
46
+ var escape;
47
+ var html = "";
48
+ var index = 0;
49
+ var lastIndex = 0;
50
+ for (index = match.index; index < str.length; index++) {
51
+ switch (str.charCodeAt(index)) {
52
+ case 34:
53
+ escape = "&quot;";
54
+ break;
55
+ case 38:
56
+ escape = "&amp;";
57
+ break;
58
+ case 39:
59
+ escape = "&#39;";
60
+ break;
61
+ case 60:
62
+ escape = "&lt;";
63
+ break;
64
+ case 62:
65
+ escape = "&gt;";
66
+ break;
67
+ default:
68
+ continue;
69
+ }
70
+ if (lastIndex !== index) {
71
+ html += str.substring(lastIndex, index);
72
+ }
73
+ lastIndex = index + 1;
74
+ html += escape;
75
+ }
76
+ return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
77
+ }
78
+ }
79
+ });
80
+
34
81
  // ../../node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/_listCacheClear.js
35
82
  var require_listCacheClear = __commonJS({
36
83
  "../../node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/_listCacheClear.js"(exports2, module2) {
@@ -1655,6 +1702,7 @@ var import_data = require("@arcanejs/react-toolkit/data");
1655
1702
  var import_react_toolkit2 = require("@arcanejs/react-toolkit");
1656
1703
  var import_toolkit = require("@arcanejs/toolkit");
1657
1704
  var import_events = require("events");
1705
+ var import_escape_html = __toESM(require_escape_html(), 1);
1658
1706
  var import_jsx_runtime = require("react/jsx-runtime");
1659
1707
 
1660
1708
  // ../../packages/net-utils/dist/index.js
@@ -1862,6 +1910,26 @@ var runSigilApp = ({
1862
1910
  debug: upstreamLogger.debug.bind(upstreamLogger)
1863
1911
  },
1864
1912
  title,
1913
+ htmlPage: (context) => `
1914
+ <html>
1915
+ <head>
1916
+ <title>${(0, import_escape_html.default)(context.title)}</title>
1917
+ <meta charset="utf-8">
1918
+ <meta name="viewport" content="width=device-width, user-scalable=no" />
1919
+ <style type="text/css">
1920
+ @font-face {
1921
+ font-family: 'Material Symbols Outlined';
1922
+ font-style: normal;
1923
+ src: url(${context.coreAssets.materialSymbolsOutlined}) format('woff');
1924
+ }
1925
+ </style>
1926
+ ${context.coreAssets.entrypointCss ? `<link rel="stylesheet" href="${context.coreAssets.entrypointCss}" />` : ""}
1927
+ </head>
1928
+ <body>
1929
+ <div id="root"></div>
1930
+ <script type="text/javascript" src="${context.coreAssets.entrypointJs}"></script>
1931
+ </body>
1932
+ </html>`,
1865
1933
  ...toolkitOptions
1866
1934
  });
1867
1935
  toolkit.start({
@@ -2057,7 +2125,8 @@ var AppListenerManager = ({
2057
2125
  const resolvedConnectionDetails = {
2058
2126
  config,
2059
2127
  host,
2060
- port
2128
+ port,
2129
+ internal: !!config.interface && !!interfaces[config.interface]?.internal
2061
2130
  };
2062
2131
  try {
2063
2132
  const listener = await toolkit.listen({
@@ -2128,11 +2197,21 @@ var AppListenerManager = ({
2128
2197
  }, [appRegistration, listenerConfig, logger2, toolkit, updateReactState]);
2129
2198
  (0, import_react3.useEffect)(() => {
2130
2199
  for (const state of Object.values(listenerState)) {
2200
+ let preferredConnection = null;
2131
2201
  if (state.state === "connected") {
2202
+ if (!preferredConnection) {
2203
+ preferredConnection = state;
2204
+ }
2205
+ if (!preferredConnection.internal && state.internal) {
2206
+ preferredConnection = state;
2207
+ }
2208
+ }
2209
+ if (preferredConnection) {
2132
2210
  setWindowUrl(
2133
- new URL(`http://${state.host ?? "localhost"}:${state.port}/`)
2211
+ new URL(
2212
+ `http://${preferredConnection.host ?? "localhost"}:${preferredConnection.port}/`
2213
+ )
2134
2214
  );
2135
- return;
2136
2215
  }
2137
2216
  }
2138
2217
  });
@@ -6205,6 +6284,24 @@ var SIGIL_COLOR = external_exports.enum([
6205
6284
  "gray"
6206
6285
  ]);
6207
6286
 
6287
+ // ../../packages/sigil/dist/shared/config.js
6288
+ var APP_LISTENER_CONFIG = zod_default.object({
6289
+ port: zod_default.union([
6290
+ zod_default.number().int().min(1).max(65535),
6291
+ zod_default.object({
6292
+ from: zod_default.number().int().min(1).max(65535),
6293
+ to: zod_default.number().int().min(1).max(65535)
6294
+ }).refine((data) => data.to >= data.from, {
6295
+ message: '"to" must be greater than or equal to "from"'
6296
+ })
6297
+ ]),
6298
+ interface: zod_default.string().optional()
6299
+ });
6300
+ var ALL_APP_LISTENER_CONFIG = zod_default.record(
6301
+ zod_default.string(),
6302
+ APP_LISTENER_CONFIG
6303
+ );
6304
+
6208
6305
  // src/components/proto.ts
6209
6306
  var NET_UTILS_GENERAL_TARGET_DEFINITION = zod_default.union([
6210
6307
  zod_default.object({
@@ -6285,6 +6382,7 @@ var OUTPUT_CONFIG = zod_default.object({
6285
6382
  link: INPUT_OR_GENERATOR_INSTANCE_ID.nullable()
6286
6383
  });
6287
6384
  var TOOLBOX_CONFIG = zod_default.object({
6385
+ appListener: APP_LISTENER_CONFIG.partial().optional(),
6288
6386
  inputs: zod_default.record(zod_default.string(), INPUT_CONFIG),
6289
6387
  generators: zod_default.record(zod_default.string(), GENERATOR_CONFIG),
6290
6388
  outputs: zod_default.record(zod_default.string(), OUTPUT_CONFIG),
@@ -6318,7 +6416,11 @@ var DEFAULT_PROPS2 = {
6318
6416
  updates: null
6319
6417
  },
6320
6418
  handlers: { children: {} },
6321
- license: ""
6419
+ license: "",
6420
+ network: {
6421
+ envPort: null,
6422
+ defaultPort: -1
6423
+ }
6322
6424
  };
6323
6425
  var ToolboxRoot = class extends import_base2.Base {
6324
6426
  /** @hidden */
@@ -6347,7 +6449,8 @@ var ToolboxRoot = class extends import_base2.Base {
6347
6449
  config: this.props.config,
6348
6450
  state: this.props.state,
6349
6451
  handlers: this.props.handlers,
6350
- license: this.props.license
6452
+ license: this.props.license,
6453
+ network: this.props.network
6351
6454
  };
6352
6455
  }
6353
6456
  /** @hidden */
@@ -14650,10 +14753,7 @@ var UpdateChecker = ({
14650
14753
 
14651
14754
  // src/env.ts
14652
14755
  var getEnv = (logger2) => {
14653
- const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : {
14654
- from: 4100,
14655
- to: 4200
14656
- };
14756
+ const PORT = process.env.PORT && parseInt(process.env.PORT, 10) || null;
14657
14757
  let API_BASE_URL;
14658
14758
  try {
14659
14759
  API_BASE_URL = process.env.API_BASE_URL ? new URL(process.env.API_BASE_URL) : new URL("https://arcanewizards.com");
@@ -14671,6 +14771,7 @@ var getEnv = (logger2) => {
14671
14771
 
14672
14772
  // src/app.tsx
14673
14773
  var import_jsx_runtime9 = require("react/jsx-runtime");
14774
+ var DEFAULT_PORT = { from: 4100, to: 4200 };
14674
14775
  var App = ({
14675
14776
  title,
14676
14777
  version: version2,
@@ -14728,14 +14829,16 @@ var App = ({
14728
14829
  [handlers]
14729
14830
  );
14730
14831
  const license = useLicense();
14731
- const appListenerConfig = (0, import_react10.useMemo)(
14732
- () => ({
14733
- default: {
14734
- port: env.PORT
14735
- }
14736
- }),
14737
- [env.PORT]
14738
- );
14832
+ const appListenerConfig = (0, import_react10.useMemo)(() => {
14833
+ const baseConfig = {
14834
+ port: data.appListener?.port ?? DEFAULT_PORT,
14835
+ interface: data.appListener?.interface ?? void 0
14836
+ };
14837
+ if (env.PORT) {
14838
+ baseConfig.port = env.PORT;
14839
+ }
14840
+ return baseConfig;
14841
+ }, [env.PORT, data.appListener]);
14739
14842
  if (!license) {
14740
14843
  return;
14741
14844
  }
@@ -14748,7 +14851,11 @@ var App = ({
14748
14851
  handlers: availableHandlers,
14749
14852
  onUpdateConfig,
14750
14853
  onCallHandler: callHandler,
14751
- license: license.text
14854
+ license: license.text,
14855
+ network: {
14856
+ envPort: env.PORT,
14857
+ defaultPort: DEFAULT_PORT
14858
+ }
14752
14859
  }
14753
14860
  ),
14754
14861
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InputConnections, { state, setState }),
@@ -14800,7 +14907,7 @@ var App = ({
14800
14907
  {
14801
14908
  toolkit,
14802
14909
  setWindowUrl,
14803
- listenerConfig: appListenerConfig
14910
+ listenerConfig: { appListenerConfig }
14804
14911
  }
14805
14912
  )
14806
14913
  ]
@@ -14818,7 +14925,7 @@ var createApp = (props) => {
14818
14925
  };
14819
14926
 
14820
14927
  // package.json
14821
- var version = "0.1.3";
14928
+ var version = "0.1.4";
14822
14929
 
14823
14930
  // src/index.ts
14824
14931
  var runTimecodeToolboxServer = ({
@@ -14883,3 +14990,14 @@ lodash/lodash.js:
14883
14990
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
14884
14991
  *)
14885
14992
  */
14993
+ /*! Bundled license information:
14994
+
14995
+ escape-html/index.js:
14996
+ (*!
14997
+ * escape-html
14998
+ * Copyright(c) 2012-2013 TJ Holowaychuk
14999
+ * Copyright(c) 2015 Andreas Lubbe
15000
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
15001
+ * MIT Licensed
15002
+ *)
15003
+ */
package/dist/start.mjs CHANGED
@@ -35,6 +35,53 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
35
35
  mod
36
36
  ));
37
37
 
38
+ // ../../node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js
39
+ var require_escape_html = __commonJS({
40
+ "../../node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js"(exports, module) {
41
+ "use strict";
42
+ var matchHtmlRegExp = /["'&<>]/;
43
+ module.exports = escapeHtml;
44
+ function escapeHtml(string) {
45
+ var str = "" + string;
46
+ var match = matchHtmlRegExp.exec(str);
47
+ if (!match) {
48
+ return str;
49
+ }
50
+ var escape;
51
+ var html = "";
52
+ var index = 0;
53
+ var lastIndex = 0;
54
+ for (index = match.index; index < str.length; index++) {
55
+ switch (str.charCodeAt(index)) {
56
+ case 34:
57
+ escape = "&quot;";
58
+ break;
59
+ case 38:
60
+ escape = "&amp;";
61
+ break;
62
+ case 39:
63
+ escape = "&#39;";
64
+ break;
65
+ case 60:
66
+ escape = "&lt;";
67
+ break;
68
+ case 62:
69
+ escape = "&gt;";
70
+ break;
71
+ default:
72
+ continue;
73
+ }
74
+ if (lastIndex !== index) {
75
+ html += str.substring(lastIndex, index);
76
+ }
77
+ lastIndex = index + 1;
78
+ html += escape;
79
+ }
80
+ return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
81
+ }
82
+ }
83
+ });
84
+
38
85
  // ../../node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/_listCacheClear.js
39
86
  var require_listCacheClear = __commonJS({
40
87
  "../../node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/_listCacheClear.js"(exports, module) {
@@ -1649,6 +1696,7 @@ var SIGIL_NAMESPACE = "sigil";
1649
1696
  var isSigilComponentCall = (call, action) => call.namespace === SIGIL_NAMESPACE && call.action === action;
1650
1697
 
1651
1698
  // ../../packages/sigil/dist/index.js
1699
+ var import_escape_html = __toESM(require_escape_html(), 1);
1652
1700
  import { useEffect as useEffect2, useMemo, useState } from "react";
1653
1701
  import {
1654
1702
  BaseParent,
@@ -1867,6 +1915,26 @@ var runSigilApp = ({
1867
1915
  debug: upstreamLogger.debug.bind(upstreamLogger)
1868
1916
  },
1869
1917
  title,
1918
+ htmlPage: (context) => `
1919
+ <html>
1920
+ <head>
1921
+ <title>${(0, import_escape_html.default)(context.title)}</title>
1922
+ <meta charset="utf-8">
1923
+ <meta name="viewport" content="width=device-width, user-scalable=no" />
1924
+ <style type="text/css">
1925
+ @font-face {
1926
+ font-family: 'Material Symbols Outlined';
1927
+ font-style: normal;
1928
+ src: url(${context.coreAssets.materialSymbolsOutlined}) format('woff');
1929
+ }
1930
+ </style>
1931
+ ${context.coreAssets.entrypointCss ? `<link rel="stylesheet" href="${context.coreAssets.entrypointCss}" />` : ""}
1932
+ </head>
1933
+ <body>
1934
+ <div id="root"></div>
1935
+ <script type="text/javascript" src="${context.coreAssets.entrypointJs}"></script>
1936
+ </body>
1937
+ </html>`,
1870
1938
  ...toolkitOptions
1871
1939
  });
1872
1940
  toolkit.start({
@@ -2062,7 +2130,8 @@ var AppListenerManager = ({
2062
2130
  const resolvedConnectionDetails = {
2063
2131
  config,
2064
2132
  host,
2065
- port
2133
+ port,
2134
+ internal: !!config.interface && !!interfaces[config.interface]?.internal
2066
2135
  };
2067
2136
  try {
2068
2137
  const listener = await toolkit.listen({
@@ -2133,11 +2202,21 @@ var AppListenerManager = ({
2133
2202
  }, [appRegistration, listenerConfig, logger2, toolkit, updateReactState]);
2134
2203
  useEffect3(() => {
2135
2204
  for (const state of Object.values(listenerState)) {
2205
+ let preferredConnection = null;
2136
2206
  if (state.state === "connected") {
2207
+ if (!preferredConnection) {
2208
+ preferredConnection = state;
2209
+ }
2210
+ if (!preferredConnection.internal && state.internal) {
2211
+ preferredConnection = state;
2212
+ }
2213
+ }
2214
+ if (preferredConnection) {
2137
2215
  setWindowUrl(
2138
- new URL(`http://${state.host ?? "localhost"}:${state.port}/`)
2216
+ new URL(
2217
+ `http://${preferredConnection.host ?? "localhost"}:${preferredConnection.port}/`
2218
+ )
2139
2219
  );
2140
- return;
2141
2220
  }
2142
2221
  }
2143
2222
  });
@@ -6218,6 +6297,24 @@ var SIGIL_COLOR = external_exports.enum([
6218
6297
  "gray"
6219
6298
  ]);
6220
6299
 
6300
+ // ../../packages/sigil/dist/shared/config.js
6301
+ var APP_LISTENER_CONFIG = zod_default.object({
6302
+ port: zod_default.union([
6303
+ zod_default.number().int().min(1).max(65535),
6304
+ zod_default.object({
6305
+ from: zod_default.number().int().min(1).max(65535),
6306
+ to: zod_default.number().int().min(1).max(65535)
6307
+ }).refine((data) => data.to >= data.from, {
6308
+ message: '"to" must be greater than or equal to "from"'
6309
+ })
6310
+ ]),
6311
+ interface: zod_default.string().optional()
6312
+ });
6313
+ var ALL_APP_LISTENER_CONFIG = zod_default.record(
6314
+ zod_default.string(),
6315
+ APP_LISTENER_CONFIG
6316
+ );
6317
+
6221
6318
  // src/components/proto.ts
6222
6319
  var NET_UTILS_GENERAL_TARGET_DEFINITION = zod_default.union([
6223
6320
  zod_default.object({
@@ -6298,6 +6395,7 @@ var OUTPUT_CONFIG = zod_default.object({
6298
6395
  link: INPUT_OR_GENERATOR_INSTANCE_ID.nullable()
6299
6396
  });
6300
6397
  var TOOLBOX_CONFIG = zod_default.object({
6398
+ appListener: APP_LISTENER_CONFIG.partial().optional(),
6301
6399
  inputs: zod_default.record(zod_default.string(), INPUT_CONFIG),
6302
6400
  generators: zod_default.record(zod_default.string(), GENERATOR_CONFIG),
6303
6401
  outputs: zod_default.record(zod_default.string(), OUTPUT_CONFIG),
@@ -6331,7 +6429,11 @@ var DEFAULT_PROPS2 = {
6331
6429
  updates: null
6332
6430
  },
6333
6431
  handlers: { children: {} },
6334
- license: ""
6432
+ license: "",
6433
+ network: {
6434
+ envPort: null,
6435
+ defaultPort: -1
6436
+ }
6335
6437
  };
6336
6438
  var ToolboxRoot = class extends Base {
6337
6439
  /** @hidden */
@@ -6360,7 +6462,8 @@ var ToolboxRoot = class extends Base {
6360
6462
  config: this.props.config,
6361
6463
  state: this.props.state,
6362
6464
  handlers: this.props.handlers,
6363
- license: this.props.license
6465
+ license: this.props.license,
6466
+ network: this.props.network
6364
6467
  };
6365
6468
  }
6366
6469
  /** @hidden */
@@ -14682,10 +14785,7 @@ var UpdateChecker = ({
14682
14785
 
14683
14786
  // src/env.ts
14684
14787
  var getEnv = (logger2) => {
14685
- const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : {
14686
- from: 4100,
14687
- to: 4200
14688
- };
14788
+ const PORT = process.env.PORT && parseInt(process.env.PORT, 10) || null;
14689
14789
  let API_BASE_URL;
14690
14790
  try {
14691
14791
  API_BASE_URL = process.env.API_BASE_URL ? new URL(process.env.API_BASE_URL) : new URL("https://arcanewizards.com");
@@ -14703,6 +14803,7 @@ var getEnv = (logger2) => {
14703
14803
 
14704
14804
  // src/app.tsx
14705
14805
  import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
14806
+ var DEFAULT_PORT = { from: 4100, to: 4200 };
14706
14807
  var App = ({
14707
14808
  title,
14708
14809
  version: version2,
@@ -14760,14 +14861,16 @@ var App = ({
14760
14861
  [handlers]
14761
14862
  );
14762
14863
  const license = useLicense();
14763
- const appListenerConfig = useMemo6(
14764
- () => ({
14765
- default: {
14766
- port: env.PORT
14767
- }
14768
- }),
14769
- [env.PORT]
14770
- );
14864
+ const appListenerConfig = useMemo6(() => {
14865
+ const baseConfig = {
14866
+ port: data.appListener?.port ?? DEFAULT_PORT,
14867
+ interface: data.appListener?.interface ?? void 0
14868
+ };
14869
+ if (env.PORT) {
14870
+ baseConfig.port = env.PORT;
14871
+ }
14872
+ return baseConfig;
14873
+ }, [env.PORT, data.appListener]);
14771
14874
  if (!license) {
14772
14875
  return;
14773
14876
  }
@@ -14780,7 +14883,11 @@ var App = ({
14780
14883
  handlers: availableHandlers,
14781
14884
  onUpdateConfig,
14782
14885
  onCallHandler: callHandler,
14783
- license: license.text
14886
+ license: license.text,
14887
+ network: {
14888
+ envPort: env.PORT,
14889
+ defaultPort: DEFAULT_PORT
14890
+ }
14784
14891
  }
14785
14892
  ),
14786
14893
  /* @__PURE__ */ jsx9(InputConnections, { state, setState }),
@@ -14832,7 +14939,7 @@ var App = ({
14832
14939
  {
14833
14940
  toolkit,
14834
14941
  setWindowUrl,
14835
- listenerConfig: appListenerConfig
14942
+ listenerConfig: { appListenerConfig }
14836
14943
  }
14837
14944
  )
14838
14945
  ]
@@ -14850,7 +14957,7 @@ var createApp = (props) => {
14850
14957
  };
14851
14958
 
14852
14959
  // package.json
14853
- var version = "0.1.3";
14960
+ var version = "0.1.4";
14854
14961
 
14855
14962
  // src/index.ts
14856
14963
  var runTimecodeToolboxServer = ({
@@ -14915,3 +15022,14 @@ lodash/lodash.js:
14915
15022
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
14916
15023
  *)
14917
15024
  */
15025
+ /*! Bundled license information:
15026
+
15027
+ escape-html/index.js:
15028
+ (*!
15029
+ * escape-html
15030
+ * Copyright(c) 2012-2013 TJ Holowaychuk
15031
+ * Copyright(c) 2015 Andreas Lubbe
15032
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
15033
+ * MIT Licensed
15034
+ *)
15035
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcanewizards/timecode-toolbox",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -58,9 +58,9 @@
58
58
  "@arcanewizards/artnet": "^0.1.3",
59
59
  "@arcanewizards/eslint-config": "^0.0.0",
60
60
  "@arcanewizards/net-utils": "^0.1.3",
61
- "@arcanewizards/sigil": "^0.1.4",
62
- "@arcanewizards/typescript-config": "^0.0.0",
63
- "@arcanewizards/tcnet": "^0.1.3"
61
+ "@arcanewizards/sigil": "^0.1.6",
62
+ "@arcanewizards/tcnet": "^0.1.3",
63
+ "@arcanewizards/typescript-config": "^0.0.0"
64
64
  },
65
65
  "dependencies": {
66
66
  "@arcanejs/react-toolkit": "^0.15.1",