@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,412 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function parseLite(code) {
|
|
4
|
+
const trimmed = code.trim();
|
|
5
|
+
const onMatch = trimmed.match(/^on\s+(\w+)(?:\s+from\s+([^\s]+))?\s+(.+)$/i);
|
|
6
|
+
if (onMatch) {
|
|
7
|
+
return {
|
|
8
|
+
event: onMatch[1],
|
|
9
|
+
filter: onMatch[2],
|
|
10
|
+
commands: parseCommands(onMatch[3]),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const everyMatch = trimmed.match(/^every\s+(\d+)(ms|s)?\s+(.+)$/i);
|
|
14
|
+
if (everyMatch) {
|
|
15
|
+
const ms = everyMatch[2] === 's' ? parseInt(everyMatch[1]) * 1000 : parseInt(everyMatch[1]);
|
|
16
|
+
return {
|
|
17
|
+
event: `interval:${ms}`,
|
|
18
|
+
commands: parseCommands(everyMatch[3]),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const initMatch = trimmed.match(/^init\s+(.+)$/i);
|
|
22
|
+
if (initMatch) {
|
|
23
|
+
return {
|
|
24
|
+
event: 'init',
|
|
25
|
+
commands: parseCommands(initMatch[1]),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return parseCommands(trimmed);
|
|
29
|
+
}
|
|
30
|
+
function parseCommands(code) {
|
|
31
|
+
const parts = code.split(/\s+(?:then|and)\s+/i);
|
|
32
|
+
return parts.map(parseCommand).filter(Boolean);
|
|
33
|
+
}
|
|
34
|
+
function parseCommand(code) {
|
|
35
|
+
const trimmed = code.trim();
|
|
36
|
+
if (!trimmed)
|
|
37
|
+
return null;
|
|
38
|
+
let match = trimmed.match(/^toggle\s+(\.\w+|\w+)(?:\s+on\s+(.+))?$/i);
|
|
39
|
+
if (match) {
|
|
40
|
+
return { name: 'toggle', args: [match[1]], target: match[2] };
|
|
41
|
+
}
|
|
42
|
+
match = trimmed.match(/^add\s+(\.\w+|\w+)(?:\s+to\s+(.+))?$/i);
|
|
43
|
+
if (match) {
|
|
44
|
+
return { name: 'add', args: [match[1]], target: match[2] };
|
|
45
|
+
}
|
|
46
|
+
match = trimmed.match(/^remove\s+(\.\w+)(?:\s+from\s+(.+))?$/i);
|
|
47
|
+
if (match) {
|
|
48
|
+
return { name: 'remove', args: [match[1]], target: match[2] };
|
|
49
|
+
}
|
|
50
|
+
match = trimmed.match(/^remove\s+(.+)$/i);
|
|
51
|
+
if (match) {
|
|
52
|
+
return { name: 'remove', args: [], target: match[1] };
|
|
53
|
+
}
|
|
54
|
+
match = trimmed.match(/^put\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s+(into|before|after)\s+(.+)$/i);
|
|
55
|
+
if (match) {
|
|
56
|
+
const content = match[1] || match[2] || match[3];
|
|
57
|
+
return { name: 'put', args: [content], modifier: match[4], target: match[5] };
|
|
58
|
+
}
|
|
59
|
+
match = trimmed.match(/^set\s+(.+?)\s+to\s+(.+)$/i);
|
|
60
|
+
if (match) {
|
|
61
|
+
return { name: 'set', args: [match[1], match[2]] };
|
|
62
|
+
}
|
|
63
|
+
match = trimmed.match(/^log\s+(.+)$/i);
|
|
64
|
+
if (match) {
|
|
65
|
+
return { name: 'log', args: [match[1]] };
|
|
66
|
+
}
|
|
67
|
+
match = trimmed.match(/^send\s+(\w+)(?:\s+to\s+(.+))?$/i);
|
|
68
|
+
if (match) {
|
|
69
|
+
return { name: 'send', args: [match[1]], target: match[2] };
|
|
70
|
+
}
|
|
71
|
+
match = trimmed.match(/^wait\s+(\d+)(ms|s)?$/i);
|
|
72
|
+
if (match) {
|
|
73
|
+
const ms = match[2] === 's' ? parseInt(match[1]) * 1000 : parseInt(match[1]);
|
|
74
|
+
return { name: 'wait', args: [ms.toString()] };
|
|
75
|
+
}
|
|
76
|
+
match = trimmed.match(/^(if|unless)\s+(.+?)\s+(toggle|add|remove|put|set|log|send|wait)\s+(.+)$/i);
|
|
77
|
+
if (match) {
|
|
78
|
+
const innerCmd = parseCommand(`${match[3]} ${match[4]}`);
|
|
79
|
+
if (innerCmd) {
|
|
80
|
+
innerCmd.modifier = match[1].toLowerCase();
|
|
81
|
+
innerCmd.args.unshift(match[2]);
|
|
82
|
+
return innerCmd;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
match = trimmed.match(/^(show|hide)(?:\s+(.+))?$/i);
|
|
86
|
+
if (match) {
|
|
87
|
+
const target = match[2];
|
|
88
|
+
return match[1].toLowerCase() === 'show'
|
|
89
|
+
? { name: 'remove', args: ['.hidden'], target }
|
|
90
|
+
: { name: 'add', args: ['.hidden'], target };
|
|
91
|
+
}
|
|
92
|
+
const parts = trimmed.split(/\s+/);
|
|
93
|
+
if (parts.length > 0) {
|
|
94
|
+
return { name: parts[0], args: parts.slice(1) };
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function resolveTarget(target, me) {
|
|
99
|
+
if (!target)
|
|
100
|
+
return me;
|
|
101
|
+
const t = target.trim();
|
|
102
|
+
if (t === 'me')
|
|
103
|
+
return me;
|
|
104
|
+
if (t === 'body')
|
|
105
|
+
return document.body;
|
|
106
|
+
if (t.startsWith('#') || t.startsWith('.') || t.startsWith('[')) {
|
|
107
|
+
const elements = document.querySelectorAll(t);
|
|
108
|
+
return elements.length === 1 ? elements[0] : Array.from(elements);
|
|
109
|
+
}
|
|
110
|
+
if (/^\w+$/.test(t) && document.getElementById(t)) {
|
|
111
|
+
return document.getElementById(t);
|
|
112
|
+
}
|
|
113
|
+
return me;
|
|
114
|
+
}
|
|
115
|
+
function getClassName(arg) {
|
|
116
|
+
return arg.startsWith('.') ? arg.slice(1) : arg;
|
|
117
|
+
}
|
|
118
|
+
async function executeCommand(cmd, me, locals) {
|
|
119
|
+
const target = resolveTarget(cmd.target, me);
|
|
120
|
+
const elements = Array.isArray(target) ? target : target ? [target] : [me];
|
|
121
|
+
switch (cmd.name) {
|
|
122
|
+
case 'toggle': {
|
|
123
|
+
const className = getClassName(cmd.args[0]);
|
|
124
|
+
for (const el of elements) {
|
|
125
|
+
el.classList.toggle(className);
|
|
126
|
+
}
|
|
127
|
+
return elements.length === 1 ? elements[0] : elements;
|
|
128
|
+
}
|
|
129
|
+
case 'add': {
|
|
130
|
+
const className = getClassName(cmd.args[0]);
|
|
131
|
+
for (const el of elements) {
|
|
132
|
+
el.classList.add(className);
|
|
133
|
+
}
|
|
134
|
+
return elements.length === 1 ? elements[0] : elements;
|
|
135
|
+
}
|
|
136
|
+
case 'remove': {
|
|
137
|
+
if (cmd.args[0]) {
|
|
138
|
+
const className = getClassName(cmd.args[0]);
|
|
139
|
+
for (const el of elements) {
|
|
140
|
+
el.classList.remove(className);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
for (const el of elements) {
|
|
145
|
+
el.remove();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
case 'put': {
|
|
151
|
+
const content = evaluateValue(cmd.args[0], me, locals);
|
|
152
|
+
for (const el of elements) {
|
|
153
|
+
switch (cmd.modifier?.toLowerCase()) {
|
|
154
|
+
case 'into':
|
|
155
|
+
el.innerHTML = String(content);
|
|
156
|
+
break;
|
|
157
|
+
case 'before':
|
|
158
|
+
el.insertAdjacentHTML('beforebegin', String(content));
|
|
159
|
+
break;
|
|
160
|
+
case 'after':
|
|
161
|
+
el.insertAdjacentHTML('afterend', String(content));
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
el.innerHTML = String(content);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return elements.length === 1 ? elements[0] : elements;
|
|
168
|
+
}
|
|
169
|
+
case 'set': {
|
|
170
|
+
const [targetExpr, valueExpr] = cmd.args;
|
|
171
|
+
const value = evaluateValue(valueExpr, me, locals);
|
|
172
|
+
if (targetExpr.startsWith(':')) {
|
|
173
|
+
locals.set(targetExpr.slice(1), value);
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
const propMatch = targetExpr.match(/^(.+?)(?:'s|\.)\s*(\w+)$/);
|
|
177
|
+
if (propMatch) {
|
|
178
|
+
const obj = resolveTarget(propMatch[1], me);
|
|
179
|
+
if (obj) {
|
|
180
|
+
obj[propMatch[2]] = value;
|
|
181
|
+
return obj;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
case 'log': {
|
|
187
|
+
const value = evaluateValue(cmd.args.join(' '), me, locals);
|
|
188
|
+
console.log(value);
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
case 'send': {
|
|
192
|
+
const eventName = cmd.args[0];
|
|
193
|
+
const event = new CustomEvent(eventName, { bubbles: true });
|
|
194
|
+
for (const el of elements) {
|
|
195
|
+
el.dispatchEvent(event);
|
|
196
|
+
}
|
|
197
|
+
return event;
|
|
198
|
+
}
|
|
199
|
+
case 'wait': {
|
|
200
|
+
const ms = parseInt(cmd.args[0]) || 0;
|
|
201
|
+
await new Promise(resolve => setTimeout(resolve, ms));
|
|
202
|
+
return ms;
|
|
203
|
+
}
|
|
204
|
+
default:
|
|
205
|
+
console.warn(`Unknown command: ${cmd.name}`);
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function evaluateValue(expr, me, locals) {
|
|
210
|
+
if (!expr)
|
|
211
|
+
return undefined;
|
|
212
|
+
const e = expr.trim();
|
|
213
|
+
if ((e.startsWith('"') && e.endsWith('"')) || (e.startsWith("'") && e.endsWith("'"))) {
|
|
214
|
+
return e.slice(1, -1);
|
|
215
|
+
}
|
|
216
|
+
if (/^-?\d+(\.\d+)?$/.test(e)) {
|
|
217
|
+
return parseFloat(e);
|
|
218
|
+
}
|
|
219
|
+
if (e === 'true')
|
|
220
|
+
return true;
|
|
221
|
+
if (e === 'false')
|
|
222
|
+
return false;
|
|
223
|
+
if (e === 'null')
|
|
224
|
+
return null;
|
|
225
|
+
if (e.startsWith(':')) {
|
|
226
|
+
return locals.get(e.slice(1));
|
|
227
|
+
}
|
|
228
|
+
if (e === 'me')
|
|
229
|
+
return me;
|
|
230
|
+
if (e === 'my')
|
|
231
|
+
return me;
|
|
232
|
+
if (e === 'body')
|
|
233
|
+
return document.body;
|
|
234
|
+
const propMatch = e.match(/^(me|my)\.(\w+)$/);
|
|
235
|
+
if (propMatch) {
|
|
236
|
+
return me[propMatch[2]];
|
|
237
|
+
}
|
|
238
|
+
return e;
|
|
239
|
+
}
|
|
240
|
+
async function executeParsed(parsed, me, locals = new Map()) {
|
|
241
|
+
if (Array.isArray(parsed)) {
|
|
242
|
+
let result;
|
|
243
|
+
for (const cmd of parsed) {
|
|
244
|
+
if (cmd.modifier === 'if' || cmd.modifier === 'unless') {
|
|
245
|
+
const condition = evaluateCondition(cmd.args[0], me, locals);
|
|
246
|
+
const shouldRun = cmd.modifier === 'if' ? condition : !condition;
|
|
247
|
+
if (!shouldRun)
|
|
248
|
+
continue;
|
|
249
|
+
cmd.args.shift();
|
|
250
|
+
}
|
|
251
|
+
result = await executeCommand(cmd, me, locals);
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
const handler = parsed;
|
|
256
|
+
const targetEl = handler.filter ? document.querySelector(handler.filter) : me;
|
|
257
|
+
const eventName = handler.event;
|
|
258
|
+
if (eventName.startsWith('interval:')) {
|
|
259
|
+
const ms = parseInt(eventName.split(':')[1]);
|
|
260
|
+
setInterval(async () => {
|
|
261
|
+
const handlerLocals = new Map(locals);
|
|
262
|
+
for (const cmd of handler.commands) {
|
|
263
|
+
await executeCommand(cmd, me, handlerLocals);
|
|
264
|
+
}
|
|
265
|
+
}, ms);
|
|
266
|
+
return me;
|
|
267
|
+
}
|
|
268
|
+
if (eventName === 'init') {
|
|
269
|
+
const handlerLocals = new Map(locals);
|
|
270
|
+
for (const cmd of handler.commands) {
|
|
271
|
+
await executeCommand(cmd, me, handlerLocals);
|
|
272
|
+
}
|
|
273
|
+
return me;
|
|
274
|
+
}
|
|
275
|
+
if (targetEl) {
|
|
276
|
+
targetEl.addEventListener(eventName, async (event) => {
|
|
277
|
+
const handlerLocals = new Map(locals);
|
|
278
|
+
handlerLocals.set('event', event);
|
|
279
|
+
for (const cmd of handler.commands) {
|
|
280
|
+
await executeCommand(cmd, me, handlerLocals);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return me;
|
|
285
|
+
}
|
|
286
|
+
function evaluateCondition(expr, me, locals) {
|
|
287
|
+
const e = expr.trim();
|
|
288
|
+
const hasMatch = e.match(/^(me|my)\s+has\s+\.(\w+)$/i);
|
|
289
|
+
if (hasMatch) {
|
|
290
|
+
return me.classList.contains(hasMatch[2]);
|
|
291
|
+
}
|
|
292
|
+
const propMatch = e.match(/^(me|my)\.(\w+)$/i);
|
|
293
|
+
if (propMatch) {
|
|
294
|
+
return Boolean(me[propMatch[2]]);
|
|
295
|
+
}
|
|
296
|
+
if (e.startsWith(':')) {
|
|
297
|
+
return Boolean(locals.get(e.slice(1)));
|
|
298
|
+
}
|
|
299
|
+
const value = evaluateValue(e, me, locals);
|
|
300
|
+
return Boolean(value);
|
|
301
|
+
}
|
|
302
|
+
function processElements(root = document) {
|
|
303
|
+
const elements = root.querySelectorAll('[_]');
|
|
304
|
+
for (const el of elements) {
|
|
305
|
+
const code = el.getAttribute('_');
|
|
306
|
+
if (code) {
|
|
307
|
+
try {
|
|
308
|
+
const parsed = parseLite(code);
|
|
309
|
+
executeParsed(parsed, el);
|
|
310
|
+
}
|
|
311
|
+
catch (err) {
|
|
312
|
+
console.error('HyperFixi Lite error:', err, 'Code:', code);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const api = {
|
|
318
|
+
version: '1.0.0-lite',
|
|
319
|
+
parse: parseLite,
|
|
320
|
+
execute: async (code, element) => {
|
|
321
|
+
const me = element || document.body;
|
|
322
|
+
const parsed = parseLite(code);
|
|
323
|
+
return executeParsed(parsed, me);
|
|
324
|
+
},
|
|
325
|
+
init: processElements,
|
|
326
|
+
process: processElements,
|
|
327
|
+
commands: ['add', 'remove', 'toggle', 'put', 'set', 'log', 'send', 'wait'],
|
|
328
|
+
};
|
|
329
|
+
if (typeof window !== 'undefined') {
|
|
330
|
+
window.hyperfixi = api;
|
|
331
|
+
if (document.readyState === 'loading') {
|
|
332
|
+
document.addEventListener('DOMContentLoaded', () => processElements());
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
processElements();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
class RegexParserImpl {
|
|
340
|
+
constructor() {
|
|
341
|
+
this.name = 'regex';
|
|
342
|
+
this.supportedCommands = [
|
|
343
|
+
'add',
|
|
344
|
+
'remove',
|
|
345
|
+
'toggle',
|
|
346
|
+
'put',
|
|
347
|
+
'set',
|
|
348
|
+
'log',
|
|
349
|
+
'send',
|
|
350
|
+
'wait',
|
|
351
|
+
];
|
|
352
|
+
}
|
|
353
|
+
parse(code) {
|
|
354
|
+
const result = api.parse(code);
|
|
355
|
+
if ('event' in result) {
|
|
356
|
+
return {
|
|
357
|
+
type: 'eventHandler',
|
|
358
|
+
event: result.event,
|
|
359
|
+
filter: result.filter,
|
|
360
|
+
commands: result.commands.map(cmd => this.convertCommand(cmd)),
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
if (Array.isArray(result)) {
|
|
364
|
+
if (result.length === 1) {
|
|
365
|
+
return this.convertCommand(result[0]);
|
|
366
|
+
}
|
|
367
|
+
return {
|
|
368
|
+
type: 'sequence',
|
|
369
|
+
commands: result.map(cmd => this.convertCommand(cmd)),
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
return this.convertCommand(result);
|
|
373
|
+
}
|
|
374
|
+
convertCommand(cmd) {
|
|
375
|
+
return {
|
|
376
|
+
type: 'command',
|
|
377
|
+
name: cmd.name,
|
|
378
|
+
args: cmd.args.map(arg => ({
|
|
379
|
+
type: 'literal',
|
|
380
|
+
value: arg,
|
|
381
|
+
})),
|
|
382
|
+
...(cmd.target && {
|
|
383
|
+
target: {
|
|
384
|
+
type: 'selector',
|
|
385
|
+
value: cmd.target,
|
|
386
|
+
},
|
|
387
|
+
}),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
parseCommands(code) {
|
|
391
|
+
const result = this.parse(code);
|
|
392
|
+
if (result.type === 'sequence' && 'commands' in result) {
|
|
393
|
+
return result.commands;
|
|
394
|
+
}
|
|
395
|
+
return [result];
|
|
396
|
+
}
|
|
397
|
+
supports(syntax) {
|
|
398
|
+
const firstWord = syntax.trim().split(/\s+/)[0]?.toLowerCase();
|
|
399
|
+
if (firstWord === 'on' || firstWord === 'every' || firstWord === 'init') {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
return this.supportedCommands.includes(firstWord);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const regexParser = new RegexParserImpl();
|
|
406
|
+
function createRegexParser() {
|
|
407
|
+
return new RegexParserImpl();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
exports.createRegexParser = createRegexParser;
|
|
411
|
+
exports.regexParser = regexParser;
|
|
412
|
+
//# sourceMappingURL=regex-parser.js.map
|