@hyperfixi/core 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +218 -0
- package/dist/__test-utils__/context-builders.d.ts +42 -0
- package/dist/__test-utils__/error-testing.d.ts +18 -0
- package/dist/__test-utils__/index.d.ts +6 -0
- package/dist/__test-utils__/mock-types.d.ts +57 -0
- package/dist/__test-utils__/parser-context-mock.d.ts +7 -0
- package/dist/__test-utils__/parser-helpers.d.ts +38 -0
- package/dist/api/dom-processor.d.ts +17 -0
- package/dist/api/hyperscript-api.d.ts +68 -0
- package/dist/api/lokascript-api.d.ts +9 -0
- package/dist/ast-utils/analyzer.d.ts +19 -0
- package/dist/ast-utils/documentation.d.ts +8 -0
- package/dist/ast-utils/generator.d.ts +9 -0
- package/dist/ast-utils/index.d.ts +12 -0
- package/dist/ast-utils/index.js +3366 -0
- package/dist/ast-utils/index.mjs +3320 -0
- package/dist/ast-utils/interchange/from-core.d.ts +8 -0
- package/dist/ast-utils/interchange/index.d.ts +6 -0
- package/dist/ast-utils/interchange/lsp.d.ts +108 -0
- package/dist/ast-utils/interchange/to-core.d.ts +8 -0
- package/dist/ast-utils/interchange/types.d.ts +113 -0
- package/dist/ast-utils/query.d.ts +25 -0
- package/dist/ast-utils/transformer.d.ts +14 -0
- package/dist/ast-utils/types.d.ts +162 -0
- package/dist/ast-utils/visitor.d.ts +40 -0
- package/dist/behaviors/boosted.d.ts +29 -0
- package/dist/behaviors/history-swap.d.ts +24 -0
- package/dist/behaviors/index.d.ts +4 -0
- package/dist/behaviors/index.js +1149 -0
- package/dist/behaviors/index.mjs +1139 -0
- package/dist/bundle-generator/generator.d.ts +4 -0
- package/dist/bundle-generator/index.d.ts +6 -0
- package/dist/bundle-generator/index.js +2294 -0
- package/dist/bundle-generator/index.mjs +2271 -0
- package/dist/bundle-generator/parser-templates.d.ts +6 -0
- package/dist/bundle-generator/template-capabilities.d.ts +10 -0
- package/dist/bundle-generator/templates.d.ts +11 -0
- package/dist/bundle-generator/types.d.ts +34 -0
- package/dist/bundles/test-minimal.d.ts +3 -0
- package/dist/bundles/test-standard.d.ts +3 -0
- package/dist/chunks/bridge-I6ceoWxV.js +2 -0
- package/dist/chunks/browser-modular-Dv6PAV3c.js +2 -0
- package/dist/chunks/feature-eventsource-DWb514fy.js +2 -0
- package/dist/chunks/feature-sockets-3PFuvCVY.js +2 -0
- package/dist/chunks/feature-webworker-DTm_eh-E.js +2 -0
- package/dist/commands/advanced/async.d.ts +28 -0
- package/dist/commands/advanced/js.d.ts +28 -0
- package/dist/commands/animation/measure.d.ts +31 -0
- package/dist/commands/animation/settle.d.ts +26 -0
- package/dist/commands/animation/take.d.ts +28 -0
- package/dist/commands/animation/transition.d.ts +31 -0
- package/dist/commands/async/fetch.d.ts +44 -0
- package/dist/commands/async/wait.d.ts +41 -0
- package/dist/commands/behaviors/install.d.ts +41 -0
- package/dist/commands/content/append.d.ts +27 -0
- package/dist/commands/control-flow/break.d.ts +15 -0
- package/dist/commands/control-flow/continue.d.ts +15 -0
- package/dist/commands/control-flow/exit.d.ts +15 -0
- package/dist/commands/control-flow/halt.d.ts +25 -0
- package/dist/commands/control-flow/if.d.ts +45 -0
- package/dist/commands/control-flow/repeat.d.ts +35 -0
- package/dist/commands/control-flow/return.d.ts +23 -0
- package/dist/commands/control-flow/signal-base.d.ts +25 -0
- package/dist/commands/control-flow/throw.d.ts +22 -0
- package/dist/commands/control-flow/unless.d.ts +3 -0
- package/dist/commands/data/decrement.d.ts +3 -0
- package/dist/commands/data/default.d.ts +31 -0
- package/dist/commands/data/get.d.ts +23 -0
- package/dist/commands/data/increment.d.ts +25 -0
- package/dist/commands/data/set.d.ts +56 -0
- package/dist/commands/decorators/index.d.ts +30 -0
- package/dist/commands/dom/__tests__/add-standalone-helpers.d.ts +11 -0
- package/dist/commands/dom/add.d.ts +31 -0
- package/dist/commands/dom/dom-modification-base.d.ts +48 -0
- package/dist/commands/dom/hide.d.ts +12 -0
- package/dist/commands/dom/make.d.ts +21 -0
- package/dist/commands/dom/process-partials.d.ts +39 -0
- package/dist/commands/dom/put.d.ts +31 -0
- package/dist/commands/dom/remove.d.ts +33 -0
- package/dist/commands/dom/show.d.ts +13 -0
- package/dist/commands/dom/swap.d.ts +38 -0
- package/dist/commands/dom/toggle.d.ts +55 -0
- package/dist/commands/dom/visibility-base.d.ts +20 -0
- package/dist/commands/events/send.d.ts +3 -0
- package/dist/commands/events/trigger.d.ts +36 -0
- package/dist/commands/execution/call.d.ts +24 -0
- package/dist/commands/execution/pseudo-command.d.ts +42 -0
- package/dist/commands/helpers/attribute-manipulation.d.ts +11 -0
- package/dist/commands/helpers/batch-dom-operations.d.ts +12 -0
- package/dist/commands/helpers/class-manipulation.d.ts +11 -0
- package/dist/commands/helpers/condition-helpers.d.ts +4 -0
- package/dist/commands/helpers/dom-mutation.d.ts +15 -0
- package/dist/commands/helpers/duration-parsing.d.ts +8 -0
- package/dist/commands/helpers/element-property-access.d.ts +7 -0
- package/dist/commands/helpers/element-resolution.d.ts +17 -0
- package/dist/commands/helpers/error-helpers.d.ts +17 -0
- package/dist/commands/helpers/event-helpers.d.ts +13 -0
- package/dist/commands/helpers/event-waiting.d.ts +37 -0
- package/dist/commands/helpers/index.d.ts +32 -0
- package/dist/commands/helpers/input-validator.d.ts +23 -0
- package/dist/commands/helpers/loop-executor.d.ts +53 -0
- package/dist/commands/helpers/numeric-target-parser.d.ts +14 -0
- package/dist/commands/helpers/property-target.d.ts +30 -0
- package/dist/commands/helpers/selector-type-detection.d.ts +24 -0
- package/dist/commands/helpers/smart-element.d.ts +16 -0
- package/dist/commands/helpers/style-manipulation.d.ts +16 -0
- package/dist/commands/helpers/temporal-modifiers.d.ts +15 -0
- package/dist/commands/helpers/url-argument-parser.d.ts +10 -0
- package/dist/commands/helpers/url-validation.d.ts +7 -0
- package/dist/commands/helpers/variable-access.d.ts +10 -0
- package/dist/commands/helpers/visibility-target-parser.d.ts +11 -0
- package/dist/commands/index.d.ts +139 -0
- package/dist/commands/index.js +9186 -0
- package/dist/commands/index.mjs +9032 -0
- package/dist/commands/navigation/go.d.ts +35 -0
- package/dist/commands/navigation/push-url.d.ts +35 -0
- package/dist/commands/navigation/replace-url.d.ts +3 -0
- package/dist/commands/templates/render.d.ts +48 -0
- package/dist/commands/utility/beep.d.ts +32 -0
- package/dist/commands/utility/copy.d.ts +29 -0
- package/dist/commands/utility/log.d.ts +24 -0
- package/dist/commands/utility/pick.d.ts +26 -0
- package/dist/commands/utility/tell.d.ts +26 -0
- package/dist/compatibility/browser-bundle-animation-generated.d.ts +16 -0
- package/dist/compatibility/browser-bundle-classic-i18n.d.ts +63 -0
- package/dist/compatibility/browser-bundle-classic.d.ts +17 -0
- package/dist/compatibility/browser-bundle-forms-generated.d.ts +16 -0
- package/dist/compatibility/browser-bundle-hybrid-complete.d.ts +28 -0
- package/dist/compatibility/browser-bundle-hybrid-hx.d.ts +43 -0
- package/dist/compatibility/browser-bundle-lite-plus.d.ts +25 -0
- package/dist/compatibility/browser-bundle-lite.d.ts +23 -0
- package/dist/compatibility/browser-bundle-minimal-generated.d.ts +16 -0
- package/dist/compatibility/browser-bundle-minimal-v2.d.ts +17 -0
- package/dist/compatibility/browser-bundle-minimal.d.ts +8 -0
- package/dist/compatibility/browser-bundle-modular.d.ts +18 -0
- package/dist/compatibility/browser-bundle-multilingual.d.ts +19 -0
- package/dist/compatibility/browser-bundle-semantic-complete.d.ts +24 -0
- package/dist/compatibility/browser-bundle-standard-v2.d.ts +17 -0
- package/dist/compatibility/browser-bundle-standard.d.ts +8 -0
- package/dist/compatibility/browser-bundle-textshelf-minimal.d.ts +16 -0
- package/dist/compatibility/browser-bundle-textshelf-profile.d.ts +18 -0
- package/dist/compatibility/browser-bundle.d.ts +140 -0
- package/dist/compatibility/browser-modular.d.ts +53 -0
- package/dist/compatibility/browser-tests/test-utils.d.ts +21 -0
- package/dist/compatibility/eval-hyperscript.d.ts +15 -0
- package/dist/compatibility/feature-loader.d.ts +8 -0
- package/dist/compatibility/hyperscript-adapter.d.ts +38 -0
- package/dist/compatibility/hyperscript-tests/test-adapter.d.ts +13 -0
- package/dist/core/ast-property-utils.d.ts +2 -0
- package/dist/core/base-expression-evaluator.d.ts +70 -0
- package/dist/core/binary-expression-evaluator.d.ts +7 -0
- package/dist/core/call-expression-evaluator.d.ts +7 -0
- package/dist/core/configurable-expression-evaluator.d.ts +5 -0
- package/dist/core/context.d.ts +15 -0
- package/dist/core/dom.d.ts +15 -0
- package/dist/core/evaluator-types.d.ts +5 -0
- package/dist/core/events.d.ts +48 -0
- package/dist/core/executor.d.ts +34 -0
- package/dist/core/expression-evaluator.d.ts +6 -0
- package/dist/core/lazy-expression-evaluator.d.ts +22 -0
- package/dist/core/parser.d.ts +21 -0
- package/dist/core/selector-evaluator.d.ts +15 -0
- package/dist/core/template-literal-evaluator.d.ts +5 -0
- package/dist/dom/attribute-processor.d.ts +40 -0
- package/dist/dom/minimal-attribute-processor.d.ts +20 -0
- package/dist/experimental/binary-tree/accessor.d.ts +10 -0
- package/dist/experimental/binary-tree/ast-serializer.d.ts +26 -0
- package/dist/experimental/binary-tree/benchmark.d.ts +24 -0
- package/dist/experimental/binary-tree/buffer-context.d.ts +27 -0
- package/dist/experimental/binary-tree/deserializer.d.ts +17 -0
- package/dist/experimental/binary-tree/index.d.ts +22 -0
- package/dist/experimental/binary-tree/serializer.d.ts +4 -0
- package/dist/experimental/binary-tree/types.d.ts +54 -0
- package/dist/expressions/base-expression.d.ts +27 -0
- package/dist/expressions/bundles/common-expressions.d.ts +9 -0
- package/dist/expressions/bundles/core-expressions.d.ts +7 -0
- package/dist/expressions/bundles/full-expressions.d.ts +10 -0
- package/dist/expressions/bundles/index.d.ts +7 -0
- package/dist/expressions/comparison/index.d.ts +80 -0
- package/dist/expressions/comparison/utils.d.ts +2 -0
- package/dist/expressions/conversion/impl/bridge.d.ts +117 -0
- package/dist/expressions/conversion/impl/index.d.ts +59 -0
- package/dist/expressions/conversion/index.d.ts +23 -0
- package/dist/expressions/expression-tiers.d.ts +13 -0
- package/dist/expressions/index.d.ts +11 -0
- package/dist/expressions/index.js +6930 -0
- package/dist/expressions/index.mjs +6912 -0
- package/dist/expressions/logical/impl/index.d.ts +54 -0
- package/dist/expressions/logical/impl/pattern-matching.d.ts +58 -0
- package/dist/expressions/logical/index.d.ts +59 -0
- package/dist/expressions/mathematical/index.d.ts +69 -0
- package/dist/expressions/positional/impl/bridge.d.ts +95 -0
- package/dist/expressions/positional/impl/index.d.ts +73 -0
- package/dist/expressions/positional/index.d.ts +26 -0
- package/dist/expressions/properties/impl/index.d.ts +105 -0
- package/dist/expressions/properties/index.d.ts +26 -0
- package/dist/expressions/property/index.d.ts +55 -0
- package/dist/expressions/property-access-utils.d.ts +23 -0
- package/dist/expressions/references/impl/bridge.d.ts +54 -0
- package/dist/expressions/references/impl/index.d.ts +65 -0
- package/dist/expressions/references/index.d.ts +40 -0
- package/dist/expressions/shared/comparison-utils.d.ts +10 -0
- package/dist/expressions/shared/index.d.ts +9 -0
- package/dist/expressions/shared/number-utils.d.ts +7 -0
- package/dist/expressions/shared/validation-utils.d.ts +13 -0
- package/dist/expressions/special/index.d.ts +104 -0
- package/dist/expressions/type-helpers.d.ts +11 -0
- package/dist/expressions/type-registry.d.ts +57 -0
- package/dist/expressions/validation-helpers.d.ts +15 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/tailwind.d.ts +22 -0
- package/dist/features/behaviors.d.ts +153 -0
- package/dist/features/def.d.ts +135 -0
- package/dist/features/eventsource.d.ts +140 -0
- package/dist/features/init.d.ts +135 -0
- package/dist/features/on.d.ts +131 -0
- package/dist/features/predefined-behaviors/dropdown-behavior.d.ts +20 -0
- package/dist/features/predefined-behaviors/index.d.ts +12 -0
- package/dist/features/predefined-behaviors/modal-behavior.d.ts +18 -0
- package/dist/features/predefined-behaviors/toggle-group-behavior.d.ts +23 -0
- package/dist/features/predefined-behaviors/types.d.ts +14 -0
- package/dist/features/sockets.d.ts +162 -0
- package/dist/features/webworker.d.ts +135 -0
- package/dist/htmx/htmx-attribute-processor.d.ts +84 -0
- package/dist/htmx/htmx-translator.d.ts +19 -0
- package/dist/htmx/index.d.ts +3 -0
- package/dist/hyperfixi-classic-i18n.js +2 -0
- package/dist/hyperfixi-hx.js +1 -0
- package/dist/hyperfixi-hybrid-complete.js +1 -0
- package/dist/hyperfixi-lite-plus.js +1 -0
- package/dist/hyperfixi-lite.js +1 -0
- package/dist/hyperfixi-minimal.js +1 -0
- package/dist/hyperfixi-multilingual.js +2 -0
- package/dist/hyperfixi-standard.js +2 -0
- package/dist/hyperfixi.js +2 -0
- package/dist/hyperfixi.mjs +2 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +65387 -0
- package/dist/index.min.js +2 -0
- package/dist/index.mjs +65343 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/morph-adapter.d.ts +22 -0
- package/dist/lib/swap-executor.d.ts +22 -0
- package/dist/lib/view-transitions.d.ts +33 -0
- package/dist/lokascript-browser-classic-i18n.js +2 -0
- package/dist/lokascript-browser-minimal.js +1 -0
- package/dist/lokascript-browser-standard.js +2 -0
- package/dist/lokascript-browser.js +2 -0
- package/dist/lokascript-hybrid-complete.js +1 -0
- package/dist/lokascript-hybrid-hx.js +1 -0
- package/dist/lokascript-lite-plus.js +1 -0
- package/dist/lokascript-lite.js +1 -0
- package/dist/lokascript-multilingual.js +2 -0
- package/dist/lsp-metadata.d.ts +25 -0
- package/dist/lsp-metadata.js +680 -0
- package/dist/lsp-metadata.mjs +670 -0
- package/dist/metadata.d.ts +213 -0
- package/dist/metadata.js +378 -0
- package/dist/metadata.mjs +368 -0
- package/dist/mod.d.ts +63 -0
- package/dist/multilingual/bridge.d.ts +36 -0
- package/dist/multilingual/index.d.ts +32 -0
- package/dist/multilingual/index.js +285 -0
- package/dist/multilingual/index.mjs +278 -0
- package/dist/parser/__types__/test-helpers.d.ts +25 -0
- package/dist/parser/command-node-builder.d.ts +45 -0
- package/dist/parser/command-parsers/animation-commands.d.ts +5 -0
- package/dist/parser/command-parsers/async-commands.d.ts +5 -0
- package/dist/parser/command-parsers/control-flow-commands.d.ts +7 -0
- package/dist/parser/command-parsers/dom-commands.d.ts +8 -0
- package/dist/parser/command-parsers/event-commands.d.ts +4 -0
- package/dist/parser/command-parsers/utility-commands.d.ts +9 -0
- package/dist/parser/command-parsers/variable-commands.d.ts +12 -0
- package/dist/parser/error-handler.d.ts +34 -0
- package/dist/parser/expression-parser.d.ts +6 -0
- package/dist/parser/full-parser.d.ts +4 -0
- package/dist/parser/full-parser.js +6532 -0
- package/dist/parser/full-parser.mjs +6529 -0
- package/dist/parser/helpers/ast-helpers.d.ts +22 -0
- package/dist/parser/helpers/parsing-helpers.d.ts +19 -0
- package/dist/parser/helpers/token-helpers.d.ts +28 -0
- package/dist/parser/hybrid/aliases.d.ts +7 -0
- package/dist/parser/hybrid/aliases.js +44 -0
- package/dist/parser/hybrid/aliases.mjs +37 -0
- package/dist/parser/hybrid/ast-types.d.ts +97 -0
- package/dist/parser/hybrid/ast-types.js +3 -0
- package/dist/parser/hybrid/ast-types.mjs +2 -0
- package/dist/parser/hybrid/index.d.ts +6 -0
- package/dist/parser/hybrid/index.js +1015 -0
- package/dist/parser/hybrid/index.mjs +1005 -0
- package/dist/parser/hybrid/parser-core.d.ts +57 -0
- package/dist/parser/hybrid/parser-core.js +1001 -0
- package/dist/parser/hybrid/parser-core.mjs +999 -0
- package/dist/parser/hybrid/tokenizer.d.ts +9 -0
- package/dist/parser/hybrid/tokenizer.js +242 -0
- package/dist/parser/hybrid/tokenizer.mjs +239 -0
- package/dist/parser/hybrid-parser.d.ts +10 -0
- package/dist/parser/hybrid-parser.js +1078 -0
- package/dist/parser/hybrid-parser.mjs +1071 -0
- package/dist/parser/parser-constants.d.ts +102 -0
- package/dist/parser/parser-interface.d.ts +11 -0
- package/dist/parser/parser-types.d.ts +175 -0
- package/dist/parser/parser.d.ts +146 -0
- package/dist/parser/regex-parser.d.ts +4 -0
- package/dist/parser/regex-parser.js +412 -0
- package/dist/parser/regex-parser.mjs +409 -0
- package/dist/parser/runtime.d.ts +3 -0
- package/dist/parser/semantic-integration.d.ts +61 -0
- package/dist/parser/token-consumer.d.ts +35 -0
- package/dist/parser/token-predicates.d.ts +77 -0
- package/dist/parser/tokenizer.d.ts +57 -0
- package/dist/parser/types.d.ts +118 -0
- package/dist/performance/expression-cache.d.ts +78 -0
- package/dist/performance/integration.d.ts +40 -0
- package/dist/performance/production-monitor.d.ts +67 -0
- package/dist/reference/index.d.ts +41 -0
- package/dist/reference/index.js +586 -0
- package/dist/reference/index.mjs +577 -0
- package/dist/registry/browser-types.d.ts +20 -0
- package/dist/registry/browser-types.js +81 -0
- package/dist/registry/browser-types.mjs +76 -0
- package/dist/registry/context-provider-registry.d.ts +38 -0
- package/dist/registry/environment.d.ts +19 -0
- package/dist/registry/environment.js +36 -0
- package/dist/registry/environment.mjs +30 -0
- package/dist/registry/event-source-registry.d.ts +54 -0
- package/dist/registry/examples/server-commands.d.ts +6 -0
- package/dist/registry/examples/server-event-source.d.ts +32 -0
- package/dist/registry/index.d.ts +54 -0
- package/dist/registry/index.js +7636 -0
- package/dist/registry/index.mjs +7612 -0
- package/dist/registry/multilingual/examples.d.ts +16 -0
- package/dist/registry/multilingual/index.d.ts +68 -0
- package/dist/registry/runtime-integration.d.ts +30 -0
- package/dist/registry/universal-types.d.ts +34 -0
- package/dist/registry/universal-types.js +91 -0
- package/dist/registry/universal-types.mjs +86 -0
- package/dist/runtime/cleanup-registry.d.ts +47 -0
- package/dist/runtime/command-adapter.d.ts +63 -0
- package/dist/runtime/environment.d.ts +75 -0
- package/dist/runtime/runtime-base.d.ts +78 -0
- package/dist/runtime/runtime-experimental.d.ts +18 -0
- package/dist/runtime/runtime-factory.d.ts +30 -0
- package/dist/runtime/runtime.d.ts +19 -0
- package/dist/runtime/temporal-modifiers.d.ts +37 -0
- package/dist/scripts/code-generator.d.ts +64 -0
- package/dist/scripts/generate-missing-commands.d.ts +4 -0
- package/dist/test-setup.d.ts +45 -0
- package/dist/test-utilities.d.ts +52 -0
- package/dist/tokenizer.d.ts +49 -0
- package/dist/types/base-types.d.ts +336 -0
- package/dist/types/code-fix.d.ts +39 -0
- package/dist/types/command-metadata.d.ts +57 -0
- package/dist/types/command-types.d.ts +272 -0
- package/dist/types/context-types.d.ts +106 -0
- package/dist/types/core-context.d.ts +21 -0
- package/dist/types/core.d.ts +203 -0
- package/dist/types/error-codes.d.ts +207 -0
- package/dist/types/expression-types.d.ts +155 -0
- package/dist/types/feature-types.d.ts +81 -0
- package/dist/types/hooks.d.ts +45 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/result.d.ts +72 -0
- package/dist/types/template-types.d.ts +162 -0
- package/dist/types/type-guards.d.ts +24 -0
- package/dist/types/unified-types.d.ts +99 -0
- package/dist/utils/debug-events.d.ts +41 -0
- package/dist/utils/debug.d.ts +35 -0
- package/dist/utils/dom-utils.d.ts +16 -0
- package/dist/utils/element-check.d.ts +7 -0
- package/dist/utils/keyboard-shortcuts.d.ts +18 -0
- package/dist/utils/performance.d.ts +40 -0
- package/dist/validation/command-pattern-validator.d.ts +53 -0
- package/dist/validation/common-validators.d.ts +24 -0
- package/dist/validation/lightweight-validators.d.ts +113 -0
- package/dist/validation/partial-validation-types.d.ts +50 -0
- package/dist/validation/partial-validator.d.ts +6 -0
- package/dist/validation/partial-warning-formatter.d.ts +6 -0
- package/dist/validation/validate-cli.d.ts +41 -0
- package/package.json +292 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
function isBrowserPayload(payload) {
|
|
2
|
+
return (typeof window !== 'undefined' &&
|
|
3
|
+
typeof document !== 'undefined' &&
|
|
4
|
+
(payload.target == null || payload.target instanceof Element));
|
|
5
|
+
}
|
|
6
|
+
function isBrowserEventSource(source) {
|
|
7
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
8
|
+
}
|
|
9
|
+
function createDOMEventSource(eventName, options) {
|
|
10
|
+
const target = options?.target ?? document;
|
|
11
|
+
const capture = options?.capture ?? false;
|
|
12
|
+
return {
|
|
13
|
+
name: eventName,
|
|
14
|
+
description: options?.description ?? `DOM ${eventName} events`,
|
|
15
|
+
supportedEvents: [eventName],
|
|
16
|
+
subscribe(subscribeOptions, context) {
|
|
17
|
+
const handler = (e) => {
|
|
18
|
+
const payload = {
|
|
19
|
+
type: eventName,
|
|
20
|
+
data: e,
|
|
21
|
+
target: e.target instanceof Element ? e.target : null,
|
|
22
|
+
nativeEvent: e,
|
|
23
|
+
};
|
|
24
|
+
subscribeOptions.handler(payload, context);
|
|
25
|
+
};
|
|
26
|
+
target.addEventListener(eventName, handler, { capture });
|
|
27
|
+
return {
|
|
28
|
+
id: `${eventName}_${Date.now()}_${Math.random().toString(36).slice(2)}`,
|
|
29
|
+
source: eventName,
|
|
30
|
+
event: eventName,
|
|
31
|
+
unsubscribe: () => target.removeEventListener(eventName, handler, { capture }),
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
supports(event) {
|
|
35
|
+
return event === eventName;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function createCustomEventSource(eventName, options) {
|
|
40
|
+
const target = options?.target ?? document;
|
|
41
|
+
return {
|
|
42
|
+
name: eventName,
|
|
43
|
+
description: options?.description ?? `Custom ${eventName} events`,
|
|
44
|
+
supportedEvents: [eventName],
|
|
45
|
+
subscribe(subscribeOptions, context) {
|
|
46
|
+
const handler = (e) => {
|
|
47
|
+
const customEvent = e;
|
|
48
|
+
const payload = {
|
|
49
|
+
type: eventName,
|
|
50
|
+
data: customEvent.detail,
|
|
51
|
+
target: e.target instanceof Element ? e.target : null,
|
|
52
|
+
nativeEvent: e,
|
|
53
|
+
meta: {
|
|
54
|
+
bubbles: customEvent.bubbles,
|
|
55
|
+
cancelable: customEvent.cancelable,
|
|
56
|
+
composed: customEvent.composed,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
subscribeOptions.handler(payload, context);
|
|
60
|
+
};
|
|
61
|
+
target.addEventListener(eventName, handler);
|
|
62
|
+
return {
|
|
63
|
+
id: `${eventName}_${Date.now()}_${Math.random().toString(36).slice(2)}`,
|
|
64
|
+
source: eventName,
|
|
65
|
+
event: eventName,
|
|
66
|
+
unsubscribe: () => target.removeEventListener(eventName, handler),
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
supports(event) {
|
|
70
|
+
return event === eventName;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { createCustomEventSource, createDOMEventSource, isBrowserEventSource, isBrowserPayload };
|
|
76
|
+
//# sourceMappingURL=browser-types.mjs.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ExecutionContext } from '../types/core';
|
|
2
|
+
export type ContextProviderFn<T = unknown> = (context: ExecutionContext) => T | Promise<T>;
|
|
3
|
+
export interface ContextProvider<T = unknown> {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly description?: string;
|
|
6
|
+
readonly provide: ContextProviderFn<T>;
|
|
7
|
+
readonly cache?: boolean;
|
|
8
|
+
readonly async?: boolean;
|
|
9
|
+
readonly dependencies?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface ContextProviderOptions<T = unknown> {
|
|
12
|
+
description?: string;
|
|
13
|
+
cache?: boolean;
|
|
14
|
+
dependencies?: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare class ContextProviderRegistry {
|
|
17
|
+
private providers;
|
|
18
|
+
private globalProviders;
|
|
19
|
+
register<T>(name: string, provider: ContextProviderFn<T> | ContextProvider<T>, options?: ContextProviderOptions<T>): void;
|
|
20
|
+
registerGlobal<T>(name: string, provider: ContextProviderFn<T> | ContextProvider<T>, options?: ContextProviderOptions<T>): void;
|
|
21
|
+
unregister(name: string): boolean;
|
|
22
|
+
unregisterGlobal(name: string): boolean;
|
|
23
|
+
get(name: string): ContextProvider | undefined;
|
|
24
|
+
has(name: string): boolean;
|
|
25
|
+
resolve<T = unknown>(name: string, context: ExecutionContext, cache?: Map<string, unknown>): Promise<T | undefined>;
|
|
26
|
+
resolveSync<T = unknown>(name: string, context: ExecutionContext, cache?: Map<string, unknown>): T | undefined;
|
|
27
|
+
enhance<T extends ExecutionContext>(context: T): T & Record<string, unknown>;
|
|
28
|
+
resolveAll(context: ExecutionContext): Promise<Record<string, unknown>>;
|
|
29
|
+
getProviderNames(): string[];
|
|
30
|
+
clear(): void;
|
|
31
|
+
}
|
|
32
|
+
export declare function createContextProviderRegistry(): ContextProviderRegistry;
|
|
33
|
+
export declare function getDefaultContextProviderRegistry(): ContextProviderRegistry;
|
|
34
|
+
export declare const meProvider: ContextProvider<Element | null>;
|
|
35
|
+
export declare const itProvider: ContextProvider<unknown>;
|
|
36
|
+
export declare const youProvider: ContextProvider<Element | null>;
|
|
37
|
+
export declare const eventProvider: ContextProvider<Event | null | undefined>;
|
|
38
|
+
//# sourceMappingURL=context-provider-registry.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type RuntimeEnvironment = 'browser' | 'node' | 'universal';
|
|
2
|
+
export type DetectEnvironment<T = typeof globalThis> = T extends {
|
|
3
|
+
document: any;
|
|
4
|
+
window: any;
|
|
5
|
+
} ? 'browser' : T extends {
|
|
6
|
+
process: any;
|
|
7
|
+
require: any;
|
|
8
|
+
} ? 'node' : 'universal';
|
|
9
|
+
export declare function isBrowserEnvironment(): boolean;
|
|
10
|
+
export declare function isNodeEnvironment(): boolean;
|
|
11
|
+
export declare function getRuntimeEnvironment(): 'browser' | 'node' | 'unknown';
|
|
12
|
+
export declare function assertBrowserEnvironment(): asserts this is {
|
|
13
|
+
window: Window;
|
|
14
|
+
document: Document;
|
|
15
|
+
};
|
|
16
|
+
export declare function assertNodeEnvironment(): asserts this is {
|
|
17
|
+
process: NodeJS.Process;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isBrowserEnvironment() {
|
|
4
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
5
|
+
}
|
|
6
|
+
function isNodeEnvironment() {
|
|
7
|
+
return (typeof process !== 'undefined' && process.versions != null && process.versions.node != null);
|
|
8
|
+
}
|
|
9
|
+
function getRuntimeEnvironment() {
|
|
10
|
+
if (isBrowserEnvironment())
|
|
11
|
+
return 'browser';
|
|
12
|
+
if (isNodeEnvironment())
|
|
13
|
+
return 'node';
|
|
14
|
+
return 'unknown';
|
|
15
|
+
}
|
|
16
|
+
function assertBrowserEnvironment() {
|
|
17
|
+
if (!isBrowserEnvironment()) {
|
|
18
|
+
throw new Error('This function requires a browser environment with DOM APIs. ' +
|
|
19
|
+
'Current environment: ' +
|
|
20
|
+
getRuntimeEnvironment());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function assertNodeEnvironment() {
|
|
24
|
+
if (!isNodeEnvironment()) {
|
|
25
|
+
throw new Error('This function requires a Node.js environment. ' +
|
|
26
|
+
'Current environment: ' +
|
|
27
|
+
getRuntimeEnvironment());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.assertBrowserEnvironment = assertBrowserEnvironment;
|
|
32
|
+
exports.assertNodeEnvironment = assertNodeEnvironment;
|
|
33
|
+
exports.getRuntimeEnvironment = getRuntimeEnvironment;
|
|
34
|
+
exports.isBrowserEnvironment = isBrowserEnvironment;
|
|
35
|
+
exports.isNodeEnvironment = isNodeEnvironment;
|
|
36
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function isBrowserEnvironment() {
|
|
2
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
3
|
+
}
|
|
4
|
+
function isNodeEnvironment() {
|
|
5
|
+
return (typeof process !== 'undefined' && process.versions != null && process.versions.node != null);
|
|
6
|
+
}
|
|
7
|
+
function getRuntimeEnvironment() {
|
|
8
|
+
if (isBrowserEnvironment())
|
|
9
|
+
return 'browser';
|
|
10
|
+
if (isNodeEnvironment())
|
|
11
|
+
return 'node';
|
|
12
|
+
return 'unknown';
|
|
13
|
+
}
|
|
14
|
+
function assertBrowserEnvironment() {
|
|
15
|
+
if (!isBrowserEnvironment()) {
|
|
16
|
+
throw new Error('This function requires a browser environment with DOM APIs. ' +
|
|
17
|
+
'Current environment: ' +
|
|
18
|
+
getRuntimeEnvironment());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function assertNodeEnvironment() {
|
|
22
|
+
if (!isNodeEnvironment()) {
|
|
23
|
+
throw new Error('This function requires a Node.js environment. ' +
|
|
24
|
+
'Current environment: ' +
|
|
25
|
+
getRuntimeEnvironment());
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { assertBrowserEnvironment, assertNodeEnvironment, getRuntimeEnvironment, isBrowserEnvironment, isNodeEnvironment };
|
|
30
|
+
//# sourceMappingURL=environment.mjs.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ExecutionContext } from '../types/core';
|
|
2
|
+
import type { RuntimeEnvironment } from './environment';
|
|
3
|
+
export type { RuntimeEnvironment } from './environment';
|
|
4
|
+
export type EventTarget<TEnv extends RuntimeEnvironment> = TEnv extends 'browser' ? Element : TEnv extends 'node' ? object : Element | object;
|
|
5
|
+
export type NativeEvent<TEnv extends RuntimeEnvironment> = TEnv extends 'browser' ? Event : TEnv extends 'node' ? never : Event | undefined;
|
|
6
|
+
export interface EventSourcePayload<TEnv extends RuntimeEnvironment = 'universal'> {
|
|
7
|
+
type: string;
|
|
8
|
+
data: unknown;
|
|
9
|
+
target?: EventTarget<TEnv> | null;
|
|
10
|
+
nativeEvent?: NativeEvent<TEnv>;
|
|
11
|
+
meta?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export type EventSourceHandler<TEnv extends RuntimeEnvironment = 'universal'> = (payload: EventSourcePayload<TEnv>, context: ExecutionContext) => void;
|
|
14
|
+
export interface EventSourceSubscription {
|
|
15
|
+
id: string;
|
|
16
|
+
source: string;
|
|
17
|
+
event: string;
|
|
18
|
+
unsubscribe: () => void;
|
|
19
|
+
}
|
|
20
|
+
export interface EventSourceSubscribeOptions {
|
|
21
|
+
event: string;
|
|
22
|
+
handler: EventSourceHandler;
|
|
23
|
+
target?: string | RegExp;
|
|
24
|
+
selector?: string;
|
|
25
|
+
options?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface EventSource {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
readonly supportedEvents?: string[];
|
|
31
|
+
subscribe(options: EventSourceSubscribeOptions, context: ExecutionContext): EventSourceSubscription;
|
|
32
|
+
supports?(event: string): boolean;
|
|
33
|
+
initialize?(): Promise<void> | void;
|
|
34
|
+
destroy?(): void;
|
|
35
|
+
}
|
|
36
|
+
export declare class EventSourceRegistry {
|
|
37
|
+
private sources;
|
|
38
|
+
private subscriptions;
|
|
39
|
+
private nextId;
|
|
40
|
+
register(name: string, source: EventSource): void;
|
|
41
|
+
unregister(name: string): boolean;
|
|
42
|
+
get(name: string): EventSource | undefined;
|
|
43
|
+
has(name: string): boolean;
|
|
44
|
+
subscribe(sourceName: string, options: EventSourceSubscribeOptions, context: ExecutionContext): EventSourceSubscription | undefined;
|
|
45
|
+
unsubscribe(subscriptionId: string): boolean;
|
|
46
|
+
getSourceNames(): string[];
|
|
47
|
+
getSubscriptions(): EventSourceSubscription[];
|
|
48
|
+
findSourceForEvent(event: string): string | undefined;
|
|
49
|
+
generateId(): string;
|
|
50
|
+
destroy(): void;
|
|
51
|
+
}
|
|
52
|
+
export declare function createEventSourceRegistry(): EventSourceRegistry;
|
|
53
|
+
export declare function getDefaultEventSourceRegistry(): EventSourceRegistry;
|
|
54
|
+
//# sourceMappingURL=event-source-registry.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandWithParseInput } from '../../runtime/command-adapter';
|
|
2
|
+
export declare const respondCommand: CommandWithParseInput;
|
|
3
|
+
export declare const redirectCommand: CommandWithParseInput;
|
|
4
|
+
export declare const setHeaderCommand: CommandWithParseInput;
|
|
5
|
+
export declare const serverPlugin: import("../index").LokaScriptPlugin;
|
|
6
|
+
//# sourceMappingURL=server-commands.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { EventSource, EventSourcePayload } from '../event-source-registry';
|
|
2
|
+
import type { ExecutionContext } from '../../types/core';
|
|
3
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
4
|
+
export interface ServerRequest {
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
url: string;
|
|
7
|
+
path: string;
|
|
8
|
+
query: Record<string, string | string[]>;
|
|
9
|
+
params: Record<string, string>;
|
|
10
|
+
headers: Record<string, string | string[]>;
|
|
11
|
+
body: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface ServerResponse {
|
|
14
|
+
status(code: number): ServerResponse;
|
|
15
|
+
header(name: string, value: string): ServerResponse;
|
|
16
|
+
json(data: unknown): void;
|
|
17
|
+
html(content: string): void;
|
|
18
|
+
text(content: string): void;
|
|
19
|
+
redirect(url: string, code?: number): void;
|
|
20
|
+
send(data: unknown): void;
|
|
21
|
+
}
|
|
22
|
+
export interface RequestHandler {
|
|
23
|
+
method: HttpMethod | '*';
|
|
24
|
+
pattern: string | RegExp;
|
|
25
|
+
handler: (payload: EventSourcePayload, context: ExecutionContext) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare function createRequestEventSource(): EventSource & {
|
|
28
|
+
handleRequest(request: ServerRequest, response: ServerResponse): boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare function createWebSocketEventSource(): EventSource;
|
|
31
|
+
export declare function createSSEEventSource(): EventSource;
|
|
32
|
+
//# sourceMappingURL=server-event-source.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type { ExecutionContext, TypedExecutionContext } from '../types/core';
|
|
2
|
+
export { EventSourceRegistry, createEventSourceRegistry, getDefaultEventSourceRegistry, type EventSource, type EventSourceHandler, type EventSourcePayload, type EventSourceSubscription, type EventSourceSubscribeOptions, } from './event-source-registry';
|
|
3
|
+
export { ContextProviderRegistry, createContextProviderRegistry, getDefaultContextProviderRegistry, type ContextProvider, type ContextProviderFn, type ContextProviderOptions, meProvider, itProvider, youProvider, eventProvider, } from './context-provider-registry';
|
|
4
|
+
export { CommandRegistryV2, CommandAdapterV2, createCommandRegistryV2, type CommandWithParseInput, type RuntimeCommand, } from '../runtime/command-adapter';
|
|
5
|
+
import { CommandRegistryV2 } from '../runtime/command-adapter';
|
|
6
|
+
import { EventSourceRegistry } from './event-source-registry';
|
|
7
|
+
import { ContextProviderRegistry } from './context-provider-registry';
|
|
8
|
+
import type { CommandWithParseInput } from '../runtime/command-adapter';
|
|
9
|
+
import type { EventSource } from './event-source-registry';
|
|
10
|
+
import type { ContextProviderFn, ContextProviderOptions } from './context-provider-registry';
|
|
11
|
+
export interface LokaScriptRegistry {
|
|
12
|
+
readonly commands: CommandRegistryV2;
|
|
13
|
+
readonly eventSources: EventSourceRegistry;
|
|
14
|
+
readonly context: ContextProviderRegistry;
|
|
15
|
+
use(plugin: LokaScriptPlugin): void;
|
|
16
|
+
reset(): void;
|
|
17
|
+
}
|
|
18
|
+
export interface LokaScriptPlugin {
|
|
19
|
+
name: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
commands?: CommandWithParseInput[];
|
|
22
|
+
eventSources?: EventSource[];
|
|
23
|
+
contextProviders?: Array<{
|
|
24
|
+
name: string;
|
|
25
|
+
provide: ContextProviderFn;
|
|
26
|
+
options?: ContextProviderOptions;
|
|
27
|
+
}>;
|
|
28
|
+
setup?(registry: LokaScriptRegistry): void | Promise<void>;
|
|
29
|
+
teardown?(registry: LokaScriptRegistry): void | Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare function createRegistry(options?: {
|
|
32
|
+
commands?: CommandRegistryV2;
|
|
33
|
+
eventSources?: EventSourceRegistry;
|
|
34
|
+
context?: ContextProviderRegistry;
|
|
35
|
+
}): LokaScriptRegistry;
|
|
36
|
+
export declare function getDefaultRegistry(): LokaScriptRegistry;
|
|
37
|
+
export declare const commands: {
|
|
38
|
+
register(command: CommandWithParseInput): void;
|
|
39
|
+
has(name: string): boolean;
|
|
40
|
+
names(): string[];
|
|
41
|
+
};
|
|
42
|
+
export declare const eventSources: {
|
|
43
|
+
register(name: string, source: EventSource): void;
|
|
44
|
+
has(name: string): boolean;
|
|
45
|
+
names(): string[];
|
|
46
|
+
};
|
|
47
|
+
export declare const context: {
|
|
48
|
+
register<T>(name: string, provide: ContextProviderFn<T>, options?: ContextProviderOptions<T>): void;
|
|
49
|
+
has(name: string): boolean;
|
|
50
|
+
names(): string[];
|
|
51
|
+
};
|
|
52
|
+
export declare function definePlugin(plugin: LokaScriptPlugin): LokaScriptPlugin;
|
|
53
|
+
export { RegistryIntegration, createRegistryIntegration, getDefaultRegistryIntegration, resetDefaultRegistryIntegration, type RegistryIntegrationOptions, } from './runtime-integration';
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|